Revert "Send notify for all lower versions as well"
authorJens Georg <mail@jensge.org>
Fri, 20 May 2011 11:44:54 +0000 (13:44 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 3 Jun 2011 23:28:54 +0000 (02:28 +0300)
This reverts commit c39bba86c215785afefd16a9eeab1def2556a4e2.

This is wrong according to UPnP spec. Announcements must only be sent
for the largest supported version.

The issue that was fixed with this is also fixed with
ad16c1ab2e14c8736bbef0397667ad782dc8d218.

libgssdp/gssdp-protocol.h
libgssdp/gssdp-resource-group.c

index 2589e23..050b122 100644 (file)
@@ -59,17 +59,6 @@ G_BEGIN_DECLS
         "NT: %s\r\n"                                \
         "USN: %s\r\n\r\n"
 
-#define SSDP_ALIVE_MESSAGE_WITH_VERSION             \
-        "NOTIFY * HTTP/1.1\r\n"                     \
-        "Host: " SSDP_ADDR ":" SSDP_PORT_STR "\r\n" \
-        "Cache-Control: max-age=%d\r\n"             \
-        "Location: %s\r\n"                          \
-        "%s"                                        \
-        "Server: %s\r\n"                            \
-        "NTS: ssdp:alive\r\n"                       \
-        "NT: %s%d\r\n"                              \
-        "USN: %s\r\n\r\n"
-
 #define SSDP_BYEBYE_MESSAGE                         \
         "NOTIFY * HTTP/1.1\r\n"                     \
         "Host: " SSDP_ADDR ":" SSDP_PORT_STR "\r\n" \
@@ -77,13 +66,6 @@ G_BEGIN_DECLS
         "NT: %s\r\n"                                \
         "USN: %s\r\n\r\n"
 
-#define SSDP_BYEBYE_MESSAGE_WITH_VERSION            \
-        "NOTIFY * HTTP/1.1\r\n"                     \
-        "Host: " SSDP_ADDR ":" SSDP_PORT_STR "\r\n" \
-        "NTS: ssdp:byebye\r\n"                      \
-        "NT: %s%d\r\n"                              \
-        "USN: %s\r\n\r\n"
-
 #define SSDP_SEARCH_METHOD "M-SEARCH"
 #define GENA_NOTIFY_METHOD "NOTIFY"
 
index 473322b..ed49e9f 100644 (file)
@@ -1007,67 +1007,14 @@ queue_message (GSSDPResourceGroup *resource_group,
 }
 
 /**
- * Add ssdp:alive messages for the given resource to sending queue
- **/
-static void
-queue_alive_messages (GSSDPResourceGroup *resource_group,
-                      guint               max_age,
-                      const char         *location,
-                      const char         *al,
-                      const char         *server_id,
-                      const char         *target,
-                      const char         *usn)
-{
-        char *version_str;
-        char *message;
-
-        version_str = get_version_for_target ((char *) target);
-        if (version_str != NULL) {
-                char *_target;
-                int version;
-
-                version = atoi (version_str);
-                _target = g_strndup (target, version_str - target);
-
-                while (version > 0) {
-                        message = g_strdup_printf
-                                              (SSDP_ALIVE_MESSAGE_WITH_VERSION,
-                                               max_age,
-                                               location,
-                                               al,
-                                               server_id,
-                                               _target,
-                                               version,
-                                               usn);
-
-                        queue_message (resource_group, message);
-
-                        version--;
-                }
-
-                g_free (_target);
-        } else {
-                message = g_strdup_printf (SSDP_ALIVE_MESSAGE,
-                                           max_age,
-                                           location,
-                                           al,
-                                           server_id,
-                                           target,
-                                           usn);
-
-                queue_message (resource_group, message);
-        }
-}
-
-/**
- * Send ssdp:alive messages for @resource
+ * Send ssdp:alive message for @resource
  **/
 static void
 resource_alive (Resource *resource)
 {
         GSSDPClient *client;
         guint max_age;
-        char *al;
+        char *al, *message;
 
         /* Send initial byebye if not sent already */
         send_initial_resource_byebye (resource);
@@ -1079,13 +1026,15 @@ resource_alive (Resource *resource)
 
         al = construct_al (resource);
 
-        queue_alive_messages (resource->resource_group,
-                              max_age,
-                              (const char *) resource->locations->data,
-                              al ? al : "",
-                              gssdp_client_get_server_id (client),
-                              resource->target,
-                              resource->usn);
+        message = g_strdup_printf (SSDP_ALIVE_MESSAGE,
+                                   max_age,
+                                   (char *) resource->locations->data,
+                                   al ? al : "",
+                                   gssdp_client_get_server_id (client),
+                                   resource->target,
+                                   resource->usn);
+
+        queue_message (resource->resource_group, message);
 
         g_free (al);
 }
@@ -1096,38 +1045,14 @@ resource_alive (Resource *resource)
 static void
 resource_byebye (Resource *resource)
 {
-        char *version_str;
         char *message;
 
-        version_str = get_version_for_target (resource->target);
-        if (version_str != NULL) {
-                char *_target;
-                int version;
-
-                version = atoi (version_str);
-                _target = g_strndup (resource->target,
-                                     version_str - resource->target);
-
-                while (version > 0) {
-                        message = g_strdup_printf
-                                              (SSDP_BYEBYE_MESSAGE_WITH_VERSION,
-                                               _target,
-                                               version,
-                                               resource->usn);
-
-                        queue_message (resource->resource_group, message);
-
-                        version--;
-                }
-
-                g_free (_target);
-        } else {
-                message = g_strdup_printf (SSDP_BYEBYE_MESSAGE,
-                                           resource->target,
-                                           resource->usn);
+        /* Queue message */
+        message = g_strdup_printf (SSDP_BYEBYE_MESSAGE,
+                                   resource->target,
+                                   resource->usn);
 
-                queue_message (resource->resource_group, message);
-        }
+        queue_message (resource->resource_group, message);
 }
 
 /**