4
* Copyright 2013 Alex <alex@linuxonly.ru>
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
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.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
#ifndef __MMGUICORE_H__
21
#define __MMGUICORE_H__
30
#define MMGUI_SPEED_VALUES_NUMBER 20
32
#define MMGUI_THREAD_SLEEP_PERIOD 1 /*seconds*/
35
MMGUI_EVENT_DEVICE_ADDED = 0,
36
MMGUI_EVENT_DEVICE_REMOVED,
37
MMGUI_EVENT_DEVICE_ENABLED_STATUS,
38
MMGUI_EVENT_DEVICE_BLOCKED_STATUS,
39
MMGUI_EVENT_DEVICE_CONNECTION_STATUS,
41
MMGUI_EVENT_SMS_LIST_READY,
42
MMGUI_EVENT_SMS_COMPLETED,
44
MMGUI_EVENT_SMS_REMOVED,
45
MMGUI_EVENT_SIGNAL_LEVEL_CHANGE,
46
MMGUI_EVENT_NETWORK_MODE_CHANGE,
47
MMGUI_EVENT_NETWORK_REGISTRATION_CHANGE,
48
MMGUI_EVENT_LOCATION_CHANGE,
50
MMGUI_EVENT_MODEM_ENABLE_RESULT,
51
MMGUI_EVENT_SCAN_RESULT,
52
MMGUI_EVENT_USSD_RESULT,
53
MMGUI_EVENT_NET_STATUS,
54
MMGUI_EVENT_TRAFFIC_LIMIT,
55
MMGUI_EVENT_TIME_LIMIT,
56
MMGUI_EVENT_UPDATE_CONNECTIONS_LIST,
60
//External event callback
61
typedef void (*mmgui_event_ext_callback)(enum _mmgui_event event, gpointer mmguicore, gpointer data, gpointer userdata);
62
//Internal event callback
63
typedef void (*mmgui_event_int_callback)(enum _mmgui_event event, gpointer mmguicore, gpointer data);
65
enum _mmgui_module_priority {
66
//module priority levels
67
MMGUI_MODULE_PRIORITY_LOW = 0x00,
68
MMGUI_MODULE_PRIORITY_NORMAL,
69
MMGUI_MODULE_PRIORITY_RECOMMENDED
72
enum _mmgui_module_type {
74
MMGUI_MODULE_TYPE_MODEM_MANAGER = 0x00,
75
MMGUI_MODULE_TYPE_CONNECTION_MANGER
78
enum _mmgui_module_functions {
79
//module functions bitmask
80
MMGUI_MODULE_FUNCTION_BASIC = 0x00,
81
//MMGUI_MODULE_FUNCTION_VOICECALL = 0x01
84
enum _mmgui_module_requirement {
86
MMGUI_MODULE_REQUIREMENT_SERVICE = 0x00,
87
MMGUI_MODULE_REQUIREMENT_FILE,
88
MMGUI_MODULE_REQUIREMENT_NONE
94
enum _mmgui_module_type type;
95
enum _mmgui_module_requirement requirement;
96
enum _mmgui_module_priority priority;
97
enum _mmgui_module_functions functions;
98
gchar servicename[256];
99
gchar description[256];
103
typedef struct _mmguimodule *mmguimodule_t;
105
enum _mmgui_device_types {
106
MMGUI_DEVICE_TYPE_GSM = 1,
107
MMGUI_DEVICE_TYPE_CDMA
110
enum _mmgui_device_modes {
111
MMGUI_DEVICE_MODE_UNKNOWN = 0,
112
MMGUI_DEVICE_MODE_GSM,
113
MMGUI_DEVICE_MODE_GSM_COMPACT,
114
MMGUI_DEVICE_MODE_GPRS,
115
MMGUI_DEVICE_MODE_EDGE,
116
MMGUI_DEVICE_MODE_UMTS,
117
MMGUI_DEVICE_MODE_HSDPA,
118
MMGUI_DEVICE_MODE_HSUPA,
119
MMGUI_DEVICE_MODE_HSPA,
120
MMGUI_DEVICE_MODE_HSPA_PLUS,
121
MMGUI_DEVICE_MODE_1XRTT,
122
MMGUI_DEVICE_MODE_EVDO0,
123
MMGUI_DEVICE_MODE_EVDOA,
124
MMGUI_DEVICE_MODE_EVDOB,
125
MMGUI_DEVICE_MODE_LTE
128
enum _mmgui_network_availability {
129
MMGUI_NA_UNKNOWN = 0,
135
enum _mmgui_access_tech {
136
MMGUI_ACCESS_TECH_GSM = 0,
137
MMGUI_ACCESS_TECH_GSM_COMPACT,
138
MMGUI_ACCESS_TECH_UMTS,
139
MMGUI_ACCESS_TECH_EDGE,
140
MMGUI_ACCESS_TECH_HSDPA,
141
MMGUI_ACCESS_TECH_HSUPA,
142
MMGUI_ACCESS_TECH_HSPA,
143
MMGUI_ACCESS_TECH_HSPA_PLUS,
144
MMGUI_ACCESS_TECH_1XRTT,
145
MMGUI_ACCESS_TECH_EVDO0,
146
MMGUI_ACCESS_TECH_EVDOA,
147
MMGUI_ACCESS_TECH_EVDOB,
148
MMGUI_ACCESS_TECH_LTE,
149
MMGUI_ACCESS_TECH_UNKNOWN
152
enum _mmgui_ussd_encoding {
153
MMGUI_USSD_ENCODING_GSM7 = 0,
154
MMGUI_USSD_ENCODING_UCS2
157
enum _mmgui_reg_status {
158
MMGUI_REG_STATUS_IDLE = 0,
159
MMGUI_REG_STATUS_HOME,
160
MMGUI_REG_STATUS_SEARCHING,
161
MMGUI_REG_STATUS_DENIED,
162
MMGUI_REG_STATUS_UNKNOWN,
163
MMGUI_REG_STATUS_ROAMING
166
enum _mmgui_device_state {
167
MMGUI_DEVICE_STATE_UNKNOWN = 0,
168
MMGUI_DEVICE_STATE_DISABLED = 10,
169
MMGUI_DEVICE_STATE_DISABLING = 20,
170
MMGUI_DEVICE_STATE_ENABLING = 30,
171
MMGUI_DEVICE_STATE_ENABLED = 40,
172
MMGUI_DEVICE_STATE_SEARCHING = 50,
173
MMGUI_DEVICE_STATE_REGISTERED = 60,
174
MMGUI_DEVICE_STATE_DISCONNECTING = 70,
175
MMGUI_DEVICE_STATE_CONNECTING = 80,
176
MMGUI_DEVICE_STATE_CONNECTED = 90
179
enum _mmgui_ussd_state {
180
MMGUI_USSD_STATE_UNKNOWN = 0,
181
MMGUI_USSD_STATE_IDLE,
182
MMGUI_USSD_STATE_ACTIVE,
183
MMGUI_USSD_STATE_USER_RESPONSE
186
enum _mmgui_ussd_validation {
187
MMGUI_USSD_VALIDATION_INVALID = 0,
188
MMGUI_USSD_VALIDATION_REQUEST,
189
MMGUI_USSD_VALIDATION_RESPONSE
192
enum _mmgui_contacts_storage {
193
MMGUI_CONTACTS_STORAGE_UNKNOWN = 0,
194
MMGUI_MODEM_CONTACTS_STORAGE_ME = 1,
195
MMGUI_MODEM_CONTACTS_STORAGE_SM = 2,
196
MMGUI_MODEM_CONTACTS_STORAGE_MT = 3,
199
/*Capbilities specifications*/
200
enum _mmgui_sms_capabilities {
201
MMGUI_SMS_CAPS_NONE = 0,
202
MMGUI_SMS_CAPS_RECEIVE = 1 << 1,
203
MMGUI_SMS_CAPS_SEND = 1 << 2
206
enum _mmgui_ussd_capabilities {
207
MMGUI_USSD_CAPS_NONE = 0,
208
MMGUI_USSD_CAPS_SEND = 1 << 1
211
enum _mmgui_location_capabilities {
212
MMGUI_LOCATION_CAPS_NONE = 0,
213
MMGUI_LOCATION_CAPS_3GPP = 1 << 1,
214
MMGUI_LOCATION_CAPS_GPS = 1 << 2
217
enum _mmgui_scan_capabilities {
218
MMGUI_SCAN_CAPS_NONE = 0,
219
MMGUI_SCAN_CAPS_OBSERVE = 1 << 1
222
enum _mmgui_contacts_capabilities {
223
MMGUI_CONTACTS_CAPS_NONE = 0,
224
MMGUI_CONTACTS_CAPS_EXPORT = 1 << 1,
225
MMGUI_CONTACTS_CAPS_EDIT = 1 << 2,
226
MMGUI_CONTACTS_CAPS_EXTENDED = 1 << 3
229
enum _mmgui_device_operation {
230
MMGUI_DEVICE_OPERATION_IDLE = 0,
231
MMGUI_DEVICE_OPERATION_ENABLE,
232
MMGUI_DEVICE_OPERATION_SEND_SMS,
233
MMGUI_DEVICE_OPERATION_SEND_USSD,
234
MMGUI_DEVICE_OPERATION_SCAN,
235
MMGUI_DEVICE_OPERATIONS
238
enum _mmgui_device_state_request {
239
MMGUI_DEVICE_STATE_REQUEST_ENABLED = 0,
240
MMGUI_DEVICE_STATE_REQUEST_LOCKED,
241
MMGUI_DEVICE_STATE_REQUEST_REGISTERED,
242
MMGUI_DEVICE_STATE_REQUEST_CONNECTED
245
enum _mmgui_event_action {
246
MMGUI_EVENT_ACTION_NOTHING = 0,
247
MMGUI_EVENT_ACTION_DISCONNECT
250
struct _mmgui_scanned_network {
251
enum _mmgui_network_availability status;
252
enum _mmgui_access_tech access_tech;
254
gchar *operator_long;
255
gchar *operator_short;
258
typedef struct _mmgui_scanned_network *mmgui_scanned_network_t;
260
struct _mmgui_ext_connection {
270
gchar srcaddr[INET6_ADDRSTRLEN + 8];
271
gchar dstaddr[INET6_ADDRSTRLEN + 8];
275
typedef struct _mmgui_ext_connection *mmgui_ext_connection_t;
277
struct _mmgui_contact {
278
guint id; //Internal private number
279
gchar *name; //Full name of the contact
280
gchar *number; //Telephone number
281
gchar *email; //Email address
282
gchar *group; //Group this contact belongs to
283
gchar *name2; //Additional contact name
284
gchar *number2; //Additional contact telephone number
285
gboolean hidden; //Boolean flag to specify whether this entry is hidden or not
286
guint storage; //Phonebook in which the contact is stored
289
typedef struct _mmgui_contact *mmgui_contact_t;
291
struct _mmgui_traffic_limits {
292
gboolean trafficenabled;
293
gboolean trafficexecuted;
297
gchar *trafficmessage;
299
gboolean timeenabled;
300
gboolean timeexecuted;
308
typedef struct _mmgui_traffic_limits *mmgui_traffic_limits_t;
310
struct _mmgui_traffic_stats {
329
typedef struct _mmgui_traffic_stats *mmgui_traffic_stats_t;
331
struct _mmguidevice {
337
enum _mmgui_device_operation operation;
347
enum _mmgui_device_types type;
352
enum _mmgui_reg_status regstatus;
354
enum _mmgui_device_modes mode;
358
guint loc3gppdata[4]; /*mcc/mnc/lac/ci*/
359
gfloat locgpsdata[4]; /*latitude/longitude/altitude/time*/
365
enum _mmgui_ussd_encoding ussdencoding;
372
time_t speedchecktime;
374
gfloat speedvalues[2][MMGUI_SPEED_VALUES_NUMBER];
377
gchar interface[IFNAMSIZ];
378
time_t sessionstarttime;
382
GSList *contactslist;
385
typedef struct _mmguidevice *mmguidevice_t;
387
//Modem manager module functions
388
typedef gboolean (*mmgui_module_init_func)(mmguimodule_t module);
389
typedef gboolean (*mmgui_module_open_func)(gpointer mmguicore);
390
typedef gboolean (*mmgui_module_close_func)(gpointer mmguicore);
391
typedef gchar *(*mmgui_module_last_error_func)(gpointer mmguicore);
392
typedef gboolean (*mmgui_module_interrupt_operation_func)(gpointer mmguicore);
393
typedef gboolean (*mmgui_module_set_timeout_func)(gpointer mmguicore, guint operation, guint timeout);
394
typedef guint (*mmgui_module_devices_enum_func)(gpointer mmguicore, GSList **devicelist);
395
typedef gboolean (*mmgui_module_devices_open_func)(gpointer mmguicore, mmguidevice_t device);
396
typedef gboolean (*mmgui_module_devices_close_func)(gpointer mmguicore);
397
typedef gboolean (*mmgui_module_devices_state_func)(gpointer mmguicore, enum _mmgui_device_state_request request);
398
typedef gboolean (*mmgui_module_devices_update_state_func)(gpointer mmguicore);
399
typedef gboolean (*mmgui_module_devices_information_func)(gpointer mmguicore);
400
typedef gboolean (*mmgui_module_devices_enable_func)(gpointer mmguicore, gboolean enabled);
401
typedef guint (*mmgui_module_sms_enum_func)(gpointer mmguicore, GSList **smslist);
402
typedef mmgui_sms_message_t (*mmgui_module_sms_get_func)(gpointer mmguicore, guint index);
403
typedef gboolean (*mmgui_module_sms_delete_func)(gpointer mmguicore, guint index);
404
typedef gboolean (*mmgui_module_sms_send_func)(gpointer mmguicore, gchar* number, gchar *text);
405
typedef gboolean (*mmgui_module_ussd_cancel_session_func)(gpointer mmguicore);
406
typedef enum _mmgui_ussd_state (*mmgui_module_ussd_get_state_func)(gpointer mmguicore);
407
typedef gboolean (*mmgui_module_ussd_send_func)(gpointer mmguicore, gchar *request, enum _mmgui_ussd_validation validationid);
408
typedef gboolean (*mmgui_module_networks_scan_func)(gpointer mmguicore);
409
typedef guint (*mmgui_module_contacts_enum_func)(gpointer mmguicore, GSList **contactslist);
410
typedef gboolean (*mmgui_module_contacts_delete_func)(gpointer mmguicore, guint index);
411
typedef gint (*mmgui_module_contacts_add_func)(gpointer mmguicore, mmgui_contact_t contact);
412
//Connection manager module functions
413
typedef gboolean (*mmgui_module_connection_open_func)(gpointer mmguicore);
414
typedef gboolean (*mmgui_module_connection_close_func)(gpointer mmguicore);
415
typedef gchar *(*mmgui_module_connection_last_error_func)(gpointer mmguicore);
416
typedef gboolean (*mmgui_module_device_connection_open_func)(gpointer mmguicore, mmguidevice_t device);
417
typedef gboolean (*mmgui_module_device_connection_close_func)(gpointer mmguicore);
418
typedef gboolean (*mmgui_module_device_connection_status_func)(gpointer mmguicore);
419
typedef guint64 (*mmgui_module_device_connection_timestamp_func)(gpointer mmguicore);
420
typedef gboolean (*mmgui_module_device_connection_disconnect_func)(gpointer mmguicore);
425
//Modem manager module
429
//Connection manager module
431
gpointer cmoduledata;
433
//Modem manager module functions
434
mmgui_module_open_func open_func;
435
mmgui_module_close_func close_func;
436
mmgui_module_last_error_func last_error_func;
437
mmgui_module_interrupt_operation_func interrupt_operation_func;
438
mmgui_module_set_timeout_func set_timeout_func;
439
mmgui_module_devices_enum_func devices_enum_func;
440
mmgui_module_devices_open_func devices_open_func;
441
mmgui_module_devices_close_func devices_close_func;
442
mmgui_module_devices_state_func devices_state_func;
443
mmgui_module_devices_update_state_func devices_update_state_func;
444
mmgui_module_devices_information_func devices_information_func;
445
mmgui_module_devices_enable_func devices_enable_func;
446
mmgui_module_sms_enum_func sms_enum_func;
447
mmgui_module_sms_get_func sms_get_func;
448
mmgui_module_sms_delete_func sms_delete_func;
449
mmgui_module_sms_send_func sms_send_func;
450
mmgui_module_ussd_cancel_session_func ussd_cancel_session_func;
451
mmgui_module_ussd_get_state_func ussd_get_state_func;
452
mmgui_module_ussd_send_func ussd_send_func;
453
mmgui_module_networks_scan_func networks_scan_func;
454
mmgui_module_contacts_enum_func contacts_enum_func;
455
mmgui_module_contacts_delete_func contacts_delete_func;
456
mmgui_module_contacts_add_func contacts_add_func;
457
//Connection manager module functions
458
mmgui_module_connection_open_func connection_open_func;
459
mmgui_module_connection_close_func connection_close_func;
460
mmgui_module_connection_last_error_func connection_last_error_func;
461
mmgui_module_device_connection_open_func device_connection_open_func;
462
mmgui_module_device_connection_close_func device_connection_close_func;
463
mmgui_module_device_connection_status_func device_connection_status_func;
464
mmgui_module_device_connection_timestamp_func device_connection_timestamp_func;
465
mmgui_module_device_connection_disconnect_func device_connection_disconnect_func;
468
mmguidevice_t device;
470
mmgui_event_int_callback eventcb;
471
mmgui_event_ext_callback extcb;
473
mmgui_traffic_limits_t limits;
477
mmgui_netlink_t netlink;
478
GHashTable *connections;
481
gint workthreadctl[2];
482
#if GLIB_CHECK_VERSION(2,32,0)
483
GMutex workthreadmutex;
484
GMutex connsyncmutex;
486
GMutex *workthreadmutex;
487
GMutex *connsyncmutex;
491
typedef struct _mmguicore *mmguicore_t;
494
gboolean mmguicore_devices_open(mmguicore_t mmguicore, guint deviceid, gboolean openfirst);
496
gboolean mmguicore_devices_enable(mmguicore_t mmguicore, gboolean enabled);
497
GSList *mmguicore_devices_get_list(mmguicore_t mmguicore);
498
mmguidevice_t mmguicore_devices_get_current(mmguicore_t mmguicore);
499
gboolean mmguicore_devices_get_enabled(mmguicore_t mmguicore);
500
gboolean mmguicore_devices_get_locked(mmguicore_t mmguicore);
501
gboolean mmguicore_devices_get_registered(mmguicore_t mmguicore);
502
gboolean mmguicore_devices_get_connected(mmguicore_t mmguicore);
503
gboolean mmguicore_devices_update_device_state(mmguicore_t mmguicore);
504
const gchar *mmguicore_devices_get_identifier(mmguicore_t mmguicore);
505
const gchar *mmguicore_devices_get_internal_identifier(mmguicore_t mmguicore);
506
gpointer mmguicore_devices_get_sms_db(mmguicore_t mmguicore);
507
gpointer mmguicore_devices_get_traffic_db(mmguicore_t mmguicore);
508
gboolean mmguicore_devices_get_connection_status(mmguicore_t mmguicore);
509
guint64 mmguicore_devices_get_connection_timestamp(mmguicore_t mmguicore);
510
guint mmguicore_devices_get_current_operation(mmguicore_t mmguicore);
512
guint mmguicore_location_get_capabilities(mmguicore_t mmguicore);
514
guint mmguicore_sms_get_capabilities(mmguicore_t mmguicore);
515
void mmguicore_sms_message_free(mmgui_sms_message_t message);
516
GSList *mmguicore_sms_enum(mmguicore_t mmguicore, gboolean concatenation);
517
mmgui_sms_message_t mmguicore_sms_get(mmguicore_t mmguicore, guint index);
518
gboolean mmguicore_sms_delete(mmguicore_t mmguicore, guint index);
519
gboolean mmguicore_sms_validate_number(const gchar *number);
520
gboolean mmguicore_sms_send(mmguicore_t mmguicore, gchar *number, gchar *text);
522
guint mmguicore_ussd_get_capabilities(mmguicore_t mmguicore);
523
enum _mmgui_ussd_validation mmguicore_ussd_validate_request(gchar *request);
524
gboolean mmguicore_ussd_cancel_session(mmguicore_t mmguicore);
525
enum _mmgui_ussd_state mmguicore_ussd_get_state(mmguicore_t mmguicore);
526
gboolean mmguicore_ussd_send(mmguicore_t mmguicore, gchar *request);
527
gboolean mmguicore_ussd_set_encoding(mmguicore_t mmguicore, enum _mmgui_ussd_encoding encoding);
528
enum _mmgui_ussd_encoding mmguicore_ussd_get_encoding(mmguicore_t mmguicore);
530
guint mmguicore_newtworks_scan_get_capabilities(mmguicore_t mmguicore);
531
void mmguicore_networks_scan_free(GSList *networks);
532
gboolean mmguicore_networks_scan(mmguicore_t mmguicore);
534
guint mmguicore_contacts_get_capabilities(mmguicore_t mmguicore);
535
void mmguicore_contacts_free_single(mmgui_contact_t contact, gboolean freestruct);
536
GSList *mmguicore_contacts_list(mmguicore_t mmguicore);
537
mmgui_contact_t mmguicore_contacts_get(mmguicore_t mmguicore, guint index);
538
gboolean mmguicore_contacts_delete(mmguicore_t mmguicore, guint index);
539
gboolean mmguicore_contacts_add(mmguicore_t mmguicore, mmgui_contact_t contact);
541
GHashTable *mmguicore_connections_sync(mmguicore_t mmguicore);
543
gchar *mmguicore_get_last_error(mmguicore_t mmguicore);
544
gchar *mmguicore_get_last_connection_error(mmguicore_t mmguicore);
545
gboolean mmguicore_interrupt_operation(mmguicore_t mmguicore);
546
mmguicore_t mmguicore_new(mmgui_event_ext_callback callback, mmgui_traffic_limits_t limits, gpointer userdata);
547
void mmguicore_close(mmguicore_t mmguicore);
549
#endif /* __MMGUICORE_H__ */