r7020 - dumbhippo/trunk/client/common/ddm
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7020 - dumbhippo/trunk/client/common/ddm
- Date: Tue, 11 Dec 2007 13:47:19 -0600 (CST)
Author: otaylor
Date: 2007-12-11 13:47:18 -0600 (Tue, 11 Dec 2007)
New Revision: 7020
Modified:
dumbhippo/trunk/client/common/ddm/ddm-feed.c
dumbhippo/trunk/client/common/ddm/ddm-feed.h
dumbhippo/trunk/client/common/ddm/test-feed-object.c
Log:
- Add ddm_feed_iter_remove()
- Add some padding fields to the public DDMFeedIter
Modified: dumbhippo/trunk/client/common/ddm/ddm-feed.c
===================================================================
--- dumbhippo/trunk/client/common/ddm/ddm-feed.c 2007-12-11 19:23:00 UTC (rev 7019)
+++ dumbhippo/trunk/client/common/ddm/ddm-feed.c 2007-12-11 19:47:18 UTC (rev 7020)
@@ -164,7 +164,6 @@
g_hash_table_insert(feed->nodes_by_resource, resource, node);
feed_insert_sorted(feed, node, timestamp);
-
g_signal_emit(feed, signals[ITEM_ADDED], 0, resource, timestamp);
}
}
@@ -185,11 +184,11 @@
return;
}
- feed->items = g_list_remove_link(feed->items, node);
+ item = node->data;
+
+ feed->items = g_list_delete_link(feed->items, node);
g_hash_table_remove(feed->nodes_by_resource, resource);
- item = node->data;
-
g_signal_emit(feed, signals[ITEM_REMOVED], 0, item->resource);
ddm_data_resource_unref(item->resource);
g_slice_free(DDMFeedItem, item);
@@ -252,10 +251,45 @@
return FALSE;
item = real->node->data;
- *resource = item->resource;
- *timestamp = item->timestamp;
+ if (resource != NULL)
+ *resource = item->resource;
+ if (timestamp != NULL)
+ *timestamp = item->timestamp;
real->node = real->node->next;
return TRUE;
}
+
+void
+ddm_feed_iter_remove (DDMFeedIter *iter)
+{
+ DDMFeedIterReal *real = (DDMFeedIterReal *)iter;
+ DDMFeedItem *item;
+ GList *node;
+
+ if (real->node) {
+ if (real->node->prev == NULL) {
+ g_warning("ddm_feed_iter_remove() called before fetching any items");
+ return;
+ }
+
+ node = real->node->prev;
+ } else {
+ if (real->feed->items == NULL) {
+ g_warning("ddm_feed_iter_remove() on an empty liste");
+ return;
+ }
+
+ node = g_list_last(real->feed->items);
+ }
+
+ item = node->data;
+
+ g_hash_table_remove(real->feed->nodes_by_resource, item->resource);
+ real->feed->items = g_list_delete_link(real->feed->items, node);
+
+ g_signal_emit(real->feed, signals[ITEM_REMOVED], 0, item->resource);
+ ddm_data_resource_unref(item->resource);
+ g_slice_free(DDMFeedItem, item);
+}
Modified: dumbhippo/trunk/client/common/ddm/ddm-feed.h
===================================================================
--- dumbhippo/trunk/client/common/ddm/ddm-feed.h 2007-12-11 19:23:00 UTC (rev 7019)
+++ dumbhippo/trunk/client/common/ddm/ddm-feed.h 2007-12-11 19:47:18 UTC (rev 7020)
@@ -32,6 +32,8 @@
struct _DDMFeedIter {
gpointer data1;
gpointer data2;
+ gpointer data3;
+ gint data4;
};
#define DDM_TYPE_FEED (ddm_feed_get_type ())
@@ -54,11 +56,13 @@
DDMDataResource *resource);
void ddm_feed_clear (DDMFeed *feed);
-void ddm_feed_iter_init (DDMFeedIter *iter,
- DDMFeed *feed);
-gboolean ddm_feed_iter_next (DDMFeedIter *iter,
- DDMDataResource **resource,
- gint64 *timestamp);
+void ddm_feed_iter_init (DDMFeedIter *iter,
+ DDMFeed *feed);
+gboolean ddm_feed_iter_next (DDMFeedIter *iter,
+ DDMDataResource **resource,
+ gint64 *timestamp);
+/* Remove the last item retrieved by ddm_feed_iter_next() */
+void ddm_feed_iter_remove (DDMFeedIter *iter);
G_END_DECLS
Modified: dumbhippo/trunk/client/common/ddm/test-feed-object.c
===================================================================
--- dumbhippo/trunk/client/common/ddm/test-feed-object.c 2007-12-11 19:23:00 UTC (rev 7019)
+++ dumbhippo/trunk/client/common/ddm/test-feed-object.c 2007-12-11 19:47:18 UTC (rev 7020)
@@ -153,6 +153,21 @@
ddm_feed_iter_init(&iter, feed);
g_assert(!ddm_feed_iter_next(&iter, &resource, ×tamp));
+
+ /* Removing items with an iter */
+ ddm_feed_add_item(feed, user1, TS1);
+ ddm_feed_add_item(feed, user2, TS2);
+
+ ddm_feed_iter_init(&iter, feed);
+ g_assert(ddm_feed_iter_next(&iter, &resource, ×tamp));
+ ddm_feed_iter_remove(&iter);
+ g_assert(ddm_feed_iter_next(&iter, &resource, ×tamp));
+ ddm_feed_iter_remove(&iter);
+ g_assert(!ddm_feed_iter_next(&iter, &resource, ×tamp));
+
+ ddm_feed_iter_init(&iter, feed);
+ g_assert(!ddm_feed_iter_next(&iter, &resource, ×tamp));
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]