--- Begin Message ---
Author: dodji
Date: 2007-04-12 10:53:35 +0200 (Thu, 12 Apr 2007)
New Revision: 1729
Added:
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-delete.c
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/tests/Makefile.am
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
Log:
Made entries deletion work, fixed leaks, added comments to test cases.
* openmoko-libs/libmokojournal/src/moko-journal.c:
(moko_j_entry_free_real): fix a leak in here.
(moko_journal_remove_entry_at): make this really remove
the entries from MokoJournal::entries.
(moko_journal_write_to_storage): fix a leak.
* openmoko-libs/libmokojournal/tests/test-create.c: added comments
and licensing blurb.
* openmoko-libs/libmokojournal/tests/test-delete.c: added
this new file to test/debug entries deletion.
Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-11 20:06:22 UTC
(rev 1728)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-12 08:53:35 UTC
(rev 1729)
@@ -1,3 +1,15 @@
+2007-04-12 Dodji Seketeli <[EMAIL PROTECTED]>
+
+ * openmoko-libs/libmokojournal/src/moko-journal.c:
+ (moko_j_entry_free_real): fix a leak in here.
+ (moko_journal_remove_entry_at): make this really remove
+ the entries from MokoJournal::entries.
+ (moko_journal_write_to_storage): fix a leak.
+ * openmoko-libs/libmokojournal/tests/test-create.c: added comments
+ and licensing blurb.
+ * openmoko-libs/libmokojournal/tests/test-delete.c: added
+ this new file to test/debug entries deletion.
+
2007-04-11 Dodji Seketeli <[EMAIL PROTECTED]>
* 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-11 20:06:22 UTC (rev 1728)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
2007-04-12 08:53:35 UTC (rev 1729)
@@ -265,6 +265,7 @@
g_warning ("unknown journal entry type. This is a leak!\n") ;
break ;
}
+ g_free (a_entry) ;
}
static gboolean
@@ -673,13 +674,14 @@
a_journal->entries_to_delete =
g_list_prepend (a_journal->entries_to_delete,
g_array_index (a_journal->entries, MokoJEntry*,
a_index));
+ g_array_remove_index (a_journal->entries, a_index) ;
return TRUE ;
}
return FALSE ;
}
/**
- * moko_journal_weite_to_storage:
+ * moko_journal_write_to_storage:
* @journal: the journal to save to storage
*
* Saves the journal to persistent storage (e.g disk) using the
@@ -818,6 +820,15 @@
a_journal->entries_to_delete = NULL ;
}
+ if (ecal_comps)
+ {
+ GList *cur;
+
+ for (cur = ecal_comps ; cur ; cur = cur->next)
+ g_object_unref (cur->data) ;
+ g_list_free (ecal_comps) ;
+ }
+
return result ;
}
Modified:
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am
2007-04-11 20:06:22 UTC (rev 1728)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am
2007-04-12 08:53:35 UTC (rev 1729)
@@ -1,5 +1,9 @@
-noinst_PROGRAMS=testcreate
+noinst_PROGRAMS=testcreate testdelete
testcreate_SOURCES=test-create.c
[EMAIL PROTECTED]@ $(top_srcdir)/libmokojournal/src/libmokojournal.la
+
+testdelete_SOURCES=test-delete.c
[EMAIL PROTECTED]@ $(top_srcdir)/libmokojournal/src/libmokojournal.la
+
INCLUDES= -I $(top_srcdir)/libmokojournal/src
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-11 20:06:22 UTC (rev 1728)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
2007-04-12 08:53:35 UTC (rev 1729)
@@ -1,9 +1,29 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include <unistd.h>
-#include <gtk/gtk.h>
+#include <glib-object.h>
#include "moko-journal.h"
int
-main (int argc, char **argv)
+main ()
{
MokoJournal *journal=NULL ;
MokoJEntry *entry=NULL ;
@@ -12,22 +32,21 @@
g_type_init () ;
+ /*open the journal*/
journal = moko_journal_open_default () ;
g_return_val_if_fail (journal, 1) ;
+ /*load all journal entries from the journal on storage*/
if (!moko_journal_load_from_storage (journal))
{
g_message ("failed to load journal from storage\n") ;
- return FALSE ;
+ goto out ;
}
- while (g_main_context_pending (g_main_context_default ()))
- {
- g_main_context_iteration (g_main_context_default (), FALSE) ;
- }
g_message ("loaded journal from storage okay\n") ;
g_message ("number journal entries: %d\n",
moko_journal_get_nb_entries (journal)) ;
+ /*create a journal entry of type 'email journal entry'*/
entry = moko_j_entry_new (EMAIL_JOURNAL_ENTRY) ;
if (!entry)
{
@@ -35,6 +54,9 @@
goto out ;
}
+ /*****************************
+ * <fill the entry with data>
+ *****************************/
moko_j_entry_set_contact_uid (entry, "foobarbazuid") ;
moko_j_entry_set_summary (entry, "back from fostel") ;
moko_j_entry_set_dtstart (entry, moko_time_new_today ()) ;
@@ -44,20 +66,44 @@
goto out ;
}
moko_j_email_info_set_was_sent (email_info, TRUE) ;
+ /*****************************
+ * </fill the entry with data>
+ *****************************/
+ /*add the entry we created to the journal*/
if (!moko_journal_add_entry (journal, entry))
{
g_warning ("could not add entry to journal\n") ;
goto out ;
}
+ /*
+ * the entry is now owned by the journal, make sure we won't ever
+ * free it ourselves (by accident)
+ */
entry = NULL ;
+
+ /*sync the journal to persistent storage*/
if (!moko_journal_write_to_storage (journal))
{
g_warning ("Could not write journal to storage") ;
goto out ;
}
+ /*
+ * sleep a bit to wait for possible notifications, in case
+ * another process has added new journal entries as well
+ * this is not mandatory, but is there for the sake of testing.
+ */
sleep (2) ;
+
+ /*
+ * notifications of new journal entries being added to the journal
+ * is done via dbus, using the glib event loop to dispatch the
+ * notifications. So let's give the event loop a chance to
+ * let us notified of new entries that could have been added.
+ * Note that when using gtk+, you usually don't have to do this,
+ * as gtk+ does it for you magically.
+ */
while (g_main_context_pending (g_main_context_default ()))
{
g_main_context_iteration (g_main_context_default (), FALSE) ;
@@ -65,6 +111,7 @@
g_message ("number journal entries after one got added: %d\n",
moko_journal_get_nb_entries (journal)) ;
+ /*if we reached this point, the test has probably succeeded*/
result = 0;
g_print ("test succeeded\n") ;
Added: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-delete.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-delete.c
2007-04-11 20:06:22 UTC (rev 1728)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-delete.c
2007-04-12 08:53:35 UTC (rev 1729)
@@ -0,0 +1,76 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <glib-object.h>
+#include "moko-journal.h"
+
+int
+main ()
+{
+ MokoJournal *journal=NULL ;
+ int result=-1 ;
+
+ g_type_init () ;
+
+ journal = moko_journal_open_default () ;
+ g_return_val_if_fail (journal, -1) ;
+
+ if (!moko_journal_load_from_storage (journal))
+ {
+ g_warning ("failed to load journal from storage\n") ;
+ goto out ;
+ }
+ g_message ("initial number of journal entries: %d\n",
+ moko_journal_get_nb_entries (journal)) ;
+
+ /*remove all entries from journal starting from the oldest one*/
+ while (moko_journal_get_nb_entries (journal) > 0)
+ {
+ if (!moko_journal_remove_entry_at (journal, 0))
+ {
+ g_message ("failed to remove an entry from journal") ;
+ goto out ;
+ }
+ }
+
+ /*write the modifications we did to persistent storage*/
+ if (!moko_journal_write_to_storage (journal))
+ {
+ g_message ("failed to write to storage\n") ;
+ goto out ;
+ }
+
+ if (moko_journal_get_nb_entries (journal) != 0)
+ {
+ g_message ("test failed, we still have %d entries left\n",
+ moko_journal_get_nb_entries (journal)) ;
+ goto out ;
+ }
+
+ /*if we reached this place, the test is prolly successful*/
+ g_message ("test succeeded") ;
+ result = 0 ;
+
+out:
+ if (journal)
+ moko_journal_close (journal) ;
+
+ return result ;
+}
--- End Message ---
--- Begin Message ---
Author: dodji
Date: 2007-04-12 11:21:34 +0200 (Thu, 12 Apr 2007)
New Revision: 1730
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:
Changed some function names for better legibility
* openmoko-libs/libmokojournal/src/moko-journal.[c|h]:
change moko_j_entry* into moko_journal_entry*,
MokoJEntry, into MokoJournalEntry, etc.
That is for better legibility.
Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-12 08:53:35 UTC
(rev 1729)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-12 09:21:34 UTC
(rev 1730)
@@ -1,5 +1,12 @@
2007-04-12 Dodji Seketeli <[EMAIL PROTECTED]>
+ * openmoko-libs/libmokojournal/src/moko-journal.[c|h]:
+ change moko_j_entry* into moko_journal_entry*,
+ MokoJEntry, into MokoJournalEntry, etc.
+ That is for better legibility.
+
+2007-04-12 Dodji Seketeli <[EMAIL PROTECTED]>
+
* openmoko-libs/libmokojournal/src/moko-journal.c:
(moko_j_entry_free_real): fix a leak in here.
(moko_journal_remove_entry_at): make this really remove
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 08:53:35 UTC (rev 1729)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
2007-04-12 09:21:34 UTC (rev 1730)
@@ -34,14 +34,14 @@
GArray *entries ;
};
-struct _MokoJEmailInfo
+struct _MokoJournalEmailInfo
{
gboolean was_sent ;
};
-struct _MokoJEntry
+struct _MokoJournalEntry
{
- MokoJEntryType type;
+ MokoJournalEntryType type;
gchar *uid ;
gchar *contact_uid ;
gchar *summary ;
@@ -49,18 +49,18 @@
MokoTime *dtend ;
union
{
- MokoJEmailInfo *email_info ;
+ MokoJournalEmailInfo *email_info ;
} extra_info ;
};
-struct _MokoJEntryInfo
+struct _MokoJournalEntryInfo
{
- MokoJEntryType type;
+ MokoJournalEntryType type;
const gchar *type_as_string ;
};
-typedef struct _MokoJEntryInfo MokoJEntryInfo ;
+typedef struct _MokoJournalEntryInfo MokoJournalEntryInfo ;
-static const MokoJEntryInfo entries_info[] =
+static const MokoJournalEntryInfo entries_info[] =
{
{EMAIL_JOURNAL_ENTRY, "EMAILENTRY"},
{SMS_JOURNAL_ENTRY, "SMSENTRY"},
@@ -72,15 +72,15 @@
static MokoJournal* moko_journal_alloc () ;
static gboolean moko_journal_find_entry_from_uid (MokoJournal *a_journal,
const gchar *a_uid,
- MokoJEntry **a_entry,
+ MokoJournalEntry **a_entry,
int *a_offset) ;
-static const gchar* entry_type_to_string (MokoJEntryType a_type) ;
-static MokoJEntryType entry_type_from_string (const gchar* a_str) ;
-static gboolean moko_j_entry_type_is_valid (MokoJEntryType a_type) ;
-static gboolean moko_j_entry_to_icalcomponent (MokoJEntry *a_entry,
- icalcomponent **a_comp) ;
+static const gchar* entry_type_to_string (MokoJournalEntryType a_type) ;
+static MokoJournalEntryType entry_type_from_string (const gchar* a_str) ;
+static gboolean moko_journal_entry_type_is_valid (MokoJournalEntryType a_type)
;
+static gboolean moko_journal_entry_to_icalcomponent (MokoJournalEntry *a_entry,
+ icalcomponent **a_comp) ;
static gboolean icalcomponent_to_j_entry (icalcomponent *a_comp,
- MokoJEntry **a_entry) ;
+ MokoJournalEntry **a_entry) ;
static gboolean icalcomponent_find_property (const icalcomponent *a_comp,
const gchar *a_name,
icalproperty **a_property) ;
@@ -93,11 +93,11 @@
GList *a_entries,
MokoJournal *a_journal) ;
static const gchar*
-entry_type_to_string (MokoJEntryType a_type)
+entry_type_to_string (MokoJournalEntryType a_type)
{
- MokoJEntryInfo *cur ;
+ MokoJournalEntryInfo *cur ;
- for (cur = (MokoJEntryInfo*)entries_info ; cur ; ++cur)
+ for (cur = (MokoJournalEntryInfo*)entries_info ; cur ; ++cur)
{
if (cur->type == a_type)
return cur->type_as_string ;
@@ -105,12 +105,12 @@
return NULL ;
}
-static MokoJEntryType
+static MokoJournalEntryType
entry_type_from_string (const gchar* a_str)
{
- MokoJEntryInfo *cur ;
+ MokoJournalEntryInfo *cur ;
- for (cur = (MokoJEntryInfo*)entries_info ; cur ; ++cur)
+ for (cur = (MokoJournalEntryInfo*)entries_info ; cur ; ++cur)
{
if (!strcmp (cur->type_as_string, a_str))
{
@@ -126,14 +126,14 @@
{
MokoJournal *result ;
result = g_new0 (MokoJournal, 1) ;
- result->entries = g_array_new (TRUE, TRUE, sizeof (MokoJEntry*)) ;
+ result->entries = g_array_new (TRUE, TRUE, sizeof (MokoJournalEntry*)) ;
return result ;
}
static gboolean
moko_journal_find_entry_from_uid (MokoJournal *a_journal,
const gchar *a_uid,
- MokoJEntry **a_entry,
+ MokoJournalEntry **a_entry,
int *a_offset)
{
int i=0 ;
@@ -149,12 +149,13 @@
for (i = 0 ; i < a_journal->entries->len ; ++i)
{
- if (g_array_index (a_journal->entries, MokoJEntry*, i)
- && g_array_index (a_journal->entries, MokoJEntry*, i)->uid
- && !strcmp (g_array_index (a_journal->entries, MokoJEntry*, i)->uid,
+ if (g_array_index (a_journal->entries, MokoJournalEntry*, i)
+ && g_array_index (a_journal->entries, MokoJournalEntry*, i)->uid
+ && !strcmp (g_array_index (a_journal->entries,
+ MokoJournalEntry*, i)->uid,
a_uid))
{
- *a_entry = g_array_index (a_journal->entries, MokoJEntry*, i) ;
+ *a_entry = g_array_index (a_journal->entries, MokoJournalEntry*, i) ;
*a_offset = i ;
return TRUE ;
}
@@ -181,10 +182,11 @@
int i ;
for (i=0 ; i < a_journal->entries->len ; ++i)
{
- if (g_array_index (a_journal->entries, MokoJEntry*, i))
+ if (g_array_index (a_journal->entries, MokoJournalEntry*, i))
{
- moko_j_entry_free (g_array_index (a_journal->entries, MokoJEntry*, i));
- g_array_index (a_journal->entries, MokoJEntry*, i) = NULL;
+ moko_journal_entry_free (g_array_index (a_journal->entries,
+ MokoJournalEntry*, i));
+ g_array_index (a_journal->entries, MokoJournalEntry*, i) = NULL;
}
}
g_array_free (a_journal->entries, TRUE) ;
@@ -193,30 +195,30 @@
g_free (a_journal) ;
}
-MokoJEmailInfo*
+MokoJournalEmailInfo*
moko_j_email_info_new ()
{
- return g_new0 (MokoJEmailInfo, 1) ;
+ return g_new0 (MokoJournalEmailInfo, 1) ;
}
void
-moko_j_email_info_free (MokoJEmailInfo *a_info)
+moko_j_email_info_free (MokoJournalEmailInfo *a_info)
{
g_return_if_fail (a_info) ;
g_free (a_info) ;
}
-static MokoJEntry*
-moko_j_entry_alloc ()
+static MokoJournalEntry*
+moko_journal_entry_alloc ()
{
- MokoJEntry *result ;
+ MokoJournalEntry *result ;
- result = g_new0 (MokoJEntry, 1) ;
+ result = g_new0 (MokoJournalEntry, 1) ;
return result ;
}
static void
-moko_j_entry_free_real (MokoJEntry *a_entry)
+moko_journal_entry_free_real (MokoJournalEntry *a_entry)
{
g_return_if_fail (a_entry) ;
@@ -269,7 +271,7 @@
}
static gboolean
-moko_j_entry_type_is_valid (MokoJEntryType a_type)
+moko_journal_entry_type_is_valid (MokoJournalEntryType a_type)
{
if (a_type > 0 && a_type < NB_OF_ENTRY_TYPES)
return TRUE ;
@@ -277,8 +279,8 @@
}
static gboolean
-moko_j_entry_to_icalcomponent (MokoJEntry *a_entry,
- icalcomponent **a_comp)
+moko_journal_entry_to_icalcomponent (MokoJournalEntry *a_entry,
+ icalcomponent **a_comp)
{
icalcomponent *comp = NULL ;
icalproperty *prop = NULL ;
@@ -286,7 +288,7 @@
g_return_val_if_fail (a_entry, FALSE) ;
g_return_val_if_fail (a_comp, FALSE) ;
- g_return_val_if_fail (moko_j_entry_type_is_valid (a_entry->type),
+ g_return_val_if_fail (moko_journal_entry_type_is_valid (a_entry->type),
FALSE) ;
comp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT) ;
@@ -299,15 +301,16 @@
}
/*add contact prop*/
- prop = icalproperty_new_contact (moko_j_entry_get_contact_uid (a_entry)) ;
+ prop = icalproperty_new_contact
+ (moko_journal_entry_get_contact_uid (a_entry)) ;
icalcomponent_add_property (comp, prop) ;
/*add summary prop*/
- prop = icalproperty_new_summary (moko_j_entry_get_summary (a_entry)) ;
+ prop = icalproperty_new_summary (moko_journal_entry_get_summary (a_entry)) ;
icalcomponent_add_property (comp, prop) ;
/*add dtstart*/
- const MokoTime *date = moko_j_entry_get_dtstart (a_entry) ;
+ const MokoTime *date = moko_journal_entry_get_dtstart (a_entry) ;
prop = NULL ;
if (!date)
goto out ;
@@ -317,19 +320,19 @@
/*add entry type*/
prop = icalproperty_new_x
- (entry_type_to_string (moko_j_entry_get_type (a_entry))) ;
+ (entry_type_to_string (moko_journal_entry_get_type (a_entry)))
;
icalproperty_set_x_name (prop, "X-OPENMOKO-ENTRY-TYPE") ;
icalcomponent_add_property (comp, prop) ;
- switch (moko_j_entry_get_type (a_entry))
+ switch (moko_journal_entry_get_type (a_entry))
{
case UNDEF_ENTRY:
g_warning ("entry is of undefined type\n") ;
return FALSE ;
case EMAIL_JOURNAL_ENTRY:
{
- MokoJEmailInfo *info=NULL ;
- if (!moko_j_entry_get_email_info (a_entry, &info) || !info)
+ 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))
prop = icalproperty_new_x ("YES") ;
@@ -365,17 +368,17 @@
static gboolean
icalcomponent_to_j_entry (icalcomponent *a_comp,
- MokoJEntry **a_entry)
+ MokoJournalEntry **a_entry)
{
icalproperty *prop = NULL ;
gchar *prop_name = NULL ;
- MokoJEntry *entry = NULL;
+ MokoJournalEntry *entry = NULL;
g_return_val_if_fail (a_comp, FALSE) ;
g_return_val_if_fail (icalcomponent_isa (a_comp) == ICAL_VJOURNAL_COMPONENT,
FALSE) ;
- entry = moko_j_entry_alloc () ;
+ entry = moko_journal_entry_alloc () ;
/*iterate through properties to scan core properties*/
for (prop = icalcomponent_get_first_property (a_comp, ICAL_ANY_PROPERTY);
@@ -393,15 +396,16 @@
}
else if (icalproperty_isa (prop) == ICAL_CONTACT_PROPERTY)
{
- moko_j_entry_set_contact_uid (entry, icalproperty_get_contact (prop)) ;
+ moko_journal_entry_set_contact_uid
+ (entry, icalproperty_get_contact (prop)) ;
}
else if (icalproperty_isa (prop) == ICAL_SUMMARY_PROPERTY)
{
- moko_j_entry_set_summary (entry, icalproperty_get_summary (prop)) ;
+ moko_journal_entry_set_summary (entry, icalproperty_get_summary (prop)) ;
}
else if (icalproperty_isa (prop) == ICAL_DTSTART_PROPERTY)
{
- moko_j_entry_set_dtstart
+ moko_journal_entry_set_dtstart
(entry,
moko_time_new_from_icaltimetype (icalproperty_get_dtstart (prop)));
}
@@ -409,7 +413,7 @@
&& !strcmp (icalproperty_get_x_name (prop),
"X-OPENMOKO-ENTRY-TYPE"))
{
- MokoJEntryType entry_type = UNDEF_ENTRY ;
+ MokoJournalEntryType entry_type = UNDEF_ENTRY ;
const char *x_val = icalproperty_get_value_as_string (prop) ;
if (!x_val)
continue ;
@@ -434,9 +438,9 @@
{
case EMAIL_JOURNAL_ENTRY:
{
- MokoJEmailInfo *info=NULL ;
+ MokoJournalEmailInfo *info=NULL ;
gchar *prop_value = NULL ;
- if (!moko_j_entry_get_email_info (entry, &info))
+ if (!moko_journal_entry_get_email_info (entry, &info))
{
g_warning ("failed to get email info") ;
goto out ;
@@ -468,7 +472,7 @@
out:
if (entry)
- moko_j_entry_free (entry) ;
+ moko_journal_entry_free (entry) ;
return TRUE ;
}
@@ -605,7 +609,7 @@
* FALSE otherwise
*/
gboolean
-moko_journal_add_entry (MokoJournal *a_journal, MokoJEntry *a_entry)
+moko_journal_add_entry (MokoJournal *a_journal, MokoJournalEntry *a_entry)
{
g_return_val_if_fail (a_journal, FALSE) ;
g_return_val_if_fail (a_entry, FALSE) ;
@@ -643,14 +647,14 @@
gboolean
moko_journal_get_entry_at (MokoJournal *a_journal,
guint a_index,
- MokoJEntry **a_entry)
+ MokoJournalEntry **a_entry)
{
g_return_val_if_fail (a_journal, FALSE) ;
g_return_val_if_fail (a_entry, FALSE) ;
g_return_val_if_fail (a_journal->entries, FALSE) ;
g_return_val_if_fail (a_index < a_journal->entries->len, FALSE) ;
- *a_entry = g_array_index (a_journal->entries, MokoJEntry*, a_index) ;
+ *a_entry = g_array_index (a_journal->entries, MokoJournalEntry*, a_index) ;
return TRUE ;
}
@@ -669,11 +673,12 @@
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, MokoJEntry*, a_index))
+ if (g_array_index (a_journal->entries, MokoJournalEntry*, a_index))
{
a_journal->entries_to_delete =
g_list_prepend (a_journal->entries_to_delete,
- g_array_index (a_journal->entries, MokoJEntry*,
a_index));
+ g_array_index (a_journal->entries,
+ MokoJournalEntry*, a_index));
g_array_remove_index (a_journal->entries, a_index) ;
return TRUE ;
}
@@ -692,7 +697,7 @@
gboolean
moko_journal_write_to_storage (MokoJournal *a_journal)
{
- MokoJEntry *cur_entry=NULL ;
+ MokoJournalEntry *cur_entry=NULL ;
int i=0 ;
GList *ecal_comps=NULL, *cur_elem=NULL ;
ECalComponent *ecal_comp=NULL ;
@@ -704,13 +709,13 @@
g_return_val_if_fail (a_journal, FALSE) ;
g_return_val_if_fail (a_journal->ecal, FALSE) ;
- /*create ECalComponent objects out of the list of MokoJEntry* we have*/
+ /*create ECalComponent objects out of the list of MokoJournalEntry* we have*/
for (i=0; a_journal->entries && i<a_journal->entries->len; ++i)
{
- cur_entry = g_array_index (a_journal->entries, MokoJEntry*, i) ;
+ cur_entry = g_array_index (a_journal->entries, MokoJournalEntry*, i) ;
if (!cur_entry)
break ;
- if (!moko_j_entry_to_icalcomponent (cur_entry, &ical_comp))
+ if (!moko_journal_entry_to_icalcomponent (cur_entry, &ical_comp))
{
if (ical_comp)
{
@@ -794,14 +799,14 @@
if (!cur_elem->data)
continue ;
- if (((MokoJEntry*)cur_elem->data)->uid)
+ if (((MokoJournalEntry*)cur_elem->data)->uid)
{
if (!e_cal_remove_object (a_journal->ecal,
- ((MokoJEntry*)cur_elem->data)->uid,
+ ((MokoJournalEntry*)cur_elem->data)->uid,
&error))
{
g_warning ("failed to remove object of UID %s\n",
- ((MokoJEntry*)cur_elem->data)->uid) ;
+ ((MokoJournalEntry*)cur_elem->data)->uid) ;
}
if (error)
{
@@ -810,7 +815,7 @@
error = NULL ;
}
}
- moko_j_entry_free ((MokoJEntry*)cur_elem->data) ;
+ moko_journal_entry_free ((MokoJournalEntry*)cur_elem->data) ;
cur_elem->data = NULL ;
}
@@ -839,7 +844,7 @@
{
icalcomponent *ical_comp = NULL ;
GList *cur_entry = NULL ;
- MokoJEntry *entry = NULL ;
+ MokoJournalEntry *entry = NULL ;
int offset=0 ;
for (cur_entry = a_entries ; cur_entry ; cur_entry = cur_entry->next)
@@ -879,7 +884,7 @@
{
if (entry)
{
- moko_j_entry_free (entry) ;
+ moko_journal_entry_free (entry) ;
entry = NULL ;
}
continue ;
@@ -954,7 +959,7 @@
if (objs)
{
GList *cur=NULL ;
- MokoJEntry *entry = NULL ;
+ MokoJournalEntry *entry = NULL ;
for (cur = objs ; cur ; cur = cur->next)
{
if (!icalcomponent_isa (cur->data))
@@ -967,7 +972,7 @@
if (entry)
{
g_warning ("entry should be NULL here") ;
- moko_j_entry_free (entry) ;
+ moko_journal_entry_free (entry) ;
entry = NULL ;
}
}
@@ -985,46 +990,46 @@
}
/**
- * moko_j_entry_new:
+ * moko_journal_entry_new:
*
* Create a Journal entry with no properties set.
* Use the JEntry accessors to get/set properties.
*
* Return value: the newly created journal entry object
*/
-MokoJEntry*
-moko_j_entry_new (MokoJEntryType a_type)
+MokoJournalEntry*
+moko_journal_entry_new (MokoJournalEntryType a_type)
{
- MokoJEntry *result ;
- result = moko_j_entry_alloc () ;
+ MokoJournalEntry *result ;
+ result = moko_journal_entry_alloc () ;
result->type = a_type ;
return result ;
}
/**
- * moko_j_entry_free:
+ * moko_journal_entry_free:
* @entry: the entry to free
*
* Deallocate the memory of the journal entry object
*/
void
-moko_j_entry_free (MokoJEntry *a_entry)
+moko_journal_entry_free (MokoJournalEntry *a_entry)
{
g_return_if_fail (a_entry) ;
- moko_j_entry_free_real (a_entry) ;
+ moko_journal_entry_free_real (a_entry) ;
}
/**
- * moko_j_entry_get_type:
+ * moko_journal_entry_get_type:
* @entry: the current journal entry
*
* get the primary type of the journal entry
*
* Return value: the type of the journal entry
*/
-MokoJEntryType
-moko_j_entry_get_type (MokoJEntry *a_entry)
+MokoJournalEntryType
+moko_journal_entry_get_type (MokoJournalEntry *a_entry)
{
g_return_val_if_fail (a_entry, UNDEF_ENTRY) ;
@@ -1033,14 +1038,15 @@
/**
- * moko_j_entry_set_type:
+ * moko_journal_entry_set_type:
* @entry: the current instance of journal entry
* @type: the new type
*
* Set the type of the journal entry
*/
void
-moko_j_entry_set_type (MokoJEntry *a_entry, MokoJEntryType a_type)
+moko_journal_entry_set_type (MokoJournalEntry *a_entry,
+ MokoJournalEntryType a_type)
{
g_return_if_fail (a_entry) ;
g_return_if_fail (a_type != UNDEF_ENTRY) ;
@@ -1049,7 +1055,7 @@
}
/**
- * moko_j_entry_get_contact_uid:
+ * moko_journal_entry_get_contact_uid:
* @entry: the current instance of journal entry
*
* get the contact uid
@@ -1058,7 +1064,7 @@
* must not deallocate or attempt to alter it.
*/
const gchar*
-moko_j_entry_get_contact_uid (MokoJEntry *a_entry)
+moko_journal_entry_get_contact_uid (MokoJournalEntry *a_entry)
{
g_return_val_if_fail (a_entry, NULL) ;
@@ -1066,7 +1072,8 @@
}
void
-moko_j_entry_set_contact_uid (MokoJEntry *a_entry, const gchar *a_uid)
+moko_journal_entry_set_contact_uid (MokoJournalEntry *a_entry,
+ const gchar *a_uid)
{
g_return_if_fail (a_entry) ;
@@ -1083,7 +1090,7 @@
}
/**
- * moko_j_entry_get_summary:
+ * moko_journal_entry_get_summary:
* @entry: the current instance of journal entry
*
* get the summary of the journal entry
@@ -1092,7 +1099,7 @@
* Client code must not deallocate or alter it.
*/
const gchar*
-moko_j_entry_get_summary (MokoJEntry *a_entry)
+moko_journal_entry_get_summary (MokoJournalEntry *a_entry)
{
g_return_val_if_fail (a_entry, NULL) ;
@@ -1100,7 +1107,7 @@
}
/**
- * moko_j_entry_set_summary:
+ * moko_journal_entry_set_summary:
* @entry: the current instance of journal entry
* @summary: the new summary of the journal entry. It is copied
* so client code is reponsible of its lifecyle.
@@ -1108,7 +1115,8 @@
* Set the summary of the journal entry
*/
void
-moko_j_entry_set_summary (MokoJEntry *a_entry, const gchar* a_summary)
+moko_journal_entry_set_summary (MokoJournalEntry *a_entry,
+ const gchar* a_summary)
{
g_return_if_fail (a_entry) ;
@@ -1124,7 +1132,7 @@
}
/**
- * moko_j_entry_get_dtdstart:
+ * moko_journal_entry_get_dtdstart:
* @entry: the current instance of journal entry
*
* get the starting date associated to the journal entry
@@ -1133,7 +1141,7 @@
* It can be NULL. Client code must not deallocate it.
*/
const MokoTime*
-moko_j_entry_get_dtstart (MokoJEntry *a_entry)
+moko_journal_entry_get_dtstart (MokoJournalEntry *a_entry)
{
g_return_val_if_fail (a_entry, NULL) ;
@@ -1144,12 +1152,12 @@
}
/**
- * moko_j_entry_set_dtstart:
+ * moko_journal_entry_set_dtstart:
* @entry: the current instance of journal entry
* @dtstart: the new starting date associated to the journal entry.
*/
void
-moko_j_entry_set_dtstart (MokoJEntry *a_entry, MokoTime* a_dtstart)
+moko_journal_entry_set_dtstart (MokoJournalEntry *a_entry, MokoTime* a_dtstart)
{
g_return_if_fail (a_entry) ;
@@ -1164,18 +1172,18 @@
}
/**
- * moko_j_entry_get_email_info:
+ * moko_journal_entry_get_email_info:
* @entry: the current instance of journal entry
* @info: extra information attached to the email info, or NULL.
* Client code must *NOT* of deallocate the returned info.
- * It is the duty of the MokoJEntry code to deallocate it when
+ * It is the duty of the MokoJournalEntry code to deallocate it when
* necessary
*
* Return value: TRUE if the call succeeded, FALSE otherwise.
*/
gboolean
-moko_j_entry_get_email_info (MokoJEntry *a_entry,
- MokoJEmailInfo **a_info)
+moko_journal_entry_get_email_info (MokoJournalEntry *a_entry,
+ MokoJournalEmailInfo **a_info)
{
g_return_val_if_fail (a_entry->type == EMAIL_JOURNAL_ENTRY, FALSE) ;
@@ -1198,7 +1206,7 @@
* Return value: TRUE if the email was sent, false if it was received
*/
gboolean
-moko_j_email_info_get_was_sent (MokoJEmailInfo *a_info)
+moko_j_email_info_get_was_sent (MokoJournalEmailInfo *a_info)
{
g_return_val_if_fail (a_info, FALSE) ;
return a_info->was_sent ;
@@ -1212,7 +1220,8 @@
* Set a boolean property stating if the email was sent or received
*/
void
-moko_j_email_info_set_was_sent (MokoJEmailInfo *a_info, gboolean a_was_sent)
+moko_j_email_info_set_was_sent (MokoJournalEmailInfo *a_info,
+ gboolean a_was_sent)
{
g_return_if_fail (a_info) ;
a_info->was_sent = a_was_sent ;
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 08:53:35 UTC (rev 1729)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h
2007-04-12 09:21:34 UTC (rev 1730)
@@ -33,24 +33,24 @@
***********************************************************/
typedef struct _MokoJournal MokoJournal ;
-typedef struct _MokoJEntry MokoJEntry ;
-typedef struct _MokoJEmailInfo MokoJEmailInfo ;
-typedef struct _MokoJSMSInfo MokoJSMSInfo ;
-typedef struct _MokoJMMSInfo MokoJMMSInfo ;
-typedef struct _MokoJCallInfo MokoJCallInfo ;
+typedef struct _MokoJournalEntry MokoJournalEntry ;
+typedef struct _MokoJournalEmailInfo MokoJournalEmailInfo ;
+typedef struct _MokoJournalSMSInfo MokoJournalSMSInfo ;
+typedef struct _MokoJournalMMSInfo MokoJournalMMSInfo ;
+typedef struct _MokoJournalCallInfo MokoJournalCallInfo ;
/**
* this represents the primary type of
* a journal entry.
*/
-typedef enum _MokoJEntryType {
+typedef enum _MokoJournalEntryType {
UNDEF_ENTRY=0,
EMAIL_JOURNAL_ENTRY,
SMS_JOURNAL_ENTRY,
MMS_JOURNAL_ENTRY,
CALL_JOURNAL_ENTRY,
NB_OF_ENTRY_TYPES /*must always be the last*/
-} MokoJEntryType ;
+} MokoJournalEntryType ;
/*<journal management>*/
/**
@@ -83,7 +83,7 @@
* Return value: TRUE if the entry got successfully added to the journal,
* FALSE otherwise
*/
-gboolean moko_journal_add_entry (MokoJournal *journal, MokoJEntry *entry) ;
+gboolean moko_journal_add_entry (MokoJournal *journal, MokoJournalEntry
*entry) ;
/**
* moko_journal_get_nb_entries:
@@ -106,7 +106,7 @@
*/
gboolean moko_journal_get_entry_at (MokoJournal *journal,
guint index,
- MokoJEntry **entry) ;
+ MokoJournalEntry **entry) ;
/**
* moko_journal_remove_entry_at:
@@ -149,7 +149,7 @@
/*<journal entries management>*/
/**
- * moko_j_entry_new:
+ * moko_journal_entry_new:
* @type: the type of journal entry
*
* Create a Journal entry with no properties set.
@@ -157,37 +157,38 @@
*
* Return value: the newly created journal entry object
*/
-MokoJEntry* moko_j_entry_new (MokoJEntryType type) ;
+MokoJournalEntry* moko_journal_entry_new (MokoJournalEntryType type) ;
/**
- * moko_j_entry_free:
+ * moko_journal_entry_free:
* @entry: the entry to free
*
* Deallocate the memory of the journal entry object
*/
-void moko_j_entry_free (MokoJEntry *entry) ;
+void moko_journal_entry_free (MokoJournalEntry *entry) ;
/**
- * moko_j_entry_get_type:
+ * moko_journal_entry_get_type:
* @entry: the current journal entry
*
* get the primary type of the journal entry
*
* Return value: the type of the journal entry
*/
-MokoJEntryType moko_j_entry_get_type (MokoJEntry *entry) ;
+MokoJournalEntryType moko_journal_entry_get_type (MokoJournalEntry *entry) ;
/**
- * moko_j_entry_set_type:
+ * moko_journal_entry_set_type:
* @entry: the current instance of journal entry
* @type: the new type
*
* Set the type of the journal entry
*/
-void moko_j_entry_set_type (MokoJEntry *entry, MokoJEntryType type) ;
+void moko_journal_entry_set_type (MokoJournalEntry *entry,
+ MokoJournalEntryType type) ;
/**
- * moko_j_entry_get_contact_uid:
+ * moko_journal_entry_get_contact_uid:
* @entry: the current instance of journal entry
*
* get the contact uid
@@ -195,10 +196,10 @@
* Return value: the UID of the contact. It can be NULL. Client code
* must not deallocate or attempt to alter it.
*/
-const gchar* moko_j_entry_get_contact_uid (MokoJEntry *entry) ;
+const gchar* moko_journal_entry_get_contact_uid (MokoJournalEntry *entry) ;
/**
- * moko_j_entry_set_contact_uid:
+ * moko_journal_entry_set_contact_uid:
* @entry: the current instance of journal entry
* @uid: the uid to set. This string is copied so the client code
* must free it.
@@ -207,10 +208,11 @@
* The UID is copied by this function so the caller is reponsible of
* taking care of the uid string lifecycle.
*/
-void moko_j_entry_set_contact_uid (MokoJEntry *entry, const gchar *uid) ;
+void moko_journal_entry_set_contact_uid (MokoJournalEntry *entry,
+ const gchar *uid) ;
/**
- * moko_j_entry_get_summary:
+ * moko_journal_entry_get_summary:
* @entry: the current instance of journal entry
*
* get the summary of the journal entry
@@ -218,20 +220,21 @@
* Return value: the summary of the journal entry. It can be NULL.
* Client code must not deallocate or alter it.
*/
-const gchar* moko_j_entry_get_summary (MokoJEntry *entry) ;
+const gchar* moko_journal_entry_get_summary (MokoJournalEntry *entry) ;
/**
- * moko_j_entry_set_summary:
+ * moko_journal_entry_set_summary:
* @entry: the current instance of journal entry
* @summary: the new summary of the journal entry. It is copied
* so client code is reponsible of its lifecyle.
*
* Set the summary of the journal entry
*/
-void moko_j_entry_set_summary (MokoJEntry *entry, const gchar* summary) ;
+void moko_journal_entry_set_summary (MokoJournalEntry *entry,
+ const gchar* summary) ;
/**
- * moko_j_entry_get_dtdstart:
+ * moko_journal_entry_get_dtdstart:
* @entry: the current instance of journal entry
*
* get the starting date associated to the journal entry
@@ -239,29 +242,29 @@
* Return value: an icaltimetype representing the starting date expected.
* It can be NULL. Client code must not deallocate it.
*/
-const MokoTime* moko_j_entry_get_dtstart (MokoJEntry *entry) ;
+const MokoTime* moko_journal_entry_get_dtstart (MokoJournalEntry *entry) ;
/**
- * moko_j_entry_set_dtstart:
+ * moko_journal_entry_set_dtstart:
* @entry: the current instance of journal entry
* @dtstart: the new starting date associated to the journal entry.
*/
-void moko_j_entry_set_dtstart (MokoJEntry *entry, MokoTime* dtstart);
+void moko_journal_entry_set_dtstart (MokoJournalEntry *entry, MokoTime*
dtstart);
/*<email info>*/
/**
- * moko_j_entry_get_email_info:
+ * moko_journal_entry_get_email_info:
* @entry: the current instance of journal entry
* @info: extra information attached to the email info, or NULL.
* Client code must *NOT* of deallocate the returned info.
- * It is the duty of the MokoJEntry code to deallocate it when
+ * It is the duty of the MokoJournalEntry code to deallocate it when
* necessary
*
* Return value: TRUE if the call succeeded, FALSE otherwise.
*/
-gboolean moko_j_entry_get_email_info (MokoJEntry *entry,
- MokoJEmailInfo **info) ;
+gboolean moko_journal_entry_get_email_info (MokoJournalEntry *entry,
+ MokoJournalEmailInfo **info) ;
/**
* moko_j_email_info_get_was_sent:
@@ -271,7 +274,7 @@
*
* Return value: TRUE if the email was sent, false if it was received
*/
-gboolean moko_j_email_info_get_was_sent (MokoJEmailInfo *info) ;
+gboolean moko_j_email_info_get_was_sent (MokoJournalEmailInfo *info) ;
/**
* moko_j_email_info_set_was_sent:
@@ -280,7 +283,8 @@
*
* Set a boolean property stating if the email was sent or received
*/
-void moko_j_email_info_set_was_sent (MokoJEmailInfo *info, gboolean was_sent) ;
+void moko_j_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 08:53:35 UTC (rev 1729)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
2007-04-12 09:21:34 UTC (rev 1730)
@@ -26,8 +26,8 @@
main ()
{
MokoJournal *journal=NULL ;
- MokoJEntry *entry=NULL ;
- MokoJEmailInfo *email_info=NULL ;
+ MokoJournalEntry *entry=NULL ;
+ MokoJournalEmailInfo *email_info=NULL ;
int result = 1 ;
g_type_init () ;
@@ -47,7 +47,7 @@
moko_journal_get_nb_entries (journal)) ;
/*create a journal entry of type 'email journal entry'*/
- entry = moko_j_entry_new (EMAIL_JOURNAL_ENTRY) ;
+ entry = moko_journal_entry_new (EMAIL_JOURNAL_ENTRY) ;
if (!entry)
{
g_warning ("failed to create journal entry\n") ;
@@ -57,10 +57,10 @@
/*****************************
* <fill the entry with data>
*****************************/
- moko_j_entry_set_contact_uid (entry, "foobarbazuid") ;
- moko_j_entry_set_summary (entry, "back from fostel") ;
- moko_j_entry_set_dtstart (entry, moko_time_new_today ()) ;
- if (!moko_j_entry_get_email_info (entry, &email_info) || !email_info)
+ moko_journal_entry_set_contact_uid (entry, "foobarbazuid") ;
+ moko_journal_entry_set_summary (entry, "back from fostel") ;
+ moko_journal_entry_set_dtstart (entry, moko_time_new_today ()) ;
+ if (!moko_journal_entry_get_email_info (entry, &email_info) || !email_info)
{
g_warning ("failed to get email extra info from journal entry\n") ;
goto out ;
@@ -119,7 +119,7 @@
if (journal)
moko_journal_close (journal) ;
if (entry)
- moko_j_entry_free (entry) ;
+ moko_journal_entry_free (entry) ;
return result ;
}
--- End Message ---