diff options
author | Som_SP <somashekhar.puttagangaiah@intel.com> | 2021-10-21 15:41:53 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-11-02 09:50:17 +0000 |
commit | 0316afee06da715e81252d26976fc83dbb95a426 (patch) | |
tree | dd37b9e8194099ee6ce41653c4f81e21b1f89e9d | |
parent | 3ab765f11c074846cdd7fc81db3f1056ae18f388 (diff) |
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.
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 103 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.h | 9 |
2 files changed, 112 insertions, 0 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 64041ce6..1e18b5b7 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -1341,6 +1341,105 @@ handle_disable_facility_lock (MmGdbusModem3gpp *skeleton, } /*****************************************************************************/ +/* 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 mm_iface_modem_3gpp_run_registration_checks_finish (MMIfaceModem3gpp *self, @@ -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 */ diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index 26843d66..b0403ea8 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -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); |