r1737 - in trunk/src/target/OM-2007/openmoko-libs: . libmokojournal/src

dodji at sita.openmoko.org dodji at sita.openmoko.org
Fri Apr 13 16:11:32 CEST 2007


Author: dodji
Date: 2007-04-13 16:11:30 +0200 (Fri, 13 Apr 2007)
New Revision: 1737

Modified:
   trunk/src/target/OM-2007/openmoko-libs/ChangeLog
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
Log:
Update the journal when another process removes entries

	* openmoko-libs/libmokojournal/src/moko-journal.c:
	  (moko_journal_load_from_storage): make sure we get notified when
	  another process removes an entry.
	  (on_entries_removed_cb): added this to handle entry removal by
	  another process.


Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog	2007-04-13 08:37:14 UTC (rev 1736)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog	2007-04-13 14:11:30 UTC (rev 1737)
@@ -1,5 +1,13 @@
 2007-04-13 Dodji Seketeli <dodji at openedhand.com>
 
+	* openmoko-libs/libmokojournal/src/moko-journal.c:
+	  (moko_journal_load_from_storage): make sure we get notified when
+	  another process removes an entry.
+	  (on_entries_removed_cb): added this to handle entry removal by
+	  another process.
+
+2007-04-13 Dodji Seketeli <dodji at openedhand.com>
+
 	* *.h,c: changed moko_j_email_info* into moko_journal_email_info*
 	* openmoko-libs/libmokojournal/src/moko-journal.c:
 	  (moko_journal_remove_entry_at): only entries that has been

Modified: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c	2007-04-13 08:37:14 UTC (rev 1736)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c	2007-04-13 14:11:30 UTC (rev 1737)
@@ -92,6 +92,11 @@
 static void on_entries_added_cb (ECalView *a_view,
                                  GList *a_entries,
                                  MokoJournal *a_journal) ;
+static void on_entries_removed_cb (ECalView *a_view,
+                                   GList *uids,
+                                   MokoJournal *a_journal) ;
+
+
 static const gchar*
 entry_type_to_string (MokoJournalEntryType a_type)
 {
@@ -953,6 +958,33 @@
   }
 }
 
+static void
+on_entries_removed_cb (ECalView *a_view,
+                       GList *a_uids,
+                       MokoJournal *a_journal)
+{
+  GList *cur = NULL ;
+
+  g_return_if_fail (a_view && E_IS_CAL_VIEW (a_view)) ;
+  g_return_if_fail (a_journal) ;
+
+  /*TODO:
+   * we should notify the world before removing an entry.
+   * Otherwise, client code may hold a reference to
+   * what will become a dangling pointer after we remove it here
+   */
+  for (cur = a_uids ; cur ; cur = cur->next)
+  {
+    if (cur->data)
+    {
+      if (!moko_journal_remove_entry_by_uid (a_journal, cur->data))
+      {
+        g_message ("failed to remove entry of uid %s\n", cur->data) ;
+      }
+    }
+  }
+}
+
 /**
  * moko_journal_load_from_storage:
  * @a_journal: the journal to load entries into
@@ -998,6 +1030,11 @@
                       "objects-added",
                       G_CALLBACK (on_entries_added_cb),
                       a_journal) ;
+    g_signal_connect (G_OBJECT (a_journal->ecal_view),
+                      "objects-removed",
+                      G_CALLBACK (on_entries_removed_cb),
+                      a_journal) ;
+
     e_cal_view_start (a_journal->ecal_view) ;
   }
 





More information about the commitlog mailing list