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

dodji at sita.openmoko.org dodji at sita.openmoko.org
Fri Apr 6 21:19:10 CEST 2007


Author: dodji
Date: 2007-04-06 21:19:06 +0200 (Fri, 06 Apr 2007)
New Revision: 1680

Added:
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/Makefile.am
   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/src/moko-time-priv.h
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.c
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.h
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c
Removed:
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.c
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h
Modified:
   trunk/src/target/OM-2007/openmoko-libs/ChangeLog
   trunk/src/target/OM-2007/openmoko-libs/configure.ac
   trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am
Log:
Can now save a log entry of type email into the journal

	* openmoko-libs/libmokojournal/src/*: moved what
	  was in openmoko-libs/libmokojournal/ into here.
	  openmoko-libs/libmokojournal/test will then contain test
	  functions.
	* openmoko-libs/libmokojournal/src/moko-journal.c: implemented
	  and debugged the needed functions to create an entry (of type email)
	  and save it in the journal, on persistent storage.
	  The journal is in ~/.moko/journal/journal.ics
	  Next step from now is to be able to load that journal.
	* openmoko-libs/libmokojournal/tests/test-create.c:
	  Tested the basic journal entry creation and saving
	  into the journal.


Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog	2007-04-06 19:19:06 UTC (rev 1680)
@@ -1,3 +1,18 @@
+2007-04-06 Dodji Seketeli
+
+	* openmoko-libs/libmokojournal/src/*: moved what
+	  was in openmoko-libs/libmokojournal/ into here.
+	  openmoko-libs/libmokojournal/test will then contain test
+	  functions.
+	* openmoko-libs/libmokojournal/src/moko-journal.c: implemented
+	  and debugged the needed functions to create an entry (of type email)
+	  and save it in the journal, on persistent storage.
+	  The journal is in ~/.moko/journal/journal.ics
+	  Next step from now is to be able to load that journal.
+	* openmoko-libs/libmokojournal/tests/test-create.c:
+	  Tested the basic journal entry creation and saving
+	  into the journal.
+
 2007-04-05  Rob Bradford  <rob at openedhand.com>
 
 	* configure.ac:
@@ -44,8 +59,8 @@
 
 2007-04-02 Dodji Seketeli
 
-	* openmoko-libs/libmokojournal/moko-journal.[c|h]: went forward with the
-	  API proposal
+	* openmoko-libs/libmokojournal/moko-journal.[c|h]:
+	  went forward with the API proposal
 
 2007-03-30 Dodji Seketeli
 

Modified: trunk/src/target/OM-2007/openmoko-libs/configure.ac
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/configure.ac	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/configure.ac	2007-04-06 19:19:06 UTC (rev 1680)
@@ -19,9 +19,16 @@
                   libecal-1.2 >= $LIBECAL_VERSION
                   gdk-pixbuf-2.0)
 
+if test x$MOKO_DEVEL = xon ; then
+    AC_MSG_NOTICE([removing -O2 from CFLAGS])
+    CFLAGS="-g -Wall"
+fi
+
 LIBS="$LIBS $DEPS_LIBS"
 CFLAGS="$CFLAGS $DEPS_CFLAGS"
 
+AC_SUBST(LIBS)
+
 # foo
 #AC_ARG_ENABLE(foo,
 #  [  --enable-foo   enable foo support],
@@ -47,5 +54,11 @@
 libmokopim/Makefile
 libmokonet/Makefile
 libmokojournal/Makefile
+libmokojournal/src/Makefile
+libmokojournal/tests/Makefile
 data/Makefile
 ])
+
+echo "CFLAGS = $CFLAGS"
+echo "PREFIX = $prefix"
+echo "LIBS   = $LIBS"

Modified: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am	2007-04-06 19:19:06 UTC (rev 1680)
@@ -1,13 +1,2 @@
-lib_LTLIBRARIES=libmokojournal.la
+SUBDIRS=src tests
 
-public_headers=moko-journal.h
-sources=moko-journal.c
-
-libmokojournal_la_SOURCES= $(sources) $(public_headers)
-libmokojournal_la_LIBADD=
-libmokojournal_la_LDFLAGS= -version-info 0:0:0
-AM_CFLAGS = -Wall -pedantic -std=c99
-
-libmokojournalheadersdir=$(includedir)/openmoko-libs/libmokojournal
-libmokojournalheaders_DATA=$(public_headers)
-

Deleted: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.c	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.c	2007-04-06 19:19:06 UTC (rev 1680)
@@ -1,367 +0,0 @@
-/* vi: set sw=2: */
-/*
- * Copyright (C) 2007 by OpenMoko, Inc.
- * Written by OpenedHand Ltd <info at openedhand.com>
- * 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 <libecal/e-cal.h>
-#include "moko-journal.h"
-
-struct _MokoJournal
-{
-  ECal *ecal ;
-};
-
-struct _MokoJEmailInfo
-{
-  gboolean was_sent ;
-};
-
-struct _MokoJEntry
-{
-  MokoJEntryType type;
-  gchar *contact_uid ;
-  gchar *summary ;
-  MokoTime *dtstart ;
-  MokoTime *dtend ;
-  union
-  {
-    MokoJEmailInfo *email_info ;
-  } extra_info ;
-};
-
-/*<private funcs>*/
-static MokoJournal*
-moko_journal_alloc ()
-{
-  MokoJournal *result ;
-  result = g_new0 (MokoJournal, 1) ;
-  return result ;
-}
-
-static void
-moko_journal_free (MokoJournal *a_journal)
-{
-  g_return_if_fail (a_journal) ;
-  if (a_journal->ecal)
-  {
-    g_object_unref (G_OBJECT (a_journal->ecal)) ;
-    a_journal->ecal = NULL ;
-  }
-  g_free (a_journal) ;
-}
-
-MokoJEmailInfo*
-moko_j_email_info_new ()
-{
-  return g_new0 (MokoJEmailInfo, 1) ;
-}
-
-void
-moko_j_email_info_free (MokoJEmailInfo *a_info)
-{
-  g_return_if_fail (a_info) ;
-  g_free (a_info) ;
-}
-
-static MokoJEntry*
-moko_j_entry_alloc ()
-{
-  MokoJEntry *result ;
-
-  result = g_new0 (MokoJEntry, 1) ;
-  return result ;
-}
-
-static void
-moko_j_entry_free_real (MokoJEntry *a_entry)
-{
-  g_return_if_fail (a_entry) ;
-
-  if (a_entry->contact_uid)
-  {
-    g_free (a_entry->contact_uid) ;
-    a_entry->contact_uid = NULL ;
-  }
-  if (a_entry->summary)
-  {
-    g_free (a_entry->summary) ;
-    a_entry->summary = NULL ;
-  }
-  if (a_entry->dtstart)
-  {
-    moko_time_free (a_entry->dtstart) ;
-    a_entry->dtstart = NULL ;
-  }
-  if (a_entry->dtend)
-  {
-    moko_time_free (a_entry->dtend) ;
-    a_entry->dtend = NULL ;
-  }
-
-  switch (a_entry->type)
-  {
-    case EMAIL_JOURNAL_ENTRY:
-      if (a_entry->extra_info.email_info)
-      {
-        moko_j_email_info_free (a_entry->extra_info.email_info) ;
-        a_entry->extra_info.email_info = NULL ;
-      }
-      break ;
-    case SMS_JOURNAL_ENTRY:
-      break ;
-    case MMS_JOURNAL_ENTRY:
-      break ;
-    case CALL_JOURNAL_ENTRY:
-         break ;
-    default:
-         g_warning ("unknown journal entry type. This is a leak!\n") ;
-         break ;
-  }
-}
-
-/*</private funcs>*/
-
-
-/*<public funcs>*/
-
-/**
- * moko_journal_open_default:
- *
- * Opens the default journal.
- *
- * Return value: a pointer to the journal object
- */
-MokoJournal*
-moko_journal_open_default ()
-{
-  ECal *ecal = NULL;
-  gchar *uri = NULL ;
-  MokoJournal *result=NULL, *journal=NULL ;
-  GError *error = NULL ;
-
-  uri = g_build_filename ("file://", g_get_home_dir (),
-                          ".moko", "journal", NULL);
-
-  ecal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL) ;
-  if (!ecal)
-  {
-    g_warning ("failed to create ecal with uri: %s\n", uri) ;
-    goto out ;
-  }
-
-  if (!e_cal_open (ecal, FALSE, &error))
-  {
-    g_warning ("could not open the journal at uri %s\n", uri) ;
-    goto out ;
-  }
-  if (error)
-  {
-    g_warning ("got error: %s\n", error->message) ;
-    goto out ;
-  }
-  journal = moko_journal_alloc () ;
-  journal->ecal = ecal ;
-  ecal = NULL ;
-
-  result = journal ;
-  journal = NULL ;
-
-out:
-  g_free (uri) ;
-
-  if (ecal)
-    g_object_unref (G_OBJECT (ecal)) ;
-
-  if (journal)
-    moko_journal_free (journal) ;
-
-  if (error)
-    g_error_free (error) ;
-
-  return result ;
-}
-
-/**
- * moko_journal_close:
- * @journal: the journal to close
- *
- * Close the journal previously opened with moko_journal_open_default().
- * This function deallocates the memory of the Journal object.
- */
-void
-moko_journal_close (MokoJournal *a_journal)
-{
-  g_return_if_fail (a_journal) ;
-
-  moko_journal_free (a_journal) ;
-}
-
-/**
- * moko_j_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 ()
-{
-  return moko_j_entry_alloc () ;
-}
-
-/**
- * moko_j_entry_free:
- * @entry: the entry to free
- *
- * Deallocate the memory of the journal entry object
- */
-void
-moko_j_entry_free (MokoJEntry *a_entry)
-{
-  g_return_if_fail (a_entry) ;
-
-  moko_j_entry_free_real (a_entry) ;
-}
-
-/**
- * moko_j_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)
-{
-  g_return_val_if_fail (a_entry, UNDEF_ENTRY) ;
-
-  return a_entry->type ;
-}
-
-
-/**
- * moko_j_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)
-{
-  g_return_if_fail (a_entry) ;
-  g_return_if_fail (a_type != UNDEF_ENTRY) ;
-
-  a_entry->type = a_type ;
-}
-
-/**
- * moko_j_entry_get_contact_uid:
- * @entry: the current instance of journal entry
- *
- * get the contact uid
- *
- * 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 *a_entry)
-{
-  g_return_val_if_fail (a_entry, NULL) ;
-
-  return a_entry->contact_uid ;
-}
-
-void
-moko_j_entry_set_contact_uid (MokoJEntry *a_entry, const gchar *a_uid)
-{
-  g_return_if_fail (a_entry) ;
-
-  if (a_entry->contact_uid)
-  {
-    g_free (a_entry->contact_uid) ;
-    a_entry->contact_uid = NULL ;
-  }
-
-  if (a_uid)
-  {
-    a_entry->contact_uid = g_strdup (a_uid) ;
-  }
-}
-
-/**
- * moko_j_entry_get_summary:
- * @entry: the current instance of journal entry
- *
- * get the summary of the journal entry
- *
- * 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 *a_entry)
-{
-  g_return_val_if_fail (a_entry, NULL) ;
-
-  return a_entry->summary ;
-}
-
-/**
- * moko_j_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 *a_entry, const gchar* a_summary)
-{
-  g_return_if_fail (a_entry) ;
-
-  if (a_entry->summary)
-  {
-    g_free (a_entry->summary) ;
-    a_entry->summary = NULL ;
-  }
-  if (a_summary)
-  {
-    a_entry->summary = g_strdup (a_summary) ;
-  }
-}
-
-/**
- * moko_j_entry_get_dtdstart:
- * @entry: the current instance of journal entry
- *
- * get the starting date associated to the journal entry
- *
- * 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 *a_entry)
-{
-  g_return_val_if_fail (a_entry, NULL) ;
-
-  return a_entry->dtstart ;
-}
-
-/*<public funcs>*/

