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

« back to all changes in this revision

Viewing changes to thermometer/manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-08-01 16:07:29 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20110801160729-s7bv7bh6u4o5vhlc
Tags: 4.96-0ubuntu1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *  BlueZ - Bluetooth protocol stack for Linux
 
4
 *
 
5
 *  Copyright (C) 2011 GSyC/LibreSoft, Universidad Rey Juan Carlos.
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 *
 
21
 */
 
22
 
 
23
#include <gdbus.h>
 
24
 
 
25
#include "adapter.h"
 
26
#include "device.h"
 
27
#include "thermometer.h"
 
28
#include "manager.h"
 
29
 
 
30
#define HEALTH_THERMOMETER_UUID         "00001809-0000-1000-8000-00805f9b34fb"
 
31
 
 
32
static DBusConnection *connection = NULL;
 
33
 
 
34
static int thermometer_driver_probe(struct btd_device *device, GSList *uuids)
 
35
{
 
36
        return thermometer_register(connection, device);
 
37
}
 
38
 
 
39
static void thermometer_driver_remove(struct btd_device *device)
 
40
{
 
41
        thermometer_unregister(device);
 
42
}
 
43
 
 
44
static struct btd_device_driver thermometer_device_driver = {
 
45
        .name   = "thermometer-device-driver",
 
46
        .uuids  = BTD_UUIDS(HEALTH_THERMOMETER_UUID),
 
47
        .probe  = thermometer_driver_probe,
 
48
        .remove = thermometer_driver_remove
 
49
};
 
50
 
 
51
int thermometer_manager_init(DBusConnection *conn)
 
52
{
 
53
        int ret;
 
54
 
 
55
        ret = btd_register_device_driver(&thermometer_device_driver);
 
56
        if (ret < 0)
 
57
                return ret;
 
58
 
 
59
        connection = dbus_connection_ref(conn);
 
60
        return 0;
 
61
}
 
62
 
 
63
void thermometer_manager_exit(void)
 
64
{
 
65
        btd_unregister_device_driver(&thermometer_device_driver);
 
66
 
 
67
        dbus_connection_unref(connection);
 
68
        connection = NULL;
 
69
}