aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/mm-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-08-01 09:59:37 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-08-28 14:59:06 +0000
commit924cf1af3c5e1aec1df680d50e4b9ae6dd8e0ba9 (patch)
tree48c1492b1412ca81b3e0abfc860d55a60a5d47cd /libmm-glib/mm-modem.c
parent5041b9c99b8587185b629715e3466d31a619abf3 (diff)
api,modem: new 'SetPrimarySimSlot' method
This new method allows changing the SIM slot considered as primary, when the modem supports multiple SIM slots. The generic handling of this method will make sure that the modem object and all its SIM objects are re-probed from scratch as soon as a successful SIM slot switch happens. Implementations may report MM_CORE_ERROR_EXISTS when the switch doesn't need to happen (e.g. if the requested SIM slot is already the active one).
Diffstat (limited to 'libmm-glib/mm-modem.c')
-rw-r--r--libmm-glib/mm-modem.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c
index 96e113bd..38300d49 100644
--- a/libmm-glib/mm-modem.c
+++ b/libmm-glib/mm-modem.c
@@ -3699,6 +3699,93 @@ mm_modem_list_sim_slots_sync (MMModem *self,
/*****************************************************************************/
+/**
+ * mm_modem_set_primary_sim_slot_finish:
+ * @self: A #MMModem.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
+ * mm_modem_set_primary_sim_slot().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with mm_modem_set_primary_sim_slot().
+ *
+ * Returns: %TRUE if the SIM slot switch has been successfully requested, %FALSE if
+ * @error is set.
+ *
+ * Since: 1.16
+ */
+gboolean
+mm_modem_set_primary_sim_slot_finish (MMModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
+
+ return mm_gdbus_modem_call_set_primary_sim_slot_finish (MM_GDBUS_MODEM (self), res, error);
+}
+
+/**
+ * mm_modem_set_primary_sim_slot:
+ * @self: A #MMModem.
+ * @sim_slot: SIM slot number.
+ * @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 requests to select which SIM slot to be considered as primary.
+ *
+ * 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_set_primary_sim_slot_finish() to get the result of the operation.
+ *
+ * See mm_modem_set_primary_sim_slot_sync() for the synchronous, blocking version of
+ * this method.
+ *
+ * Since: 1.16
+ */
+void
+mm_modem_set_primary_sim_slot (MMModem *self,
+ guint sim_slot,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (MM_IS_MODEM (self));
+
+ mm_gdbus_modem_call_set_primary_sim_slot (MM_GDBUS_MODEM (self), sim_slot, cancellable, callback, user_data);
+}
+
+/**
+ * mm_modem_set_primary_sim_slot_sync:
+ * @self: A #MMModem.
+ * @sim_slot: SIM slot number.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously requests to select which SIM slot to be considered as primary.
+ *
+ * The calling thread is blocked until a reply is received. See
+ * mm_modem_set_primary_sim_slot() for the asynchronous version of this method.
+ *
+ * Returns: %TRUE if the SIM slot switch has been successfully requested, %FALSE if
+ * @error is set.
+ *
+ * Since: 1.16
+ */
+gboolean
+mm_modem_set_primary_sim_slot_sync (MMModem *self,
+ guint sim_slot,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
+
+ return mm_gdbus_modem_call_set_primary_sim_slot_sync (MM_GDBUS_MODEM (self), sim_slot, cancellable, error);
+}
+
+/*****************************************************************************/
+
static void
mm_modem_init (MMModem *self)
{