diff options
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r-- | src/mm-iface-modem.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 17bf93a8..a6e1968c 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -20,6 +20,7 @@ #include "mm-modem-helpers.h" #include "mm-iface-modem.h" #include "mm-base-modem.h" +#include "mm-base-modem-at.h" #include "mm-sim.h" #include "mm-bearer-list.h" #include "mm-log.h" @@ -302,6 +303,57 @@ handle_create_bearer (MmGdbusModem *skeleton, return TRUE; } +static void +command_done (MMIfaceModem *self, + GAsyncResult *res, + DbusCallContext *ctx) +{ + GError *error = NULL; + const gchar *result; + + result = MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish (self, + res, + &error); + if (error) + g_dbus_method_invocation_take_error (ctx->invocation, + error); + else + mm_gdbus_modem_complete_command (ctx->skeleton, + ctx->invocation, + result); + dbus_call_context_free (ctx); +} + +static gboolean +handle_command (MmGdbusModem *skeleton, + GDBusMethodInvocation *invocation, + const gchar *cmd, + guint timeout, + MMIfaceModem *self) +{ + + /* If command is not implemented, report an error */ + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command || + !MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) { + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Cannot send AT command to modem: " + "operation not supported"); + return TRUE; + } + + MM_IFACE_MODEM_GET_INTERFACE (self)->command (self, + cmd, + timeout, + (GAsyncReadyCallback)command_done, + dbus_call_context_new (skeleton, + invocation, + self)); + + return TRUE; +} + /*****************************************************************************/ static gboolean @@ -2921,6 +2973,10 @@ interface_initialization_step (InitializationContext *ctx) G_CALLBACK (handle_create_bearer), ctx->self); g_signal_connect (ctx->skeleton, + "handle-command", + G_CALLBACK (handle_command), + ctx->self); + g_signal_connect (ctx->skeleton, "handle-delete-bearer", G_CALLBACK (handle_delete_bearer), ctx->self); |