[asterisk-commits] crichter: branch group/trunk-cm-csel-hash r47417 - /team/group/trunk-cm-csel-...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Nov 10 05:23:25 MST 2006


Author: crichter
Date: Fri Nov 10 06:23:25 2006
New Revision: 47417

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47417
Log:
* moved information event to statemachine
* added logging of dad/oad 
* removed do_immediate_setup
* merged config related stuff (pres/screen) from mevent_setup to config_ch_pres_screen


Modified:
    team/group/trunk-cm-csel-hash/channels/chan_misdn.c

Modified: team/group/trunk-cm-csel-hash/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_misdn.c?view=diff&rev=47417&r1=47416&r2=47417
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_misdn.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_misdn.c Fri Nov 10 06:23:25 2006
@@ -791,6 +791,9 @@
 /* State Machine: mISDN */
 static int handle_aevent_hangup (void *p, int state, int event);
 static int handle_mevent_setup (void *p, int state, int event);
+static int handle_mevent_setup_folowup (void *p, int state, int event);
+static int handle_mevent_information(void *p, int state, int event);
+static int handle_mevent_information_dtmf(void *p, int state, int event);
 static int handle_mevent_setup_acknowledge (void *p, int state, int event);
 static int handle_mevent_connect (void *p, int state, int event);
 static int handle_mevent_disconnect (void *p, int state, int event);
@@ -828,7 +831,11 @@
 	/*
 	 * MISDN EVENTS
 	 */
-	{ STATE_ANY,                  EVENT_SETUP,                MISDN_DIALING,               EVENT_SETUP_ACKNOWLEDGE,     handle_mevent_setup },
+	{ STATE_ANY,                  EVENT_SETUP,                STATE_CONTINUE,              EVENT_NONE,     		    handle_mevent_setup },
+	{ STATE_ANY,                  EVENT_SETUP,                MISDN_DIALING,               EVENT_NONE,		    handle_mevent_setup_folowup },
+	{ MISDN_WAITING4DIGS,         EVENT_INFORMATION,          STATE_CONTINUE,              EVENT_NONE,		    handle_mevent_information},
+	{ MISDN_WAITING4DIGS,         EVENT_INFORMATION,          STATE_KEEP,          	       EVENT_NONE,		    handle_mevent_setup_folowup},
+	{ MISDN_CONNECTED,            EVENT_INFORMATION,          STATE_KEEP,                  EVENT_NONE,		    handle_mevent_information_dtmf},
 	{ STATE_ANY,                  EVENT_SETUP_ACKNOWLEDGE,    MISDN_CALLING_ACKNOWLEDGE,   EVENT_NONE,                  handle_mevent_setup_acknowledge },
 	{ STATE_ANY,                  EVENT_PROCEEDING,           MISDN_PROCEEDING,            AEVENT_CPROCEEDING,          handle_mevent_proceeding_progress },
 	{ STATE_ANY,                  EVENT_PROGRESS,             MISDN_PROGRESS,              AEVENT_CPROGRESS,            handle_mevent_proceeding_progress },
