dispatcher-connection: replace 'connected' boolean with a new enum
The next commit will introduce a new dispatcher event. This commit should not change anything user-facing Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
This commit is contained in:
@@ -472,7 +472,7 @@ dispatcher_connection_run_ready (MMDispatcherConnection *dispatcher,
|
||||
|
||||
static void
|
||||
bearer_run_dispatcher_scripts (MMBaseBearer *self,
|
||||
gboolean connected)
|
||||
MMDispatcherConnectionEvent event)
|
||||
{
|
||||
MMDispatcherConnection *dispatcher;
|
||||
const gchar *interface;
|
||||
@@ -486,7 +486,7 @@ bearer_run_dispatcher_scripts (MMBaseBearer *self,
|
||||
g_dbus_object_get_object_path (G_DBUS_OBJECT (self->priv->modem)),
|
||||
self->priv->path,
|
||||
interface,
|
||||
connected,
|
||||
event,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)dispatcher_connection_run_ready,
|
||||
g_object_ref (self));
|
||||
@@ -531,7 +531,7 @@ bearer_update_status (MMBaseBearer *self,
|
||||
g_autoptr(GString) report = NULL;
|
||||
|
||||
/* Report disconnection via dispatcher scripts, before resetting the interface */
|
||||
bearer_run_dispatcher_scripts (self, FALSE);
|
||||
bearer_run_dispatcher_scripts (self, MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED);
|
||||
|
||||
bearer_reset_interface_status (self);
|
||||
/* Cleanup flag to ignore disconnection reports */
|
||||
@@ -599,7 +599,7 @@ bearer_update_status_connected (MMBaseBearer *self,
|
||||
connection_monitor_start (self);
|
||||
|
||||
/* Run dispatcher scripts */
|
||||
bearer_run_dispatcher_scripts (self, TRUE);
|
||||
bearer_run_dispatcher_scripts (self, MM_DISPATCHER_CONNECTION_EVENT_CONNECTED);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#endif
|
||||
|
||||
#define OPERATION_DESCRIPTION "connection status report"
|
||||
#define CONNECTED_STRING "connected"
|
||||
#define DISCONNECTED_STRING "disconnected"
|
||||
|
||||
/* Maximum time a connection dispatcher command is allowed to run before
|
||||
* us killing it */
|
||||
@@ -51,15 +49,28 @@ G_DEFINE_TYPE (MMDispatcherConnection, mm_dispatcher_connection, MM_TYPE_DISPATC
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gchar *modem_dbus_path;
|
||||
gchar *bearer_dbus_path;
|
||||
gchar *data_port;
|
||||
gboolean connected;
|
||||
GList *dispatcher_scripts;
|
||||
GFile *current;
|
||||
guint n_failures;
|
||||
gchar *modem_dbus_path;
|
||||
gchar *bearer_dbus_path;
|
||||
gchar *data_port;
|
||||
MMDispatcherConnectionEvent event;
|
||||
GList *dispatcher_scripts;
|
||||
GFile *current;
|
||||
guint n_failures;
|
||||
} ConnectionRunContext;
|
||||
|
||||
static gchar *
|
||||
mm_dispatcher_connection_event_to_string (MMDispatcherConnectionEvent event)
|
||||
{
|
||||
switch (event) {
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_CONNECTED:
|
||||
return g_strdup ("connected");
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED:
|
||||
return g_strdup ("disconnected");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_run_context_free (ConnectionRunContext *ctx)
|
||||
{
|
||||
@@ -137,7 +148,7 @@ connection_run_next (GTask *task)
|
||||
g_ptr_array_add (aux, g_strdup (ctx->modem_dbus_path));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->bearer_dbus_path));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->data_port));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->connected ? CONNECTED_STRING : DISCONNECTED_STRING));
|
||||
g_ptr_array_add (aux, mm_dispatcher_connection_event_to_string (ctx->event));
|
||||
g_ptr_array_add (aux, NULL);
|
||||
argv = (GStrv) g_ptr_array_free (aux, FALSE);
|
||||
|
||||
@@ -168,7 +179,7 @@ mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
const gchar *modem_dbus_path,
|
||||
const gchar *bearer_dbus_path,
|
||||
const gchar *data_port,
|
||||
gboolean connected,
|
||||
MMDispatcherConnectionEvent event,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@@ -187,7 +198,7 @@ mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
ctx->modem_dbus_path = g_strdup (modem_dbus_path);
|
||||
ctx->bearer_dbus_path = g_strdup (bearer_dbus_path);
|
||||
ctx->data_port = g_strdup (data_port);
|
||||
ctx->connected = connected;
|
||||
ctx->event = event;
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)connection_run_context_free);
|
||||
|
||||
/* Iterate over all enabled dirs and collect all dispatcher script paths */
|
||||
|
||||
@@ -32,13 +32,18 @@ typedef struct _MMDispatcherConnection MMDispatcherConnection;
|
||||
typedef struct _MMDispatcherConnectionClass MMDispatcherConnectionClass;
|
||||
typedef struct _MMDispatcherConnectionPrivate MMDispatcherConnectionPrivate;
|
||||
|
||||
typedef enum { /*< underscore_name=mm_dispatcher_connection_event >*/
|
||||
MM_DISPATCHER_CONNECTION_EVENT_CONNECTED,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED,
|
||||
} MMDispatcherConnectionEvent;
|
||||
|
||||
GType mm_dispatcher_connection_get_type (void);
|
||||
MMDispatcherConnection *mm_dispatcher_connection_get (void);
|
||||
void mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
const gchar *modem_dbus_path,
|
||||
const gchar *bearer_dbus_path,
|
||||
const gchar *data_port,
|
||||
gboolean connected,
|
||||
MMDispatcherConnectionEvent event,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
Reference in New Issue
Block a user