-
Notifications
You must be signed in to change notification settings - Fork 319
/
manager.c
749 lines (662 loc) · 21.4 KB
/
manager.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#ifdef BUILD_MANAGER /* no manager, no copyright */
/*
Copyright (C) 2009 - 2010
Artem Makhutov <[email protected]>
http://www.makhutov.org
Dmitry Vagin <[email protected]>
bg <[email protected]>
*/
#include <asterisk.h>
#include <asterisk/stringfields.h> /* AST_DECLARE_STRING_FIELDS for asterisk/manager.h */
#include <asterisk/manager.h> /* struct mansession, struct message ... */
#include <asterisk/strings.h> /* ast_strlen_zero() */
#include <asterisk/callerid.h> /* ast_describe_caller_presentation */
#include "manager.h"
#include "chan_dongle.h" /* devices */
#include "helpers.h" /* ITEMS_OF() send_ccwa_set() send_reset() send_sms() send_ussd() */
static char * espace_newlines(const char * text);
static int manager_show_devices (struct mansession* s, const struct message* m)
{
const char * id = astman_get_header (m, "ActionID");
const char * device = astman_get_header (m, "Device");
struct pvt * pvt;
size_t count = 0;
char buf[40];
astman_send_listack (s, m, "Device status list will follow", "start");
AST_RWLIST_RDLOCK (&gpublic->devices);
AST_RWLIST_TRAVERSE (&gpublic->devices, pvt, entry)
{
ast_mutex_lock (&pvt->lock);
if(ast_strlen_zero(device) || strcmp(device, PVT_ID(pvt)) == 0)
{
astman_append (s, "Event: DongleDeviceEntry\r\n");
if(!ast_strlen_zero (id))
astman_append (s, "ActionID: %s\r\n", id);
astman_append (s, "Device: %s\r\n", PVT_ID(pvt));
/* settings */
astman_append (s, "AudioSetting: %s\r\n", CONF_UNIQ(pvt, audio_tty));
astman_append (s, "DataSetting: %s\r\n", CONF_UNIQ(pvt, data_tty));
astman_append (s, "IMEISetting: %s\r\n", CONF_UNIQ(pvt, imei));
astman_append (s, "IMSISetting: %s\r\n", CONF_UNIQ(pvt, imsi));
astman_append (s, "ChannelLanguage: %s\r\n", CONF_SHARED(pvt, language));
astman_append (s, "Context: %s\r\n", CONF_SHARED(pvt, context));
astman_append (s, "Exten: %s\r\n", CONF_SHARED(pvt, exten));
astman_append (s, "Group: %d\r\n", CONF_SHARED(pvt, group));
astman_append (s, "RXGain: %d\r\n", CONF_SHARED(pvt, rxgain));
astman_append (s, "TXGain: %d\r\n", CONF_SHARED(pvt, txgain));
astman_append (s, "U2DIAG: %d\r\n", CONF_SHARED(pvt, u2diag));
astman_append (s, "UseCallingPres: %s\r\n", CONF_SHARED(pvt, usecallingpres) ? "Yes" : "No");
astman_append (s, "DefaultCallingPres: %s\r\n", CONF_SHARED(pvt, callingpres) < 0 ? "<Not set>" : ast_describe_caller_presentation (CONF_SHARED(pvt, callingpres)));
astman_append (s, "AutoDeleteSMS: %s\r\n", CONF_SHARED(pvt, autodeletesms) ? "Yes" : "No");
astman_append (s, "DisableSMS: %s\r\n", CONF_SHARED(pvt, disablesms) ? "Yes" : "No");
astman_append (s, "ResetDongle: %s\r\n", CONF_SHARED(pvt, resetdongle) ? "Yes" : "No");
astman_append (s, "SMSPDU: %s\r\n", CONF_SHARED(pvt, smsaspdu) ? "Yes" : "No");
astman_append (s, "CallWaitingSetting: %s\r\n", dc_cw_setting2str(CONF_SHARED(pvt, callwaiting)));
astman_append (s, "DTMF: %s\r\n", dc_dtmf_setting2str(CONF_SHARED(pvt, dtmf)));
astman_append (s, "MinimalDTMFGap: %d\r\n", CONF_SHARED(pvt, mindtmfgap));
astman_append (s, "MinimalDTMFDuration: %d\r\n", CONF_SHARED(pvt, mindtmfduration));
astman_append (s, "MinimalDTMFInterval: %d\r\n", CONF_SHARED(pvt, mindtmfinterval));
/* state */
astman_append (s, "State: %s\r\n", pvt_str_state(pvt));
astman_append (s, "AudioState: %s\r\n", PVT_STATE(pvt, audio_tty));
astman_append (s, "DataState: %s\r\n", PVT_STATE(pvt, data_tty));
astman_append (s, "Voice: %s\r\n", (pvt->has_voice) ? "Yes" : "No");
astman_append (s, "SMS: %s\r\n", (pvt->has_sms) ? "Yes" : "No");
astman_append (s, "Manufacturer: %s\r\n", pvt->manufacturer);
astman_append (s, "Model: %s\r\n", pvt->model);
astman_append (s, "Firmware: %s\r\n", pvt->firmware);
astman_append (s, "IMEIState: %s\r\n", pvt->imei);
astman_append (s, "IMSIState: %s\r\n", pvt->imsi);
astman_append (s, "GSMRegistrationStatus: %s\r\n", GSM_regstate2str(pvt->gsm_reg_status));
astman_append (s, "RSSI: %d, %s\r\n", pvt->rssi, rssi2dBm(pvt->rssi, buf, sizeof(buf)));
astman_append (s, "Mode: %s\r\n", sys_mode2str(pvt->linkmode));
astman_append (s, "Submode: %s\r\n", sys_submode2str(pvt->linksubmode));
astman_append (s, "ProviderName: %s\r\n", pvt->provider_name);
astman_append (s, "LocationAreaCode: %s\r\n", pvt->location_area_code);
astman_append (s, "CellID: %s\r\n", pvt->cell_id);
astman_append (s, "SubscriberNumber: %s\r\n", pvt->subscriber_number);
astman_append (s, "SMSServiceCenter: %s\r\n", pvt->sms_scenter);
astman_append (s, "UseUCS2Encoding: %s\r\n", pvt->use_ucs2_encoding ? "Yes" : "No");
astman_append (s, "USSDUse7BitEncoding: %s\r\n", pvt->cusd_use_7bit_encoding ? "Yes" : "No");
astman_append (s, "USSDUseUCS2Decoding: %s\r\n", pvt->cusd_use_ucs2_decoding ? "Yes" : "No");
astman_append (s, "TasksInQueue: %u\r\n", PVT_STATE(pvt, at_tasks));
astman_append (s, "CommandsInQueue: %u\r\n", PVT_STATE(pvt, at_cmds));
astman_append (s, "CallWaitingState: %s\r\n", pvt->has_call_waiting ? "Enabled" : "Disabled");
astman_append (s, "CurrentDeviceState: %s\r\n", dev_state2str(pvt->current_state));
astman_append (s, "DesiredDeviceState: %s\r\n", dev_state2str(pvt->desired_state));
astman_append (s, "CallsChannels: %u\r\n", PVT_STATE(pvt, chansno));
astman_append (s, "Active: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_ACTIVE]));
astman_append (s, "Held: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_ONHOLD]));
astman_append (s, "Dialing: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_DIALING]));
astman_append (s, "Alerting: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_ALERTING]));
astman_append (s, "Incoming: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_INCOMING]));
astman_append (s, "Waiting: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_WAITING]));
astman_append (s, "Releasing: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_RELEASED]));
astman_append (s, "Initializing: %u\r\n", PVT_STATE(pvt, chan_count[CALL_STATE_INIT]));
/* TODO: stats */
astman_append (s, "\r\n");
count++;
}
ast_mutex_unlock (&pvt->lock);
}
AST_RWLIST_UNLOCK (&gpublic->devices);
astman_append (s, "Event: DongleShowDevicesComplete\r\n");
if(!ast_strlen_zero (id))
astman_append (s, "ActionID: %s\r\n", id);
astman_append (s,
"EventList: Complete\r\n"
"ListItems: %zu\r\n"
"\r\n",
count
);
return 0;
}
static int manager_send_ussd (struct mansession* s, const struct message* m)
{
const char* device = astman_get_header (m, "Device");
const char* ussd = astman_get_header (m, "USSD");
char buf[256];
const char* msg;
int status;
void * msgid = NULL;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
if (ast_strlen_zero (ussd))
{
astman_send_error (s, m, "USSD not specified");
return 0;
}
msg = send_ussd(device, ussd, &status, &msgid);
snprintf(buf, sizeof (buf), "[%s] %s\r\nID: %p", device, msg, msgid);
if(status)
{
astman_send_ack(s, m, buf);
}
else
{
astman_send_error(s, m, buf);
}
return 0;
}
static int manager_send_sms (struct mansession* s, const struct message* m)
{
const char* device = astman_get_header (m, "Device");
const char* number = astman_get_header (m, "Number");
const char* message = astman_get_header (m, "Message");
const char* validity= astman_get_header (m, "Validity");
const char* report = astman_get_header (m, "Report");
char buf[256];
const char* msg;
int status;
void * msgid;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
if (ast_strlen_zero (number))
{
astman_send_error (s, m, "Number not specified");
return 0;
}
if (ast_strlen_zero (message))
{
astman_send_error (s, m, "Message not specified");
return 0;
}
msg = send_sms(device, number, message, validity, report, &status, &msgid);
snprintf (buf, sizeof (buf), "[%s] %s\r\nID: %p", device, msg, msgid);
if(status)
{
astman_send_ack(s, m, buf);
}
else
{
astman_send_error(s, m, buf);
}
return 0;
}
static int manager_send_pdu (struct mansession* s, const struct message* m)
{
const char* device = astman_get_header (m, "Device");
const char* pdu = astman_get_header (m, "PDU");
char buf[256];
const char* msg;
int status;
void * msgid;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
if (ast_strlen_zero (pdu))
{
astman_send_error (s, m, "PDU not specified");
return 0;
}
msg = send_pdu(device, pdu, &status, &msgid);
snprintf (buf, sizeof (buf), "[%s] %s\r\nID: %p", device, msg, msgid);
if(status)
{
astman_send_ack(s, m, buf);
}
else
{
astman_send_error(s, m, buf);
}
return 0;
}
#/* */
EXPORT_DEF void manager_event_sent_notify(const char * devname, const char * type, const void * id, const char * result)
{
char buf[40];
snprintf(buf, sizeof(buf), "Dongle%sStatus", type);
manager_event (EVENT_FLAG_CALL, buf,
"Device: %s\r\n"
"ID: %p\r\n"
"Status: %s\r\n",
devname,
id,
result
);
}
/*!
* \brief Send a DongleNewUSSD event to the manager
* This function splits the message in multiple lines, so multi-line
* USSD messages can be send over the manager API.
* \param pvt a pvt structure
* \param message a null terminated buffer containing the message
*/
EXPORT_DEF void manager_event_new_ussd (const char * devname, char* message)
{
struct ast_str* buf;
char* s = message;
char* sl;
size_t linecount = 0;
buf = ast_str_create (256);
while ((sl = strsep (&s, "\r\n")))
{
if (*sl != '\0')
{
ast_str_append (&buf, 0, "MessageLine%zu: %s\r\n", linecount, sl);
linecount++;
}
}
manager_event (EVENT_FLAG_CALL, "DongleNewUSSD",
"Device: %s\r\n"
"LineCount: %zu\r\n"
/* FIXME: empty lines inserted */
// "%s\r\n",
"%s",
devname, linecount, ast_str_buffer (buf)
);
ast_free (buf);
}
#/* */
EXPORT_DEF void manager_event_message(const char * event, const char * devname, const char * message)
{
char * escaped = espace_newlines(message);
if(escaped) {
manager_event_message_raw(event, devname, escaped);
ast_free(escaped);
}
}
#/* */
EXPORT_DEF void manager_event_message_raw(const char * event, const char * devname, const char * message)
{
manager_event (EVENT_FLAG_CALL, event,
"Device: %s\r\n"
"Message: %s\r\n",
devname,
message
);
}
#/* */
static char * espace_newlines(const char * text)
{
char * escaped;
int i, j;
for(j = i = 0; text[i]; ++i, ++j) {
if(text[i] == '\r' || text[i] == '\n')
j++;
}
escaped = ast_malloc(j + 1);
if(escaped) {
for(j = i = 0; text[i]; ++i) {
if(text[i] == '\r') {
escaped[j++] = '\\';
escaped[j++] = 'r';
}
else if(text[i] == '\n') {
escaped[j++] = '\\';
escaped[j++] = 'n';
} else {
escaped[j++] = text[i];
}
}
escaped[j] = 0;
}
return escaped;
}
#/* */
EXPORT_DEF void manager_event_cend(const char * devname, int call_index, int duration, int end_status, int cc_cause)
{
manager_event( EVENT_FLAG_CALL, "DongleCEND",
"Device: %s\r\n"
"CallIdx: %d\r\n"
"Duration: %d\r\n"
"EndStatus: %d\r\n"
"CCCause: %d\r\n",
devname,
call_index,
duration,
end_status,
cc_cause
);
}
#/* */
EXPORT_DEF void manager_event_call_state_change(const char * devname, int call_index, const char * newstate)
{
manager_event(EVENT_FLAG_CALL, "DongleCallStateChange",
"Device: %s\r\n"
"CallIdx: %d\r\n"
"NewState: %s\r\n",
devname,
call_index,
newstate
);
}
#/* */
EXPORT_DEF void manager_event_device_status(const char * devname, const char * newstate)
{
manager_event(EVENT_FLAG_CALL, "DongleStatus",
"Device: %s\r\n"
"Status: %s\r\n",
devname,
newstate
);
}
/*!
* \brief Send a DongleNewSMS event to the manager
* This function splits the message in multiple lines, so multi-line
* SMS messages can be send over the manager API.
* \param pvt a pvt structure
* \param number a null terminated buffer containing the from number
* \param message a null terminated buffer containing the message
*/
// TODO: use espace_newlines() and join with manager_event_new_sms_base64()
EXPORT_DEF void manager_event_new_sms (const char * devname, char* number, char* message)
{
struct ast_str* buf;
size_t linecount = 0;
char* s = message;
char* sl;
buf = ast_str_create (256);
while ((sl = strsep (&s, "\r\n")))
{
if (*sl != '\0')
{
ast_str_append (&buf, 0, "MessageLine%zu: %s\r\n", linecount, sl);
linecount++;
}
}
manager_event (EVENT_FLAG_CALL, "DongleNewSMS",
"Device: %s\r\n"
"From: %s\r\n"
"LineCount: %zu\r\n"
"%s\r\n",
devname, number, linecount, ast_str_buffer (buf)
);
ast_free (buf);
}
/*!
* \brief Send a DongleNewSMSBase64 event to the manager
* \param pvt a pvt structure
* \param number a null terminated buffer containing the from number
* \param message_base64 a null terminated buffer containing the base64 encoded message
*/
EXPORT_DEF void manager_event_new_sms_base64 (const char * devname, char * number, char * message_base64)
{
manager_event (EVENT_FLAG_CALL, "DongleNewSMSBase64",
"Device: %s\r\n"
"From: %s\r\n"
"Message: %s\r\n",
devname, number, message_base64
);
}
static int manager_ccwa_set (struct mansession* s, const struct message* m)
{
const char* device = astman_get_header (m, "Device");
const char* value = astman_get_header (m, "Value");
// const char* id = astman_get_header (m, "ActionID");
char buf[256];
const char* msg;
int status;
call_waiting_t enable;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
if (strcmp("enable", value) == 0)
enable = CALL_WAITING_ALLOWED;
else if (strcmp("disable", value) == 0)
enable = CALL_WAITING_DISALLOWED;
else
{
astman_send_error (s, m, "Invalid Value");
return 0;
}
msg = send_ccwa_set(device, enable, &status);
snprintf (buf, sizeof (buf), "[%s] %s", device, msg);
(status ? astman_send_ack : astman_send_error)(s, m, buf);
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
static int manager_reset (struct mansession* s, const struct message* m)
{
const char* device = astman_get_header (m, "Device");
// const char* id = astman_get_header (m, "ActionID");
char buf[256];
const char* msg;
int status;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
msg = send_reset(device, &status);
snprintf (buf, sizeof (buf), "[%s] %s", device, msg);
(status ? astman_send_ack : astman_send_error)(s, m, buf);
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
static const char * const b_choices[] = { "now", "gracefully", "when convenient" };
#/* */
static int manager_restart_action(struct mansession * s, const struct message * m, dev_state_t event)
{
const char * device = astman_get_header (m, "Device");
const char * when = astman_get_header (m, "When");
// const char * id = astman_get_header (m, "ActionID");
char buf[256];
const char * msg;
int status;
unsigned i;
if (ast_strlen_zero (device))
{
astman_send_error (s, m, "Device not specified");
return 0;
}
for(i = 0; i < ITEMS_OF(b_choices); i++)
{
if(event == DEV_STATE_STARTED || strcasecmp(when, b_choices[i]) == 0)
{
msg = schedule_restart_event(event, i, device, &status);
snprintf (buf, sizeof (buf), "[%s] %s", device, msg);
(status ? astman_send_ack : astman_send_error)(s, m, buf);
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
}
astman_send_error (s, m, "Invalid value of When");
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
#/* */
static int manager_restart(struct mansession * s, const struct message * m)
{
return manager_restart_action(s, m, DEV_STATE_RESTARTED);
}
#/* */
static int manager_stop(struct mansession * s, const struct message * m)
{
return manager_restart_action(s, m, DEV_STATE_STOPPED);
}
#/* */
static int manager_start(struct mansession * s, const struct message * m)
{
return manager_restart_action(s, m, DEV_STATE_STARTED);
}
#/* */
static int manager_remove(struct mansession * s, const struct message * m)
{
return manager_restart_action(s, m, DEV_STATE_REMOVED);
}
#/* */
static int manager_reload(struct mansession * s, const struct message * m)
{
const char * when = astman_get_header (m, "When");
// const char * id = astman_get_header (m, "ActionID");
unsigned i;
for(i = 0; i < ITEMS_OF(b_choices); i++)
{
if(strcasecmp(when, b_choices[i]) == 0)
{
pvt_reload(i);
astman_send_ack(s, m, "reload scheduled");
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
}
astman_send_error (s, m, "Invalid value of When");
// if(!ast_strlen_zero(id))
// astman_append (s, "ActionID: %s\r\n", id);
return 0;
}
static const struct dongle_manager
{
int (*func)(struct mansession* s, const struct message* m);
int authority;
const char* name;
const char* brief;
const char* desc;
} dcm[] =
{
{
manager_show_devices,
EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING,
"DongleShowDevices",
"List Dongle devices",
"Description: Lists Dongle devices in text format with details on current status.\n\n"
"DongleShowDevicesComplete.\n"
"Variables:\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" Device: <name> Optional name of device.\n"
},
{
manager_send_ussd,
EVENT_FLAG_CALL,
"DongleSendUSSD",
"Send a ussd command to the dongle.",
"Description: Send a ussd message to a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle to which the ussd code will be send.\n"
" *USSD: <code> The ussd code that will be send to the device.\n"
},
{
manager_send_sms,
EVENT_FLAG_CALL,
"DongleSendSMS",
"Send a SMS message.",
"Description: Send a SMS message from a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle to which the SMS be send.\n"
" *Number: <number> The phone number to which the SMS will be send.\n"
" *Message: <message> The SMS message that will be send.\n"
},
{
manager_send_pdu,
EVENT_FLAG_CALL,
"DongleSendPDU",
"Send a PDU of message.",
"Description: Send a PDU of message from a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle to which the PDU be send.\n"
" *PDU: <PDU> The PDU of SMS.\n"
},
{
manager_ccwa_set,
EVENT_FLAG_CONFIG,
"DongleSetCCWA",
"Enable/Disabled Call-Waiting on a dongle.",
"Description: Enable/Disabled Call-Waiting on a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle to which the command be send.\n"
" *Value: <enable|disable> Value of Call Waiting\n"
},
{
manager_reset,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleReset",
"Reset a dongle.",
"Description: Reset a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle which should be reset.\n"
},
{
manager_restart,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleRestart",
"Restart a dongle.",
"Description: Restart a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle which should be restart.\n"
" *When: < now | gracefully | when convenient > Time when device restarted.\n"
},
{
manager_stop,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleStop",
"Stop a dongle.",
"Description: Stop a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle which should be stopped.\n"
" *When: < now | gracefully | when convenient > Time when device stopped.\n"
},
{
manager_start,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleStart",
"Start a dongle.",
"Description: Start a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle which should be started.\n"
},
{
manager_remove,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleRemove",
"Remove a dongle.",
"Description: Remove a dongle.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *Device: <device> The dongle which should be removed.\n"
" *When: < now | gracefully | when convenient > Time when device removed.\n"
},
{
manager_reload,
EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG,
"DongleReload",
"Reload a module configuration.",
"Description: Reload the module configuration.\n\n"
"Variables: (Names marked with * are required)\n"
" ActionID: <id> Action ID for this transaction. Will be returned.\n"
" *When: < now | gracefully | when convenient > Time when devices reconfigured.\n"
},
};
EXPORT_DEF void manager_register()
{
unsigned i;
for(i = 0; i < ITEMS_OF(dcm); i++)
{
ast_manager_register2 (dcm[i].name, dcm[i].authority, dcm[i].func, dcm[i].brief, dcm[i].desc);
}
}
EXPORT_DEF void manager_unregister()
{
int i;
for(i = ITEMS_OF(dcm)-1; i >= 0; i--)
{
ast_manager_unregister((char*)dcm[i].name);
}
}
#endif /* BUILD_MANAGER */