*** chan_skinny.c	Fri Nov 12 22:29:51 2004
--- /mnt/shared/chan_skinny.c	Fri Nov 12 21:15:02 2004
***************
*** 254,263 ****
--- 254,265 ----
  #define DISPLAYTEXT_MESSAGE 0x0099
  typedef struct displaytext_message {
  	char text[40];
  } displaytext_message;
  
+ #define CLEAR_DISPLAY_MESSAGE 0x009A
+ 
  #define	REGISTER_REJ_MESSAGE 0x009D
  typedef struct register_rej_message {
  	char errMsg[33];
  } register_rej_message;
  
***************
*** 932,941 ****
--- 934,970 ----
  	req->e = SET_RINGER_MESSAGE; 
  	req->data.setringer.ringerMode = mode; 
  	transmit_response(s, req);
  }
  
+ static void transmit_displaymessage(struct skinnysession *s, char *text)
+ {
+ 	skinny_req *req;
+ 
+ 	if (text == 0){
+ 		req = req_alloc(4);
+ 		req->len = 4;
+ 		req->e = CLEAR_DISPLAY_MESSAGE;
+ 	}else{
+ 		req = req_alloc(sizeof(struct displaytext_message));
+ 
+ 		/*XXX Is using 39 here legal? */
+ 		strncpy(req->data.displaytext.text,text,39);
+ 		req->len = sizeof(displaytext_message)+4;
+ 		req->e = DISPLAYTEXT_MESSAGE;
+ 		if (skinnydebug) {
+ 			ast_verbose("Displaying message '%s'\n",req->data.displaytext.text);
+ 		}
+ 	}
+ 
+ 	if (!req) {
+ 		ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
+ 		return;
+ 	}
+ 	transmit_response(s, req);
+ }
+ 
  /* I do not believe skinny can deal with video. 
     Anyone know differently? */
  static struct ast_rtp *skinny_get_vrtp_peer(struct ast_channel *chan)
  {
  	return NULL;
***************
*** 1506,1515 ****
--- 1535,1546 ----
              break;
      	}
  
  	transmit_lamp_indication(session, l->instance, SKINNY_LAMP_BLINK);
  	transmit_ringer_mode(session, SKINNY_RING_INSIDE);
+ 	/*transmit_displaymessage(session, "Incoming Call! w00t!");*/
+ 	transmit_displaymessage(session, ast->cid.cid_num);
  	transmit_tone(session, tone);
  	transmit_callstate(session, l->instance, SKINNY_RINGIN, sub->callid);
  
  	/* XXX need to set the prompt */
  	/* XXX need to deal with softkeys */
***************
*** 1549,1564 ****
--- 1580,1605 ----
  
      if (l->parent->registered) {
  	if ((sub->parent->type = TYPE_LINE) && (sub->parent->hookstate == SKINNY_OFFHOOK)) {
  			sub->parent->hookstate = SKINNY_ONHOOK;
  			transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
+ 			transmit_lamp_indication(s, l->instance, SKINNY_LAMP_OFF);
+ 			if (skinnydebug) {
+ 				ast_verbose("Attempting to Clear display on Skinny %s@%s\n",sub->parent->name, sub->parent->parent->name);
+ 			}
+ 			transmit_displaymessage(s, 0); /* clear display */
  			transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 
  		} else if ((sub->parent->type = TYPE_LINE) && (sub->parent->hookstate == SKINNY_ONHOOK)) {
  			transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
  			transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 
  			transmit_ringer_mode(s, SKINNY_RING_OFF);
  			transmit_tone(s, SKINNY_SILENCE);
+ 			transmit_lamp_indication(s, l->instance, SKINNY_LAMP_OFF);
+ 			if (skinnydebug) {
+ 				ast_verbose("Attempting to Clear display on Skinny %s@%s\n",sub->parent->name, sub->parent->parent->name);
+ 			}
+ 			transmit_displaymessage(s, 0); /* clear display */
  		} 
      }
      ast_mutex_lock(&sub->lock);
      sub->owner = NULL;
      ast->pvt->pvt = NULL;
***************
*** 2180,2189 ****
--- 2221,2237 ----
                 ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", 
                             sub->parent->name, sub->parent->parent->name, sub->callid);
             }
         	}
  
+ 	if (skinnydebug) {
+ 		ast_verbose("Attempting to Clear display on Skinny %s@%s\n",sub->parent->name, sub->parent->parent->name);
+ 	}
+ 	
+ 	transmit_displaymessage(s, 0); /* clear display */
+ 
+ 
         	if ((sub->parent->hookstate == SKINNY_ONHOOK) && (!sub->next->rtp)) {
  	    if (has_voicemail(sub->parent)) {
  	    	transmit_lamp_indication(s, s->device->lines->instance, SKINNY_LAMP_FLASH); 
              } else {
  		transmit_lamp_indication(s, s->device->lines->instance, SKINNY_LAMP_OFF);
