[svn-commits] mvanbaak: trunk r249670 - /trunk/channels/chan_skinny.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 1 13:33:30 CST 2010


Author: mvanbaak
Date: Mon Mar  1 13:33:26 2010
New Revision: 249670

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=249670
Log:
Cleanup display_*message functions.

This patch splits transmit_displaymessage into transmit_clear_display_message and transmit_display_message which better aligns with the skinny protocol. The new transmit_display_message is not used in the current code, but will be and so it is commented.

Moved handle_datetime from this function to onhook and offhook functions (display now properly cleared at the end of a call on 30VIP).

Removed skinny debug messages from inline code as there's an ast_verb in transmit_clear_display_message. Also, removed commentary that it was a clear display as it is now apparent from the function name.

Split transmit_displaypromptmessage into display and clear.

(closes issue #16878)
Reported by: wedhorn
Patches: 
	skinny-clean02.diff uploaded by wedhorn (license 30)
	skinny-clean03.diff uploaded by wedhorn (license 30)


Modified:
    trunk/channels/chan_skinny.c

Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=249670&r1=249669&r2=249670
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Mon Mar  1 13:33:26 2010
@@ -2288,35 +2288,40 @@
 	transmit_response(d, req);
 }
 
-static void transmit_displaymessage(struct skinny_device *d, const char *text, int instance, int reference)
+static void transmit_clear_display_message(struct skinny_device *d, int instance, int reference)
 {
 	struct skinny_req *req;
+	if (!(req = req_alloc(0, CLEAR_DISPLAY_MESSAGE)))
+		return;
+
+	//what do we want hear CLEAR_DISPLAY_MESSAGE or CLEAR_PROMPT_STATUS???
+	//if we are clearing the display, it appears there is no instance and refernece info (size 0)
+	//req->data.clearpromptstatus.lineInstance = instance;
+	//req->data.clearpromptstatus.callReference = reference;
+
+	if (skinnydebug)
+		ast_verb(1, "Clearing Display\n");
+	transmit_response(d, req);
+}
+
+/* This function is not currently used, but will be (wedhorn)*/
+/* static void transmit_display_message(struct skinny_device *d, const char *text, int instance, int reference)
+{
+	struct skinny_req *req;
 
 	if (text == 0) {
-		if (!(req = req_alloc(0, CLEAR_DISPLAY_MESSAGE)))
-			return;
-
-		//what do we want hear CLEAR_DISPLAY_MESSAGE or CLEAR_PROMPT_STATUS???
-		//if we are clearing the display, it appears there is no instance and refernece info (size 0)
-		//req->data.clearpromptstatus.lineInstance = instance;
-		//req->data.clearpromptstatus.callReference = reference;
-
-		/* send datetime message. We have to do it here because it will clear the display on the phone if we do it elsewhere */
-		handle_time_date_req_message(NULL, d->session);
-
-		if (skinnydebug)
-			ast_verb(1, "Clearing Display\n");
-	} else {
-		if (!(req = req_alloc(sizeof(struct displaytext_message), DISPLAYTEXT_MESSAGE)))
-			return;
-
-		ast_copy_string(req->data.displaytext.text, text, sizeof(req->data.displaytext.text));
-		if (skinnydebug)
-			ast_verb(1, "Displaying message '%s'\n", req->data.displaytext.text);
-	}
-
+		ast_verb(1, "Bug, Asked to display empty message\n");
+		return;
+	}
+
+	if (!(req = req_alloc(sizeof(struct displaytext_message), DISPLAYTEXT_MESSAGE)))
+		return;
+
+	ast_copy_string(req->data.displaytext.text, text, sizeof(req->data.displaytext.text));
+	if (skinnydebug)
+		ast_verb(1, "Displaying message '%s'\n", req->data.displaytext.text);
 	transmit_response(d, req);
-}
+} */
 
 static void transmit_displaynotify(struct skinny_device *d, const char *text, int t)
 {
@@ -2338,27 +2343,32 @@
 {
 	struct skinny_req *req;
 
-	if (text == 0) {
-		if (!(req = req_alloc(sizeof(struct clear_prompt_message), CLEAR_PROMPT_MESSAGE)))
-			return;
-
-		req->data.clearpromptstatus.lineInstance = htolel(instance);
-		req->data.clearpromptstatus.callReference = htolel(callid);
-
-		if (skinnydebug)
-			ast_verb(1, "Clearing Prompt\n");
-	} else {
-		if (!(req = req_alloc(sizeof(struct display_prompt_status_message), DISPLAY_PROMPT_STATUS_MESSAGE)))
-			return;
-
-		ast_copy_string(req->data.displaypromptstatus.promptMessage, text, sizeof(req->data.displaypromptstatus.promptMessage));
-		req->data.displaypromptstatus.messageTimeout = htolel(t);
-		req->data.displaypromptstatus.lineInstance = htolel(instance);
-		req->data.displaypromptstatus.callReference = htolel(callid);
-
-		if (skinnydebug)
-			ast_verb(1, "Displaying Prompt Status '%s'\n", text);
-	}
+	if (!(req = req_alloc(sizeof(struct display_prompt_status_message), DISPLAY_PROMPT_STATUS_MESSAGE)))
+		return;
+
+	ast_copy_string(req->data.displaypromptstatus.promptMessage, text, sizeof(req->data.displaypromptstatus.promptMessage));
+	req->data.displaypromptstatus.messageTimeout = htolel(t);
+	req->data.displaypromptstatus.lineInstance = htolel(instance);
+	req->data.displaypromptstatus.callReference = htolel(callid);
+
+	if (skinnydebug)
+		ast_verb(1, "Displaying Prompt Status '%s'\n", text);
+
+	transmit_response(d, req);
+}
+
+static void transmit_clearpromptmessage(struct skinny_device *d, int instance, int callid)
+{
+	struct skinny_req *req;
+
+	if (!(req = req_alloc(sizeof(struct clear_prompt_message), CLEAR_PROMPT_MESSAGE)))
+		return;
+
+	req->data.clearpromptstatus.lineInstance = htolel(instance);
+	req->data.clearpromptstatus.callReference = htolel(callid);
+
+	if (skinnydebug)
+		ast_verb(1, "Clearing Prompt\n");
 
 	transmit_response(d, req);
 }
@@ -2446,7 +2456,7 @@
 
 		transmit_speaker_mode(d, SKINNY_SPEAKEROFF);
 
-		transmit_displaypromptstatus(d, NULL, 0, instance, callid);
+		transmit_clearpromptmessage(d, instance, callid);
 	}
 
 	if (!(req = req_alloc(sizeof(struct call_state_message), CALL_STATE_MESSAGE)))