Deleted: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h	2007-04-06 19:19:06 UTC (rev 1680)
@@ -1,208 +0,0 @@
-/* vi: set sw=2: */
-/*
- * Copyright (C) 2007 by OpenMoko, Inc.
- * Written by OpenedHand Ltd <info at openedhand.com>
- * 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.
- */
-#ifndef __MOKO_JOURNAL_H__
-#define  __MOKO_JOURNAL_H__
-
-#include <glib.h>
-#include "moko-time.h" 
-
-/************************************************************
- * this API abstracts the process of adding
- * journal entries into the default system
- * journal. Journal entries contain information
- * about communation history like calls, sms, or,
- * emails issued or received.
- ***********************************************************/
-
-typedef struct _MokoJournal MokoJournal ;
-typedef struct _MokoJEntry MokoJEntry ;
-typedef struct _MokoJEmailInfo MokoJEmailInfo ;
-typedef struct _MokoJSMSInfo MokoJSMSInfo ;
-typedef struct _MokoJMMSInfo MokoJMMSInfo ;
-typedef struct _MokoJCallInfo MokoJCallInfo ;
-
-/**
- * this represents the primary type of
- * a journal entry.
- */
-typedef enum _MokoJEntryType {
-  UNDEF_ENTRY=0,
-  EMAIL_JOURNAL_ENTRY,
-  SMS_JOURNAL_ENTRY,
-  MMS_JOURNAL_ENTRY,
-  CALL_JOURNAL_ENTRY,
-} MokoJEntryType ;
-
-/*<journal management>*/
-/**
- * moko_journal_open_default:
- *
- * Opens the default journal.
- *
- * Return value: a pointer to the journal object
- */
-MokoJournal* moko_journal_open_default () ;
-
-/**
- * moko_journal_close:
- * @journal: the journal to close
- *
- * Close the journal previously opened with moko_journal_open_default().
- * This function deallocates the memory of the Journal object.
- */
-void moko_journal_close (MokoJournal *journal) ;
-
-/*<journal entries querying>*/
-/*</journal entries querying>*/
-
-/*</journal management>*/
-
-
-/*<journal entries management>*/
-
-/**
- * moko_j_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 () ;
-
-/**
- * moko_j_entry_free:
- * @entry: the entry to free
- *
- * Deallocate the memory of the journal entry object
- */
-void moko_j_entry_free (MokoJEntry *entry) ;
-
-/**
- * moko_j_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) ;
-
-/**
- * moko_j_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) ;
-
-/**
- * moko_j_entry_get_contact_uid:
- * @entry: the current instance of journal entry
- *
- * get the contact uid
- *
- * 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) ;
-
-/**
- * moko_j_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.
- *
- * Associate a new contact UID to the journal entry uid.
- * 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) ;
-
-/**
- * moko_j_entry_get_summary:
- * @entry: the current instance of journal entry
- *
- * get the summary of the journal entry
- *
- * 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) ;
-
-/**
- * moko_j_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) ;
-
-/**
- * moko_j_entry_get_dtdstart:
- * @entry: the current instance of journal entry
- *
- * get the starting date associated to the journal entry
- *
- * 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) ;
-
-/**
- * moko_j_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);
-
-/*<email info>*/
-
-/**
- * moko_j_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
- * necessary
- *
- * Return value: TRUE if the call succeeded, FALSE otherwise.
- */
-gboolean moko_j_entry_get_email_info (MokoJEntry *entry,
-                                      MokoJEmailInfo **info) ;
-
-/**
- * moko_j_email_info_get_was_sent:
- * @info: the current instance of email extra info
- *
- * Return value: TRUE if the email was sent, FALSE if it was received.
- */
-gboolean moko_j_email_info_get_was_sent (MokoJEmailInfo *info) ;
-
-/*</email info>*/
-
-
-/*</journal entries management>*/
-
-#endif /*__MOKO_JOURNAL_H__*/

