3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
6
* Copyright (C) 2011 BMW Car IT GmbH. All rights reserved.
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License version 2 as
10
* published by the Free Software Foundation.
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.
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
31
#include <gatresult.h>
33
#include <ofono/log.h>
34
#include <ofono/modem.h>
35
#include <ofono/devinfo.h>
41
guint register_source;
44
static void hfp_query_serial(struct ofono_devinfo *info,
45
ofono_devinfo_query_cb_t cb,
48
struct devinfo_data *dev = ofono_devinfo_get_data(info);
49
CALLBACK_WITH_SUCCESS(cb, dev->device_address, data);
52
static gboolean hfp_devinfo_register(gpointer user_data)
54
struct ofono_devinfo *info = user_data;
55
struct devinfo_data *dd = ofono_devinfo_get_data(info);
57
dd->register_source = 0;
59
ofono_devinfo_register(info);
64
static int hfp_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
67
const char *device_address = user;
68
struct devinfo_data *dd;
70
dd = g_new0(struct devinfo_data, 1);
71
dd->device_address = g_strdup(device_address);
73
ofono_devinfo_set_data(info, dd);
75
dd->register_source = g_idle_add(hfp_devinfo_register, info);
79
static void hfp_devinfo_remove(struct ofono_devinfo *info)
81
struct devinfo_data *dd = ofono_devinfo_get_data(info);
83
ofono_devinfo_set_data(info, NULL);
87
if (dd->register_source != 0)
88
g_source_remove(dd->register_source);
90
g_free(dd->device_address);
94
static struct ofono_devinfo_driver driver = {
96
.probe = hfp_devinfo_probe,
97
.remove = hfp_devinfo_remove,
98
.query_serial = hfp_query_serial
101
void hfp_devinfo_init(void)
103
ofono_devinfo_driver_register(&driver);
106
void hfp_devinfo_exit(void)
108
ofono_devinfo_driver_unregister(&driver);