/**
 * mm_modem_create_sms_sync:
 * @self: A #MMModemMessaging.
 * @properties: A ##MMSmsProperties object with the properties to use.
 * @cancellable: (allow-none): A #GCancellable or %NULL.
 * @error: Return location for error or %NULL.
 *
 * Synchronously creates a new #MMSms in the modem.
 *
 * The calling thread is blocked until a reply is received. See mm_modem_messaging_create()
 * for the asynchronous version of this method.
 *
 * Returns: (transfer full): A newly created #MMSms, or %NULL if @error is set. The returned value should be freed with g_object_unref().
 */
MMSms *
mm_modem_messaging_create_sync (MMModemMessaging *self,
                                MMSmsProperties *properties,
                                GCancellable *cancellable,
                                GError **error)
{
    MMSms *sms = NULL;
    gchar *sms_path = NULL;
    GVariant *dictionary;

    g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL);

    dictionary = (mm_sms_properties_get_dictionary (properties));
    mm_gdbus_modem_messaging_call_create_sync (MM_GDBUS_MODEM_MESSAGING (self),
                                               dictionary,
                                               &sms_path,
                                               cancellable,
                                               error);
    if (sms_path) {
        sms = g_initable_new (MM_TYPE_SMS,
                              cancellable,
                              error,
                              "g-flags",          G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
                              "g-name",           MM_DBUS_SERVICE,
                              "g-connection",     g_dbus_proxy_get_connection (G_DBUS_PROXY (self)),
                              "g-object-path",    sms_path,
                              "g-interface-name", "org.freedesktop.ModemManager1.Sms",
                              NULL);
        g_free (sms_path);
    }

    g_variant_unref (dictionary);

    return (sms ? MM_SMS (sms) : NULL);
}
static void
list_process_reply (GList        *result,
                    const GError *error)
{
    if (error) {
        g_printerr ("error: couldn't list SMS: '%s'\n",
                    error->message);
        exit (EXIT_FAILURE);
    }

    g_print ("\n");
    if (!result) {
        g_print ("No SMS messages were found\n");
    } else {
        GList *l;

        g_print ("Found %u SMS messages:\n", g_list_length (result));
        for (l = result; l; l = g_list_next (l)) {
            MMSms *sms = MM_SMS (l->data);

            print_sms_short_info (sms);
            g_object_unref (sms);
        }
        g_list_free (result);
    }
}
示例#3
0
static MMSms *
find_sms_in_list (GList *list,
                  const gchar *sms_path)
{
    GList *l;

    for (l = list; l; l = g_list_next (l)) {
        MMSms *sms = MM_SMS (l->data);

        if (g_str_equal (mm_sms_get_path (sms), sms_path)) {
            g_debug ("Sms found at '%s'\n", sms_path);
            return g_object_ref (sms);
        }
    }

    return NULL;
}