aboutsummaryrefslogtreecommitdiff
path: root/src/mm-dispatcher-connection.c
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@atmark-techno.com>2025-05-01 14:28:04 +0900
committerDominique Martinet <dominique.martinet@atmark-techno.com>2025-05-16 15:34:02 +0900
commitf3aaa113e02f5b18550e0ebecd8de08fb2eb9cdb (patch)
tree5f0f895a72013b3def57c3a4ee849a999f6d935f /src/mm-dispatcher-connection.c
parenta4421095f8464eaf678824a15a8e382a8b653ce5 (diff)
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>
Diffstat (limited to 'src/mm-dispatcher-connection.c')
-rw-r--r--src/mm-dispatcher-connection.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/mm-dispatcher-connection.c b/src/mm-dispatcher-connection.c
index 7f370a59..dec195d3 100644
--- a/src/mm-dispatcher-connection.c
+++ b/src/mm-dispatcher-connection.c
@@ -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 */