iface-modem-3gpp: implement handling of 'SetPacketServiceState()'
Includes updates by Aleksander Morgado to fix coding style issues and to place this logic in the correct interface.
This commit is contained in:

committed by
Aleksander Morgado

parent
3ab765f11c
commit
0316afee06
@@ -1340,6 +1340,105 @@ handle_disable_facility_lock (MmGdbusModem3gpp *skeleton,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Set Packet Service State */
|
||||
|
||||
typedef struct {
|
||||
MMIfaceModem3gpp *self;
|
||||
MmGdbusModem3gpp *skeleton;
|
||||
GDBusMethodInvocation *invocation;
|
||||
MMModem3gppPacketServiceState packet_service_state;
|
||||
} HandlePacketServiceStateContext;
|
||||
|
||||
static void
|
||||
handle_set_packet_service_state_context_free (HandlePacketServiceStateContext *ctx)
|
||||
{
|
||||
g_object_unref (ctx->invocation);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_object_unref (ctx->self);
|
||||
g_slice_free (HandlePacketServiceStateContext,ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_ready(MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
HandlePacketServiceStateContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_packet_service_state_finish (self, res, &error))
|
||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||
else
|
||||
mm_gdbus_modem3gpp_complete_set_packet_service_state (ctx->skeleton, ctx->invocation);
|
||||
handle_set_packet_service_state_context_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_auth_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
HandlePacketServiceStateContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||
handle_set_packet_service_state_context_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mm_iface_modem_abort_invocation_if_state_not_reached (MM_IFACE_MODEM (self),
|
||||
ctx->invocation,
|
||||
MM_MODEM_STATE_ENABLED)) {
|
||||
handle_set_packet_service_state_context_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (ctx->self)->set_packet_service_state ||
|
||||
!MM_IFACE_MODEM_3GPP_GET_INTERFACE (ctx->self)->set_packet_service_state_finish) {
|
||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||
MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Explicit packet service attach/detach operation not supported");
|
||||
handle_set_packet_service_state_context_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ctx->packet_service_state != MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED) &&
|
||||
(ctx->packet_service_state != MM_MODEM_3GPP_PACKET_SERVICE_STATE_DETACHED)) {
|
||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||
MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Invalid packet service state requested");
|
||||
handle_set_packet_service_state_context_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_packet_service_state (ctx->self,
|
||||
ctx->packet_service_state,
|
||||
(GAsyncReadyCallback)set_packet_service_state_ready,
|
||||
ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_set_packet_service_state (MmGdbusModem3gpp *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
MMModem3gppPacketServiceState packet_service_state,
|
||||
MMIfaceModem3gpp *self)
|
||||
{
|
||||
HandlePacketServiceStateContext *ctx;
|
||||
|
||||
ctx = g_slice_new (HandlePacketServiceStateContext);
|
||||
ctx->skeleton = g_object_ref (skeleton);
|
||||
ctx->invocation = g_object_ref (invocation);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->packet_service_state = packet_service_state;
|
||||
|
||||
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||
invocation,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
(GAsyncReadyCallback)set_packet_service_state_auth_ready,
|
||||
ctx);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
@@ -2974,6 +3073,10 @@ interface_initialization_step (GTask *task)
|
||||
"handle-set-initial-eps-bearer-settings",
|
||||
G_CALLBACK (handle_set_initial_eps_bearer_settings),
|
||||
self);
|
||||
g_signal_connect (ctx->skeleton,
|
||||
"handle-set-packet-service-state",
|
||||
G_CALLBACK (handle_set_packet_service_state),
|
||||
self);
|
||||
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
@@ -245,6 +245,15 @@ struct _MMIfaceModem3gpp {
|
||||
gboolean (* disable_facility_lock_finish) (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Set Packet service */
|
||||
void (*set_packet_service_state) (MMIfaceModem3gpp *self,
|
||||
MMModem3gppPacketServiceState state,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean (*set_packet_service_state_finish) (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType mm_iface_modem_3gpp_get_type (void);
|
||||
|
Reference in New Issue
Block a user