Upgrade ofono to 1.11 and merge to 2.0alpha
[profile/ivi/ofono.git] / src / ofono.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
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 version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #include <glib.h>
23
24 #define OFONO_API_SUBJECT_TO_CHANGE
25
26 #include <ofono/types.h>
27
28 void __ofono_exit(void);
29
30 int __ofono_manager_init(void);
31 void __ofono_manager_cleanup(void);
32
33 void __ofono_modem_shutdown(void);
34
35 #include <ofono/log.h>
36
37 int __ofono_log_init(const char *program, const char *debug,
38                                                 ofono_bool_t detach);
39 void __ofono_log_cleanup(void);
40 void __ofono_log_enable(struct ofono_debug_desc *start,
41                                         struct ofono_debug_desc *stop);
42
43 #include <ofono/dbus.h>
44
45 int __ofono_dbus_init(DBusConnection *conn);
46 void __ofono_dbus_cleanup(void);
47
48 DBusMessage *__ofono_error_invalid_args(DBusMessage *msg);
49 DBusMessage *__ofono_error_invalid_format(DBusMessage *msg);
50 DBusMessage *__ofono_error_not_implemented(DBusMessage *msg);
51 DBusMessage *__ofono_error_failed(DBusMessage *msg);
52 DBusMessage *__ofono_error_busy(DBusMessage *msg);
53 DBusMessage *__ofono_error_not_found(DBusMessage *msg);
54 DBusMessage *__ofono_error_not_active(DBusMessage *msg);
55 DBusMessage *__ofono_error_not_supported(DBusMessage *msg);
56 DBusMessage *__ofono_error_not_available(DBusMessage *msg);
57 DBusMessage *__ofono_error_timed_out(DBusMessage *msg);
58 DBusMessage *__ofono_error_sim_not_ready(DBusMessage *msg);
59 DBusMessage *__ofono_error_in_use(DBusMessage *msg);
60 DBusMessage *__ofono_error_not_attached(DBusMessage *msg);
61 DBusMessage *__ofono_error_attach_in_progress(DBusMessage *msg);
62 DBusMessage *__ofono_error_not_registered(DBusMessage *msg);
63 DBusMessage *__ofono_error_canceled(DBusMessage *msg);
64 DBusMessage *__ofono_error_access_denied(DBusMessage *msg);
65 DBusMessage *__ofono_error_emergency_active(DBusMessage *msg);
66 DBusMessage *__ofono_error_incorrect_password(DBusMessage *msg);
67 DBusMessage *__ofono_error_not_allowed(DBusMessage *msg);
68 DBusMessage *__ofono_error_not_recognized(DBusMessage *msg);
69
70 DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
71                                                 DBusMessage *msg);
72
73 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
74
75 gboolean __ofono_dbus_valid_object_path(const char *path);
76
77 struct ofono_watchlist_item {
78         unsigned int id;
79         void *notify;
80         void *notify_data;
81         ofono_destroy_func destroy;
82 };
83
84 struct ofono_watchlist {
85         int next_id;
86         GSList *items;
87         ofono_destroy_func destroy;
88 };
89
90 struct ofono_watchlist *__ofono_watchlist_new(ofono_destroy_func destroy);
91 unsigned int __ofono_watchlist_add_item(struct ofono_watchlist *watchlist,
92                                         struct ofono_watchlist_item *item);
93 gboolean __ofono_watchlist_remove_item(struct ofono_watchlist *watchlist,
94                                         unsigned int id);
95 void __ofono_watchlist_free(struct ofono_watchlist *watchlist);
96
97 #include <ofono/plugin.h>
98
99 int __ofono_plugin_init(const char *pattern, const char *exclude);
100 void __ofono_plugin_cleanup(void);
101
102 #include <ofono/modem.h>
103
104 typedef void (*ofono_modem_foreach_func)(struct ofono_modem *modem,
105                                                 void *data);
106 void __ofono_modem_foreach(ofono_modem_foreach_func cb, void *userdata);
107
108 unsigned int __ofono_modem_callid_next(struct ofono_modem *modem);
109 void __ofono_modem_callid_hold(struct ofono_modem *modem, int id);
110 void __ofono_modem_callid_release(struct ofono_modem *modem, int id);
111 void __ofono_modem_append_properties(struct ofono_modem *modem,
112                                                 DBusMessageIter *dict);
113
114 struct ofono_atom;
115
116 enum ofono_atom_type {
117         OFONO_ATOM_TYPE_DEVINFO,
118         OFONO_ATOM_TYPE_CALL_BARRING,
119         OFONO_ATOM_TYPE_CALL_FORWARDING,
120         OFONO_ATOM_TYPE_CALL_METER,
121         OFONO_ATOM_TYPE_CALL_SETTINGS,
122         OFONO_ATOM_TYPE_NETREG,
123         OFONO_ATOM_TYPE_PHONEBOOK,
124         OFONO_ATOM_TYPE_SMS,
125         OFONO_ATOM_TYPE_SIM,
126         OFONO_ATOM_TYPE_USSD,
127         OFONO_ATOM_TYPE_VOICECALL,
128         OFONO_ATOM_TYPE_HISTORY,
129         OFONO_ATOM_TYPE_SSN,
130         OFONO_ATOM_TYPE_MESSAGE_WAITING,
131         OFONO_ATOM_TYPE_CBS,
132         OFONO_ATOM_TYPES_CALL_VOLUME,
133         OFONO_ATOM_TYPE_GPRS,
134         OFONO_ATOM_TYPE_GPRS_CONTEXT,
135         OFONO_ATOM_TYPE_RADIO_SETTINGS,
136         OFONO_ATOM_TYPE_AUDIO_SETTINGS,
137         OFONO_ATOM_TYPE_STK,
138         OFONO_ATOM_TYPE_NETTIME,
139         OFONO_ATOM_TYPE_CTM,
140         OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER,
141         OFONO_ATOM_TYPE_CDMA_CONNMAN,
142         OFONO_ATOM_TYPE_SIM_AUTH,
143         OFONO_ATOM_TYPE_EMULATOR_DUN,
144         OFONO_ATOM_TYPE_EMULATOR_HFP,
145         OFONO_ATOM_TYPE_LOCATION_REPORTING,
146         OFONO_ATOM_TYPE_GNSS,
147         OFONO_ATOM_TYPE_CDMA_SMS,
148         OFONO_ATOM_TYPE_CDMA_NETREG,
149         OFONO_ATOM_TYPE_HANDSFREE,
150 };
151
152 enum ofono_atom_watch_condition {
153         OFONO_ATOM_WATCH_CONDITION_REGISTERED,
154         OFONO_ATOM_WATCH_CONDITION_UNREGISTERED
155 };
156
157 typedef void (*ofono_atom_watch_func)(struct ofono_atom *atom,
158                                         enum ofono_atom_watch_condition cond,
159                                         void *data);
160
161 typedef void (*ofono_atom_func)(struct ofono_atom *atom, void *data);
162
163 struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
164                                         enum ofono_atom_type type,
165                                         void (*destruct)(struct ofono_atom *),
166                                         void *data);
167
168 struct ofono_atom *__ofono_modem_add_atom_offline(struct ofono_modem *modem,
169                                         enum ofono_atom_type type,
170                                         void (*destruct)(struct ofono_atom *),
171                                         void *data);
172
173 struct ofono_atom *__ofono_modem_find_atom(struct ofono_modem *modem,
174                                                 enum ofono_atom_type type);
175
176 void __ofono_modem_foreach_atom(struct ofono_modem *modem,
177                                 enum ofono_atom_type type,
178                                 ofono_atom_func callback, void *data);
179
180 void __ofono_modem_foreach_registered_atom(struct ofono_modem *modem,
181                                                 enum ofono_atom_type type,
182                                                 ofono_atom_func callback,
183                                                 void *data);
184
185 void *__ofono_atom_get_data(struct ofono_atom *atom);
186 const char *__ofono_atom_get_path(struct ofono_atom *atom);
187 struct ofono_modem *__ofono_atom_get_modem(struct ofono_atom *atom);
188
189 #define __ofono_atom_find(enum_type, modem)                     \
190 ({                                                              \
191         struct ofono_atom *tmp_atom =                           \
192                 __ofono_modem_find_atom(modem, enum_type);      \
193                                                                 \
194         tmp_atom ? __ofono_atom_get_data(tmp_atom) : NULL;      \
195 })
196
197 void __ofono_atom_register(struct ofono_atom *atom,
198                                 void (*unregister)(struct ofono_atom *));
199 void __ofono_atom_unregister(struct ofono_atom *atom);
200
201 gboolean __ofono_atom_get_registered(struct ofono_atom *atom);
202
203 unsigned int __ofono_modem_add_atom_watch(struct ofono_modem *modem,
204                                         enum ofono_atom_type type,
205                                         ofono_atom_watch_func notify,
206                                         void *data,
207                                         ofono_destroy_func destroy);
208 gboolean __ofono_modem_remove_atom_watch(struct ofono_modem *modem,
209                                                 unsigned int id);
210
211 void __ofono_atom_free(struct ofono_atom *atom);
212
213 typedef void (*ofono_modemwatch_cb_t)(struct ofono_modem *modem,
214                                         gboolean added, void *data);
215 void __ofono_modemwatch_init(void);
216 void __ofono_modemwatch_cleanup(void);
217 unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t cb, void *user,
218                                         ofono_destroy_func destroy);
219 gboolean __ofono_modemwatch_remove(unsigned int id);
220
221 typedef void (*ofono_modem_online_notify_func)(struct ofono_modem *modem,
222                                                 ofono_bool_t online,
223                                                 void *data);
224 unsigned int __ofono_modem_add_online_watch(struct ofono_modem *modem,
225                                         ofono_modem_online_notify_func notify,
226                                         void *data, ofono_destroy_func destroy);
227 void __ofono_modem_remove_online_watch(struct ofono_modem *modem,
228                                         unsigned int id);
229
230 typedef void (*ofono_modem_powered_notify_func)(struct ofono_modem *modem,
231                                                 ofono_bool_t powered,
232                                                 void *data);
233
234 unsigned int __ofono_modem_add_powered_watch(struct ofono_modem *modem,
235                                         ofono_modem_online_notify_func notify,
236                                         void *data, ofono_destroy_func destroy);
237 void __ofono_modem_remove_powered_watch(struct ofono_modem *modem,
238                                         unsigned int id);
239
240 void __ofono_modem_sim_reset(struct ofono_modem *modem);
241
242 void __ofono_modem_inc_emergency_mode(struct ofono_modem *modem);
243 void __ofono_modem_dec_emergency_mode(struct ofono_modem *modem);
244
245 #include <ofono/call-barring.h>
246
247 gboolean __ofono_call_barring_is_busy(struct ofono_call_barring *cb);
248
249 #include <ofono/call-forwarding.h>
250
251 gboolean __ofono_call_forwarding_is_busy(struct ofono_call_forwarding *cf);
252
253 #include <ofono/call-meter.h>
254 #include <ofono/call-settings.h>
255
256 gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs);
257
258 #include <ofono/cbs.h>
259 #include <ofono/devinfo.h>
260 #include <ofono/phonebook.h>
261 #include <ofono/gprs.h>
262 #include <ofono/gprs-context.h>
263 #include <ofono/radio-settings.h>
264 #include <ofono/audio-settings.h>
265 #include <ofono/ctm.h>
266 #include <ofono/location-reporting.h>
267
268 #include <ofono/voicecall.h>
269
270 enum ofono_voicecall_interaction {
271         OFONO_VOICECALL_INTERACTION_NONE        = 0,
272         OFONO_VOICECALL_INTERACTION_PUT_ON_HOLD = 1,
273         OFONO_VOICECALL_INTERACTION_DISCONNECT  = 2,
274 };
275
276 typedef void (*ofono_voicecall_dial_cb_t)(struct ofono_call *call, void *data);
277 typedef void (*ofono_voicecall_tone_cb_t)(int error, void *data);
278
279 ofono_bool_t __ofono_voicecall_is_busy(struct ofono_voicecall *vc,
280                                         enum ofono_voicecall_interaction type);
281
282 int __ofono_voicecall_dial(struct ofono_voicecall *vc,
283                                 const char *addr, int addr_type,
284                                 const char *message, unsigned char icon_id,
285                                 enum ofono_voicecall_interaction interaction,
286                                 ofono_voicecall_dial_cb_t cb, void *user_data);
287 void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
288
289 void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
290                                                 const char *addr, int addr_type,
291                                                 const char *message,
292                                                 unsigned char icon_id);
293 void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
294
295 int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
296                                 const char *tone_str,
297                                 ofono_voicecall_tone_cb_t cb, void *user_data);
298 void __ofono_voicecall_tone_cancel(struct ofono_voicecall *vc, int id);
299
300 struct ofono_call *__ofono_voicecall_find_call_with_status(
301                                 struct ofono_voicecall *vc, int status);
302
303 #include <ofono/sms.h>
304
305 struct sms;
306
307 enum ofono_sms_submit_flag {
308         OFONO_SMS_SUBMIT_FLAG_REQUEST_SR =      0x1,
309         OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY =  0x2,
310         OFONO_SMS_SUBMIT_FLAG_RETRY =           0x4,
311         OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS =     0x8,
312         OFONO_SMS_SUBMIT_FLAG_REUSE_UUID =      0x10,
313 };
314
315 typedef void (*ofono_sms_txq_submit_cb_t)(gboolean ok, void *data);
316 typedef void (*ofono_sms_txq_queued_cb_t)(struct ofono_sms *sms,
317                                                 const struct ofono_uuid *uuid,
318                                                 void *data);
319 typedef void (*ofono_sms_text_notify_cb_t)(const char *from,
320                                                 const struct tm *remote,
321                                                 const struct tm *local,
322                                                 const char *text,
323                                                 void *data);
324 typedef void (*ofono_sms_datagram_notify_cb_t)(const char *from,
325                                                 const struct tm *remote,
326                                                 const struct tm *local,
327                                                 int dst, int src,
328                                                 const unsigned char *buffer,
329                                                 unsigned int len,
330                                                 void *data);
331
332 int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
333                                 unsigned int flags, struct ofono_uuid *uuid,
334                                 ofono_sms_txq_queued_cb_t, void *data);
335
336 int __ofono_sms_txq_set_submit_notify(struct ofono_sms *sms,
337                                         struct ofono_uuid *uuid,
338                                         ofono_sms_txq_submit_cb_t cb,
339                                         void *data,
340                                         ofono_destroy_func destroy);
341
342 int __ofono_sms_txq_cancel(struct ofono_sms *sms,
343                                 const struct ofono_uuid *uuid);
344
345 const char *__ofono_sms_message_path_from_uuid(struct ofono_sms *sms,
346                                                 const struct ofono_uuid *uuid);
347
348 unsigned int __ofono_sms_text_watch_add(struct ofono_sms *sms,
349                                         ofono_sms_text_notify_cb_t cb,
350                                         void *data, ofono_destroy_func destroy);
351 gboolean __ofono_sms_text_watch_remove(struct ofono_sms *sms,
352                                         unsigned int id);
353
354 unsigned int __ofono_sms_datagram_watch_add(struct ofono_sms *sms,
355                                         ofono_sms_datagram_notify_cb_t cb,
356                                         int dst, int src, void *data,
357                                         ofono_destroy_func destroy);
358 gboolean __ofono_sms_datagram_watch_remove(struct ofono_sms *sms,
359                                         unsigned int id);
360
361 unsigned short __ofono_sms_get_next_ref(struct ofono_sms *sms);
362
363 #include <ofono/sim.h>
364
365 ofono_bool_t __ofono_sim_service_available(struct ofono_sim *sim,
366                                                 int ust_service,
367                                                 int sst_service);
368 ofono_bool_t __ofono_sim_cphs_service_available(struct ofono_sim *sim,
369                                                 int cphs_service);
370
371 ofono_bool_t __ofono_is_valid_sim_pin(const char *pin,
372                                         enum ofono_sim_password_type type);
373
374 ofono_bool_t __ofono_is_valid_net_pin(const char *pin);
375
376 void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
377                                 ofono_bool_t full_file_change,
378                                 ofono_bool_t naa_init);
379
380 void __ofono_sim_recheck_pin(struct ofono_sim *sim);
381
382 #include <ofono/stk.h>
383
384 typedef void (*__ofono_sms_sim_download_cb_t)(ofono_bool_t ok,
385                                                 const unsigned char *tp_ud,
386                                                 int len, void *data);
387
388 struct cbs;
389 void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg);
390
391 struct sms;
392 int __ofono_sms_sim_download(struct ofono_stk *stk, const struct sms *msg,
393                                 __ofono_sms_sim_download_cb_t cb, void *data);
394
395 #include <ofono/ussd.h>
396
397 typedef gboolean (*ofono_ussd_ssc_cb_t)(int type,
398                                         const char *sc,
399                                         const char *sia, const char *sib,
400                                         const char *sic, const char *dn,
401                                         DBusMessage *msg, void *data);
402
403 typedef gboolean (*ofono_ussd_passwd_cb_t)(const char *sc,
404                                         const char *old, const char *new,
405                                         DBusMessage *msg, void *data);
406
407 typedef void (*ofono_ussd_request_cb_t)(int error, int dcs,
408                                         const unsigned char *pdu, int len,
409                                         void *data);
410
411 gboolean __ofono_ussd_ssc_register(struct ofono_ussd *ussd, const char *sc,
412                                         ofono_ussd_ssc_cb_t cb, void *data,
413                                         ofono_destroy_func destroy);
414 void __ofono_ussd_ssc_unregister(struct ofono_ussd *ussd, const char *sc);
415
416 gboolean __ofono_ussd_passwd_register(struct ofono_ussd *ussd, const char *sc,
417                                         ofono_ussd_passwd_cb_t cb, void *data,
418                                         ofono_destroy_func destroy);
419 void __ofono_ussd_passwd_unregister(struct ofono_ussd *ussd, const char *sc);
420 gboolean __ofono_ussd_is_busy(struct ofono_ussd *ussd);
421
422 int __ofono_ussd_initiate(struct ofono_ussd *ussd, int dcs,
423                         const unsigned char *pdu, int len,
424                         ofono_ussd_request_cb_t cb, void *user_data);
425 void __ofono_ussd_initiate_cancel(struct ofono_ussd *ussd);
426
427 #include <ofono/netreg.h>
428
429 typedef void (*ofono_netreg_status_notify_cb_t)(int status, int lac, int ci,
430                         int tech, const char *mcc, const char *mnc,
431                         void *data);
432
433 unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
434                                 ofono_netreg_status_notify_cb_t cb,
435                                 void *data, ofono_destroy_func destroy);
436
437 gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
438                                                 unsigned int id);
439
440 void __ofono_netreg_set_base_station_name(struct ofono_netreg *netreg,
441                                                 const char *name);
442
443 #include <ofono/history.h>
444
445 void __ofono_history_probe_drivers(struct ofono_modem *modem);
446
447 void __ofono_history_call_ended(struct ofono_modem *modem,
448                                 const struct ofono_call *call,
449                                 time_t start, time_t end);
450
451 void __ofono_history_call_missed(struct ofono_modem *modem,
452                                 const struct ofono_call *call, time_t when);
453
454 void __ofono_history_sms_received(struct ofono_modem *modem,
455                                         const struct ofono_uuid *uuid,
456                                         const char *from,
457                                         const struct tm *remote,
458                                         const struct tm *local,
459                                         const char *text);
460
461 void __ofono_history_sms_send_pending(struct ofono_modem *modem,
462                                         const struct ofono_uuid *uuid,
463                                         const char *to,
464                                         time_t when, const char *text);
465
466 void __ofono_history_sms_send_status(struct ofono_modem *modem,
467                                         const struct ofono_uuid *uuid,
468                                         time_t when,
469                                         enum ofono_history_sms_status status);
470
471 #include <ofono/message-waiting.h>
472
473 struct sms;
474
475 void __ofono_message_waiting_mwi(struct ofono_message_waiting *mw,
476                                 struct sms *sms, gboolean *out_discard);
477
478 const struct ofono_phone_number *__ofono_message_waiting_get_mbdn(
479                                         struct ofono_message_waiting *mw,
480                                         unsigned int index);
481
482 #include <ofono/nettime.h>
483
484 void __ofono_nettime_probe_drivers(struct ofono_modem *modem);
485
486 void __ofono_nettime_info_received(struct ofono_modem *modem,
487                                         struct ofono_network_time *info);
488
489 #include <ofono/cdma-voicecall.h>
490 #include <ofono/cdma-connman.h>
491 #include <ofono/sim-auth.h>
492
493 #include <ofono/gprs-provision.h>
494 ofono_bool_t __ofono_gprs_provision_get_settings(const char *mcc,
495                                 const char *mnc, const char *spn,
496                                 struct ofono_gprs_provision_data **settings,
497                                 int *count);
498 void __ofono_gprs_provision_free_settings(
499                                 struct ofono_gprs_provision_data *settings,
500                                 int count);
501
502 #include <ofono/emulator.h>
503 void __ofono_emulator_set_indicator_forced(struct ofono_emulator *em,
504                                                 const char *name, int value);
505
506 #include <ofono/gnss.h>
507 #include <ofono/cdma-sms.h>
508 #include <ofono/cdma-netreg.h>
509
510 #include <ofono/cdma-provision.h>
511 ofono_bool_t __ofono_cdma_provision_get_name(const char *sid, char **name);
512
513 #include <ofono/private-network.h>
514
515 void __ofono_private_network_release(int id);
516 ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
517                                                 int *id, void *data);