Deleted: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h	2007-04-06 19:19:06 UTC (rev 1680)
@@ -1,36 +0,0 @@
-/* vi: set sw=2: */
-/*
- * Copyright (C) 2007 by OpenMoko, Inc.
- * Written by OpenedHand Ltd <info at openedhand.com>
- * 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.
- */
-#ifndef __MOKO_TIME_H__
-#define  __MOKO_TIME_H__
-
-#include <time.h>
-
-typedef struct _MokoTime MokoTime ;
-
-MokoTime* moko_time_null_date () ;
-MokoTime* moko_time_null_time () ;
-MokoTime* moko_time_today () ;
-MokoTime* moko_time_from_timet (const time_t t) ;
-MokoTime* moko_time_from_string (const gchar *iso_format_date) ;
-void moko_time_free (MokoTime *a_time) ;
-
-const gchar* moko_time_as_string (MokoTime *t) ;
-#endif /*__MOKO_TIME_H__*/

Copied: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/Makefile.am (from rev 1679, trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am)
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/Makefile.am	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/Makefile.am	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,13 @@
+lib_LTLIBRARIES=libmokojournal.la
+
+public_headers=moko-journal.h moko-time.h
+sources=moko-journal.c moko-time.c
+
+libmokojournal_la_SOURCES= $(sources) $(public_headers)
+libmokojournal_la_LIBADD=
+libmokojournal_la_LDFLAGS= -version-info 0:0:0
+AM_CFLAGS = -Wall -pedantic -std=c99
+
+libmokojournalheadersdir=$(includedir)/openmoko-libs/libmokojournal
+libmokojournalheaders_DATA=$(public_headers)
+

