r1736 - in trunk/src/target/OM-2007/openmoko-libs: . libmokojournal/src libmokojournal/tests
dodji at sita.openmoko.org
dodji at sita.openmoko.org
Fri Apr 13 10:37:16 CEST 2007
Author: dodji
Date: 2007-04-13 10:37:14 +0200 (Fri, 13 Apr 2007)
New Revision: 1736
Modified:
trunk/src/target/OM-2007/openmoko-libs/ChangeLog
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
Log:
Better entries removal handling, renamed more moko_j_* into moko_journal_*
* *.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
persisted should be queued for removal from eds.
(moko_journal_write_to_storage): do not cry too much when
an entry queued for removal could not be removed. It can happen
in nominal cases, for instance another process could have
deleted it already.
* openmoko-libs/libmokojournal/tests/test-create.c: update this
because of the moko_j_email* into moko_journal_email renaming.
Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-12 23:35:33 UTC (rev 1735)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-13 08:37:14 UTC (rev 1736)
@@ -1,3 +1,16 @@
+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
+ persisted should be queued for removal from eds.
+ (moko_journal_write_to_storage): do not cry too much when
+ an entry queued for removal could not be removed. It can happen
+ in nominal cases, for instance another process could have
+ deleted it already.
+ * openmoko-libs/libmokojournal/tests/test-create.c: update this
+ because of the moko_j_email* into moko_journal_email renaming.
+
2007-04-12 Dodji Seketeli <dodji at openedhand.com>
* openmoko-libs/libmokojournal/src/moko-journal.c,h:
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-12 23:35:33 UTC (rev 1735)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c 2007-04-13 08:37:14 UTC (rev 1736)
@@ -196,13 +196,13 @@
}
MokoJournalEmailInfo*
-moko_j_email_info_new ()
+moko_journal_email_info_new ()
{
return g_new0 (MokoJournalEmailInfo, 1) ;
}
void
-moko_j_email_info_free (MokoJournalEmailInfo *a_info)
+moko_journal_email_info_free (MokoJournalEmailInfo *a_info)
{
g_return_if_fail (a_info) ;
g_free (a_info) ;
@@ -253,7 +253,7 @@
case EMAIL_JOURNAL_ENTRY:
if (a_entry->extra_info.email_info)
{
- moko_j_email_info_free (a_entry->extra_info.email_info) ;
+ moko_journal_email_info_free (a_entry->extra_info.email_info) ;
a_entry->extra_info.email_info = NULL ;
}
break ;
@@ -334,7 +334,7 @@
MokoJournalEmailInfo *info=NULL ;
if (!moko_journal_entry_get_email_info (a_entry, &info) || !info)
goto out ;
- if (moko_j_email_info_get_was_sent (info))
+ if (moko_journal_email_info_get_was_sent (info))
prop = icalproperty_new_x ("YES") ;
else
prop = icalproperty_new_x ("NO") ;
@@ -451,9 +451,9 @@
&prop_value))
{
if (prop_value && !strcmp (prop_value, "YES"))
- moko_j_email_info_set_was_sent (info, TRUE) ;
+ moko_journal_email_info_set_was_sent (info, TRUE) ;
else
- moko_j_email_info_set_was_sent (info, FALSE) ;
+ moko_journal_email_info_set_was_sent (info, FALSE) ;
}
}
break ;
@@ -669,17 +669,37 @@
moko_journal_remove_entry_at (MokoJournal *a_journal,
guint a_index)
{
+ MokoJournalEntry *entry = NULL ;
+
g_return_val_if_fail (a_journal, FALSE) ;
g_return_val_if_fail (a_journal->entries, FALSE) ;
g_return_val_if_fail (a_index < a_journal->entries->len, FALSE) ;
- if (g_array_index (a_journal->entries, MokoJournalEntry*, a_index))
+ entry = g_array_index (a_journal->entries, MokoJournalEntry*, a_index) ;
+ if (entry)
{
- a_journal->entries_to_delete =
- g_list_prepend (a_journal->entries_to_delete,
- g_array_index (a_journal->entries,
- MokoJournalEntry*, a_index));
+ /*
+ * if entry has been persisted already,
+ * queue a removal from storage
+ */
+ if (entry->uid)
+ {
+ a_journal->entries_to_delete =
+ g_list_prepend (a_journal->entries_to_delete, entry);
+ }
+ /*
+ * remove entry from memory cache
+ */
g_array_remove_index (a_journal->entries, a_index) ;
+ /*
+ * if entry has not been pushed onto
+ * storage deletion queue,
+ * deallocate its memory
+ */
+ if (!entry->uid)
+ {
+ moko_journal_entry_free (entry) ;
+ }
return TRUE ;
}
return FALSE ;
@@ -822,7 +842,10 @@
}
}
- /*remove entries that are to be removed*/
+ /*
+ * remove entries that have been
+ * queued to be removed
+ */
for (cur_elem = a_journal->entries_to_delete ;
cur_elem ;
cur_elem = cur_elem->next)
@@ -836,7 +859,12 @@
((MokoJournalEntry*)cur_elem->data)->uid,
&error))
{
- g_warning ("failed to remove object of UID %s\n",
+ /*
+ * this can happen if another process for instance, has
+ * already deleted the entry. In that case, we just
+ * print message and continue
+ */
+ g_message ("failed to remove object with UID %s\n",
((MokoJournalEntry*)cur_elem->data)->uid) ;
}
if (error)
@@ -1238,7 +1266,7 @@
if (!a_entry->extra_info.email_info)
{
- a_entry->extra_info.email_info = moko_j_email_info_new () ;
+ a_entry->extra_info.email_info = moko_journal_email_info_new () ;
}
g_return_val_if_fail (a_entry->extra_info.email_info, FALSE) ;
@@ -1247,7 +1275,7 @@
}
/**
- * moko_j_email_info_get_was_sent:
+ * moko_journal_email_info_get_was_sent:
* @info: the current instance of email info
*
* Get a boolean property stating if the email was sent or received.
@@ -1255,21 +1283,21 @@
* Return value: TRUE if the email was sent, false if it was received
*/
gboolean
-moko_j_email_info_get_was_sent (MokoJournalEmailInfo *a_info)
+moko_journal_email_info_get_was_sent (MokoJournalEmailInfo *a_info)
{
g_return_val_if_fail (a_info, FALSE) ;
return a_info->was_sent ;
}
/**
- * moko_j_email_info_set_was_sent:
+ * moko_journal_email_info_set_was_sent:
* @info: the current instance of email info
* @was_sent: TRUE if the email was sent, FALSE if it was received
*
* Set a boolean property stating if the email was sent or received
*/
void
-moko_j_email_info_set_was_sent (MokoJournalEmailInfo *a_info,
+moko_journal_email_info_set_was_sent (MokoJournalEmailInfo *a_info,
gboolean a_was_sent)
{
g_return_if_fail (a_info) ;
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h 2007-04-12 23:35:33 UTC (rev 1735)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h 2007-04-13 08:37:14 UTC (rev 1736)
@@ -300,7 +300,7 @@
*
* Return value: TRUE if the email was sent, false if it was received
*/
-gboolean moko_j_email_info_get_was_sent (MokoJournalEmailInfo *info) ;
+gboolean moko_journal_email_info_get_was_sent (MokoJournalEmailInfo *info) ;
/**
* moko_j_email_info_set_was_sent:
@@ -309,8 +309,8 @@
*
* Set a boolean property stating if the email was sent or received
*/
-void moko_j_email_info_set_was_sent (MokoJournalEmailInfo *info,
- gboolean was_sent) ;
+void moko_journal_email_info_set_was_sent (MokoJournalEmailInfo *info,
+ gboolean was_sent) ;
/*</email info>*/
Modified: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c 2007-04-12 23:35:33 UTC (rev 1735)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c 2007-04-13 08:37:14 UTC (rev 1736)
@@ -65,7 +65,7 @@
g_warning ("failed to get email extra info from journal entry\n") ;
goto out ;
}
- moko_j_email_info_set_was_sent (email_info, TRUE) ;
+ moko_journal_email_info_set_was_sent (email_info, TRUE) ;
/*****************************
* </fill the entry with data>
*****************************/
More information about the commitlog
mailing list