@@ -3915,7 +3925,7 @@
 				transmit_stopmediatransmission(d, sub);
 				transmit_speaker_mode(d, SKINNY_SPEAKEROFF);
 				transmit_ringer_mode(d, SKINNY_RING_OFF);
-				transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+				transmit_clear_display_message(d, l->instance, sub->callid);
 				transmit_stop_tone(d, l->instance, sub->callid);
 				/* we should check to see if we can start the ringer if another line is ringing */
 			}
@@ -4563,9 +4573,7 @@
 			newsub->xferor = 1;
 			l->activesub = newsub;
 			transmit_callstate(d, l->instance, SKINNY_OFFHOOK, newsub->callid);
-			if (skinnydebug)
-				ast_debug(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-			transmit_displaymessage(d, NULL, l->instance, newsub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, newsub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, newsub->callid);
 			transmit_selectsoftkeys(d, l->instance, newsub->callid, KEYDEF_OFFHOOKWITHFEAT);
 			/* start the switch thread */
@@ -4684,9 +4692,7 @@
 		transmit_speaker_mode(d, SKINNY_SPEAKERON);
 		transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 	}
-	if (skinnydebug)
-		ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-	transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+	transmit_clear_display_message(d, l->instance, sub->callid);
 
 	if (l->cfwdtype & cfwdtype) {
 		set_callforwards(l, NULL, cfwdtype);
@@ -4843,9 +4849,7 @@
 				l->hookstate = SKINNY_OFFHOOK;
 				transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 			}
-			if (skinnydebug)
-				ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-			transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, sub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 			transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGOUT);
 
@@ -4885,9 +4889,7 @@
 				transmit_speaker_mode(d, SKINNY_SPEAKERON);
 				transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 			}
-			if (skinnydebug)
-				ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-			transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, sub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 			transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGOUT);
 
@@ -4950,10 +4952,7 @@
 				transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 			}
 
-			if (skinnydebug)
-				ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-
-			transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, sub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 			transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGOUT);
 
@@ -5106,9 +5105,7 @@
 					sub = c->tech_pvt;
 					l->activesub = sub;
 					transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
-					if (skinnydebug)
-						ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-					transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+					transmit_clear_display_message(d, l->instance, sub->callid);
 					transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 					transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_OFFHOOK);
 
@@ -5175,6 +5172,9 @@
 		sub = l->activesub;
 	}
 
+	/* Not ideal, but let's send updated time at onhook and offhook, as it clears the display */
+	handle_time_date_req_message(NULL, d->session);
+	
 	transmit_ringer_mode(d, SKINNY_RING_OFF);
 	l->hookstate = SKINNY_OFFHOOK;
 
@@ -5204,9 +5204,7 @@
 				sub = c->tech_pvt;
 				l->activesub = sub;
 				transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
-				if (skinnydebug)
-					ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-				transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+				transmit_clear_display_message(d, l->instance, sub->callid);
 				transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 				transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_OFFHOOK);
 
@@ -5293,6 +5291,8 @@
 			ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n",
 				l->name, d->name, sub->callid);
 		}
+		/* Not ideal, but let's send updated time at onhook and offhook, as it clears the display */
+		handle_time_date_req_message(NULL, d->session);
 	}
 	return 1;
 }
@@ -5699,9 +5699,7 @@
 		sub = c->tech_pvt;
 		l->activesub = sub;
 		transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
-		if (skinnydebug)
-			ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-		transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+		transmit_clear_display_message(d, l->instance, sub->callid);
 		transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 
 		if (!ast_ignore_pattern(c->context, req->data.enbloccallmessage.calledParty)) {
@@ -5820,9 +5818,7 @@
 				transmit_speaker_mode(d, SKINNY_SPEAKERON);
 				transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 			}
-			if (skinnydebug)
-				ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-			transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, sub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 			transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_RINGOUT);
 
@@ -5862,9 +5858,7 @@
 
 			transmit_callstate(d, l->instance, SKINNY_OFFHOOK, sub->callid);
 
-			if (skinnydebug)
-				ast_verb(1, "Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
-			transmit_displaymessage(d, NULL, l->instance, sub->callid); /* clear display */
+			transmit_clear_display_message(d, l->instance, sub->callid);
 			transmit_start_tone(d, SKINNY_DIALTONE, l->instance, sub->callid);
 			transmit_selectsoftkeys(d, l->instance, sub->callid, KEYDEF_OFFHOOK);
 




More information about the svn-commits mailing list