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

« back to all changes in this revision

Viewing changes to plugins/hal.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) 2004-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
6
6
 *
7
7
 *
8
8
 *  This program is free software; you can redistribute it and/or modify
29
29
#include <dbus/dbus.h>
30
30
 
31
31
#include <bluetooth/bluetooth.h>
32
 
#include <bluetooth/hci.h>
33
 
#include <bluetooth/hci_lib.h>
34
32
 
35
33
#include "plugin.h"
36
34
#include "adapter.h"
37
 
#include "logging.h"
 
35
#include "log.h"
38
36
#include "dbus-hci.h"
39
37
 
40
38
static void formfactor_reply(DBusPendingCall *call, void *user_data)
42
40
        struct btd_adapter *adapter = user_data;
43
41
        const char *formfactor = NULL;
44
42
        DBusMessage *reply;
45
 
        uint8_t cls[3], minor = 0;
46
 
        int dd;
 
43
        uint8_t minor = 0;
47
44
 
48
45
        reply = dbus_pending_call_steal_reply(call);
49
46
 
60
57
                return;
61
58
        }
62
59
 
63
 
        debug("Computer is classified as %s", formfactor);
 
60
        DBG("Computer is classified as %s", formfactor);
64
61
 
65
62
        if (formfactor != NULL) {
66
63
                if (g_str_equal(formfactor, "laptop") == TRUE)
75
72
 
76
73
        dbus_message_unref(reply);
77
74
 
78
 
        dd = hci_open_dev(adapter_get_dev_id(adapter));
79
 
        if (dd < 0)
80
 
                return;
81
 
 
82
 
        if (hci_read_class_of_dev(dd, cls, 500) < 0) {
83
 
                hci_close_dev(dd);
84
 
                return;
85
 
        }
86
 
 
87
 
        debug("Current device class is 0x%02x%02x%02x\n",
88
 
                                                cls[2], cls[1], cls[0]);
89
 
 
90
75
        /* Computer major class */
91
 
        debug("Setting 0x%06x for major/minor device class", (1 << 8) | minor);
92
 
 
93
 
        set_major_and_minor_class(dd, cls, 0x01, minor);
94
 
 
95
 
        hci_close_dev(dd);
 
76
        DBG("Setting 0x%06x for major/minor device class", (1 << 8) | minor);
 
77
 
 
78
        btd_adapter_set_class(adapter, 0x01, minor);
96
79
}
97
80
 
98
81
static DBusConnection *connection;
158
141
        btd_unregister_adapter_driver(&hal_driver);
159
142
}
160
143
 
161
 
BLUETOOTH_PLUGIN_DEFINE("hal", VERSION, hal_init, hal_exit)
 
144
BLUETOOTH_PLUGIN_DEFINE(hal, VERSION,
 
145
                BLUETOOTH_PLUGIN_PRIORITY_LOW, hal_init, hal_exit)