~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to plugins/service.c

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  BlueZ - Bluetooth protocol stack for Linux
4
4
 *
5
 
 *  Copyright (C) 2006-2007  Nokia Corporation
6
 
 *  Copyright (C) 2004-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2006-2010  Nokia Corporation
 
6
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
7
7
 *
8
8
 *
9
9
 *  This program is free software; you can redistribute it and/or modify
31
31
#include <string.h>
32
32
 
33
33
#include <bluetooth/bluetooth.h>
34
 
#include <bluetooth/hci.h>
35
 
#include <bluetooth/hci_lib.h>
36
34
#include <bluetooth/sdp.h>
37
35
#include <bluetooth/sdp_lib.h>
38
36
 
43
41
#include "plugin.h"
44
42
#include "adapter.h"
45
43
#include "error.h"
46
 
#include "logging.h"
 
44
#include "log.h"
47
45
 
48
46
#define SERVICE_INTERFACE "org.bluez.Service"
49
47
 
107
105
                                break;
108
106
                        }
109
107
                }
110
 
                debug("New attribute 0x%04x", ctx_data->attr_id);
 
108
                DBG("New attribute 0x%04x", ctx_data->attr_id);
111
109
                return;
112
110
        }
113
111
 
174
172
                        int ret = sdp_attr_add(ctx_data->record, ctx_data->attr_id,
175
173
                                                        ctx_data->stack_head->data);
176
174
                        if (ret == -1)
177
 
                                debug("Trouble adding attribute\n");
 
175
                                DBG("Trouble adding attribute\n");
178
176
 
179
177
                        ctx_data->stack_head->data = NULL;
180
178
                        sdp_xml_data_free(ctx_data->stack_head);
181
179
                        ctx_data->stack_head = NULL;
182
180
                } else {
183
 
                        debug("No data for attribute 0x%04x\n", ctx_data->attr_id);
 
181
                        DBG("No data for attribute 0x%04x\n", ctx_data->attr_id);
184
182
                }
185
183
                return;
186
184
        }
321
319
        struct service_adapter *serv_adapter = user_record->serv_adapter;
322
320
        struct pending_auth *auth;
323
321
 
324
 
        debug("remove record");
 
322
        DBG("remove record");
325
323
 
326
324
        serv_adapter->records = g_slist_remove(serv_adapter->records,
327
325
                                                user_record);
359
357
static inline DBusMessage *failed_strerror(DBusMessage *msg, int err)
360
358
{
361
359
        return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
362
 
                        strerror(err));
 
360
                                                        "%s", strerror(err));
363
361
}
364
362
 
365
363
static inline DBusMessage *not_authorized(DBusMessage *msg)
409
407
        serv_adapter->records = g_slist_append(serv_adapter->records,
410
408
                                                                user_record);
411
409
 
412
 
        debug("listener_id %d", user_record->listener_id);
 
410
        DBG("listener_id %d", user_record->listener_id);
413
411
 
414
412
        *handle = user_record->handle;
415
413
 
442
440
                error("Failed to update the service record");
443
441
                return g_dbus_create_error(msg,
444
442
                                ERROR_INTERFACE ".Failed",
445
 
                                strerror(EIO));
 
443
                                "%s", strerror(EIO));
446
444
        }
447
445
 
448
446
        return dbus_message_new_method_return(msg);
481
479
                sdp_record_free(sdp_record);
482
480
                return g_dbus_create_error(msg,
483
481
                                ERROR_INTERFACE ".Failed",
484
 
                                strerror(EIO));
 
482
                                "%s", strerror(EIO));
485
483
        }
486
484
 
487
485
        return update_record(conn, msg, serv_adapter, handle, sdp_record);
493
491
{
494
492
        struct record_data *user_record;
495
493
 
496
 
        debug("remove record 0x%x", handle);
 
494
        DBG("remove record 0x%x", handle);
497
495
 
498
496
        user_record = find_record(serv_adapter, handle, sender);
499
497
        if (!user_record)
500
498
                return -1;
501
499
 
502
 
        debug("listner_id %d", user_record->listener_id);
 
500
        DBG("listner_id %d", user_record->listener_id);
503
501
 
504
502
        g_dbus_remove_watch(conn, user_record->listener_id);
505
503
 
640
638
        }
641
639
 
642
640
        record = sdp_record_find(user_record->handle);
 
641
        if (record == NULL)
 
642
                return not_authorized(msg);
643
643
 
644
644
        if (sdp_get_service_classes(record, &services) < 0) {
645
645
                sdp_record_free(record);
761
761
                g_dbus_remove_watch(connection, user_record->listener_id);
762
762
                exit_callback(connection, user_record);
763
763
        }
 
764
 
 
765
        g_free(serv_adapter);
764
766
}
765
767
 
766
768
static int register_interface(const char *path, struct btd_adapter *adapter)
785
787
                return -EIO;
786
788
        }
787
789
 
788
 
        debug("Registered interface %s on path %s", SERVICE_INTERFACE, path);
 
790
        DBG("Registered interface %s on path %s", SERVICE_INTERFACE, path);
789
791
 
790
792
        if (serv_adapter->adapter == NULL)
791
793
                serv_adapter_any = serv_adapter;
859
861
        dbus_connection_unref(connection);
860
862
}
861
863
 
862
 
BLUETOOTH_PLUGIN_DEFINE("service", VERSION, service_init, service_exit)
 
864
BLUETOOTH_PLUGIN_DEFINE(service, VERSION,
 
865
                BLUETOOTH_PLUGIN_PRIORITY_HIGH, service_init, service_exit)