@@ -855,68 +862,68 @@
 static const struct event_log_info * geteventinfo (int event)
 {
 	static struct event_log_info mevents[] = {
-		{ "NOTHING", L_PID, 0 },
-		{ "TONE_GENERATE", L_PID, 0 },
-		{ "BCHAN_DATA", L_PID, 0 },
-		{ "BCHAN_ACTIVATED", L_PID, 0 },
-		{ "BCHAN_ERROR", L_PID, 0 },
-		{ "CLEANUP", L_PID, 0 },
-		{ "PROCEEDING", L_PID, 0 },
-		{ "PROGRESS", L_PID, 0 },
-		{ "SETUP", L_PID | L_MODE | L_CHANNEL, L_SCREEN | L_CONTEXT },
-		{ "ALERTING", L_PID, 0 },
-		{ "CONNECT", L_PID, 0 },
-		{ "SETUP_ACKNOWLEDGE", L_PID, 0 },
-		{ "CONNECT_ACKNOWLEDGE ", L_PID, 0 },
-		{ "USER_INFORMATION", L_PID, 0 },
-		{ "SUSPEND_REJECT", L_PID, 0 },
-		{ "RESUME_REJECT", L_PID, 0 },
-		{ "HOLD", L_PID, 0 },
-		{ "SUSPEND", L_PID, 0 },
-		{ "RESUME", L_PID, 0 },
-		{ "HOLD_ACKNOWLEDGE", L_PID, 0 },
-		{ "SUSPEND_ACKNOWLEDGE", L_PID, 0 },
-		{ "RESUME_ACKNOWLEDGE", L_PID, 0 },
-		{ "HOLD_REJECT", L_PID, 0 },
-		{ "RETRIEVE", L_PID, 0 },
-		{ "RETRIEVE_ACKNOWLEDGE", L_PID, 0 },
-		{ "RETRIEVE_REJECT", L_PID, 0 },
-		{ "DISCONNECT", L_PID, 0 },
-		{ "RESTART", L_PID, 0 },
-		{ "RELEASE", L_PID, 0 },
-		{ "RELEASE_COMPLETE", L_PID, 0 },
-		{ "FACILITY", L_PID, 0 },
-		{ "NOTIFY", L_PID, 0 },
-		{ "STATUS_ENQUIRY", L_PID, 0 },
-		{ "INFORMATION", L_PID, 0 },
-		{ "STATUS", L_PID, 0 },
-		{ "TIMEOUT", L_PID, 0 },
-		{ "DTMF_TONE", L_PID, 0 },
-		{ "NEW_L3ID", L_PID, 0 },
-		{ "NEW_BC", L_PID, 0 },
-		{ "PORT_ALARM", L_PID, 0 },
-		{ "NEW_CHANNEL", L_PID, 0 },
-		{ "UNKNOWN", L_PID, 0 },
+		{ "NOTHING", L_PID | L_OAD | L_DAD, 0 },
+		{ "TONE_GENERATE", L_PID | L_OAD | L_DAD, 0 },
+		{ "BCHAN_DATA", L_PID | L_OAD | L_DAD, 0 },
+		{ "BCHAN_ACTIVATED", L_PID | L_OAD | L_DAD, 0 },
+		{ "BCHAN_ERROR", L_PID | L_OAD | L_DAD, 0 },
+		{ "CLEANUP", L_PID | L_OAD | L_DAD, 0 },
+		{ "PROCEEDING", L_PID | L_OAD | L_DAD, 0 },
+		{ "PROGRESS", L_PID | L_OAD | L_DAD, 0 },
+		{ "SETUP", L_PID | L_OAD | L_DAD, 0},
+		{ "ALERTING", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONNECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "SETUP_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONNECT_ACKNOWLEDGE ", L_PID | L_OAD | L_DAD, 0 },
+		{ "USER_INFORMATION", L_PID | L_OAD | L_DAD, 0 },
+		{ "SUSPEND_REJECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "RESUME_REJECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "HOLD", L_PID | L_OAD | L_DAD, 0 },
+		{ "SUSPEND", L_PID | L_OAD | L_DAD, 0 },
+		{ "RESUME", L_PID | L_OAD | L_DAD, 0 },
+		{ "HOLD_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
+		{ "SUSPEND_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
+		{ "RESUME_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
+		{ "HOLD_REJECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "RETRIEVE", L_PID | L_OAD | L_DAD, 0 },
+		{ "RETRIEVE_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
+		{ "RETRIEVE_REJECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "DISCONNECT", L_PID | L_OAD | L_DAD, 0 },
+		{ "RESTART", L_PID | L_OAD | L_DAD, 0 },
+		{ "RELEASE", L_PID | L_OAD | L_DAD, 0 },
+		{ "RELEASE_COMPLETE", L_PID | L_OAD | L_DAD, 0 },
+		{ "FACILITY", L_PID | L_OAD | L_DAD, 0 },
+		{ "NOTIFY", L_PID | L_OAD | L_DAD, 0 },
+		{ "STATUS_ENQUIRY", L_PID | L_OAD | L_DAD, 0 },
+		{ "INFORMATION", L_PID | L_OAD | L_DAD, 0 },
+		{ "STATUS", L_PID | L_OAD | L_DAD, 0 },
+		{ "TIMEOUT", L_PID | L_OAD | L_DAD, 0 },
+		{ "DTMF_TONE", L_PID | L_OAD | L_DAD, 0 },
+		{ "NEW_L3ID", L_PID | L_OAD | L_DAD, 0 },
+		{ "NEW_BC", L_PID | L_OAD | L_DAD, 0 },
+		{ "PORT_ALARM", L_PID | L_OAD | L_DAD, 0 },
+		{ "NEW_CHANNEL", L_PID | L_OAD | L_DAD, 0 },
+		{ "UNKNOWN", L_PID | L_OAD | L_DAD, 0 },
 	};
 
 	static struct event_log_info aevents[] = {
-		{ "NOTHING", L_PID, 0 },
-		{ "CALL", L_PID, 0 },
-		{ "HANGUP", L_PID, 0 },
-		{ "ANSWER", L_PID, 0 },
-		{ "CONTROL_BUSY", L_PID, 0 },
-		{ "CONTROL_RING", L_PID, 0 },
-		{ "CONTROL_RINGING", L_PID, 0 },
-		{ "CONTROL_ANSWER", L_PID, 0 },
-		{ "CONTROL_TAKEOFFHOOK", L_PID, 0 },
-		{ "CONTROL_OFFHOOK", L_PID, 0 },
-		{ "CONTROL_FLASH", L_PID, 0 },
-		{ "CONTROL_PROGRESS", L_PID, 0 },
-		{ "CONTROL_PROCEEDING", L_PID, 0 },
-		{ "CONTROL_CONGESTION", L_PID, 0 },
-		{ "CONTROL_HOLD", L_PID, 0 },
-		{ "CONTROL_UNHOLD", L_PID, 0 },
-		{ "UNKNOWN", L_PID, 0 },
+		{ "NOTHING", L_PID | L_OAD | L_DAD, 0 },
+		{ "CALL", L_PID | L_OAD | L_DAD, 0 },
+		{ "HANGUP", L_PID | L_OAD | L_DAD, 0 },
+		{ "ANSWER", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_BUSY", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_RING", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_RINGING", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_ANSWER", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_TAKEOFFHOOK", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_OFFHOOK", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_FLASH", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_PROGRESS", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_PROCEEDING", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_CONGESTION", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_HOLD", L_PID | L_OAD | L_DAD, 0 },
+		{ "CONTROL_UNHOLD", L_PID | L_OAD | L_DAD, 0 },
+		{ "UNKNOWN", L_PID | L_OAD | L_DAD, 0 },
 	};
 
 	if (event >= EVENT_NOTHING && event <= EVENT_UNKNOWN)
@@ -996,6 +1003,7 @@
 
 	IF_INFO(L_CHANNEL, "ch:%d", ch->bc->channel);
 	IF_INFO(L_OAD, "oad:%s", ch->bc->oad);
+	IF_INFO(L_DAD, "dad:%s", ch->bc->dad);
 	IF_INFO(L_PID, "pid:%d", ch->bc->pid);
 	IF_INFO(L_MODE, "mode:%s", ch->bc->nt ? "nt" : "te");
 	IF_INFO(L_SCREEN, "screen:%d", ch->bc->screen);
@@ -1977,41 +1985,6 @@
 	state_machine_set_state(holded_chan->sm, MISDN_CONNECTED);
 /* 	misdn_lib_transfer(holded_chan->bc); */
 	ast_channel_masquerade(holded_chan->ast, AST_BRIDGED_P(tmp_ch->ast));
-}
-
-static void do_immediate_setup (struct misdn_bchannel *bc, struct chan_list *ch , struct ast_channel *ast)
-{
-	char predial[256] = "";
-	char *p = predial;
-	struct ast_frame fr;
-
-	strncpy(predial, ast->exten, sizeof(predial) - 1);
-	state_machine_set_state(ch->sm, MISDN_DIALING);
-	misdn_lib_send_event(bc, (bc->nt || misdn_lib_is_ptp(bc->port)) ? EVENT_SETUP_ACKNOWLEDGE : EVENT_PROCEEDING);
-
-	if (!bc->nt && (ch->orginator == ORG_MISDN) && !ch->incoming_early_audio) 
-		chan_misdn_log(2, bc->port, " --> incoming_early_audio off\n");
-	else  
-		dialtone_indicate(ch);
-
-	chan_misdn_log(2, bc->port, "* Starting Ast ctx:%s dad:%s oad:%s with 's' extension\n", ast->context, ast->exten, AST_CID_P(ast));
-	strncpy(ast->exten, "s", 2);
-
-	if (pbx_start_chan(ch) < 0) {
-		hangup_chan(ch);
-		hanguptone_indicate(ch);
-		misdn_lib_send_event(bc, bc->nt ? EVENT_RELEASE_COMPLETE : EVENT_DISCONNECT);
-	}
-
-	for (; !ast_strlen_zero(p); ++p) {
-		fr.frametype = AST_FRAME_DTMF;
-		fr.subclass = *p;
-		fr.src = fr.data = NULL;
-		fr.datalen = fr.samples = fr.mallocd = fr.offset = 0;
-		fr.delivery = ast_tv(0, 0);
-		if (ch->ast && MISDN_ASTERISK_PVT(ch->ast) && MISDN_ASTERISK_TECH_PVT(ch->ast))
-			ast_queue_frame(ch->ast, &fr);
-	}
 }
 
 static int add_in_calls (int port)
@@ -2537,49 +2510,79 @@
 		return -1;
 	}
 
-	chan_misdn_log(5, bc->port, "config_ch_pres_screen: Getting Config\n");
-	cm_get_int(misdn_cm, pres, PORT, MCFG_PRESENTATION, bc->port);
-	cm_get_int(misdn_cm, screen, PORT, MCFG_SCREEN, bc->port);
-	chan_misdn_log(2, bc->port, " --> pres: %d screen: %d\n", pres, screen);
-	if ((pres + screen) < 0) {
-		chan_misdn_log(2, bc->port, " --> pres: %x\n", ast->cid.cid_pres);
-		switch (ast->cid.cid_pres & 0x60) {
-		case AST_PRES_RESTRICTED:
-			bc->pres = 1;
-			chan_misdn_log(2, bc->port, " --> PRES: Restricted (0x1)\n");
+	if (ch->orginator == ORG_AST) {
+		/*misdn_call*/
+		chan_misdn_log(5, bc->port, "config_ch_pres_screen: Getting Config\n");
+		cm_get_int(misdn_cm, pres, PORT, MCFG_PRESENTATION, bc->port);
+		cm_get_int(misdn_cm, screen, PORT, MCFG_SCREEN, bc->port);
+		chan_misdn_log(2, bc->port, " --> pres: %d screen: %d\n", pres, screen);
+		if ((pres + screen) < 0) {
+			/*use asterisks screening and pres values*/
+			chan_misdn_log(2, bc->port, " --> pres: %x\n", ast->cid.cid_pres);
+			switch (ast->cid.cid_pres & 0x60) {
+			case AST_PRES_RESTRICTED:
+				bc->pres = 1;
+				chan_misdn_log(2, bc->port, " --> PRES: Restricted (0x1)\n");
+				break;
+			case AST_PRES_UNAVAILABLE:
+				bc->pres = 2;
+				chan_misdn_log(2, bc->port, " --> PRES: Unavailable (0x2)\n");
+				break;
+			default:
+				bc->pres = 0;
+				chan_misdn_log(2, bc->port, " --> PRES: Allowed (0x0)\n");
+			}
+			switch (ast->cid.cid_pres & 0x3) {
+			case AST_PRES_USER_NUMBER_UNSCREENED:
+				bc->screen = 0;
+				chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0x0)\n");
+				break;
+			case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+				bc->screen = 1;
+				chan_misdn_log(2, bc->port, " --> SCREEN: Passed Screen (0x1)\n");
+				break;
+			case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+				bc->screen = 2;
+				chan_misdn_log(2, bc->port, " --> SCREEN: Failed Screen (0x2)\n");
+				break;
+			case AST_PRES_NETWORK_NUMBER:
+				bc->screen = 3;
+				chan_misdn_log(2, bc->port, " --> SCREEN: Network Nr. (0x3)\n");
+				break;
+			default:
+				bc->screen = 0;
+				chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0x0)\n");
+			}
+		} else {
+			bc->screen = screen;
+			bc->pres = pres;
+		}
+	} else {
+		/*SETUP EVENT from MISDN*/
+		pres = bc->pres == 1 ? AST_PRES_RESTRICTED : (bc->pres == 2 ? AST_PRES_UNAVAILABLE : AST_PRES_ALLOWED);
+		chan_misdn_log(2, bc->port, " --> PRES: Restricted (%d)\n", bc->pres);
+		switch (bc->screen) {
+		case 0:
+			screen = AST_PRES_USER_NUMBER_UNSCREENED;
+			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0)\n");
 			break;
-		case AST_PRES_UNAVAILABLE:
-			bc->pres = 2;
-			chan_misdn_log(2, bc->port, " --> PRES: Unavailable (0x2)\n");
+		case 1:
+			screen = AST_PRES_USER_NUMBER_PASSED_SCREEN;
+			chan_misdn_log(2, bc->port, " --> SCREEN: Passed screen (1)\n");
+			break;
+		case 2:
+			screen = AST_PRES_USER_NUMBER_FAILED_SCREEN;
+			chan_misdn_log(2, bc->port, " --> SCREEN: Failed screen (2)\n");
+			break;
+		case 3:
+			screen = AST_PRES_NETWORK_NUMBER;
+			chan_misdn_log(2, bc->port, " --> SCREEN: Network Number (3)\n");
 			break;
 		default:
-			bc->pres = 0;
-			chan_misdn_log(2, bc->port, " --> PRES: Allowed (0x0)\n");
-		}
-		switch (ast->cid.cid_pres & 0x3) {
-		case AST_PRES_USER_NUMBER_UNSCREENED:
-			bc->screen = 0;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0x0)\n");
-			break;
-		case AST_PRES_USER_NUMBER_PASSED_SCREEN:
-			bc->screen = 1;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Passed Screen (0x1)\n");
-			break;
-		case AST_PRES_USER_NUMBER_FAILED_SCREEN:
-			bc->screen = 2;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Failed Screen (0x2)\n");
-			break;
-		case AST_PRES_NETWORK_NUMBER:
-			bc->screen = 3;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Network Nr. (0x3)\n");
-			break;
-		default:
-			bc->screen = 0;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0x0)\n");
-		}
-	} else {
-		bc->screen = screen;
-		bc->pres = pres;
+			screen = AST_PRES_USER_NUMBER_UNSCREENED;
+			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
+		}
+		ch->ast->cid.cid_pres = pres + screen;
 	}
 
 	return 0;
@@ -3643,39 +3646,10 @@
 {
 	struct chan_list *ch = p;
 	struct misdn_bchannel *bc = ch->bc;
-	int pres,
-		screen,
-		i,
-		im,
-		dad_len;
+	int i;
 
 	ch->ast->rings = 1;
 	ast_setstate(ch->ast, AST_STATE_RINGING);
-
-	pres = bc->pres == 1 ? AST_PRES_RESTRICTED : (bc->pres == 2 ? AST_PRES_UNAVAILABLE : AST_PRES_ALLOWED);
-	chan_misdn_log(2, bc->port, " --> PRES: Restricted (%d)\n", bc->pres);
-	switch (bc->screen) {
-	case 0:
-		screen = AST_PRES_USER_NUMBER_UNSCREENED;
-		chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (0)\n");
-		break;
-	case 1:
-		screen = AST_PRES_USER_NUMBER_PASSED_SCREEN;
-		chan_misdn_log(2, bc->port, " --> SCREEN: Passed screen (1)\n");
-		break;
-	case 2:
-		screen = AST_PRES_USER_NUMBER_FAILED_SCREEN;
-		chan_misdn_log(2, bc->port, " --> SCREEN: Failed screen (2)\n");
-		break;
-	case 3:
-		screen = AST_PRES_NETWORK_NUMBER;
-		chan_misdn_log(2, bc->port, " --> SCREEN: Network Number (3)\n");
-		break;
-	default:
-		screen = AST_PRES_USER_NUMBER_UNSCREENED;
-		chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
-	}
-	ch->ast->cid.cid_pres = pres + screen;
 
 	pbx_builtin_setvar_helper(ch->ast, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
 	ch->ast->transfercapability = bc->capability;
@@ -3692,6 +3666,16 @@
 			}
 		}
 	}
+	
+	return EVENT_NONE;
+}
+
+static int handle_mevent_setup_folowup (void *p, int state, int event)
+{
+	struct chan_list *ch = p;
+	struct misdn_bchannel *bc = ch->bc;
+	int 	im,
+		dad_len;
 
 	/* Check for Pickup Request first */
 	if (!strcmp(ch->ast->exten, ast_pickup_ext())) {
@@ -3711,8 +3695,12 @@
 	im = 0;
 	cm_get_int(misdn_cm, im, PORT, MCFG_IMMEDIATE, bc->port);
 	if (im && ast_strlen_zero(bc->dad)) {
-		do_immediate_setup(bc, ch , ch->ast);
-		return EVENT_BREAK;
+		if (!bc->nt && (ch->orginator == ORG_MISDN) && !ch->incoming_early_audio)
+			chan_misdn_log(2, bc->port, " --> incoming_early_audio off\n");
+		else
+			dialtone_indicate(ch);
+
+		goto START_PBX;
 	}
 
 	chan_misdn_log(5, bc->port, "CONTEXT: %s\n", ch->context);
@@ -3726,7 +3714,17 @@
 		return EVENT_BREAK;
 	}
 
+	if (state == MISDN_WAITING4DIGS && ch->overlap_dial) {
+		ast_mutex_lock(&ch->overlap_tv_lock);
+		ch->overlap_tv = ast_tvnow();
+		ast_mutex_unlock(&ch->overlap_tv_lock);
+		if (ch->overlap_dial_task == -1)
+			ch->overlap_dial_task = misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch);
+		return EVENT_BREAK;
+	}
+
 	if (!ch->overlap_dial && ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
+		START_PBX:
 		state_machine_set_state(ch->sm, MISDN_DIALING);
 		misdn_lib_send_event(bc, (bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port))) ?
 							 EVENT_SETUP_ACKNOWLEDGE : EVENT_PROCEEDING);
