desktop-data-model r7251 - in trunk: ddm engine-dbus



Author: otaylor
Date: Mon Feb 11 23:29:07 2008
New Revision: 7251
URL: http://svn.gnome.org/viewvc/desktop-data-model?rev=7251&view=rev

Log:
hippo-dbus-model-client.c: Fix a bug where if a notification caused
  a feed to be newly and indirectly fetched, the feed entries wouldn't
  be sent.
ddm-data-resource.c: Some simplification in the code to record feed
 timestamps for a notification.


Modified:
   trunk/ddm/ddm-data-resource.c
   trunk/engine-dbus/hippo-dbus-model-client.c

Modified: trunk/ddm/ddm-data-resource.c
==============================================================================
--- trunk/ddm/ddm-data-resource.c	(original)
+++ trunk/ddm/ddm-data-resource.c	Mon Feb 11 23:29:07 2008
@@ -2234,30 +2234,6 @@
     }
 }
 
-static void
-add_to_notification_set(DDMDataResource          *resource,
-                        DDMClientNotificationSet *notification_set,
-                        DDMClient                *client,
-                        DDMDataFetch             *fetch,
-                        GSList                   *changed_properties)
-{
-    GSList *l;
-    
-    _ddm_client_notification_set_add(notification_set,
-                                     resource,
-                                     client,
-                                     fetch,
-                                     changed_properties);
-
-    for (l = resource->properties; l; l = l->next) {
-        DDMDataProperty *property = l->data;
-        if (property->value.type == DDM_DATA_FEED && property->value.u.feed != NULL &&
-            g_slist_find(changed_properties, property->qname) != NULL)
-            _ddm_client_notification_set_add_feed_timestamp(notification_set, property->value.u.feed,
-                                                            ddm_feed_get_notify_timestamp(property->value.u.feed));
-    }
-}
-
 void
 _ddm_data_resource_resolve_notifications (DDMDataResource          *resource,
                                           DDMClientNotificationSet *notification_set)
@@ -2268,10 +2244,10 @@
     for (l = resource->clients; l; l = l->next) {
         DataClient *data_client = l->data;
 
-        add_to_notification_set(resource, notification_set,
-                                data_client->client,
-                                data_client->fetch,
-                                resource->changed_properties);
+        _ddm_client_notification_set_add(notification_set, resource,
+                                         data_client->client,
+                                         data_client->fetch,
+                                         resource->changed_properties);
     }
 
     if (data_resource_needs_local_notifications(resource, resource->changed_properties)) {
@@ -2282,19 +2258,29 @@
          *
          * See also comment in ddm-data-query.c:mark_received_fetches()
          */
-        add_to_notification_set(resource, notification_set,
-                                _ddm_data_model_get_local_client(resource->model),
-                                resource->received_fetch,
-                                resource->changed_properties);
+        _ddm_client_notification_set_add(notification_set, resource,
+                                         _ddm_data_model_get_local_client(resource->model),
+                                         resource->received_fetch,
+                                         resource->changed_properties);
         
     }
 
-    g_slist_free(resource->changed_properties);
-    resource->changed_properties = NULL;
-    
+    /* Save and reset the notification timestamps for any feeds that changed. (Checking
+     * for resource->clients is a small optimization in the case where we have no
+     * existing clients for the resource... we could save the timestamp in that case,
+     * but we don't need to. We don't need the timestamps for the local case.)
+     */
     for (l = resource->properties; l; l = l->next) {
         DDMDataProperty *property = l->data;
-        if (property->value.type == DDM_DATA_FEED && property->value.u.feed != NULL)
+        if (property->value.type == DDM_DATA_FEED && property->value.u.feed != NULL &&
+            g_slist_find(resource->changed_properties, property->qname) != NULL) {
+            if (resource->clients)
+                _ddm_client_notification_set_add_feed_timestamp(notification_set, property->value.u.feed,
+                                                                ddm_feed_get_notify_timestamp(property->value.u.feed));
             ddm_feed_reset_notify_timestamp(property->value.u.feed);
+        }
     }
