~ubuntu-branches/ubuntu/oneiric/bluez/oneiric-201105191013

« back to all changes in this revision

Viewing changes to attrib/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-12-20 16:08:47 UTC
  • mfrom: (1.1.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20101220160847-wc1907sgz6x3vjz7
Tags: 4.82-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
        return g_strcmp0(watcher->path, match->path);
192
192
}
193
193
 
194
 
static inline DBusMessage *invalid_args(DBusMessage *msg)
195
 
{
196
 
        return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
197
 
                        "Invalid arguments in method call");
198
 
}
199
 
 
200
 
static inline DBusMessage *not_authorized(DBusMessage *msg)
201
 
{
202
 
        return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAuthorized",
203
 
                        "Not authorized");
204
 
}
205
 
 
206
194
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
207
195
{
208
196
        DBusMessageIter dict;
466
454
 
467
455
        if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
468
456
                                                        DBUS_TYPE_INVALID))
469
 
                return invalid_args(msg);
 
457
                return btd_error_invalid_args(msg);
470
458
 
471
459
        if (l2cap_connect(prim->gatt, &gerr, TRUE) < 0) {
472
 
                DBusMessage *reply;
473
 
                reply = g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
474
 
                                                        "%s", gerr->message);
 
460
                DBusMessage *reply = btd_error_failed(msg, gerr->message);
475
461
                g_error_free(gerr);
476
 
 
477
462
                return reply;
478
463
        }
479
464
 
500
485
 
501
486
        if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
502
487
                                                        DBUS_TYPE_INVALID))
503
 
                return invalid_args(msg);
 
488
                return btd_error_invalid_args(msg);
504
489
 
505
490
        match = g_new0(struct watcher, 1);
506
491
        match->name = g_strdup(sender);
508
493
        l = g_slist_find_custom(prim->watchers, match, watcher_cmp);
509
494
        watcher_free(match);
510
495
        if (!l)
511
 
                return not_authorized(msg);
 
496
                return btd_error_not_authorized(msg);
512
497
 
513
498
        watcher = l->data;
514
499
        g_dbus_remove_watch(conn, watcher->id);
538
523
 
539
524
        if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY ||
540
525
                        dbus_message_iter_get_element_type(iter) != DBUS_TYPE_BYTE)
541
 
                return invalid_args(msg);
 
526
                return btd_error_invalid_args(msg);
542
527
 
543
528
        dbus_message_iter_recurse(iter, &sub);
544
529
 
545
530
        dbus_message_iter_get_fixed_array(&sub, &value, &len);
546
531
 
547
532
        if (l2cap_connect(gatt, &gerr, FALSE) < 0) {
548
 
                DBusMessage *reply;
549
 
                reply = g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
550
 
                                                        "%s", gerr->message);
 
533
                DBusMessage *reply = btd_error_failed(msg, gerr->message);
551
534
                g_error_free(gerr);
552
 
 
553
535
                return reply;
554
536
        }
555
537
 
587
569
        const char *property;
588
570
 
589
571
        if (!dbus_message_iter_init(msg, &iter))
590
 
                return invalid_args(msg);
 
572
                return btd_error_invalid_args(msg);
591
573
 
592
574
        if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
593
 
                return invalid_args(msg);
 
575
                return btd_error_invalid_args(msg);
594
576
 
595
577
        dbus_message_iter_get_basic(&iter, &property);
596
578
        dbus_message_iter_next(&iter);
597
579
 
598
580
        if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
599
 
                return invalid_args(msg);
 
581
                return btd_error_invalid_args(msg);
600
582
 
601
583
        dbus_message_iter_recurse(&iter, &sub);
602
584
 
603
585
        if (g_str_equal("Value", property))
604
586
                return set_value(conn, msg, &sub, chr);
605
587
 
606
 
        return invalid_args(msg);
 
588
        return btd_error_invalid_args(msg);
607
589
}
608
590
 
609
591
static GDBusMethodTable char_methods[] = {