packaging: Bump to 1.17
[platform/upstream/ofono.git] / dundee / dundee.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2008-2012  Intel Corporation. All rights reserved.
6  *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
7  *
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.
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 <glib.h>
24
25 #define OFONO_API_SUBJECT_TO_CHANGE
26
27 #include <ofono/types.h>
28
29 #define DUN_VERSION_1_2 0x0102
30
31 void __dundee_exit(void);
32
33 enum dundee_error_type {
34         DUNDEE_ERROR_TYPE_NO_ERROR = 0,
35         DUNDEE_ERROR_TYPE_FAILURE,
36 };
37
38 struct dundee_error {
39         enum dundee_error_type type;
40         int error;
41 };
42
43 struct cb_data {
44         void *cb;
45         void *data;
46         void *user;
47 };
48
49 static inline struct cb_data *cb_data_new(void *cb, void *data)
50 {
51         struct cb_data *ret;
52
53         ret = g_new0(struct cb_data, 1);
54         ret->cb = cb;
55         ret->data = data;
56
57         return ret;
58 }
59
60 #define CALLBACK_WITH_FAILURE(cb, args...)              \
61         do {                                            \
62                 struct dundee_error cb_e;               \
63                 cb_e.type = DUNDEE_ERROR_TYPE_FAILURE;  \
64                 cb_e.error = 0;                         \
65                                                         \
66                 cb(&cb_e, ##args);                      \
67         } while (0)                                     \
68
69 #define CALLBACK_WITH_SUCCESS(f, args...)               \
70         do {                                            \
71                 struct dundee_error e;                  \
72                 e.type = DUNDEE_ERROR_TYPE_NO_ERROR;    \
73                 e.error = 0;                            \
74                 f(&e, ##args);                          \
75         } while(0)                                      \
76
77 #include <ofono/log.h>
78
79 int __ofono_log_init(const char *program, const char *debug,
80                                         ofono_bool_t detach);
81 void __ofono_log_cleanup(void);
82 void __ofono_log_enable(struct ofono_debug_desc *start,
83                                         struct ofono_debug_desc *stop);
84
85 #include <ofono/dbus.h>
86
87 #define DUNDEE_SERVICE                  "org.ofono.dundee"
88 #define DUNDEE_MANAGER_INTERFACE        "org.ofono.dundee.Manager"
89 #define DUNDEE_DEVICE_INTERFACE         "org.ofono.dundee.Device"
90 #define DUNDEE_MANAGER_PATH             "/"
91
92 int __ofono_dbus_init(DBusConnection *conn);
93 void __ofono_dbus_cleanup(void);
94
95 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
96
97 DBusMessage *__dundee_error_invalid_args(DBusMessage *msg);
98 DBusMessage *__dundee_error_failed(DBusMessage *msg);
99 DBusMessage *__dundee_error_in_progress(DBusMessage *msg);
100 DBusMessage *__dundee_error_timed_out(DBusMessage *msg);
101
102
103 int __dundee_manager_init(void);
104 void __dundee_manager_cleanup(void);
105
106
107 struct dundee_device;
108
109 int __dundee_device_init(void);
110 void __dundee_device_cleanup(void);
111 void __dundee_device_shutdown(void);
112
113 typedef void (*dundee_device_connect_cb_t)(const struct dundee_error *error,
114                                                 int fd, void *data);
115 typedef void (*dundee_device_disconnect_cb_t)(const struct dundee_error *error,
116                                                 void *data);
117
118 struct dundee_device_driver {
119         const char *name;
120
121         /* Connect and dial */
122         void (*connect)(struct dundee_device *device,
123                         dundee_device_connect_cb_t cb, void *data);
124
125         /* Hangup and disconnect */
126         void (*disconnect)(struct dundee_device *device,
127                         dundee_device_disconnect_cb_t cb, void *data);
128 };
129
130 struct dundee_device *dundee_device_create(struct dundee_device_driver *d);
131 int dundee_device_register(struct dundee_device *device);
132 void dundee_device_unregister(struct dundee_device *device);
133
134 void dundee_device_disconnect(const struct dundee_error *error,
135                                                 struct dundee_device *device);
136
137 void dundee_device_set_data(struct dundee_device *device, void *data);
138 void *dundee_device_get_data(struct dundee_device *device);
139
140 int dundee_device_set_name(struct dundee_device *device, const char *name);
141
142 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
143                                                 void *data);
144 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
145
146 const char *__dundee_device_get_path(struct dundee_device *device);
147 void __dundee_device_append_properties(struct dundee_device *device,
148                                         DBusMessageIter *dict);
149
150 int __dundee_bluetooth_init(void);
151 void  __dundee_bluetooth_cleanup(void);