X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=remote.cpp;h=d181fb835af2d57cba70cc1c8dfbc43684fe6ff0;hp=43c9233543fe5c18625683bfbb29d2488d8d1e95;hb=7f0d14c706328e1ff74fe8b8c16ae54407cc8055;hpb=f6aea744f84e702b3469393f007b9e1bf25f6737 diff --git a/remote.cpp b/remote.cpp index 43c9233..d181fb8 100644 --- a/remote.cpp +++ b/remote.cpp @@ -16,14 +16,13 @@ unsigned int new_remote = 1000; /* * constructor */ -Premote::Premote(int type, char *portname, struct port_settings *settings, struct interface *interface, int remote_id) : Port(type, portname, settings) +Premote::Premote(int type, char *portname, struct port_settings *settings, struct interface *interface, int remote_id) : Port(type, portname, settings, interface) { union parameter param; p_callerinfo.itype = (interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN; p_r_ref = new_remote++; SCPY(p_r_remote_app, interface->remote_app); - SCPY(p_r_interface_name, interface->name); p_r_tones = (interface->is_tones == IS_YES); /* send new ref to remote socket */ @@ -56,11 +55,12 @@ int Premote::message_epoint(unsigned int epoint_id, int message_type, union para if (Port::message_epoint(epoint_id, message_type, param)) return 1; - if (message_type == MESSAGE_SETUP) { + switch (message_type) { + case MESSAGE_SETUP: struct interface *interface; - interface = getinterfacebyname(p_r_interface_name); + interface = getinterfacebyname(p_interface_name); if (!interface) { - PERROR("Cannot find interface %s.\n", p_r_interface_name); + PERROR("Cannot find interface %s.\n", p_interface_name); return 0; } /* attach only if not already */ @@ -81,6 +81,28 @@ int Premote::message_epoint(unsigned int epoint_id, int message_type, union para SCPY(param->setup.dialinginfo.context, "lcr"); } + new_state(PORT_STATE_OUT_SETUP); + break; + + case MESSAGE_PROCEEDING: + new_state(PORT_STATE_IN_PROCEEDING); + break; + + case MESSAGE_ALERTING: + new_state(PORT_STATE_IN_ALERTING); + break; + + case MESSAGE_CONNECT: + new_state(PORT_STATE_CONNECT); + break; + + case MESSAGE_DISCONNECT: + new_state(PORT_STATE_OUT_DISCONNECT); + break; + + case MESSAGE_RELEASE: + new_state(PORT_STATE_RELEASE); + break; } /* look for Remote's interface */ @@ -89,20 +111,6 @@ int Premote::message_epoint(unsigned int epoint_id, int message_type, union para return 0; } -#if 0 - /* enable audio path */ - if (message_type == MESSAGE_SETUP) { - union parameter newparam; - memset(&newparam, 0, sizeof(union parameter)); - admin_message_from_lcr(p_r_remote_id, p_r_ref, MESSAGE_PATTERN, &newparam); - newparam.audiopath = 1; - admin_message_from_lcr(p_r_remote_id, p_r_ref, MESSAGE_AUDIOPATH, &newparam); - } -#endif - - if (message_type == MESSAGE_CONNECT) - new_state(PORT_STATE_CONNECT); - if (message_type == MESSAGE_RELEASE) { new_state(PORT_STATE_RELEASE); delete this; @@ -124,9 +132,9 @@ void Premote::message_remote(int message_type, union parameter *param) break; case MESSAGE_SETUP: - interface = getinterfacebyname(p_r_interface_name); + interface = getinterfacebyname(p_interface_name); if (!interface) { - PERROR("Cannot find interface %s.\n", p_r_interface_name); + PERROR("Cannot find interface %s.\n", p_interface_name); return; } @@ -151,20 +159,40 @@ void Premote::message_remote(int message_type, union parameter *param) epoint->ep_app = new_endpointapp(epoint, 0, interface->app); //incoming epointlist_new(epoint->ep_serial); - /* FALL THROUGH: */ - default: - if (message_type == MESSAGE_CONNECT) - new_state(PORT_STATE_CONNECT); - /* cannot just forward, because param is not of container "struct lcr_msg" */ - message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, message_type); - memcpy(&message->param, param, sizeof(message->param)); - message_put(message); - - if (message_type == MESSAGE_RELEASE) { - new_state(PORT_STATE_RELEASE); - delete this; - return; - } + + new_state(PORT_STATE_IN_SETUP); + break; + + case MESSAGE_PROCEEDING: + new_state(PORT_STATE_OUT_PROCEEDING); + break; + + case MESSAGE_ALERTING: + new_state(PORT_STATE_OUT_ALERTING); + break; + + case MESSAGE_CONNECT: + new_state(PORT_STATE_CONNECT); + break; + + case MESSAGE_DISCONNECT: + new_state(PORT_STATE_IN_DISCONNECT); + break; + + case MESSAGE_RELEASE: + new_state(PORT_STATE_RELEASE); + break; + } + + /* cannot just forward, because param is not of container "struct lcr_msg" */ + message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, message_type); + memcpy(&message->param, param, sizeof(message->param)); + message_put(message); + + if (message_type == MESSAGE_RELEASE) { + new_state(PORT_STATE_RELEASE); + delete this; + return; } }