Revision
17320
Author
math.parent
Date
2010-04-16 08:16:27 -0500 (Fri, 16 Apr 2010)

Log Message

Skinny: allow firmware version per device

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h (17319 => 17320)


--- freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h	2010-04-16 13:03:37 UTC (rev 17319)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/mod_skinny.h	2010-04-16 13:16:27 UTC (rev 17320)
@@ -107,6 +107,8 @@
     skinny_profile_t *profile;
     char device_name[16];
     uint32_t device_instance;
+    
+    char firmware_version[16];
 
     switch_socket_t *sock;
     switch_memory_pool_t *pool;

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


--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-16 13:03:37 UTC (rev 17319)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-04-16 13:16:27 UTC (rev 17320)
@@ -1609,7 +1609,7 @@
 	skinny_profile_t *profile;
 	switch_event_t *event = NULL;
 	switch_event_t *params = NULL;
-	switch_xml_t xroot, xdomain, xgroup, xuser, xskinny, xbuttons, xbutton;
+	switch_xml_t xroot, xdomain, xgroup, xuser, xskinny, xparams, xparam, xbuttons, xbutton;
 	char *sql;
 	assert(listener->profile);
 	profile = listener->profile;
@@ -1658,8 +1658,16 @@
 
 	xskinny = switch_xml_child(xuser, "skinny");
 	if (xskinny) {
-		xbuttons = switch_xml_child(xskinny, "buttons");
-		if (xbuttons) {
+		if ((xparams = switch_xml_child(xskinny, "params"))) {
+			for (xparam = switch_xml_child(xparams, "param"); xparam; xparam = xparam->next) {
+				const char *name = switch_xml_attr_soft(xparam, "name");
+				const char *value = switch_xml_attr_soft(xparam, "value");
+				if (!strcasecmp(name, "skinny-firmware-version")) {
+					strncpy(listener->firmware_version, value, 16);
+				}
+			}
+		}
+		if ((xbuttons = switch_xml_child(xskinny, "buttons"))) {
 			uint32_t line_instance = 1;
 			for (xbutton = switch_xml_child(xbuttons, "button"); xbutton; xbutton = xbutton->next) {
 				uint32_t position = atoi(switch_xml_attr_soft(xbutton, "position"));
@@ -2118,11 +2126,14 @@
 
 switch_status_t skinny_handle_version_request(listener_t *listener, skinny_message_t *request)
 {
-	/* TODO */
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-		"VersionReqMessage not implemented yet.\n");
-	return SWITCH_STATUS_SUCCESS;
-	/* return send_version(listener, ""); */
+	if (!zstr(listener->firmware_version)) {
+		return send_version(listener, listener->firmware_version);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+			"Device %s:%d is requesting for firmware version, but none is set.\n",
+			listener->device_name, listener->device_instance);
+		return SWITCH_STATUS_SUCCESS;
+	}
 }
 
 switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny_message_t *request)