~binli/ubuntu/vivid/modemmanager/lp1441095

« back to all changes in this revision

Viewing changes to cli/mmcli-modem-messaging.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Guido Günther, Michael Biebl
  • Date: 2014-06-25 02:23:09 UTC
  • mfrom: (20.2.2 sid)
  • Revision ID: package-import@ubuntu.com-20140625022309-43papaenj5ikbx3y
Tags: 1.2.0-1
[ Guido Günther ]
* New upstream version 1.2.0 (Closes: #731851)
* Update patches
* Install locale files
* Require newer libqmi
* Update symbols file
* Ship gobject introspection data
* Ship vala bindings

[ Michael Biebl ]
* Use canonical URI for Vcs-Git
* Use gir dh addon
* Update extendend package description (Closes: #744180)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
/* Context */
38
38
typedef struct {
 
39
    GDBusConnection *connection;
39
40
    MMManager *manager;
40
41
    GCancellable *cancellable;
41
42
    MMObject *object;
69
70
    },
70
71
    { "messaging-delete-sms", 0, 0, G_OPTION_ARG_STRING, &delete_str,
71
72
      "Delete a SMS from a given modem",
72
 
      "[PATH]"
 
73
      "[PATH|INDEX]"
73
74
    },
74
75
    { NULL }
75
76
};
135
136
        g_object_unref (ctx->object);
136
137
    if (ctx->manager)
137
138
        g_object_unref (ctx->manager);
 
139
    if (ctx->connection)
 
140
        g_object_unref (ctx->connection);
138
141
    g_free (ctx);
139
142
}
140
143
 
336
339
}
337
340
 
338
341
static void
 
342
get_sms_to_delete_ready (GDBusConnection *connection,
 
343
                         GAsyncResult *res)
 
344
{
 
345
    MMSms *sms;
 
346
    MMObject *obj = NULL;
 
347
 
 
348
    sms = mmcli_get_sms_finish (res, NULL, &obj);
 
349
    if (!g_str_equal (mm_object_get_path (obj), mm_modem_messaging_get_path (ctx->modem_messaging))) {
 
350
        g_printerr ("error: SMS '%s' not owned by modem '%s'",
 
351
                    mm_sms_get_path (sms),
 
352
                    mm_modem_messaging_get_path (ctx->modem_messaging));
 
353
        exit (EXIT_FAILURE);
 
354
    }
 
355
 
 
356
    mm_modem_messaging_delete (ctx->modem_messaging,
 
357
                               mm_sms_get_path (sms),
 
358
                               ctx->cancellable,
 
359
                               (GAsyncReadyCallback)delete_ready,
 
360
                               NULL);
 
361
    g_object_unref (sms);
 
362
    g_object_unref (obj);
 
363
}
 
364
 
 
365
static void
339
366
get_modem_ready (GObject      *source,
340
367
                 GAsyncResult *result,
341
368
                 gpointer      none)
380
407
 
381
408
    /* Request to delete a given SMS? */
382
409
    if (delete_str) {
383
 
        mm_modem_messaging_delete (ctx->modem_messaging,
384
 
                                   delete_str,
385
 
                                   ctx->cancellable,
386
 
                                   (GAsyncReadyCallback)delete_ready,
387
 
                                   NULL);
 
410
        mmcli_get_sms (ctx->connection,
 
411
                       delete_str,
 
412
                       ctx->cancellable,
 
413
                       (GAsyncReadyCallback)get_sms_to_delete_ready,
 
414
                       NULL);
388
415
        return;
389
416
    }
390
417
 
399
426
    ctx = g_new0 (Context, 1);
400
427
    if (cancellable)
401
428
        ctx->cancellable = g_object_ref (cancellable);
 
429
    ctx->connection = g_object_ref (connection);
402
430
 
403
431
    /* Get proper modem */
404
432
    mmcli_get_modem (connection,
465
493
    /* Request to delete a given SMS? */
466
494
    if (delete_str) {
467
495
        gboolean result;
 
496
        MMSms *sms;
 
497
        MMObject *obj = NULL;
 
498
 
 
499
        sms = mmcli_get_sms_sync (connection,
 
500
                                  delete_str,
 
501
                                  NULL,
 
502
                                  &obj);
 
503
        if (!g_str_equal (mm_object_get_path (obj), mm_modem_messaging_get_path (ctx->modem_messaging))) {
 
504
            g_printerr ("error: SMS '%s' not owned by modem '%s'",
 
505
                        mm_sms_get_path (sms),
 
506
                        mm_modem_messaging_get_path (ctx->modem_messaging));
 
507
            exit (EXIT_FAILURE);
 
508
        }
468
509
 
469
510
        result = mm_modem_messaging_delete_sync (ctx->modem_messaging,
470
 
                                                 delete_str,
 
511
                                                 mm_sms_get_path (sms),
471
512
                                                 NULL,
472
513
                                                 &error);
 
514
        g_object_unref (sms);
 
515
        g_object_unref (obj);
473
516
 
474
517
        delete_process_reply (result, error);
475
518
        return;