+    
+    g_slist_free(resource->changed_properties);
+    resource->changed_properties = NULL;
 }

Modified: trunk/engine-dbus/hippo-dbus-model-client.c
==============================================================================
--- trunk/engine-dbus/hippo-dbus-model-client.c	(original)
+++ trunk/engine-dbus/hippo-dbus-model-client.c	Mon Feb 11 23:29:07 2008
@@ -307,7 +307,8 @@
                                  DDMClientNotificationSet *notification_set,
                                  DBusMessageIter          *resource_array_iter,
                                  DDMDataProperty          *property,
-                                 DDMDataFetch             *children)
+                                 DDMDataFetch             *children,
+                                 gboolean                  direct_notification)
 {
     DDMDataValue value;
             
@@ -325,7 +326,10 @@
         gint64 min_timestamp;
         gint64 item_timestamp;
 
-        if (notification_set != NULL)
+        /* When notifying of changes of a previously fetched property, we can check against the
+         * previous timestamp, otherwise we have to send everything.
+         */
+        if (direct_notification)
             min_timestamp = ddm_client_notification_set_get_feed_timestamp(notification_set, value.u.feed);
         else
             min_timestamp = 0;
@@ -343,7 +347,8 @@
 static void
 add_property_to_message(DBusMessageIter          *property_array_iter,
                         DDMDataProperty          *property,
-                        DDMClientNotificationSet *notification_set)
+                        DDMClientNotificationSet *notification_set,
+                        gboolean                  direct_notification)
 {
     DDMDataCardinality cardinality;
     DDMDataValue value;
@@ -376,7 +381,10 @@
             gint64 min_timestamp;
             gboolean first;
 
-            if (notification_set != NULL)
+            /* When notifying of changes of a previously fetched property, we can check against the
+             * previous timestamp, otherwise we have to send everything.
+             */
+            if (direct_notification)
                 min_timestamp = ddm_client_notification_set_get_feed_timestamp(notification_set, value.u.feed);
             else
                 min_timestamp = 0;
@@ -417,6 +425,7 @@
     DBusMessageIter property_array_iter;
     const char *resource_id;
     const char *class_id;
+    gboolean direct_notification;
     dbus_bool_t indirect_bool;
 
     connection = g_hash_table_lookup(client->connections, ddm_data_resource_get_resource_id(resource));
@@ -425,7 +434,13 @@
         g_hash_table_insert(client->connections, (char *)ddm_data_resource_get_resource_id(resource), connection);
     }
 
-    if (notification_set != NULL && !indirect) {
+    /* Unless we are notifying of changes to *this* object, then we only
+     * want to include properties that we haven't sent before to the
+     * client
+     */
+    direct_notification = (notification_set != NULL && !indirect);
+
+    if (direct_notification) {
         new_fetch = ddm_data_fetch_ref(fetch);
     } else {
         if (connection->fetch)
@@ -462,7 +477,7 @@
             if (notification_set != NULL && !indirect && g_slist_find(changed_properties, ddm_data_property_get_qname(property)) == NULL)
                 continue;
             
-            add_property_children_to_message(client, notification_set, resource_array_iter, property, children);
+            add_property_children_to_message(client, notification_set, resource_array_iter, property, children, direct_notification);
         }
         ddm_data_fetch_iter_clear(&fetch_iter);
     }
@@ -488,7 +503,7 @@
             if (notification_set != NULL && !indirect && g_slist_find(changed_properties, ddm_data_property_get_qname(property)) == NULL)
                 continue;
             
-            add_property_to_message(&property_array_iter, property, notification_set);
+            add_property_to_message(&property_array_iter, property, notification_set, direct_notification);
         }
         
         ddm_data_fetch_iter_clear(&fetch_iter);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]