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