@@ -3763,7 +3761,47 @@
 			}
 		}
 	}
+
 	return EVENT_BREAK;
+}
+
+static int handle_mevent_information(void *p, int state, int event)
+{
+	struct chan_list *ch = p;
+	struct misdn_bchannel *bc = ch->bc;
+
+	stop_indicate(ch);
+	/*  Ok, incomplete Setup, waiting till extension exists */
+	if (ast_strlen_zero(bc->info_dad) && !ast_strlen_zero(bc->keypad)) {
+		chan_misdn_log(2, bc->port, " --> using keypad as info\n");
+		strcpy(bc->info_dad, bc->keypad);
+	}
+	strncat(bc->dad, bc->info_dad, sizeof(bc->dad));
+	bc->dad[sizeof(bc->dad) - 1] = 0;
+	strncpy(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
+	ch->ast->exten[sizeof(ch->ast->exten) - 1] = 0;
+
+	return EVENT_NONE;
+}
+
+static int handle_mevent_information_dtmf(void *p, int state, int event)
+{
+	struct chan_list *ch = p;
+	struct misdn_bchannel *bc = ch->bc;
+
+	/* sending INFOS as DTMF-Frames */
+	struct ast_frame fr;
+	strncat(bc->dad, bc->info_dad, sizeof(bc->dad));
+	bc->dad[sizeof(bc->dad) - 1] = 0;
+	strncpy(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
+	ch->ast->exten[sizeof(ch->ast->exten) - 1] = 0;
+	ast_cdr_update(ch->ast);
+	memset(&fr, 0, sizeof(fr));
+	fr.frametype = AST_FRAME_DTMF;
+	fr.subclass = bc->info_dad[0] ;
+	fr.delivery = ast_tv(0, 0);
+	ast_queue_frame(ch->ast, &fr);
+	return EVENT_NONE;
 }
 
 static int handle_mevent_setup_acknowledge (void *p, int state, int event)
@@ -4138,6 +4176,7 @@
 		}
 
 		config_ch(ch, ORG_MISDN);
+		config_ch_pres_screen(ch);
 		export_chan(ch->ast, bc, ch);
 	}
 
