diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-11-22 19:12:33 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:23 +0100 |
commit | 1dcd20f18db2941f87a774ca58bfacf345ccec45 (patch) | |
tree | da3aa75706104fdd6237d33c562dfacdbd3059e8 | |
parent | b9d60d2de49e91c60eb2fcef779d769d39ee3c12 (diff) |
iface-modem: handle SetAllowedBands()
Also considering that playing with bands may not be supported.
-rw-r--r-- | src/mm-iface-modem.c | 69 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 9 |
2 files changed, 76 insertions, 2 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 13cf466c..a814f3a1 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -247,13 +247,78 @@ handle_factory_reset (MmGdbusModem *skeleton, return TRUE; } +/*****************************************************************************/ + +static void +set_allowed_bands_ready (MMIfaceModem *self, + GAsyncResult *res, + DbusCallContext *ctx) +{ + GError *error = NULL; + + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands_finish (self, + res, + &error)) + g_dbus_method_invocation_take_error (ctx->invocation, + error); + else + mm_gdbus_modem_complete_set_allowed_bands (ctx->skeleton, + ctx->invocation); + dbus_call_context_free (ctx); +} + static gboolean -handle_set_allowed_bands (MmGdbusModem *object, +handle_set_allowed_bands (MmGdbusModem *skeleton, GDBusMethodInvocation *invocation, guint64 arg_bands, MMIfaceModem *self) { - return FALSE; /* Currently unhandled */ + MMModemState modem_state; + + /* If setting allowed bands is not implemented, report an error */ + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands || + !MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands_finish) { + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Setting allowed bands not supported"); + return TRUE; + } + + modem_state = MM_MODEM_STATE_UNKNOWN; + g_object_get (self, + MM_IFACE_MODEM_STATE, &modem_state, + NULL); + + switch (modem_state) { + case MM_MODEM_STATE_UNKNOWN: + case MM_MODEM_STATE_LOCKED: + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_WRONG_STATE, + "Cannot reset the modem to factory defaults: " + "not initialized/unlocked yet"); + break; + + case MM_MODEM_STATE_DISABLED: + case MM_MODEM_STATE_DISABLING: + case MM_MODEM_STATE_ENABLING: + case MM_MODEM_STATE_ENABLED: + case MM_MODEM_STATE_SEARCHING: + case MM_MODEM_STATE_REGISTERED: + case MM_MODEM_STATE_DISCONNECTING: + case MM_MODEM_STATE_CONNECTING: + case MM_MODEM_STATE_CONNECTED: + MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands (self, + arg_bands, + (GAsyncReadyCallback)set_allowed_bands_ready, + dbus_call_context_new (skeleton, + invocation, + self)); + break; + } + + return TRUE; } static gboolean diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index c81565e1..5fe0fcc5 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -153,6 +153,15 @@ struct _MMIfaceModem { gboolean (*factory_reset_finish) (MMIfaceModem *self, GAsyncResult *res, GError **error); + + /* Asynchronous allowed band setting operation */ + void (*set_allowed_bands) (MMIfaceModem *self, + MMModemBand bands, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*set_allowed_bands_finish) (MMIfaceModem *self, + GAsyncResult *res, + GError **error); }; GType mm_iface_modem_get_type (void); |