iface-modem: include policy authorization checks
This commit is contained in:
@@ -72,37 +72,6 @@ mm_iface_modem_bind_simple_status (MMIfaceModem *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
MmGdbusModem *skeleton;
|
|
||||||
GDBusMethodInvocation *invocation;
|
|
||||||
MMIfaceModem *self;
|
|
||||||
} DbusCallContext;
|
|
||||||
|
|
||||||
static void
|
|
||||||
dbus_call_context_free (DbusCallContext *ctx)
|
|
||||||
{
|
|
||||||
g_object_unref (ctx->skeleton);
|
|
||||||
g_object_unref (ctx->invocation);
|
|
||||||
g_object_unref (ctx->self);
|
|
||||||
g_free (ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DbusCallContext *
|
|
||||||
dbus_call_context_new (MmGdbusModem *skeleton,
|
|
||||||
GDBusMethodInvocation *invocation,
|
|
||||||
MMIfaceModem *self)
|
|
||||||
{
|
|
||||||
DbusCallContext *ctx;
|
|
||||||
|
|
||||||
ctx = g_new (DbusCallContext, 1);
|
|
||||||
ctx->skeleton = g_object_ref (skeleton);
|
|
||||||
ctx->invocation = g_object_ref (invocation);
|
|
||||||
ctx->self = g_object_ref (self);
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static MMModemState get_current_consolidated_state (MMIfaceModem *self);
|
static MMModemState get_current_consolidated_state (MMIfaceModem *self);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -257,10 +226,27 @@ mm_iface_modem_create_bearer (MMIfaceModem *self,
|
|||||||
g_object_unref (list);
|
g_object_unref (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
GVariant *dictionary;
|
||||||
|
} HandleCreateBearerContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_create_bearer_context_free (HandleCreateBearerContext *ctx)
|
||||||
|
{
|
||||||
|
g_variant_unref (ctx->dictionary);
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_create_bearer_ready (MMIfaceModem *self,
|
handle_create_bearer_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleCreateBearerContext *ctx)
|
||||||
{
|
{
|
||||||
MMBearer *bearer;
|
MMBearer *bearer;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -274,7 +260,37 @@ handle_create_bearer_ready (MMIfaceModem *self,
|
|||||||
mm_bearer_get_path (bearer));
|
mm_bearer_get_path (bearer));
|
||||||
g_object_unref (bearer);
|
g_object_unref (bearer);
|
||||||
}
|
}
|
||||||
dbus_call_context_free (ctx);
|
|
||||||
|
handle_create_bearer_context_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_create_bearer_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleCreateBearerContext *ctx)
|
||||||
|
{
|
||||||
|
MMCommonBearerProperties *properties;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_create_bearer_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
properties = mm_common_bearer_properties_new_from_dictionary (ctx->dictionary, &error);
|
||||||
|
if (!properties) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_create_bearer_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_iface_modem_create_bearer (
|
||||||
|
ctx->self,
|
||||||
|
properties,
|
||||||
|
(GAsyncReadyCallback)handle_create_bearer_ready,
|
||||||
|
ctx);
|
||||||
|
g_object_unref (properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -283,30 +299,46 @@ handle_create_bearer (MmGdbusModem *skeleton,
|
|||||||
GVariant *dictionary,
|
GVariant *dictionary,
|
||||||
MMIfaceModem *self)
|
MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
HandleCreateBearerContext *ctx;
|
||||||
MMCommonBearerProperties *properties;
|
|
||||||
|
|
||||||
properties = mm_common_bearer_properties_new_from_dictionary (dictionary, &error);
|
ctx = g_new (HandleCreateBearerContext, 1);
|
||||||
if (!properties) {
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
g_dbus_method_invocation_take_error (invocation, error);
|
ctx->invocation = g_object_ref (invocation);
|
||||||
} else {
|
ctx->self = g_object_ref (self);
|
||||||
mm_iface_modem_create_bearer (
|
ctx->dictionary = g_variant_ref (dictionary);
|
||||||
self,
|
|
||||||
properties,
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
(GAsyncReadyCallback)handle_create_bearer_ready,
|
|
||||||
dbus_call_context_new (skeleton,
|
|
||||||
invocation,
|
invocation,
|
||||||
self));
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
g_object_unref (properties);
|
(GAsyncReadyCallback)handle_create_bearer_auth_ready,
|
||||||
}
|
ctx);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
gchar *cmd;
|
||||||
|
guint timeout;
|
||||||
|
} HandleCommandContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
command_done (MMIfaceModem *self,
|
handle_command_context_free (HandleCommandContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx->cmd);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
command_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleCommandContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const gchar *result;
|
const gchar *result;
|
||||||
@@ -315,13 +347,43 @@ command_done (MMIfaceModem *self,
|
|||||||
res,
|
res,
|
||||||
&error);
|
&error);
|
||||||
if (error)
|
if (error)
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation,
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
error);
|
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_command (ctx->skeleton,
|
mm_gdbus_modem_complete_command (ctx->skeleton, ctx->invocation, result);
|
||||||
ctx->invocation,
|
|
||||||
result);
|
handle_command_context_free (ctx);
|
||||||
dbus_call_context_free (ctx);
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_command_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleCommandContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_command_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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 (ctx->invocation,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
|
"Cannot send AT command to modem: "
|
||||||
|
"operation not supported");
|
||||||
|
handle_command_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (self)->command (ctx->self,
|
||||||
|
ctx->cmd,
|
||||||
|
ctx->timeout,
|
||||||
|
(GAsyncReadyCallback)command_ready,
|
||||||
|
ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -331,50 +393,88 @@ handle_command (MmGdbusModem *skeleton,
|
|||||||
guint timeout,
|
guint timeout,
|
||||||
MMIfaceModem *self)
|
MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
|
HandleCommandContext *ctx;
|
||||||
|
|
||||||
/* If command is not implemented, report an error */
|
ctx = g_new (HandleCommandContext, 1);
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command ||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
!MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) {
|
ctx->invocation = g_object_ref (invocation);
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
ctx->self = g_object_ref (self);
|
||||||
MM_CORE_ERROR,
|
ctx->cmd = g_strdup (cmd);
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
ctx->timeout = timeout;
|
||||||
"Cannot send AT command to modem: "
|
|
||||||
"operation not supported");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->command (self,
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
cmd,
|
|
||||||
timeout,
|
|
||||||
(GAsyncReadyCallback)command_done,
|
|
||||||
dbus_call_context_new (skeleton,
|
|
||||||
invocation,
|
invocation,
|
||||||
self));
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_command_auth_ready,
|
||||||
|
ctx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
typedef struct {
|
||||||
handle_delete_bearer (MmGdbusModem *skeleton,
|
MmGdbusModem *skeleton;
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation;
|
||||||
const gchar *arg_bearer,
|
MMIfaceModem *self;
|
||||||
MMIfaceModem *self)
|
gchar *bearer_path;
|
||||||
|
} HandleDeleteBearerContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx->bearer_path);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_delete_bearer_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleDeleteBearerContext *ctx)
|
||||||
{
|
{
|
||||||
MMBearerList *list = NULL;
|
MMBearerList *list = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_delete_bearer_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
MM_IFACE_MODEM_BEARER_LIST, &list,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!mm_bearer_list_delete_bearer (list, arg_bearer, &error))
|
if (!mm_bearer_list_delete_bearer (list, ctx->bearer_path, &error))
|
||||||
g_dbus_method_invocation_take_error (invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_delete_bearer (skeleton, invocation);
|
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
||||||
|
|
||||||
g_object_unref (list);
|
g_object_unref (list);
|
||||||
|
handle_delete_bearer_context_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_delete_bearer (MmGdbusModem *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
const gchar *bearer,
|
||||||
|
MMIfaceModem *self)
|
||||||
|
{
|
||||||
|
HandleDeleteBearerContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new (HandleDeleteBearerContext, 1);
|
||||||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->bearer_path = g_strdup (bearer);
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_delete_bearer_auth_ready,
|
||||||
|
ctx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1028,75 +1128,186 @@ mm_iface_modem_update_subsystem_state (MMIfaceModem *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
gboolean enable;
|
||||||
|
} HandleEnableContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enable_disable_ready (MMIfaceModem *self,
|
handle_enable_context_free (HandleEnableContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enable_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleEnableContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!MM_BASE_MODEM_GET_CLASS (self)->enable_finish (MM_BASE_MODEM (self),
|
if (ctx->enable) {
|
||||||
res,
|
if (!MM_BASE_MODEM_GET_CLASS (self)->enable_finish (self, res, &error))
|
||||||
&error))
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation,
|
|
||||||
error);
|
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_enable (ctx->skeleton,
|
mm_gdbus_modem_complete_enable (ctx->skeleton, ctx->invocation);
|
||||||
ctx->invocation);
|
} else {
|
||||||
dbus_call_context_free (ctx);
|
if (!MM_BASE_MODEM_GET_CLASS (self)->disable_finish (self, res, &error))
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
else
|
||||||
|
mm_gdbus_modem_complete_enable (ctx->skeleton, ctx->invocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_enable_context_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_enable_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleEnableContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_enable_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->enable) {
|
||||||
|
g_assert (MM_BASE_MODEM_GET_CLASS (self)->enable != NULL);
|
||||||
|
g_assert (MM_BASE_MODEM_GET_CLASS (self)->enable_finish != NULL);
|
||||||
|
|
||||||
|
MM_BASE_MODEM_GET_CLASS (self)->enable (
|
||||||
|
self,
|
||||||
|
NULL, /* cancellable */
|
||||||
|
(GAsyncReadyCallback)enable_ready,
|
||||||
|
ctx);
|
||||||
|
} else {
|
||||||
|
g_assert (MM_BASE_MODEM_GET_CLASS (self)->disable != NULL);
|
||||||
|
g_assert (MM_BASE_MODEM_GET_CLASS (self)->disable_finish != NULL);
|
||||||
|
|
||||||
|
MM_BASE_MODEM_GET_CLASS (self)->disable (
|
||||||
|
self,
|
||||||
|
NULL, /* cancellable */
|
||||||
|
(GAsyncReadyCallback)enable_ready,
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_enable (MmGdbusModem *skeleton,
|
handle_enable (MmGdbusModem *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
gboolean arg_enable,
|
gboolean enable,
|
||||||
MMIfaceModem *self)
|
MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
MMModemState modem_state;
|
HandleEnableContext *ctx;
|
||||||
|
|
||||||
g_assert (MM_BASE_MODEM_GET_CLASS (self)->enable != NULL);
|
ctx = g_new (HandleEnableContext, 1);
|
||||||
g_assert (MM_BASE_MODEM_GET_CLASS (self)->enable_finish != NULL);
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->enable = enable;
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_enable_auth_ready,
|
||||||
|
ctx);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
} HandleResetContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_reset_context_free (HandleResetContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_reset_ready (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleResetContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->reset_finish (self, res, &error))
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
else
|
||||||
|
mm_gdbus_modem_complete_reset (ctx->skeleton, ctx->invocation);
|
||||||
|
|
||||||
|
handle_reset_context_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_reset_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleResetContext *ctx)
|
||||||
|
{
|
||||||
|
MMModemState modem_state;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_reset_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If reseting is not implemented, report an error */
|
||||||
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->reset ||
|
||||||
|
!MM_IFACE_MODEM_GET_INTERFACE (self)->reset_finish) {
|
||||||
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
|
"Cannot reset the modem: operation not supported");
|
||||||
|
handle_reset_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
modem_state = MM_MODEM_STATE_UNKNOWN;
|
modem_state = MM_MODEM_STATE_UNKNOWN;
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_STATE, &modem_state,
|
MM_IFACE_MODEM_STATE, &modem_state,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (arg_enable)
|
switch (modem_state) {
|
||||||
MM_BASE_MODEM_GET_CLASS (self)->enable (MM_BASE_MODEM (self),
|
case MM_MODEM_STATE_UNKNOWN:
|
||||||
NULL, /* cancellable */
|
case MM_MODEM_STATE_LOCKED:
|
||||||
(GAsyncReadyCallback)enable_disable_ready,
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
dbus_call_context_new (skeleton,
|
MM_CORE_ERROR,
|
||||||
invocation,
|
MM_CORE_ERROR_WRONG_STATE,
|
||||||
self));
|
"Cannot reset modem: not initialized/unlocked yet");
|
||||||
else
|
handle_reset_context_free (ctx);
|
||||||
MM_BASE_MODEM_GET_CLASS (self)->disable (MM_BASE_MODEM (self),
|
return;
|
||||||
NULL, /* cancellable */
|
|
||||||
(GAsyncReadyCallback)enable_disable_ready,
|
|
||||||
dbus_call_context_new (skeleton,
|
|
||||||
invocation,
|
|
||||||
self));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
case MM_MODEM_STATE_DISABLED:
|
||||||
|
case MM_MODEM_STATE_DISABLING:
|
||||||
static void
|
case MM_MODEM_STATE_ENABLING:
|
||||||
reset_ready (MMIfaceModem *self,
|
case MM_MODEM_STATE_ENABLED:
|
||||||
GAsyncResult *res,
|
case MM_MODEM_STATE_SEARCHING:
|
||||||
DbusCallContext *ctx)
|
case MM_MODEM_STATE_REGISTERED:
|
||||||
{
|
case MM_MODEM_STATE_DISCONNECTING:
|
||||||
GError *error = NULL;
|
case MM_MODEM_STATE_CONNECTING:
|
||||||
|
case MM_MODEM_STATE_CONNECTED:
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->reset_finish (self,
|
MM_IFACE_MODEM_GET_INTERFACE (self)->reset (MM_IFACE_MODEM (self),
|
||||||
res,
|
(GAsyncReadyCallback)handle_reset_ready,
|
||||||
&error))
|
ctx);
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation,
|
break;
|
||||||
error);
|
}
|
||||||
else
|
|
||||||
mm_gdbus_modem_complete_reset (ctx->skeleton,
|
|
||||||
ctx->invocation);
|
|
||||||
dbus_call_context_free (ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1104,89 +1315,80 @@ handle_reset (MmGdbusModem *skeleton,
|
|||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
MMIfaceModem *self)
|
MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
MMModemState modem_state;
|
HandleResetContext *ctx;
|
||||||
|
|
||||||
/* If reseting is not implemented, report an error */
|
ctx = g_new (HandleResetContext, 1);
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->reset ||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
!MM_IFACE_MODEM_GET_INTERFACE (self)->reset_finish) {
|
ctx->invocation = g_object_ref (invocation);
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
ctx->self = g_object_ref (self);
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"Cannot reset the modem: operation not supported");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
modem_state = MM_MODEM_STATE_UNKNOWN;
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
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 modem: 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)->reset (self,
|
|
||||||
(GAsyncReadyCallback)reset_ready,
|
|
||||||
dbus_call_context_new (skeleton,
|
|
||||||
invocation,
|
invocation,
|
||||||
self));
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
break;
|
(GAsyncReadyCallback)handle_reset_auth_ready,
|
||||||
}
|
ctx);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
gchar *code;
|
||||||
|
} HandleFactoryResetContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
factory_reset_ready (MMIfaceModem *self,
|
handle_factory_reset_context_free (HandleFactoryResetContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx->code);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_factory_reset_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleFactoryResetContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset_finish (self,
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset_finish (self, res, &error))
|
||||||
res,
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
&error))
|
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation,
|
|
||||||
error);
|
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_factory_reset (ctx->skeleton,
|
mm_gdbus_modem_complete_factory_reset (ctx->skeleton, ctx->invocation);
|
||||||
ctx->invocation);
|
|
||||||
dbus_call_context_free (ctx);
|
handle_factory_reset_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
handle_factory_reset (MmGdbusModem *skeleton,
|
handle_factory_reset_auth_ready (MMBaseModem *self,
|
||||||
GDBusMethodInvocation *invocation,
|
GAsyncResult *res,
|
||||||
const gchar *arg_code,
|
HandleFactoryResetContext *ctx)
|
||||||
MMIfaceModem *self)
|
|
||||||
{
|
{
|
||||||
MMModemState modem_state;
|
MMModemState modem_state;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_factory_reset_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* If reseting is not implemented, report an error */
|
/* If reseting is not implemented, report an error */
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset ||
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset ||
|
||||||
!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset_finish) {
|
!MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset_finish) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
"Cannot reset the modem to factory defaults: "
|
"Cannot reset the modem to factory defaults: "
|
||||||
"operation not supported");
|
"operation not supported");
|
||||||
return TRUE;
|
handle_factory_reset_context_free (ctx);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modem_state = MM_MODEM_STATE_UNKNOWN;
|
modem_state = MM_MODEM_STATE_UNKNOWN;
|
||||||
@@ -1197,12 +1399,13 @@ handle_factory_reset (MmGdbusModem *skeleton,
|
|||||||
switch (modem_state) {
|
switch (modem_state) {
|
||||||
case MM_MODEM_STATE_UNKNOWN:
|
case MM_MODEM_STATE_UNKNOWN:
|
||||||
case MM_MODEM_STATE_LOCKED:
|
case MM_MODEM_STATE_LOCKED:
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_WRONG_STATE,
|
MM_CORE_ERROR_WRONG_STATE,
|
||||||
"Cannot reset the modem to factory defaults: "
|
"Cannot reset the modem to factory defaults: "
|
||||||
"not initialized/unlocked yet");
|
"not initialized/unlocked yet");
|
||||||
break;
|
handle_factory_reset_context_free (ctx);
|
||||||
|
return;
|
||||||
|
|
||||||
case MM_MODEM_STATE_DISABLED:
|
case MM_MODEM_STATE_DISABLED:
|
||||||
case MM_MODEM_STATE_DISABLING:
|
case MM_MODEM_STATE_DISABLING:
|
||||||
@@ -1213,14 +1416,33 @@ handle_factory_reset (MmGdbusModem *skeleton,
|
|||||||
case MM_MODEM_STATE_DISCONNECTING:
|
case MM_MODEM_STATE_DISCONNECTING:
|
||||||
case MM_MODEM_STATE_CONNECTING:
|
case MM_MODEM_STATE_CONNECTING:
|
||||||
case MM_MODEM_STATE_CONNECTED:
|
case MM_MODEM_STATE_CONNECTED:
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset (self,
|
MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset (MM_IFACE_MODEM (self),
|
||||||
arg_code,
|
ctx->code,
|
||||||
(GAsyncReadyCallback)factory_reset_ready,
|
(GAsyncReadyCallback)handle_factory_reset_ready,
|
||||||
dbus_call_context_new (skeleton,
|
ctx);
|
||||||
invocation,
|
|
||||||
self));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_factory_reset (MmGdbusModem *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
const gchar *code,
|
||||||
|
MMIfaceModem *self)
|
||||||
|
{
|
||||||
|
HandleFactoryResetContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new (HandleFactoryResetContext, 1);
|
||||||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->code = g_strdup (code);
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_factory_reset_auth_ready,
|
||||||
|
ctx);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1386,29 +1608,53 @@ mm_iface_modem_set_bands (MMIfaceModem *self,
|
|||||||
g_array_unref (supported_bands_array);
|
g_array_unref (supported_bands_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
GVariant *bands;
|
||||||
|
} HandleSetBandsContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_set_bands_context_free (HandleSetBandsContext *ctx)
|
||||||
|
{
|
||||||
|
g_variant_unref (ctx->bands);
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_set_bands_ready (MMIfaceModem *self,
|
handle_set_bands_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleSetBandsContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_iface_modem_set_bands_finish (self, res, &error))
|
if (!mm_iface_modem_set_bands_finish (self, res, &error))
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_set_bands (ctx->skeleton,
|
mm_gdbus_modem_complete_set_bands (ctx->skeleton, ctx->invocation);
|
||||||
ctx->invocation);
|
|
||||||
dbus_call_context_free (ctx);
|
handle_set_bands_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
handle_set_bands (MmGdbusModem *skeleton,
|
handle_set_bands_auth_ready (MMBaseModem *self,
|
||||||
GDBusMethodInvocation *invocation,
|
GAsyncResult *res,
|
||||||
GVariant *bands_variant,
|
HandleSetBandsContext *ctx)
|
||||||
MMIfaceModem *self)
|
|
||||||
{
|
{
|
||||||
MMModemState modem_state = MM_MODEM_STATE_UNKNOWN;
|
MMModemState modem_state;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_set_bands_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_state = MM_MODEM_STATE_UNKNOWN;
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_STATE, &modem_state,
|
MM_IFACE_MODEM_STATE, &modem_state,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -1416,12 +1662,13 @@ handle_set_bands (MmGdbusModem *skeleton,
|
|||||||
switch (modem_state) {
|
switch (modem_state) {
|
||||||
case MM_MODEM_STATE_UNKNOWN:
|
case MM_MODEM_STATE_UNKNOWN:
|
||||||
case MM_MODEM_STATE_LOCKED:
|
case MM_MODEM_STATE_LOCKED:
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_WRONG_STATE,
|
MM_CORE_ERROR_WRONG_STATE,
|
||||||
"Cannot set allowed bands: "
|
"Cannot set allowed bands: "
|
||||||
"not initialized/unlocked yet");
|
"not initialized/unlocked yet");
|
||||||
break;
|
handle_set_bands_context_free (ctx);
|
||||||
|
return;
|
||||||
|
|
||||||
case MM_MODEM_STATE_DISABLED:
|
case MM_MODEM_STATE_DISABLED:
|
||||||
case MM_MODEM_STATE_DISABLING:
|
case MM_MODEM_STATE_DISABLING:
|
||||||
@@ -1434,18 +1681,36 @@ handle_set_bands (MmGdbusModem *skeleton,
|
|||||||
case MM_MODEM_STATE_CONNECTED: {
|
case MM_MODEM_STATE_CONNECTED: {
|
||||||
GArray *bands_array;
|
GArray *bands_array;
|
||||||
|
|
||||||
bands_array = mm_common_bands_variant_to_garray (bands_variant);
|
bands_array = mm_common_bands_variant_to_garray (ctx->bands);
|
||||||
mm_iface_modem_set_bands (self,
|
mm_iface_modem_set_bands (MM_IFACE_MODEM (self),
|
||||||
bands_array,
|
bands_array,
|
||||||
(GAsyncReadyCallback)handle_set_bands_ready,
|
(GAsyncReadyCallback)handle_set_bands_ready,
|
||||||
dbus_call_context_new (skeleton,
|
ctx);
|
||||||
invocation,
|
|
||||||
self));
|
|
||||||
g_array_unref (bands_array);
|
g_array_unref (bands_array);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_set_bands (MmGdbusModem *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
GVariant *bands_variant,
|
||||||
|
MMIfaceModem *self)
|
||||||
|
{
|
||||||
|
HandleSetBandsContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new (HandleSetBandsContext, 1);
|
||||||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->bands = g_variant_ref (bands_variant);
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_set_bands_auth_ready,
|
||||||
|
ctx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1586,30 +1851,53 @@ mm_iface_modem_set_allowed_modes (MMIfaceModem *self,
|
|||||||
ctx);
|
ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
MMModemMode allowed;
|
||||||
|
MMModemMode preferred;
|
||||||
|
} HandleSetAllowedModesContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_set_allowed_modes_context_free (HandleSetAllowedModesContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_set_allowed_modes_ready (MMIfaceModem *self,
|
handle_set_allowed_modes_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DbusCallContext *ctx)
|
HandleSetAllowedModesContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_iface_modem_set_allowed_modes_finish (self, res, &error))
|
if (!mm_iface_modem_set_allowed_modes_finish (self, res, &error))
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else
|
else
|
||||||
mm_gdbus_modem_complete_set_allowed_modes (ctx->skeleton,
|
mm_gdbus_modem_complete_set_allowed_modes (ctx->skeleton, ctx->invocation);
|
||||||
ctx->invocation);
|
|
||||||
dbus_call_context_free (ctx);
|
handle_set_allowed_modes_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
handle_set_allowed_modes (MmGdbusModem *skeleton,
|
handle_set_allowed_modes_auth_ready (MMBaseModem *self,
|
||||||
GDBusMethodInvocation *invocation,
|
GAsyncResult *res,
|
||||||
guint modes,
|
HandleSetAllowedModesContext *ctx)
|
||||||
guint preferred,
|
|
||||||
MMIfaceModem *self)
|
|
||||||
{
|
{
|
||||||
MMModemState modem_state = MM_MODEM_STATE_UNKNOWN;
|
MMModemState modem_state;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_set_allowed_modes_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_state = MM_MODEM_STATE_UNKNOWN;
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_STATE, &modem_state,
|
MM_IFACE_MODEM_STATE, &modem_state,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -1617,12 +1905,13 @@ handle_set_allowed_modes (MmGdbusModem *skeleton,
|
|||||||
switch (modem_state) {
|
switch (modem_state) {
|
||||||
case MM_MODEM_STATE_UNKNOWN:
|
case MM_MODEM_STATE_UNKNOWN:
|
||||||
case MM_MODEM_STATE_LOCKED:
|
case MM_MODEM_STATE_LOCKED:
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_WRONG_STATE,
|
MM_CORE_ERROR_WRONG_STATE,
|
||||||
"Cannot set allowed modes: "
|
"Cannot set allowed modes: "
|
||||||
"not initialized/unlocked yet");
|
"not initialized/unlocked yet");
|
||||||
break;
|
handle_set_allowed_modes_context_free (ctx);
|
||||||
|
return;
|
||||||
|
|
||||||
case MM_MODEM_STATE_DISABLED:
|
case MM_MODEM_STATE_DISABLED:
|
||||||
case MM_MODEM_STATE_DISABLING:
|
case MM_MODEM_STATE_DISABLING:
|
||||||
@@ -1633,16 +1922,36 @@ handle_set_allowed_modes (MmGdbusModem *skeleton,
|
|||||||
case MM_MODEM_STATE_DISCONNECTING:
|
case MM_MODEM_STATE_DISCONNECTING:
|
||||||
case MM_MODEM_STATE_CONNECTING:
|
case MM_MODEM_STATE_CONNECTING:
|
||||||
case MM_MODEM_STATE_CONNECTED:
|
case MM_MODEM_STATE_CONNECTED:
|
||||||
mm_iface_modem_set_allowed_modes (self,
|
mm_iface_modem_set_allowed_modes (MM_IFACE_MODEM (self),
|
||||||
modes,
|
ctx->allowed,
|
||||||
preferred,
|
ctx->preferred,
|
||||||
(GAsyncReadyCallback)handle_set_allowed_modes_ready,
|
(GAsyncReadyCallback)handle_set_allowed_modes_ready,
|
||||||
dbus_call_context_new (skeleton,
|
ctx);
|
||||||
invocation,
|
|
||||||
self));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_set_allowed_modes (MmGdbusModem *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
guint allowed,
|
||||||
|
guint preferred,
|
||||||
|
MMIfaceModem *self)
|
||||||
|
{
|
||||||
|
HandleSetAllowedModesContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_new (HandleSetAllowedModesContext, 1);
|
||||||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->allowed = allowed;
|
||||||
|
ctx->preferred = preferred;
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_set_allowed_modes_auth_ready,
|
||||||
|
ctx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user