@@ -4164,77 +4203,6 @@
 	 * this is for events not (yet) handled by our state machine
 	 */
 	switch (event) {
-	case EVENT_INFORMATION:
-		{
-			stop_indicate(ch);
-			if (state_machine_get_state(ch->sm) == MISDN_WAITING4DIGS) {
-				/*  Ok, incomplete Setup, waiting till extension exists */
-				if (ast_strlen_zero(bc->info_dad) && !ast_strlen_zero(bc->keypad)) {
-					chan_misdn_log(2, bc->port, " --> using keypad as info\n");
-					strcpy(bc->info_dad, bc->keypad);
-				}
-				strncat(bc->dad, bc->info_dad, sizeof(bc->dad));
-				bc->dad[sizeof(bc->dad) - 1] = 0;
-				strncpy(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
-				ch->ast->exten[sizeof(ch->ast->exten) - 1] = 0;
-				
-				/* Check for Pickup Request first */
-				if (!strcmp(ch->ast->exten, ast_pickup_ext())) {
-					misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);
-					if (ast_pickup_call(ch->ast))
-						hangup_chan(ch);
-					else {
-						state_machine_set_state(ch->sm, MISDN_CALLING_ACKNOWLEDGE);
-						ast_setstate(ch->ast, AST_STATE_DOWN);
-						hangup_chan(ch);
-						ch->ast = NULL;
-					}
-					break;
-				}
-				if (!ast_canmatch_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
-					chan_misdn_log(-1, bc->port, "Extension can never match, so disconnecting.\n");
-					if (bc->nt)
-						hanguptone_indicate(ch);
-					state_machine_set_state(ch->sm, MISDN_EXTCANTMATCH);
-					bc->out_cause = 1;
-					misdn_lib_send_event(bc, EVENT_DISCONNECT);
-					break;
-				}
-				if (ch->overlap_dial) {
-					ast_mutex_lock(&ch->overlap_tv_lock);
-					ch->overlap_tv = ast_tvnow();
-					ast_mutex_unlock(&ch->overlap_tv_lock);
-					if (ch->overlap_dial_task == -1)
-						ch->overlap_dial_task =	misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch);
-					break;
-				}
-				if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
-					state_machine_set_state(ch->sm, MISDN_DIALING);
-					stop_indicate(ch);
-					if (pbx_start_chan(ch) < 0) {
-						hangup_chan(ch);
-						chan_misdn_log(-1, bc->port, "ast_pbx_start returned < 0 in INFO\n");
-						if (bc->nt)
-							hanguptone_indicate(ch);
-						misdn_lib_send_event(bc, EVENT_DISCONNECT);
-					}
-				}
-			} else if (state_machine_get_state(ch->sm) != MISDN_CONNECTED) {
-				/* sending INFOS as DTMF-Frames */
-				struct ast_frame fr;
-				strncat(bc->dad, bc->info_dad, sizeof(bc->dad));
-				bc->dad[sizeof(bc->dad) - 1] = 0;
-				strncpy(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
-				ch->ast->exten[sizeof(ch->ast->exten) - 1] = 0;
-				ast_cdr_update(ch->ast);
-				memset(&fr, 0, sizeof(fr));
-				fr.frametype = AST_FRAME_DTMF;
-				fr.subclass = bc->info_dad[0] ;
-				fr.delivery = ast_tv(0, 0);
-				ast_queue_frame(ch->ast, &fr);
-			}
-		}
-		break;
 	case EVENT_BCHAN_ERROR:
 	case EVENT_TIMEOUT:
 		if (ch && bc)



More information about the asterisk-commits mailing list