gboolean mmcli_sms_options_enabled (void) { static guint n_actions = 0; static gboolean checked = FALSE; if (checked) return !!n_actions; n_actions = (send_flag + store_flag); if (n_actions == 0 && mmcli_get_common_sms_string ()) { /* default to info */ info_flag = TRUE; n_actions++; } if (n_actions > 1) { g_printerr ("error: too many SMS actions requested\n"); exit (EXIT_FAILURE); } if (info_flag) mmcli_force_sync_operation (); checked = TRUE; return !!n_actions; }
void mmcli_sms_run_asynchronous (GDBusConnection *connection, GCancellable *cancellable) { /* Initialize context */ ctx = g_new0 (Context, 1); if (cancellable) ctx->cancellable = g_object_ref (cancellable); /* Get proper sms */ mmcli_get_sms (connection, mmcli_get_common_sms_string (), cancellable, (GAsyncReadyCallback)get_sms_ready, NULL); }
void mmcli_sms_run_synchronous (GDBusConnection *connection) { GError *error = NULL; /* Initialize context */ ctx = g_new0 (Context, 1); ctx->sms = mmcli_get_sms_sync (connection, mmcli_get_common_sms_string (), &ctx->manager, &ctx->object); /* Request to get info from SMS? */ if (info_flag) { g_debug ("Printing SMS info..."); print_sms_info (ctx->sms); return; } /* Requesting to send the SMS? */ if (send_flag) { gboolean operation_result; operation_result = mm_sms_send_sync (ctx->sms, NULL, &error); send_process_reply (operation_result, error); return; } /* Requesting to store the SMS? */ if (store_flag) { gboolean operation_result; operation_result = mm_sms_store_sync (ctx->sms, NULL, &error); store_process_reply (operation_result, error); return; } g_warn_if_reached (); }
void mmcli_sms_run_synchronous (GDBusConnection *connection) { GError *error = NULL; /* Initialize context */ ctx = g_new0 (Context, 1); ctx->sms = mmcli_get_sms_sync (connection, mmcli_get_common_sms_string (), &ctx->manager, &ctx->object); /* Setup operation timeout */ mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sms)); /* Request to get info from SMS? */ if (info_flag) { g_debug ("Printing SMS info..."); print_sms_info (ctx->sms); return; } /* Request to create a new file with the data from the SMS? */ if (create_file_with_data_str) { g_debug ("Creating file with SMS data..."); create_file_with_data (ctx->sms, create_file_with_data_str); return; } /* Requesting to send the SMS? */ if (send_flag) { gboolean operation_result; operation_result = mm_sms_send_sync (ctx->sms, NULL, &error); send_process_reply (operation_result, error); return; } /* Requesting to store the SMS? */ if (store_flag) { gboolean operation_result; operation_result = mm_sms_store_sync (ctx->sms, MM_SMS_STORAGE_UNKNOWN, NULL, &error); store_process_reply (operation_result, error); return; } /* Requesting to store the SMS in a specific storage? */ if (store_in_storage_str) { gboolean operation_result; MMSmsStorage storage; GError *error = NULL; storage = mm_common_get_sms_storage_from_string (store_in_storage_str, &error); if (error) { g_printerr ("error: couldn't store the SMS: '%s'\n", error->message); exit (EXIT_FAILURE); } operation_result = mm_sms_store_sync (ctx->sms, storage, NULL, &error); store_process_reply (operation_result, error); return; } g_warn_if_reached (); }