enable SUSPEND in vbox (transfer call to a phone)
This commit is contained in:
parent
9c4b8b6574
commit
0a857f6f85
|
@ -74,11 +74,12 @@ extern char *vboxd_get_message(void);
|
|||
|
||||
#define CTRL_NAME_MAGIC "vboxctrl-"
|
||||
|
||||
#define CTRL_NAME_STOP CTRL_NAME_MAGIC "stop"
|
||||
#define CTRL_NAME_STOP CTRL_NAME_MAGIC "stop"
|
||||
#define CTRL_NAME_ANSWERNOW CTRL_NAME_MAGIC "answernow"
|
||||
#define CTRL_NAME_ANSWERALL CTRL_NAME_MAGIC "answerall"
|
||||
#define CTRL_NAME_REJECT CTRL_NAME_MAGIC "reject"
|
||||
#define CTRL_NAME_AUDIO CTRL_NAME_MAGIC "audio"
|
||||
#define CTRL_NAME_REJECT CTRL_NAME_MAGIC "reject"
|
||||
#define CTRL_NAME_AUDIO CTRL_NAME_MAGIC "audio"
|
||||
#define CTRL_NAME_SUSPEND CTRL_NAME_MAGIC "suspend"
|
||||
|
||||
#define CTRL_MODE_REMOVE (0)
|
||||
#define CTRL_MODE_CREATE (1)
|
||||
|
|
|
@ -467,9 +467,9 @@ int modem_get_sequence(char *seq)
|
|||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/** modem_get_rawsequence(): Reads a raw sequence from modem. This is **/
|
||||
/** a subroutine for modem_get_sequence() & **/
|
||||
/** modem_get_echo(). **/
|
||||
/** modem_get_rawsequence(): Reads a raw sequence from modem. This is**/
|
||||
/** a subroutine for modem_get_sequence() & **/
|
||||
/** modem_get_echo(). **/
|
||||
/*************************************************************************/
|
||||
|
||||
static int modem_get_rawsequence(char *line, int echo)
|
||||
|
@ -521,6 +521,48 @@ static int modem_get_rawsequence(char *line, int echo)
|
|||
returnok();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/** modem_wait_sequence(): Reads a sequence from modem and breaks **/
|
||||
/** on timeout or if the sequence was **/
|
||||
/** matched. **/
|
||||
/*************************************************************************/
|
||||
|
||||
int modem_wait_sequence(char *line)
|
||||
{
|
||||
char c;
|
||||
int i=0;
|
||||
int timeout;
|
||||
|
||||
timeout = setup.modem.timeout_cmd;
|
||||
log_line(L_DEBUG, "Waiting (%d secs timeout) for sequence \"", timeout);
|
||||
log_code(L_DEBUG, line);
|
||||
log_text(L_DEBUG, "\"... ");
|
||||
modem_set_timeout(timeout);
|
||||
while (1)
|
||||
{
|
||||
if ((modem_raw_read(&c, 1) != 1) || (modem_get_timeout()))
|
||||
{
|
||||
modem_set_timeout(0);
|
||||
log_text(L_DEBUG, " NOT FOUND\n");
|
||||
returnerror();
|
||||
}
|
||||
|
||||
if (line[i] == c)
|
||||
{
|
||||
i++;
|
||||
if (i==strlen(line)) {
|
||||
modem_set_timeout(0);
|
||||
log_text(L_DEBUG, " GOT IT\n");
|
||||
returnok();
|
||||
}
|
||||
} else {
|
||||
i=0;
|
||||
if (line[i] == c)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/** modem_read(): Reads a terminated string from the modem. **/
|
||||
/*************************************************************************/
|
||||
|
|
|
@ -83,5 +83,6 @@ extern int modem_check_input(void);
|
|||
extern int modem_hangup(void);
|
||||
extern char *modem_get_s_register(int);
|
||||
extern int modem_get_sequence(char *);
|
||||
extern int modem_wait_sequence(char *);
|
||||
|
||||
#endif /* _VBOX_MODEM_H */
|
||||
|
|
|
@ -65,11 +65,12 @@ static int forcepass = FALSE;
|
|||
static struct statusled statusleds[] =
|
||||
{
|
||||
{ 1, CTRL_NAME_STOP , 0, "" },
|
||||
{ 5, CTRL_NAME_REJECT , 0, "" },
|
||||
{ 5, CTRL_NAME_REJECT , 0, "" },
|
||||
{ 7, CTRL_NAME_ANSWERNOW, 0, "" },
|
||||
{ 9, CTRL_NAME_ANSWERALL, 0, "" },
|
||||
{ 11, CTRL_NAME_AUDIO , 0, "" },
|
||||
{ -1, NULL , 0, "" }
|
||||
{ 13, CTRL_NAME_SUSPEND , 0, "" },
|
||||
{ -1, NULL , 0, "" }
|
||||
};
|
||||
|
||||
static struct colortable colortable[] =
|
||||
|
|
|
@ -312,6 +312,23 @@ int voice_put_message(char *message)
|
|||
}
|
||||
else log(L_ERROR, "Can't read input from modem.\n");
|
||||
}
|
||||
if (ctrl_ishere(setup.spool, CTRL_NAME_SUSPEND)) {
|
||||
log(L_INFO, "Control file \"%s\" exists - suspending call...\n", CTRL_NAME_SUSPEND);
|
||||
if (!ctrl_remove(setup.spool, CTRL_NAME_SUSPEND)) {
|
||||
log(L_WARN, "Can't remove control file \"%s\"!\n", CTRL_NAME_SUSPEND);
|
||||
}
|
||||
log(L_JUNK, "Sending \"<DLE><ETX>\"...\n");
|
||||
printstring(line_o, "%c%c", DLE, ETX);
|
||||
modem_raw_write(line_o, strlen(line_o));
|
||||
if (modem_command("", "VCON")>0) {
|
||||
if (modem_command("AT+S1", "OK") <= 0) {
|
||||
log(L_WARN, "Can't suspend call\n");
|
||||
} else {
|
||||
log(L_INFO, "Call suspended\n");
|
||||
voicestatus = VOICE_ACTION_REMOTEHANGUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timeend = time(NULL);
|
||||
|
@ -351,11 +368,8 @@ int voice_put_message(char *message)
|
|||
*/
|
||||
|
||||
log(L_JUNK, "Sending \"<DLE><ETX>\"...\n");
|
||||
|
||||
printstring(line_o, "%c%c", DLE, ETX);
|
||||
|
||||
modem_raw_write(line_o, strlen(line_o));
|
||||
|
||||
modem_command("", "VCON");
|
||||
}
|
||||
|
||||
|
@ -508,6 +522,26 @@ int voice_get_message(char *name, char *timestr, int save)
|
|||
else voicestatus = VOICE_ACTION_TIMEOUT;
|
||||
}
|
||||
|
||||
if ((result == 1) && (ctrl_ishere(setup.spool, CTRL_NAME_SUSPEND))) {
|
||||
log(L_INFO, "Control file \"%s\" exists - suspending call...\n", CTRL_NAME_SUSPEND);
|
||||
if (!ctrl_remove(setup.spool, CTRL_NAME_SUSPEND)) {
|
||||
log(L_WARN, "Can't remove control file \"%s\"!\n", CTRL_NAME_SUSPEND);
|
||||
}
|
||||
log(L_JUNK, "Sending \"<DLE><DC4>\"...\n");
|
||||
printstring(line_o, "%c%c", DLE, DC4);
|
||||
printstring(line_i, "%c%c", DLE, ETX);
|
||||
modem_raw_write(line_o, strlen(line_o));
|
||||
modem_wait_sequence(line_i);
|
||||
if (modem_command("", "VCON")>0) {
|
||||
if (modem_command("AT+S1", "OK") <= 0) {
|
||||
log(L_WARN, "Can't suspend call\n");
|
||||
} else {
|
||||
log(L_INFO, "Call suspended\n");
|
||||
voicestatus = VOICE_ACTION_REMOTEHANGUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((voicestatus == VOICE_ACTION_OK) || (voicestatus == VOICE_ACTION_TIMEOUT))
|
||||
{
|
||||
if ((index(touchtones, '#')) && (index(touchtones, '*')))
|
||||
|
|
Loading…
Reference in New Issue