iface-modem: handle SetAllowedBands()
Also considering that playing with bands may not be supported.
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user