static void unlock_dialog_response (GtkDialog *dialog, gint response, gpointer user_data) { BroadbandDeviceInfo *info = user_data; const char *code1, *code2; MMModemLock lock; if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) { unlock_dialog_destroy (info); return; } lock = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (info->dialog), "unlock-code")); g_assert (lock == MM_MODEM_LOCK_SIM_PIN || lock == MM_MODEM_LOCK_SIM_PUK); /* Start the spinner to show the progress of the unlock */ applet_mobile_pin_dialog_start_spinner (info->dialog, _("Sending unlock code...")); code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog); if (!code1 || !strlen (code1)) { g_warn_if_fail (code1 != NULL); g_warn_if_fail (strlen (code1)); unlock_dialog_destroy (info); return; } /* Send the code to ModemManager */ if (lock == MM_MODEM_LOCK_SIM_PIN) { mm_sim_send_pin (info->mm_sim, code1, NULL, /* cancellable */ (GAsyncReadyCallback)dialog_sim_send_pin_ready, info); return; } if (lock == MM_MODEM_LOCK_SIM_PUK) { code2 = applet_mobile_pin_dialog_get_entry2 (info->dialog); if (!code2) { g_warn_if_fail (code2 != NULL); unlock_dialog_destroy (info); return; } mm_sim_send_puk (info->mm_sim, code1, /* puk */ code2, /* new pin */ NULL, /* cancellable */ (GAsyncReadyCallback)dialog_sim_send_puk_ready, info); return; } g_assert_not_reached (); }
static void keyring_pin_check_cb (GnomeKeyringResult result, GList *list, gpointer user_data) { BroadbandDeviceInfo *info = user_data; GList *iter; const char *pin = NULL; const char *simid; info->keyring_id = NULL; if (result != GNOME_KEYRING_RESULT_OK) { /* No saved PIN, just ask the user */ unlock_dialog_new (info->device, info); return; } /* Look for a result with a matching "simid" attribute since that's * better than just using a matching "devid". The PIN is really tied * to the SIM, not the modem itself. */ simid = mm_sim_get_identifier (info->mm_sim); if (simid) { for (iter = list; (pin == NULL) && iter; iter = g_list_next (iter)) { GnomeKeyringFound *found = iter->data; int i; /* Look for a matching "simid" attribute */ for (i = 0; (pin == NULL) && i < found->attributes->len; i++) { GnomeKeyringAttribute attr = gnome_keyring_attribute_list_index (found->attributes, i); if (g_strcmp0 (attr.name, "simid") == 0 && attr.type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING && g_strcmp0 (attr.value.string, simid) == 0) { pin = found->secret; break; } } } } if (pin == NULL) { /* Fall back to the first result's PIN */ pin = ((GnomeKeyringFound *) list->data)->secret; if (pin == NULL) { /* Should never get here */ g_warn_if_fail (pin != NULL); unlock_dialog_new (info->device, info); return; } } mm_sim_send_pin (info->mm_sim, pin, NULL, /* cancellable */ (GAsyncReadyCallback)autounlock_sim_send_pin_ready, info); }
static void keyring_pin_check_cb (GObject *source, GAsyncResult *result, gpointer user_data) { BroadbandDeviceInfo *info = user_data; GList *iter; GList *list; SecretItem *item; SecretValue *pin = NULL; GHashTable *attributes; GError *error = NULL; const char *simid; list = secret_service_search_finish (NULL, result, &error); if (error != NULL) { /* No saved PIN, just ask the user */ unlock_dialog_new (info->device, info); g_error_free (error); return; } /* Look for a result with a matching "simid" attribute since that's * better than just using a matching "devid". The PIN is really tied * to the SIM, not the modem itself. */ simid = mm_sim_get_identifier (info->mm_sim); if (simid) { for (iter = list; (pin == NULL) && iter; iter = g_list_next (iter)) { item = iter->data; /* Look for a matching "simid" attribute */ attributes = secret_item_get_attributes (item); if (g_strcmp0 (simid, g_hash_table_lookup (attributes, "simid"))) pin = secret_item_get_secret (item); else pin = NULL; g_hash_table_unref (attributes); if (pin != NULL) break; } } if (pin == NULL) { /* Fall back to the first result's PIN if we have one */ if (list) pin = secret_item_get_secret (list->data); if (pin == NULL) { unlock_dialog_new (info->device, info); return; } } /* Send the PIN code to ModemManager */ mm_sim_send_pin (info->mm_sim, secret_value_get (pin, NULL), NULL, /* cancellable */ (GAsyncReadyCallback)autounlock_sim_send_pin_ready, info); secret_value_unref (pin); }
static void get_sim_ready (GObject *source, GAsyncResult *result, gpointer none) { ctx->sim = mmcli_get_sim_finish (result, &ctx->manager, &ctx->object); if (info_flag) g_assert_not_reached (); /* Requesting to enable PIN? */ if (enable_pin_flag) { mm_sim_enable_pin (ctx->sim, pin_str, ctx->cancellable, (GAsyncReadyCallback)enable_pin_ready, NULL); return; } /* Requesting to disable PIN? */ if (disable_pin_flag) { mm_sim_disable_pin (ctx->sim, pin_str, ctx->cancellable, (GAsyncReadyCallback)disable_pin_ready, NULL); return; } /* Requesting to change PIN? */ if (change_pin_str) { mm_sim_change_pin (ctx->sim, pin_str, /* current */ change_pin_str, /* new */ ctx->cancellable, (GAsyncReadyCallback)change_pin_ready, NULL); return; } /* Requesting to send PUK? */ if (puk_str) { mm_sim_send_puk (ctx->sim, puk_str, pin_str, ctx->cancellable, (GAsyncReadyCallback)send_puk_ready, NULL); return; } /* Requesting to send PIN? (always LAST check!) */ if (pin_str) { mm_sim_send_pin (ctx->sim, pin_str, ctx->cancellable, (GAsyncReadyCallback)send_pin_ready, NULL); return; } g_warn_if_reached (); }