{ PARAM_ON,
"on", PARAM_TYPE_STRING,
"on=[init|hangup]", "Defines if the action is executed on call init or on hangup."},
+ { PARAM_KEYPAD,
+ "keypad", PARAM_TYPE_NULL,
+ "keypad", "Use 'keypad facility' for dialing, instead of 'called number'."},
{ 0, NULL, 0, NULL, NULL}
};
struct action_defs action_defs[] = {
{ ACTION_EXTERNAL,
"extern", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_external, &EndpointAppPBX::action_hangup_call,
- PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_TIMEOUT,
+ PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_KEYPAD | PARAM_TIMEOUT,
"Call is routed to extern number as dialed."},
{ ACTION_INTERNAL,
"intern", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_internal, &EndpointAppPBX::action_hangup_call,
"Call is routed to intern extension as given by the dialed number or specified by option."},
{ ACTION_OUTDIAL,
"outdial", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_external, &EndpointAppPBX::action_hangup_call,
- PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_TIMEOUT,
+ PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_KEYPAD | PARAM_TIMEOUT,
"Same as 'extern'"},
{ ACTION_REMOTE,
"remote", &EndpointAppPBX::action_init_remote, &EndpointAppPBX::action_dialing_remote, &EndpointAppPBX::action_hangup_call,
int integer;
char *string;
FILE *tfp;
- double timeout;
+ long long timeout, now_ll = 0, match_timeout = 0;
+ struct timeval current_time;
struct mISDNport *mISDNport;
struct admin_list *admin;
+ time_t now;
+ struct tm *now_tm;
/* reset timeout action */
- e_match_timeout = 0; /* no timeout */
e_match_to_action = NULL;
SCPY(callerid, numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
goto match_string_prefix;
case MATCH_TIME:
+ time(&now);
+ now_tm = localtime(&now);
integer = now_tm->tm_hour*100 + now_tm->tm_min;
goto match_integer;
case MATCH_MDAY:
+ time(&now);
+ now_tm = localtime(&now);
integer = now_tm->tm_mday;
goto match_integer;
case MATCH_MONTH:
+ time(&now);
+ now_tm = localtime(&now);
integer = now_tm->tm_mon+1;
goto match_integer;
case MATCH_YEAR:
+ time(&now);
+ now_tm = localtime(&now);
integer = now_tm->tm_year + 1900;
goto match_integer;
case MATCH_WDAY:
+ time(&now);
+ now_tm = localtime(&now);
integer = now_tm->tm_wday;
integer = integer?integer:7; /* correct sunday */
goto match_integer;
break;
case MATCH_TIMEOUT:
- timeout = now_d + cond->integer_value;
+ if (!now_ll) {
+ gettimeofday(¤t_time, NULL);
+ now_ll = current_time.tv_sec * MICRO_SECONDS + current_time.tv_usec;
+ }
+ timeout = now_ll + (cond->integer_value * MICRO_SECONDS);
istrue = 1;
break;
cond = cond->next;
}
- if (timeout>now_d && match==1) /* the matching rule with timeout in the future */
- if (e_match_timeout<1 || timeout<e_match_timeout) { /* first timeout or lower */
+ if (timeout>now_ll && match==1) /* the matching rule with timeout in the future */
+ if (match_timeout == 0 || timeout < match_timeout) { /* first timeout or lower */
/* set timeout in the furture */
- e_match_timeout = timeout;
+ match_timeout = timeout;
e_match_to_action = rule->action_first;
e_match_to_extdialing = e_dialinginfo.id + dialing_required;
match = 0; /* matches in the future */
if (match == 1) {
/* matching, we return first action */
action = rule->action_first;
- e_match_timeout = 0; /* no timeout */
+ match_timeout = 0; /* no timeout */
e_match_to_action = NULL;
e_extdialing = e_dialinginfo.id + dialing_required;
break;
}
rule = rule->next;
}
+ if (match_timeout == 0)
+ unsched_timer(&e_match_timeout); /* no timeout */
+ else {
+ schedule_timer(&e_match_timeout, match_timeout / 1000000, match_timeout % 1000000);
+ }
return(action);
}