X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=apppbx.cpp;h=c19865bdf30fdf9185c1fc191df906afa4e3911b;hp=981c8679bec10279dd7b35b740d033756d9ec9a2;hb=b2a665f8f1cdeb7d02c3f665d95e6a80297e21d1;hpb=026b04fc75011a144285f399b82890803b4315bd diff --git a/apppbx.cpp b/apppbx.cpp index 981c867..c19865b 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -73,6 +73,7 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint, int origin) : EndpointApp e_dtmf = 0; e_dtmf_time = 0; e_dtmf_last = 0; + e_enablekeypad = 0; e_cfnr_release = 0; e_cfnr_call = 0; e_password_timeout = 0; @@ -127,7 +128,7 @@ EndpointAppPBX::~EndpointAppPBX(void) /* * trace header for application */ -void EndpointAppPBX::trace_header(char *name, int direction) +void EndpointAppPBX::trace_header(const char *name, int direction) { struct trace _trace; @@ -238,6 +239,7 @@ void EndpointAppPBX::release(int release, int joinlocation, int joincause, int p e_dtmf = 0; e_dtmf_time = 0; e_dtmf_last = 0; + e_enablekeypad = 0; e_cfnr_release = 0; e_cfnr_call = 0; e_multipoint_cause = 0; @@ -325,12 +327,12 @@ void apply_callerid_restriction(struct extension *ext, char *id, int *ntype, int } /* used display message to display callerid as available */ -char *EndpointAppPBX::apply_callerid_display(char *id, int itype, int ntype, int present, int screen, char *extension, char *name) +char *EndpointAppPBX::apply_callerid_display(const char *id, int itype, int ntype, int present, int screen, const char *extension, const char *name) { static char display[81]; display[0] = '\0'; - char *cid = numberrize_callerinfo(id, ntype, options.national, options.international); + const char *cid = numberrize_callerinfo(id, ntype, options.national, options.international); PDEBUG(DEBUG_EPOINT, "EPOINT(%d) id='%s' itype=%d ntype=%d present=%d screen=%d extension='%s' name='%s'\n", ea_endpoint->ep_serial, (id)?id:"NULL", itype, ntype, present, screen, (extension)?extension:"NULL", (name)?name:"NULL"); @@ -526,7 +528,7 @@ void EndpointAppPBX::keypad_function(char digit) /* set tone pattern for port */ -void EndpointAppPBX::set_tone(struct port_list *portlist, char *tone) +void EndpointAppPBX::set_tone(struct port_list *portlist, const char *tone) { struct lcr_msg *message; @@ -830,7 +832,7 @@ void EndpointAppPBX::out_setup(void) struct lcr_msg *message; int anycall = 0; int cause = CAUSE_RESSOURCEUNAVAIL; - char *p; + const char *p; char cfp[64]; struct mISDNport *mISDNport; char portname[32]; @@ -843,6 +845,10 @@ void EndpointAppPBX::out_setup(void) struct port_settings port_settings; int channel = 0; int earlyb; + int mode = B_MODE_TRANSPARENT; + + /* set bchannel mode */ + mode = e_capainfo.source_mode; /* create settings for creating port */ memset(&port_settings, 0, sizeof(port_settings)); @@ -981,7 +987,7 @@ void EndpointAppPBX::out_setup(void) } /* creating INTERNAL port */ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum); - port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force); + port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); if (!port) FATAL("No memory for DSS1 Port instance\n"); PDEBUG(DEBUG_EPOINT, "EPOINT(%d) got port %s\n", ea_endpoint->ep_serial, port->p_name); @@ -1089,7 +1095,7 @@ void EndpointAppPBX::out_setup(void) { /* creating EXTERNAL port*/ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum); - if (!(port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force))) + if (!(port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode))) FATAL("No memory for DSS1 Port instance\n"); earlyb = mISDNport->earlyb; } else @@ -1183,7 +1189,7 @@ void EndpointAppPBX::out_setup(void) } /* creating EXTERNAL port*/ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum); - if (!(port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force))) + if (!(port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode))) FATAL("No memory for DSS1 Port instance\n"); earlyb = mISDNport->earlyb; PDEBUG(DEBUG_EPOINT, "EPOINT(%d) created port %s\n", ea_endpoint->ep_serial, port->p_name); @@ -1476,7 +1482,7 @@ void EndpointAppPBX::port_setup(struct port_list *portlist, int message_type, un memcpy(&e_dialinginfo, ¶m->setup.dialinginfo, sizeof(e_dialinginfo)); memcpy(&e_redirinfo, ¶m->setup.redirinfo, sizeof(e_redirinfo)); memcpy(&e_capainfo, ¶m->setup.capainfo, sizeof(e_capainfo)); - e_dtmf = param->setup.dtmf; +// e_dtmf = param->setup.dtmf; /* screen incoming caller id */ interface = interface_first; while(interface) @@ -1631,6 +1637,10 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty { logmessage(message_type, param, portlist->port_id, DIRECTION_IN); + /* ignore information message without digit information */ + if (!param->information.id[0]) + return; + e_overlap = 1; /* turn off dtmf detection, in case dtmf is sent with keypad information */ @@ -1666,7 +1676,7 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty /* keypad when connected */ if (e_state == EPOINT_STATE_CONNECT) { - if (e_ext.keypad) + if (e_ext.keypad || e_enablekeypad) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received during connect: %s.\n", ea_endpoint->ep_serial, param->information.id); /* processing keypad function */ @@ -1703,7 +1713,8 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty } if (e_action) if (e_action->index==ACTION_OUTDIAL - || e_action->index==ACTION_EXTERNAL) + || e_action->index==ACTION_EXTERNAL + || e_action->index==ACTION_REMOTE) { if (!e_extdialing) set_tone(portlist, "dialing"); @@ -1947,6 +1958,9 @@ void EndpointAppPBX::port_alerting(struct port_list *portlist, int message_type, /* signal to call tool */ admin_call_response(e_adminid, ADMIN_CALL_ALERTING, "", 0, 0, 0); +//#warning hack!! +// if (e_adminid) +// set_tone(portlist, "hold"); new_state(EPOINT_STATE_OUT_ALERTING); /* check if pattern is available */ @@ -1985,7 +1999,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, { struct lcr_msg *message; char buffer[256]; - unsigned long port_id = portlist->port_id; + unsigned int port_id = portlist->port_id; struct port_list *tportlist; class Port *port; struct interface *interface; @@ -2195,7 +2209,7 @@ void EndpointAppPBX::port_disconnect_release(struct port_list *portlist, int mes { struct lcr_msg *message; char buffer[256]; - unsigned long port_id = portlist->port_id; + unsigned int port_id = portlist->port_id; int cause, location; @@ -2408,7 +2422,7 @@ void EndpointAppPBX::port_notify(struct port_list *portlist, int message_type, u logmessage(message_type, param, portlist->port_id, DIRECTION_IN); struct lcr_msg *message; - char *logtext = ""; + const char *logtext = ""; char buffer[64]; /* signal to call tool */ @@ -2590,7 +2604,7 @@ void EndpointAppPBX::port_resume(struct port_list *portlist, int message_type, u /* port sends message to the endpoint */ -void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, union parameter *param) +void EndpointAppPBX::ea_message_port(unsigned int port_id, int message_type, union parameter *param) { struct port_list *portlist; struct lcr_msg *message; @@ -2881,10 +2895,16 @@ void EndpointAppPBX::join_overlap(struct port_list *portlist, int message_type, set_tone(portlist, "dialtone"); return; } - if (e_ext.number[0]) - set_tone(portlist, "dialpbx"); - else - set_tone(portlist, "dialtone"); + if (e_dialinginfo.id[0]) + { + set_tone(portlist, "dialing"); + } else + { + if (e_ext.number[0]) + set_tone(portlist, "dialpbx"); + else + set_tone(portlist, "dialtone"); + } } /* join MESSAGE_PROCEEDING */ @@ -2957,8 +2977,10 @@ void EndpointAppPBX::join_connect(struct port_list *portlist, int message_type, new_state(EPOINT_STATE_CONNECT); // UCPY(e_join_tone, ""); +// if (e_ext.number[0]) e_dtmf = 1; /* allow dtmf */ + e_powerdialing = 0; memcpy(&e_connectinfo, ¶m->connectinfo, sizeof(e_callerinfo)); if(portlist) @@ -3311,7 +3333,7 @@ void EndpointAppPBX::join_notify(struct port_list *portlist, int message_type, u /* JOIN sends messages to the endpoint */ -void EndpointAppPBX::ea_message_join(unsigned long join_id, int message_type, union parameter *param) +void EndpointAppPBX::ea_message_join(unsigned int join_id, int message_type, union parameter *param) { struct port_list *portlist; struct lcr_msg *message; @@ -3370,7 +3392,7 @@ void EndpointAppPBX::ea_message_join(unsigned long join_id, int message_type, un /* JOIN sends OVERLAP message */ case MESSAGE_OVERLAP: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received 'more info available'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received 'more info required'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_IN_SETUP && e_state!=EPOINT_STATE_IN_OVERLAP) { @@ -3503,6 +3525,15 @@ void EndpointAppPBX::ea_message_join(unsigned long join_id, int message_type, un join_notify(portlist, message_type, param); break; + /* JOIN wants keypad / dtml */ + case MESSAGE_ENABLEKEYPAD: + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received keypad enable request.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + e_enablekeypad = 1; + e_dtmf = 1; + trace_header("ENABLE KEYPAD", DIRECTION_NONE); + end_trace(); + break; + default: PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: #%d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, message); } @@ -3682,7 +3713,8 @@ reject: /* connnecting our endpoint */ new_state(EPOINT_STATE_CONNECT); - e_dtmf = 1; + if (e_ext.number[0]) + e_dtmf = 1; set_tone(ea_endpoint->ep_portlist, NULL); /* now we send a release to the ringing endpoint */ @@ -3933,7 +3965,7 @@ void EndpointAppPBX::join_join(void) /* check if we have an external call * this is used to check for encryption ability */ -int EndpointAppPBX::check_external(char **errstr, class Port **port) +int EndpointAppPBX::check_external(const char **errstr, class Port **port) { struct join_relation *relation; class Join *join; @@ -4035,9 +4067,9 @@ int EndpointAppPBX::check_external(char **errstr, class Port **port) return(0); } -void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsigned long port_id, int dir) +void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsigned int port_id, int dir) { - char *logtext = "unknown"; + const char *logtext = "unknown"; char buffer[64]; switch(message_type) @@ -4079,6 +4111,10 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign } if (param->setup.dialinginfo.id[0]) add_trace("dialing", NULL, "%s", param->setup.dialinginfo.id); + if (param->setup.dialinginfo.display[0]) + add_trace("display", NULL, "%s", param->setup.dialinginfo.display); + if (param->setup.dialinginfo.sending_complete) + add_trace("complete", NULL, "true", param->setup.dialinginfo.sending_complete); end_trace(); break; @@ -4129,6 +4165,8 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign default: add_trace("connect id", "present", "not available"); } + if (param->connectinfo.display[0]) + add_trace("display", NULL, "%s", param->connectinfo.display); end_trace(); break; @@ -4172,6 +4210,8 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign default: add_trace("cause", "location", "%d", param->disconnectinfo.location); } + if (param->disconnectinfo.display[0]) + add_trace("display", NULL, "%s", param->disconnectinfo.display); end_trace(); break; @@ -4288,7 +4328,12 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign add_trace("to", NULL, "CH(%lu)", port_id); if (dir == DIRECTION_IN) add_trace("from", NULL, "CH(%lu)", port_id); - add_trace("dialing", NULL, "%s", param->information.id); + if (param->information.id[0]) + add_trace("dialing", NULL, "%s", param->information.id); + if (param->information.display[0]) + add_trace("display", NULL, "%s", param->information.display); + if (param->information.sending_complete) + add_trace("complete", NULL, "true", param->information.sending_complete); end_trace(); break; @@ -4363,7 +4408,7 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign } } -void EndpointAppPBX::message_disconnect_port(struct port_list *portlist, int cause, int location, char *display) +void EndpointAppPBX::message_disconnect_port(struct port_list *portlist, int cause, int location, const char *display) { struct lcr_msg *message;