api,3gpp: new 'SetPacketServiceState()' method
This commit is contained in:
@@ -52,6 +52,7 @@ static gchar *register_in_operator_str;
|
||||
static gchar *set_eps_ue_mode_operation_str;
|
||||
static gchar *set_initial_eps_bearer_settings_str;
|
||||
static gchar *disable_facility_lock_str;
|
||||
static gchar *set_packet_service_state_str;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "3gpp-scan", 0, 0, G_OPTION_ARG_NONE, &scan_flag,
|
||||
@@ -78,6 +79,10 @@ static GOptionEntry entries[] = {
|
||||
"Disable facility personalization",
|
||||
"[facility,key]"
|
||||
},
|
||||
{ "3gpp-set-packet-service-state", 0, 0, G_OPTION_ARG_STRING, &set_packet_service_state_str,
|
||||
"Set packet service state",
|
||||
"[attached|detached]"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -110,7 +115,8 @@ mmcli_modem_3gpp_options_enabled (void)
|
||||
!!register_in_operator_str +
|
||||
!!set_eps_ue_mode_operation_str +
|
||||
!!set_initial_eps_bearer_settings_str +
|
||||
!!disable_facility_lock_str);
|
||||
!!disable_facility_lock_str +
|
||||
!!set_packet_service_state_str);
|
||||
|
||||
if (n_actions > 1) {
|
||||
g_printerr ("error: too many 3GPP actions requested\n");
|
||||
@@ -340,6 +346,47 @@ disable_facility_lock_ready (MMModem3gpp *modem_3gpp,
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_process_reply (gboolean result,
|
||||
const GError *error)
|
||||
{
|
||||
if (!result) {
|
||||
g_printerr ("error: couldn't set packet service state: '%s'\n",
|
||||
error ? error->message : "unknown error");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_print ("successfully set packet service state\n");
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_ready (MMModem3gpp *modem_3gpp,
|
||||
GAsyncResult *result,
|
||||
gpointer nothing)
|
||||
{
|
||||
gboolean operation_result;
|
||||
GError *error = NULL;
|
||||
|
||||
operation_result = mm_modem_3gpp_set_packet_service_state_finish (modem_3gpp, result, &error);
|
||||
set_packet_service_state_process_reply (operation_result, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_packet_service_state_parse_input (const gchar *str,
|
||||
MMModem3gppPacketServiceState *out_state)
|
||||
{
|
||||
MMModem3gppPacketServiceState state;
|
||||
|
||||
state = mm_common_get_3gpp_packet_service_state_from_string (str, NULL);
|
||||
if (state == MM_MODEM_3GPP_PACKET_SERVICE_STATE_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
*out_state = state;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
get_modem_ready (GObject *source,
|
||||
GAsyncResult *result)
|
||||
@@ -435,6 +482,24 @@ get_modem_ready (GObject *source,
|
||||
|
||||
}
|
||||
|
||||
/* Request to set packet service state */
|
||||
if (set_packet_service_state_str) {
|
||||
MMModem3gppPacketServiceState state;
|
||||
|
||||
if (!set_packet_service_state_parse_input (set_packet_service_state_str, &state)) {
|
||||
g_printerr ("Error parsing packet service state string.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Asynchronously setting packet service state...");
|
||||
mm_modem_3gpp_set_packet_service_state (ctx->modem_3gpp,
|
||||
state,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)set_packet_service_state_ready,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
||||
@@ -552,5 +617,24 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to set packet service state */
|
||||
if (set_packet_service_state_str) {
|
||||
gboolean result;
|
||||
MMModem3gppPacketServiceState state;
|
||||
|
||||
if (!set_packet_service_state_parse_input (set_packet_service_state_str, &state)) {
|
||||
g_printerr ("Error parsing packet service state string.\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Asynchronously setting packet service state...");
|
||||
result = mm_modem_3gpp_set_packet_service_state_sync (ctx->modem_3gpp,
|
||||
state,
|
||||
NULL,
|
||||
&error);
|
||||
set_packet_service_state_process_reply (result, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
@@ -324,6 +324,9 @@ mm_modem_3gpp_set_initial_eps_bearer_settings_sync
|
||||
mm_modem_3gpp_disable_facility_lock
|
||||
mm_modem_3gpp_disable_facility_lock_finish
|
||||
mm_modem_3gpp_disable_facility_lock_sync
|
||||
mm_modem_3gpp_set_packet_service_state
|
||||
mm_modem_3gpp_set_packet_service_state_finish
|
||||
mm_modem_3gpp_set_packet_service_state_sync
|
||||
<SUBSECTION Standard>
|
||||
MMModem3gppClass
|
||||
MMModem3gppPrivate
|
||||
@@ -2134,12 +2137,16 @@ mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings_sync
|
||||
mm_gdbus_modem3gpp_call_disable_facility_lock
|
||||
mm_gdbus_modem3gpp_call_disable_facility_lock_finish
|
||||
mm_gdbus_modem3gpp_call_disable_facility_lock_sync
|
||||
mm_gdbus_modem3gpp_call_set_packet_service_state
|
||||
mm_gdbus_modem3gpp_call_set_packet_service_state_finish
|
||||
mm_gdbus_modem3gpp_call_set_packet_service_state_sync
|
||||
<SUBSECTION Private>
|
||||
mm_gdbus_modem3gpp_complete_register
|
||||
mm_gdbus_modem3gpp_complete_scan
|
||||
mm_gdbus_modem3gpp_complete_set_eps_ue_mode_operation
|
||||
mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings
|
||||
mm_gdbus_modem3gpp_complete_disable_facility_lock
|
||||
mm_gdbus_modem3gpp_complete_set_packet_service_state
|
||||
mm_gdbus_modem3gpp_interface_info
|
||||
mm_gdbus_modem3gpp_override_properties
|
||||
mm_gdbus_modem3gpp_set_enabled_facility_locks
|
||||
|
@@ -213,6 +213,18 @@
|
||||
<arg name="properties" type="(us)" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SetPacketServiceState:
|
||||
@state: a <link linkend="MMModem3gppPacketServiceState">MMModem3gppPacketServiceState</link>.
|
||||
|
||||
Explicitly attach or detach packet service on the current registered network.
|
||||
|
||||
Since: 1.20
|
||||
-->
|
||||
<method name="SetPacketServiceState">
|
||||
<arg name="state" type="u" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SubscriptionState:
|
||||
|
||||
|
@@ -669,6 +669,16 @@ mm_common_get_3gpp_facility_from_string (const gchar *str,
|
||||
error);
|
||||
}
|
||||
|
||||
MMModem3gppPacketServiceState
|
||||
mm_common_get_3gpp_packet_service_state_from_string (const gchar *str,
|
||||
GError **error)
|
||||
{
|
||||
return _enum_from_string (MM_TYPE_MODEM_3GPP_PACKET_SERVICE_STATE,
|
||||
str,
|
||||
MM_MODEM_3GPP_PACKET_SERVICE_STATE_UNKNOWN,
|
||||
error);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* MMModemPortInfo array management */
|
||||
|
||||
|
@@ -85,6 +85,8 @@ MMBearerApnType mm_common_get_apn_type_from_string
|
||||
GError **error);
|
||||
MMModem3gppFacility mm_common_get_3gpp_facility_from_string (const gchar *str,
|
||||
GError **error);
|
||||
MMModem3gppPacketServiceState mm_common_get_3gpp_packet_service_state_from_string (const gchar *str,
|
||||
GError **error);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@@ -1281,6 +1281,93 @@ mm_modem_3gpp_disable_facility_lock_sync (MMModem3gpp *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_set_packet_service_state_finish:
|
||||
* @self: A #MMModem3gpp.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_3gpp_set_packet_service_state().
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_3gpp_set_packet_service_state().
|
||||
*
|
||||
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_set_packet_service_state_finish (MMModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE);
|
||||
|
||||
return mm_gdbus_modem3gpp_call_set_packet_service_state_finish (MM_GDBUS_MODEM3GPP (self), res, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_set_packet_service_state:
|
||||
* @self: A #MMModem3gpp.
|
||||
* @state: A #MMModem3gppPacketServiceState.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or
|
||||
* %NULL.
|
||||
* @user_data: User data to pass to @callback.
|
||||
*
|
||||
* Asynchronously tries to attach or detach from the packet domain service.
|
||||
*
|
||||
*
|
||||
* When the operation is finished, @callback will be invoked in the
|
||||
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
|
||||
* of the thread you are calling this method from. You can then call
|
||||
* mm_modem_3gpp_set_packet_service_state_finish() to get the result of the operation.
|
||||
*
|
||||
* See mm_modem_3gpp_set_packet_service_state_sync() for the synchronous,
|
||||
* blocking version of this method.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
void
|
||||
mm_modem_3gpp_set_packet_service_state (MMModem3gpp *self,
|
||||
MMModem3gppPacketServiceState state,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_3GPP (self));
|
||||
|
||||
mm_gdbus_modem3gpp_call_set_packet_service_state (MM_GDBUS_MODEM3GPP (self), state, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_set_packet_service_state_sync:
|
||||
* @self: A #MMModem3gpp.
|
||||
* @state: A #MMModem3gppPacketServiceState.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Synchronously tries to attach or detach from the packet domain service.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_3gpp_set_packet_service_state() for the asynchronous version of
|
||||
* this method.
|
||||
*
|
||||
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_set_packet_service_state_sync (MMModem3gpp *self,
|
||||
MMModem3gppPacketServiceState state,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP (self), FALSE);
|
||||
|
||||
return mm_gdbus_modem3gpp_call_set_packet_service_state_sync (MM_GDBUS_MODEM3GPP (self), state, cancellable, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_modem_3gpp_init (MMModem3gpp *self)
|
||||
{
|
||||
|
@@ -189,6 +189,19 @@ gboolean mm_modem_3gpp_disable_facility_lock_sync (MMModem3gpp *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void mm_modem_3gpp_set_packet_service_state (MMModem3gpp *self,
|
||||
MMModem3gppPacketServiceState state,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_modem_3gpp_set_packet_service_state_finish (MMModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
gboolean mm_modem_3gpp_set_packet_service_state_sync (MMModem3gpp *self,
|
||||
MMModem3gppPacketServiceState state,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _MM_MODEM_3GPP_H_ */
|
||||
|
Reference in New Issue
Block a user