Added: 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-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,713 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * 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 <string.h>
+#include <libecal/e-cal.h>
+#include <libecal/e-cal-component.h>
+#include "moko-journal.h"
+#include "moko-time-priv.h"
+
+static const int JOURNAL_MAX_SIZE = 100 ;
+
+struct _MokoJournal
+{
+  ECal *ecal ;
+  MokoJEntry **entries ;
+  int next_entry ;
+};
+
+struct _MokoJEmailInfo
+{
+  gboolean was_sent ;
+};
+
+struct _MokoJEntry
+{
+  MokoJEntryType type;
+  gchar *contact_uid ;
+  gchar *summary ;
+  MokoTime *dtstart ;
+  MokoTime *dtend ;
+  union
+  {
+    MokoJEmailInfo *email_info ;
+  } extra_info ;
+};
+
+struct _MokoJEntryInfo
+{
+  MokoJEntryType type;
+  const gchar *type_as_string ;
+};
+typedef struct _MokoJEntryInfo MokoJEntryInfo ;
+
+static const MokoJEntryInfo entries_info[] =
+{
+  {EMAIL_JOURNAL_ENTRY, "EMAILENTRY"},
+  {SMS_JOURNAL_ENTRY, "SMSENTRY"},
+  {MMS_JOURNAL_ENTRY, "MMSENTRY"},
+  {CALL_JOURNAL_ENTRY, "CALLENTRY"},
+  {0}
+} ;
+
+static const gchar*
+entry_type_to_string (MokoJEntryType a_type)
+{
+  MokoJEntryInfo *cur ;
+
+  for (cur = (MokoJEntryInfo*)entries_info ; cur ; ++cur)
+  {
+    if (cur->type == a_type)
+      return cur->type_as_string ;
+  }
+  return NULL ;
+}
+
+/*
+static MokoJEntryType
+entry_type_from_string (const gchar* a_str)
+{
+  MokoJEntryInfo *cur ;
+
+  for (cur = (MokoJEntryInfo*)entries_info ; cur ; ++cur)
+  {
+    if (!strcmp (cur->type_as_string, a_str))
+    {
+      return cur->type ;
+    }
+  }
+  return UNDEF_ENTRY ;
+}
+*/
+
+/*<private funcs>*/
+static MokoJournal*
+moko_journal_alloc ()
+{
+  MokoJournal *result ;
+  result = g_new0 (MokoJournal, 1) ;
+  result->entries = g_new0 (MokoJEntry*, JOURNAL_MAX_SIZE) ;
+  return result ;
+}
+
+static void
+moko_journal_free (MokoJournal *a_journal)
+{
+  g_return_if_fail (a_journal) ;
+  if (a_journal->ecal)
+  {
+    g_object_unref (G_OBJECT (a_journal->ecal)) ;
+    a_journal->ecal = NULL ;
+  }
+  if (a_journal->entries)
+  {
+    int i ;
+    for (i=0 ; i < JOURNAL_MAX_SIZE ; ++i)
+    {
+      if (a_journal->entries[i])
+      {
+        moko_j_entry_free (a_journal->entries[i]) ;
+        a_journal->entries[i] = NULL ;
+      }
+    }
+    g_free (a_journal->entries) ;
+    a_journal->entries = NULL ;
+  }
+  g_free (a_journal) ;
+}
+
+MokoJEmailInfo*
+moko_j_email_info_new ()
+{
+  return g_new0 (MokoJEmailInfo, 1) ;
+}
+
+void
+moko_j_email_info_free (MokoJEmailInfo *a_info)
+{
+  g_return_if_fail (a_info) ;
+  g_free (a_info) ;
+}
+
+static MokoJEntry*
+moko_j_entry_alloc ()
+{
+  MokoJEntry *result ;
+
+  result = g_new0 (MokoJEntry, 1) ;
+  return result ;
+}
+
+static void
+moko_j_entry_free_real (MokoJEntry *a_entry)
+{
+  g_return_if_fail (a_entry) ;
+
+  if (a_entry->contact_uid)
+  {
+    g_free (a_entry->contact_uid) ;
+    a_entry->contact_uid = NULL ;
+  }
+  if (a_entry->summary)
+  {
+    g_free (a_entry->summary) ;
+    a_entry->summary = NULL ;
+  }
+  if (a_entry->dtstart)
+  {
+    moko_time_free (a_entry->dtstart) ;
+    a_entry->dtstart = NULL ;
+  }
+  if (a_entry->dtend)
+  {
+    moko_time_free (a_entry->dtend) ;
+    a_entry->dtend = NULL ;
+  }
+
+  switch (a_entry->type)
+  {
+    case EMAIL_JOURNAL_ENTRY:
+      if (a_entry->extra_info.email_info)
+      {
+        moko_j_email_info_free (a_entry->extra_info.email_info) ;
+        a_entry->extra_info.email_info = NULL ;
+      }
+      break ;
+    case SMS_JOURNAL_ENTRY:
+      break ;
+    case MMS_JOURNAL_ENTRY:
+      break ;
+    case CALL_JOURNAL_ENTRY:
+         break ;
+    default:
+         g_warning ("unknown journal entry type. This is a leak!\n") ;
+         break ;
+  }
+}
+
+static gboolean
+moko_j_entry_type_is_valid (MokoJEntryType a_type)
+{
+  if (a_type > 0 && a_type < NB_OF_ENTRY_TYPES)
+    return TRUE ;
+  return FALSE ;
+}
+
+static gboolean
+moko_j_entry_to_icalcomponent (MokoJEntry *a_entry,
+                               icalcomponent **a_comp)
+{
+  icalcomponent *comp = NULL ;
+  icalproperty *prop = NULL ;
+  gboolean result = FALSE ;
+
+  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),
+                        FALSE) ;
+
+  comp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT) ;
+
+  /*add contact prop*/
+  prop = icalproperty_new_contact (moko_j_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)) ;
+  icalcomponent_add_property (comp, prop) ;
+
+  /*add dtstart*/
+  const MokoTime *date = moko_j_entry_get_dtstart (a_entry) ;
+  prop = NULL ;
+  if (!date)
+    goto out ;
+
+  prop = icalproperty_new_dtstart (date->t) ;
+  icalcomponent_add_property (comp, prop) ;
+
+  /*add entry type*/
+  prop = icalproperty_new_x
+                  (entry_type_to_string (moko_j_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))
+  {
+    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)
+          goto out ;
+        if (moko_j_email_info_get_was_sent (info))
+          prop = icalproperty_new_x ("YES") ;
+        else
+          prop = icalproperty_new_x ("NO") ;
+        icalproperty_set_x_name (prop, "X_OPENMOKO_EMAIL_WAS_SENT") ;
+        icalcomponent_add_property (comp, prop) ;
+      }
+      break ;
+    case SMS_JOURNAL_ENTRY:
+      break ;
+    case MMS_JOURNAL_ENTRY:
+      break ;
+    case CALL_JOURNAL_ENTRY:
+      break ;
+    default:
+      break ;
+  }
+
+  *a_comp = comp ;
+  prop = NULL ;
+  comp = NULL ;
+  result = TRUE ;
+out:
+  if (prop)
+    icalproperty_free (prop) ;
+
+  if (comp)
+    icalcomponent_free (comp) ;
+
+  return result ;
+}
+
+
+/*</private funcs>*/
+
+
+/*<public funcs>*/
+
+/**
+ * moko_journal_open_default:
+ *
+ * Opens the default journal.
+ *
+ * Return value: a pointer to the journal object
+ */
+MokoJournal*
+moko_journal_open_default ()
+{
+  ECal *ecal = NULL;
+  gchar *uri = NULL ;
+  MokoJournal *result=NULL, *journal=NULL ;
+  GError *error = NULL ;
+
+  uri = g_build_filename ("file://", g_get_home_dir (),
+                          ".moko", "journal", NULL);
+
+  ecal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL) ;
+  if (!ecal)
+  {
+    g_warning ("failed to create ecal with uri: %s\n", uri) ;
+    goto out ;
+  }
+
+  if (!e_cal_open (ecal, FALSE, &error))
+  {
+    g_warning ("could not open the journal at uri %s\n", uri) ;
+    goto out ;
+  }
+  if (error)
+  {
+    g_warning ("got error: %s\n", error->message) ;
+    goto out ;
+  }
+  journal = moko_journal_alloc () ;
+  journal->ecal = ecal ;
+  ecal = NULL ;
+
+  result = journal ;
+  journal = NULL ;
+
+out:
+  g_free (uri) ;
+
+  if (ecal)
+    g_object_unref (G_OBJECT (ecal)) ;
+
+  if (journal)
+    moko_journal_free (journal) ;
+
+  if (error)
+    g_error_free (error) ;
+
+  return result ;
+}
+
+/**
+ * moko_journal_close:
+ * @journal: the journal to close
+ *
+ * Close the journal previously opened with moko_journal_open_default().
+ * This function deallocates the memory of the Journal object.
+ */
+void
+moko_journal_close (MokoJournal *a_journal)
+{
+  g_return_if_fail (a_journal) ;
+
+  moko_journal_free (a_journal) ;
+}
+
+/**
+ * moko_journal_add_entry:
+ * @journal: the current instance of journal
+ * @entry: the new entry to add to the journal. The journal is responsible
+ * of deallocating the memory of the entry object.
+ *
+ * Add a journal entry to the journal
+ *
+ * Return value: TRUE if the entry got successfully added to the journal,
+ * FALSE otherwise
+ */
+gboolean
+moko_journal_add_entry (MokoJournal *a_journal, MokoJEntry *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->next_entry < JOURNAL_MAX_SIZE, FALSE) ;
+
+  if (a_journal->entries[a_journal->next_entry])
+  {
+    moko_j_entry_free (a_journal->entries[a_journal->next_entry]) ;
+  }
+
+  a_journal->entries[a_journal->next_entry] = a_entry ;
+  a_journal->next_entry++ ;
+  if (a_journal->next_entry >= JOURNAL_MAX_SIZE)
+  {
+    a_journal->next_entry = 0 ;
+  }
+
+  return TRUE ;
+}
+
+gboolean
+moko_journal_write_to_storage (MokoJournal *a_journal)
+{
+  MokoJEntry *cur_entry=NULL ;
+  int i=0 ;
+  GList *ecal_comps=NULL, *cur_elem=NULL ;
+  ECalComponent *ecal_comp=NULL ;
+  icalcomponent *ical_comp=NULL ;
+  GError *error=NULL ;
+  gchar *uid=NULL ;
+  gboolean result = TRUE;
+
+  g_return_val_if_fail (a_journal, FALSE) ;
+  g_return_val_if_fail (a_journal->ecal, FALSE) ;
+
+  for (i=0; i<JOURNAL_MAX_SIZE; ++i)
+  {
+    cur_entry = a_journal->entries[i] ;
+    if (!cur_entry)
+      break ;
+    if (!moko_j_entry_to_icalcomponent (cur_entry, &ical_comp))
+    {
+      if (ical_comp)
+      {
+        icalcomponent_free (ical_comp) ;
+        ical_comp = NULL ;
+      }
+      continue ;
+    }
+    ecal_comp = e_cal_component_new () ;
+    e_cal_component_set_icalcomponent (ecal_comp, ical_comp) ;
+    ecal_comps = g_list_prepend (ecal_comps, ecal_comp) ;
+    ecal_comp = NULL ;
+    ical_comp = NULL ;
+  }
+
+  for (cur_elem = ecal_comps ; cur_elem ; cur_elem = cur_elem->next)
+  {
+    if (!cur_elem->data)
+    {
+      g_warning ("Got an empty ECalComponent\n") ;
+      result = FALSE ;
+      continue ;
+    }
+    ical_comp = e_cal_component_get_icalcomponent (cur_elem->data) ;
+    if (!ical_comp)
+    {
+      g_warning ("Got an empty icalcomponent") ;
+      result = FALSE ;
+      continue ;
+    }
+    if (!e_cal_create_object (a_journal->ecal, ical_comp, &uid, &error))
+    {
+      g_warning ("Could not write the entry to the journal") ;
+      result = FALSE ;
+    }
+    else
+    {
+      e_cal_component_commit_sequence (cur_elem->data) ;
+    }
+    if (error)
+    {
+      g_warning ("got error: %s\n", error->message) ;
+      g_error_free (error) ;
+      error = NULL ;
+    }
+    if (uid)
+    {
+      g_free (uid) ;
+      uid = NULL ;
+    }
+  }
+  return result ;
+}
+
+/**
+ * moko_j_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)
+{
+  MokoJEntry *result ;
+  result = moko_j_entry_alloc () ;
+  result->type = a_type ;
+  return result ;
+}
+
+/**
+ * moko_j_entry_free:
+ * @entry: the entry to free
+ *
+ * Deallocate the memory of the journal entry object
+ */
+void
+moko_j_entry_free (MokoJEntry *a_entry)
+{
+  g_return_if_fail (a_entry) ;
+
+  moko_j_entry_free_real (a_entry) ;
+}
+
+/**
+ * moko_j_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)
+{
+  g_return_val_if_fail (a_entry, UNDEF_ENTRY) ;
+
+  return a_entry->type ;
+}
+
+
+/**
+ * moko_j_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)
+{
+  g_return_if_fail (a_entry) ;
+  g_return_if_fail (a_type != UNDEF_ENTRY) ;
+
+  a_entry->type = a_type ;
+}
+
+/**
+ * moko_j_entry_get_contact_uid:
+ * @entry: the current instance of journal entry
+ *
+ * get the contact uid
+ *
+ * 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 *a_entry)
+{
+  g_return_val_if_fail (a_entry, NULL) ;
+
+  return a_entry->contact_uid ;
+}
+
+void
+moko_j_entry_set_contact_uid (MokoJEntry *a_entry, const gchar *a_uid)
+{
+  g_return_if_fail (a_entry) ;
+
+  if (a_entry->contact_uid)
+  {
+    g_free (a_entry->contact_uid) ;
+    a_entry->contact_uid = NULL ;
+  }
+
+  if (a_uid)
+  {
+    a_entry->contact_uid = g_strdup (a_uid) ;
+  }
+}
+
+/**
+ * moko_j_entry_get_summary:
+ * @entry: the current instance of journal entry
+ *
+ * get the summary of the journal entry
+ *
+ * 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 *a_entry)
+{
+  g_return_val_if_fail (a_entry, NULL) ;
+
+  return a_entry->summary ;
+}
+
+/**
+ * moko_j_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 *a_entry, const gchar* a_summary)
+{
+  g_return_if_fail (a_entry) ;
+
+  if (a_entry->summary)
+  {
+    g_free (a_entry->summary) ;
+    a_entry->summary = NULL ;
+  }
+  if (a_summary)
+  {
+    a_entry->summary = g_strdup (a_summary) ;
+  }
+}
+
+/**
+ * moko_j_entry_get_dtdstart:
+ * @entry: the current instance of journal entry
+ *
+ * get the starting date associated to the journal entry
+ *
+ * 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 *a_entry)
+{
+  g_return_val_if_fail (a_entry, NULL) ;
+
+  if (!a_entry->dtstart)
+    a_entry->dtstart = moko_time_new_today () ;
+
+  return a_entry->dtstart ;
+}
+
+/**
+ * moko_j_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)
+{
+  g_return_if_fail (a_entry) ;
+
+  if (a_entry->dtstart)
+  {
+    moko_time_free (a_entry->dtstart) ;
+    a_entry->dtstart = NULL ;
+  }
+
+  if (a_dtstart)
+    a_entry->dtstart = a_dtstart ;
+}
+
+/**
+ * moko_j_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
+ * necessary
+ *
+ * Return value: TRUE if the call succeeded, FALSE otherwise.
+ */
+gboolean
+moko_j_entry_get_email_info (MokoJEntry *a_entry,
+                             MokoJEmailInfo **a_info)
+{
+  g_return_val_if_fail (a_entry->type == EMAIL_JOURNAL_ENTRY, FALSE) ;
+
+  if (!a_entry->extra_info.email_info)
+  {
+    a_entry->extra_info.email_info = moko_j_email_info_new () ;
+  }
+  g_return_val_if_fail (a_entry->extra_info.email_info, FALSE) ;
+
+  *a_info = a_entry->extra_info.email_info ;
+  return TRUE ;
+}
+
+/**
+ * moko_j_email_info_get_was_sent:
+ * @info: the current instance of email info
+ *
+ * Get a boolean property stating if the email was sent or received.
+ *
+ * Return value: TRUE if the email was sent, false if it was received
+ */
+gboolean
+moko_j_email_info_get_was_sent (MokoJEmailInfo *a_info)
+{
+  g_return_val_if_fail (a_info, FALSE) ;
+  return a_info->was_sent ;
+}
+
+/**
+ * moko_j_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 (MokoJEmailInfo *a_info, gboolean a_was_sent)
+{
+  g_return_if_fail (a_info) ;
+  a_info->was_sent = a_was_sent ;
+}
+
+/*</public funcs>*/

