Revision
17303
Author
math.parent
Date
2010-04-15 07:47:01 -0500 (Thu, 15 Apr 2010)

Log Message

Skinny: correct backspace handling, and behave more like CCM

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (17302 => 17303)


--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-15 09:11:05 UTC (rev 17302)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-15 12:47:01 UTC (rev 17303)
@@ -608,21 +608,24 @@
 	tech_pvt = switch_core_session_get_private(session);
 
 	if (!dest) {
+        if (strlen(tech_pvt->caller_profile->destination_number) == 0) {/* no digit yet */
+		    send_start_tone(listener, SKINNY_TONE_DIALTONE, 0, line_instance, tech_pvt->call_id);
+		}
 		if (backspace) { /* backspace */
-			*tech_pvt->caller_profile->destination_number++ = '\0';
+			tech_pvt->caller_profile->destination_number[strlen(tech_pvt->caller_profile->destination_number)-1] = '\0';
+			if (strlen(tech_pvt->caller_profile->destination_number) == 0) {
+				send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_OFF_HOOK, 0xffff);
+			}
 			send_back_space_request(listener, line_instance, tech_pvt->call_id);
 		}
-	    if (append_dest != '\0' && !backspace) {/* append digit */
+	    if (append_dest != '\0') {/* append digit */
 	        tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
 	            "%s%c", tech_pvt->caller_profile->destination_number, append_dest);
 	    }
-        if (strlen(tech_pvt->caller_profile->destination_number) == 0) {/* no digit yet */
-		    send_start_tone(listener, SKINNY_TONE_DIALTONE, 0, line_instance, tech_pvt->call_id);
-		    if(backspace) {
-				send_select_soft_keys(listener, line_instance, tech_pvt->call_id, SKINNY_KEY_SET_OFF_HOOK, 0xffff);
-		    }
-		} else if (strlen(tech_pvt->caller_profile->destination_number) == 1) {/* first digit */
-	        send_stop_tone(listener, line_instance, tech_pvt->call_id);
+		if (strlen(tech_pvt->caller_profile->destination_number) == 1) {/* first digit */
+			if(!backspace) {
+	        	send_stop_tone(listener, line_instance, tech_pvt->call_id);
+	        }
             send_select_soft_keys(listener, line_instance, tech_pvt->call_id,
                 SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT, 0xffff);
         }