2007-05-16 Zeeshan Ali <zeenix@gstreamer.net>
authorJorn Baayen <jorn@openedhand.com>
Fri, 18 May 2007 14:42:17 +0000 (14:42 +0000)
committerJorn Baayen <jorn@openedhand.com>
Fri, 18 May 2007 14:42:17 +0000 (14:42 +0000)
* tools/gssdp-device-sniffer.c: (append_device),
(resource_available_cb):

Append the device to the device treeview even when all details are not
yet known.

* tools/gssdp-device-sniffer.glade:

Fix the closing of dialog.

git-svn-id: https://svn.o-hand.com/repos/gupnp/trunk/gssdp@215 d8cb91d7-bff9-0310-92b9-80b65e4482b2

ChangeLog
tools/gssdp-device-sniffer.c
tools/gssdp-device-sniffer.glade

index 32df090..6c8095f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,27 @@
-2007-05-15  Jorn Baayen  <jorn@openedhand.com>
+2007-05-16  Zeeshan Ali  <zeenix@gstreamer.net>
+
+       * tools/gssdp-device-sniffer.c: (append_device),
+       (resource_available_cb):
+
+       Append the device to the device treeview even when all details are not
+       yet known.
+       
+       * tools/gssdp-device-sniffer.glade:
+
+       Fix the closing of dialog.
+
+2007-05-15  Zeeshan Ali  <zeenix@gstreamer.net>
+
+       reviewed by: Jorn Baayen  <jorn@openedhand.com>
 
        * tools/gssdp-device-sniffer.c: (packet_to_treeview_data),
+       (on_enable_packet_capture_activate), (packet_to_treeview_data),
        (on_ssdp_message):
        * tools/gssdp-device-sniffer.glade:
 
-       Updates by Zeeshan.
+       - Implement start/stop of packet capturing.
+       - Ignore discovery request packets rather than response packets.
+       - Minor UI fixes.
 
 2007-05-11  Jorn Baayen  <jorn@openedhand.com>
 
index 1a25baa..da19462 100644 (file)
@@ -246,31 +246,6 @@ on_ssdp_message (GSSDPClient *client,
         append_packet (from_ip, arrival_time, type, headers);
 }
 
-static void
-append_device (const char *uuid,
-               const char *last_notify,
-               const char *device_type,
-               const char *location)
-{
-        GtkWidget *treeview;
-        GtkListStore *liststore;
-        GtkTreeIter iter;
-       
-        treeview = glade_xml_get_widget (glade_xml, "device-details-treeview");
-        g_assert (treeview != NULL);
-        liststore = GTK_LIST_STORE (
-                        gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
-        g_assert (liststore != NULL);
-       
-        gtk_list_store_insert_with_values (liststore, &iter, 0,
-                        0, uuid,
-                        1, (guint64) 1,
-                        2, last_notify,
-                        3, device_type,
-                        4, location,
-                        -1);
-}
-
 static gboolean 
 find_device (GtkTreeModel *model, const char *uuid, GtkTreeIter *iter)
 {
@@ -296,8 +271,10 @@ find_device (GtkTreeModel *model, const char *uuid, GtkTreeIter *iter)
 }
 
 static void
-update_device (const char *uuid,
-               const char *last_notify)
+append_device (const char *uuid,
+               const char *last_notify,
+               const char *device_type,
+               const char *location)
 {
         GtkWidget *treeview;
         GtkTreeModel *model;
@@ -307,15 +284,27 @@ update_device (const char *uuid,
         g_assert (treeview != NULL);
         model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
         g_assert (model != NULL);
-      
+       
         if (find_device (model, uuid, &iter)) {
+                /* Only update the device row if it's already been added */
                 gint64 notify;
 
                 gtk_tree_model_get (model, &iter, 1, (gint64 *) &notify, -1);
                 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                                 1, (gint64) notify+1,
+                                2, last_notify, -1);
+        } else {
+                gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
+                                &iter, 0,
+                                0, uuid,
+                                1, (guint64) 1,
                                 2, last_notify,
-                                -1);
+                                4, location, -1);
+        }
+                
+        if (device_type) {
+                gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                                3, device_type, -1);
         }
 }
 
@@ -327,6 +316,15 @@ resource_available_cb (GSSDPResourceBrowser *resource_browser,
 
         char **usn_tokens;
         char *uuid;
+        char *device_type = NULL;
+        time_t current_time;
+        struct tm *tm;
+        char *last_notify;
+                
+        current_time = time (NULL);
+        tm = localtime (&current_time);
+        last_notify = g_strdup_printf ("%02d:%02d",
+        tm->tm_hour, tm->tm_min);
 
         usn_tokens = g_strsplit (usn, "::", -1);
         g_assert (usn_tokens != NULL && usn_tokens[0] != NULL);
@@ -335,36 +333,23 @@ resource_available_cb (GSSDPResourceBrowser *resource_browser,
 
         if (usn_tokens[1]) {
                 char **urn_tokens;
-                time_t current_time;
-                struct tm *tm;
-                char *last_notify;
 
                 urn_tokens = g_strsplit (usn_tokens[1], ":device:", -1);
                         
-                current_time = time (NULL);
-                tm = localtime (&current_time);
-                last_notify = g_strdup_printf ("%02d:%02d",
-                                tm->tm_hour, tm->tm_min);
-
-                if (urn_tokens[1]) {
-                        /* Device Announcement */
-                        append_device (uuid,
-                                       last_notify,
-                                       urn_tokens[1],
-                                       (char *) locations->data);
-                }
-                
-                else {
-                        /* FIXME: not all notifications are getting
-                         * counted using this logic
-                         */
-                        update_device (uuid, last_notify);
-                }
-
-                g_free (last_notify);
+                if (urn_tokens[1])
+                        device_type = g_strdup (urn_tokens[1]);
                 g_strfreev (urn_tokens);
         }
-                
+
+        /* Device Announcement */
+        append_device (uuid,
+                       last_notify,
+                       device_type,
+                       (char *) locations->data);
+        
+        if (device_type)
+                g_free (device_type);
+        g_free (last_notify);
         g_strfreev (usn_tokens);
 }
 
index 6c8d67d..72d12da 100644 (file)
@@ -279,6 +279,8 @@ Inspired by Intel Tools for UPnP.</property>
   <property name="wrap_license">False</property>
   <property name="authors">Zeeshan Ali &lt;zeenix@gstreamer.net&gt;</property>
   <property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
+  <signal name="close" handler="gtk_widget_hide" object="about-dialog" last_modification_time="Tue, 15 May 2007 21:16:34 GMT"/>
+  <signal name="delete_event" handler="gtk_widget_hide" object="about-dialog" last_modification_time="Tue, 15 May 2007 21:17:51 GMT"/>
 </widget>
 
 <widget class="GtkDialog" id="address-filter-dialog">