Copied: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h (from rev 1679, trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h)
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-journal.h	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,246 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * 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.
+ */
+#ifndef __MOKO_JOURNAL_H__
+#define  __MOKO_JOURNAL_H__
+
+#include <glib.h>
+#include "moko-time.h" 
+
+/************************************************************
+ * this API abstracts the process of adding
+ * journal entries into the default system
+ * journal. Journal entries contain information
+ * about communation history like calls, sms, or,
+ * emails issued or received.
+ ***********************************************************/
+
+typedef struct _MokoJournal MokoJournal ;
+typedef struct _MokoJEntry MokoJEntry ;
+typedef struct _MokoJEmailInfo MokoJEmailInfo ;
+typedef struct _MokoJSMSInfo MokoJSMSInfo ;
+typedef struct _MokoJMMSInfo MokoJMMSInfo ;
+typedef struct _MokoJCallInfo MokoJCallInfo ;
+
+/**
+ * this represents the primary type of
+ * a journal entry.
+ */
+typedef enum _MokoJEntryType {
+  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 ;
+
+/*<journal management>*/
+/**
+ * moko_journal_open_default:
+ *
+ * Opens the default journal.
+ *
+ * Return value: a pointer to the journal object
+ */
+MokoJournal* moko_journal_open_default () ;
+
+/**
+ * moko_journal_close:
+ * @journal: the journal to close
+ *
+ * Close the journal previously opened with moko_journal_open_default().
+ * This function deallocates the memory of the Journal object.
+ */
+void moko_journal_close (MokoJournal *journal) ;
+
+/**
+ * moko_journal_add_entry:
+ * @journal: the current instance of journal
+ * @entry: the new entry to add to the journal. Must be non NULL.
+ * The journal is responsible
+ * of deallocating the memory of the entry object.
+ *
+ * Add a journal entry to the journal
+ *
+ * Return value: TRUE if the entry got successfully added to the journal,
+ * FALSE otherwise
+ */
+gboolean moko_journal_add_entry (MokoJournal *journal, MokoJEntry *entry) ;
+
+/**
+ * moko_journal_weite_to_storage:
+ * @journal: the journal to save to storage
+ *
+ * Saves the journal to persistent storage (e.g disk) using the
+ * appropriate backend. The backend currently used is evolution data server
+ *
+ * Return TRUE in case of success, FALSE otherwise
+ */
+gboolean moko_journal_write_to_storage (MokoJournal *journal) ;
+
+/*<journal entries querying>*/
+/*</journal entries querying>*/
+
+/*</journal management>*/
+
+
+/*<journal entries management>*/
+
+/**
+ * moko_j_entry_new:
+ * @type: the type of journal entry
+ *
+ * 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 type) ;
+
+/**
+ * moko_j_entry_free:
+ * @entry: the entry to free
+ *
+ * Deallocate the memory of the journal entry object
+ */
+void moko_j_entry_free (MokoJEntry *entry) ;
+
+/**
+ * moko_j_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) ;
+
+/**
+ * moko_j_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) ;
+
+/**
+ * moko_j_entry_get_contact_uid:
+ * @entry: the current instance of journal entry
+ *
+ * get the contact uid
+ *
+ * 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) ;
+
+/**
+ * moko_j_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.
+ *
+ * Associate a new contact UID to the journal entry uid.
+ * 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) ;
+
+/**
+ * moko_j_entry_get_summary:
+ * @entry: the current instance of journal entry
+ *
+ * get the summary of the journal entry
+ *
+ * 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) ;
+
+/**
+ * moko_j_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) ;
+
+/**
+ * moko_j_entry_get_dtdstart:
+ * @entry: the current instance of journal entry
+ *
+ * get the starting date associated to the journal entry
+ *
+ * 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) ;
+
+/**
+ * moko_j_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);
+
+/*<email info>*/
+
+/**
+ * moko_j_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
+ * necessary
+ *
+ * Return value: TRUE if the call succeeded, FALSE otherwise.
+ */
+gboolean moko_j_entry_get_email_info (MokoJEntry *entry,
+                                      MokoJEmailInfo **info) ;
+
+/**
+ * moko_j_email_info_get_was_sent:
+ * @info: the current instance of email info
+ *
+ * Get a boolean property stating if the email was sent or received.
+ *
+ * Return value: TRUE if the email was sent, false if it was received
+ */
+gboolean moko_j_email_info_get_was_sent (MokoJEmailInfo *info) ;
+
+/**
+ * moko_j_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 (MokoJEmailInfo *info, gboolean was_sent) ;
+
+/*</email info>*/
+
+
+/*</journal entries management>*/
+
+#endif /*__MOKO_JOURNAL_H__*/

Copied: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time-priv.h (from rev 1679, trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h)
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time-priv.h	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,29 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * 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.
+ */
+#ifndef __MOKO_TIME_PRIV_H__
+#define  __MOKO_TIME_PRIV_H__
+
+struct _MokoTime
+{
+    icaltimetype t ;
+};
+
+#endif  /*__MOKO_TIME_PRIV_H__*/

Added: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.c	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.c	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,71 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * 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 <libical/icaltime.h>
+#include <glib.h>
+#include "moko-time.h"
+#include "moko-time-priv.h"
+
+
+MokoTime*
+moko_time_new_today ()
+{
+    MokoTime *result ;
+    result = g_new0 (MokoTime, 1) ;
+    result->t = icaltime_today () ;
+    return result ;
+}
+
+MokoTime*
+moko_time_from_timet (const time_t a_t, gboolean a_is_date)
+{
+    MokoTime *result ;
+
+    result = g_new0 (MokoTime, 1) ;
+    result->t = icaltime_from_timet (a_t, a_is_date) ;
+    return result ;
+}
+
+MokoTime*
+moko_time_from_string (const gchar *a_iso_format_date)
+{
+    MokoTime *result ;
+
+    g_return_val_if_fail (a_iso_format_date, NULL) ;
+
+    result = g_new0 (MokoTime, 1) ;
+    result->t = icaltime_from_string (a_iso_format_date) ;
+    return result ;
+}
+
+void
+moko_time_free (MokoTime *a_time)
+{
+    g_return_if_fail (a_time) ;
+
+    g_free (a_time) ;
+}
+
+const gchar*
+moko_time_as_ical_string (MokoTime *a_t)
+{
+    g_return_val_if_fail (a_t, NULL) ;
+    return icaltime_as_ical_string (a_t->t) ;
+}

Copied: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.h (from rev 1679, trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h)
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/moko-time.h	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-time.h	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,34 @@
+/* vi: set sw=2: */
+/*
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * 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.
+ */
+#ifndef __MOKO_TIME_H__
+#define  __MOKO_TIME_H__
+
+#include <time.h>
+
+typedef struct _MokoTime MokoTime ;
+
+MokoTime* moko_time_new_today () ;
+MokoTime* moko_time_from_timet (const time_t t, gboolean is_date) ;
+MokoTime* moko_time_from_string (const gchar *iso_format_date) ;
+void moko_time_free (MokoTime *time) ;
+
+const gchar* moko_time_as_ical_string (MokoTime *t) ;
+#endif /*__MOKO_TIME_H__*/

Added: trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am	2007-04-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/Makefile.am	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,5 @@
+noinst_PROGRAMS=testcreate
+
+testcreate_SOURCES=test-create.c
+testcreate_LDADD=@LIBS@ $(top_srcdir)/libmokojournal/src/libmokojournal.la
+INCLUDES= -I $(top_srcdir)/libmokojournal/src

Added: 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-06 19:19:02 UTC (rev 1679)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c	2007-04-06 19:19:06 UTC (rev 1680)
@@ -0,0 +1,56 @@
+#include "moko-journal.h"
+
+int
+main ()
+{
+    MokoJournal *journal=NULL ;
+    MokoJEntry *entry=NULL ;
+    MokoJEmailInfo *email_info=NULL ;
+    int result = 1 ;
+
+    g_type_init () ;
+
+    journal = moko_journal_open_default () ;
+    g_return_val_if_fail (journal, 1) ;
+
+    entry = moko_j_entry_new (EMAIL_JOURNAL_ENTRY) ;
+    if (!entry)
+    {
+        g_warning ("failed to create journal entry\n") ;
+        goto out ;
+    }
+
+    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)
+    {
+        g_warning ("failed to get email extra info from journal entry\n") ;
+        goto out ;
+    }
+    moko_j_email_info_set_was_sent (email_info, TRUE) ;
+
+    if (!moko_journal_add_entry (journal, entry))
+    {
+        g_warning ("could not add entry to journal\n") ;
+        goto out ;
+    }
+    entry = NULL ;/*entry belongs to journal now, don't free it*/
+    if (!moko_journal_write_to_storage (journal))
+    {
+        g_warning ("Could not write journal to storage") ;
+        goto out ;
+    }
+
+    result = 0; /*success*/
+    g_print ("test succeeded\n") ;
+
+out:
+    if (journal)
+        moko_journal_close (journal) ;
+    if (entry)
+        moko_j_entry_free (entry) ;
+
+    return result ;
+}
+





More information about the commitlog mailing list