static void
dialog_sim_send_pin_ready (MMSim *sim,
                           GAsyncResult *res,
                           BroadbandDeviceInfo *info)
{
	GError *error = NULL;

	if (!mm_sim_send_pin_finish (sim, res, &error)) {
		if (g_error_matches (error,
		                     MM_MOBILE_EQUIPMENT_ERROR,
		                     MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK)) {
			/* Destroy previous dialog and launch a new one rebuilt to ask for PUK */
			unlock_dialog_destroy (info);
			unlock_dialog_new (info->device, info);
		} else {
			const gchar *msg = NULL;

			/* Report error and re-try PIN request */
			if (g_error_matches (error,
			                     MM_MOBILE_EQUIPMENT_ERROR,
			                     MM_MOBILE_EQUIPMENT_ERROR_INCORRECT_PASSWORD))
				msg = _("Wrong PIN code; please contact your provider.");
			else {
				g_dbus_error_strip_remote_error (error);
				msg = error ? error->message : NULL;
			}

			applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
		}

		g_warning ("Failed to send PIN to devid: '%s' simid: '%s' : %s",
		           mm_modem_get_device_identifier (info->mm_modem),
		           mm_sim_get_identifier (info->mm_sim),
		           error->message);

		g_error_free (error);
		return;
	}

	/* Good */

	if (applet_mobile_pin_dialog_get_auto_unlock (info->dialog)) {
		const gchar *code1;

		code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
		mobile_helper_save_pin_in_keyring (mm_modem_get_device_identifier (info->mm_modem),
		                                   mm_sim_get_identifier (info->mm_sim),
		                                   code1);
	} else
		mobile_helper_delete_pin_in_keyring (mm_modem_get_device_identifier (info->mm_modem));

	unlock_dialog_destroy (info);
}
Example #2
0
static void
send_pin_ready (MMSim        *sim,
                GAsyncResult *result,
                gpointer      nothing)
{
    gboolean operation_result;
    GError *error = NULL;

    operation_result = mm_sim_send_pin_finish (sim, result, &error);
    send_pin_process_reply (operation_result, error);

    mmcli_async_operation_done ();
}
static void
autounlock_sim_send_pin_ready (MMSim *sim,
                               GAsyncResult *res,
                               BroadbandDeviceInfo *info)
{
	GError *error = NULL;

	if (!mm_sim_send_pin_finish (sim, res, &error)) {
		g_warning ("Failed to auto-unlock devid: '%s' simid: '%s' : %s",
		           mm_modem_get_device_identifier (info->mm_modem),
		           mm_sim_get_identifier (info->mm_sim),
		           error->message);
		g_error_free (error);

		/* Remove PIN from keyring right away */
		mobile_helper_delete_pin_in_keyring (mm_modem_get_device_identifier (info->mm_modem));

		/* Ask the user */
		unlock_dialog_new (info->device, info);
	}
}