Index: channels/chan_skinny.c
===================================================================
--- channels/chan_skinny.c	(revision 248223)
+++ channels/chan_skinny.c	(working copy)
@@ -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;
 
-	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;
 
-		//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);
+}
 
-		/* 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);
+/* 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 (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);
+	if (text == 0) {
+		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)
 {
@@ -3915,7 +3920,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 +4568,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 +4687,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 +4844,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 +4884,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 +4947,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 +5100,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 +5167,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 +5199,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 +5286,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 +5694,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)) {
@@ -5818,9 +5811,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);
 
@@ -5860,9 +5851,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);
 
