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