r1850 - in trunk/src/target/OM-2007/openmoko-libs: . libmokojournal/src libmokojournal/tests
dodji at sita.openmoko.org
dodji at sita.openmoko.org
Thu Apr 26 18:46:09 CEST 2007
Author: dodji
Date: 2007-04-26 18:46:05 +0200 (Thu, 26 Apr 2007)
New Revision: 1850
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:
Added "dialed-number" and "was-missed" properties
* src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c,h:
added MokoJournalVoiceInfo::dialed_number
and MokoJournalVoiceInfo::was_missed properties. These a serialized
and deserialized.
Started to add MokoJournalEntry::wifi_ap_mac and
MokoJournalEntry::bluetooth_ap_mac entries. not finished
* src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c:
updated this to test dialed number an "was-missed" property.
Modified: trunk/src/target/OM-2007/openmoko-libs/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-26 16:09:48 UTC (rev 1849)
+++ trunk/src/target/OM-2007/openmoko-libs/ChangeLog 2007-04-26 16:46:05 UTC (rev 1850)
@@ -1,5 +1,16 @@
2007-04-26 Dodji Seketeli <dodji at openedhand.com>
+ * src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c,h:
+ added MokoJournalVoiceInfo::dialed_number
+ and MokoJournalVoiceInfo::was_missed properties. These a serialized
+ and deserialized.
+ Started to add MokoJournalEntry::wifi_ap_mac and
+ MokoJournalEntry::bluetooth_ap_mac entries. not finished
+ * src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c:
+ updated this to test dialed number an "was-missed" property.
+
+2007-04-26 Dodji Seketeli <dodji at openedhand.com>
+
* oe/conf/distro/include/sane-srcdates.inc: this needs and update of the version
of edsdbus to svn 20070426 because we pushed a couple of fixes and enhancement in
there. These fixes/enhancements are mandatory for this patch to work.
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-26 16:09:48 UTC (rev 1849)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c 2007-04-26 16:46:05 UTC (rev 1850)
@@ -27,6 +27,8 @@
#include "moko-journal.h"
#include "moko-time-priv.h"
+#define WIFI_AP_MAC_ADDR_LEN 48
+
struct _MokoJournal
{
ECal *ecal ;
@@ -37,7 +39,8 @@
struct _MokoJournalVoiceInfo
{
- int nothing ;
+ gchar *dialed_number ;
+ gboolean was_missed ;
};
struct _MokoJournalFaxInfo
@@ -73,6 +76,8 @@
float start_latitude ;
gchar *source ;
MokoGSMLocation gsm_loc ;
+ guchar *wifi_ap_mac ;
+ guchar *bluetooth_ap_mac ;
union
{
MokoJournalEmailInfo *email_info ;
@@ -283,6 +288,15 @@
moko_journal_voice_info_free (MokoJournalVoiceInfo *a_info)
{
g_return_if_fail (a_info) ;
+
+ if (a_info)
+ {
+ if (a_info->dialed_number)
+ {
+ g_free (a_info->dialed_number) ;
+ a_info->dialed_number = NULL ;
+ }
+ }
g_free (a_info) ;
}
@@ -351,6 +365,16 @@
g_free (a_entry->source) ;
a_entry->source = NULL ;
}
+ if (a_entry->wifi_ap_mac)
+ {
+ g_free (a_entry->wifi_ap_mac) ;
+ a_entry->wifi_ap_mac = NULL ;
+ }
+ if (a_entry->bluetooth_ap_mac)
+ {
+ g_free (a_entry->bluetooth_ap_mac) ;
+ a_entry->bluetooth_ap_mac = NULL;
+ }
switch (a_entry->type)
{
@@ -506,6 +530,36 @@
case EMAIL_JOURNAL_ENTRY:
break ;
case VOICE_JOURNAL_ENTRY:
+ {
+ MokoJournalVoiceInfo *info = NULL ;
+ gchar *number="NULL" ;
+ gchar *missed=NULL ;
+
+ if (!moko_journal_entry_get_voice_info (a_entry, &info))
+ break ;
+ if (!info)
+ break ;
+
+ /*
+ * serialize dialed number
+ */
+ if (moko_journal_voice_info_get_dialed_number (info))
+ number = (gchar*)moko_journal_voice_info_get_dialed_number (info) ;
+ prop = icalproperty_new_x (number) ;
+ icalproperty_set_x_name (prop, "X-OPENMOKO-VOICE-DIALED-NUMBER") ;
+ icalcomponent_add_property (comp, prop) ;
+
+ /*
+ * serialize the "was-missed" property
+ */
+ if (moko_journal_voice_info_get_was_missed (info))
+ missed = "YES" ;
+ else
+ missed = "NO" ;
+ prop = icalproperty_new_x (missed) ;
+ icalproperty_set_x_name (prop, "X-OPENMOKO-VOICE-CALL-WAS-MISSED") ;
+ icalcomponent_add_property (comp, prop) ;
+ }
break ;
case FAX_JOURNAL_ENTRY:
break ;
@@ -653,6 +707,40 @@
{
case VOICE_JOURNAL_ENTRY:
{
+ MokoJournalVoiceInfo *info = NULL ;
+ prop = NULL ;
+ prop_value = NULL ;
+
+ moko_journal_entry_get_voice_info (entry, &info) ;
+ g_return_val_if_fail (info, FALSE) ;
+
+ /*
+ * deserialize dialed number
+ */
+ if (icalcomponent_find_property_as_string
+ (a_comp,
+ "X-OPENMOKO-VOICE-DIALED-NUMBER",
+ &prop_value))
+ {
+ if (prop_value)
+ {
+ moko_journal_voice_info_set_dialed_number (info, prop_value) ;
+ }
+ }
+ prop_value = NULL ;
+ if (icalcomponent_find_property_as_string
+ (a_comp,
+ "X-OPENMOKO-VOICE-CALL-WAS-MISSED",
+ &prop_value))
+ {
+ if (prop_value)
+ {
+ gboolean was_missed = FALSE ;
+ if (!strcmp ("YES", prop_value))
+ was_missed = TRUE ;
+ moko_journal_voice_info_set_was_missed (info, was_missed) ;
+ }
+ }
}
break ;
case FAX_JOURNAL_ENTRY:
@@ -1634,11 +1722,63 @@
g_return_val_if_fail (a_info, FALSE) ;
g_return_val_if_fail (a_info, FALSE) ;
- memset (a_location, &a_info->gsm_loc, sizeof (MokoGSMLocation)) ;
+ memcpy (a_location, &a_info->gsm_loc, sizeof (MokoGSMLocation)) ;
return TRUE ;
}
/**
+ * moko_journal_entry_set_wifi_ap_mac_address:
+ * @entry: the current instance of journal entry
+ *
+ * the mac address of the wifi access point.
+ * It is must be a 48 bits long string of bytes.
+ *
+ * Returns: TRUE in case of success, FALSE otherwise.
+ */
+gboolean
+moko_journal_entry_set_wifi_ap_mac_address (MokoJournalEntry *a_entry,
+ const guchar *a_address)
+{
+ g_return_val_if_fail (a_entry, FALSE) ;
+
+ if (!a_address)
+ {
+ if (a_entry->wifi_ap_mac)
+ {
+ g_free (a_entry->wifi_ap_mac) ;
+ a_entry->wifi_ap_mac = NULL ;
+ }
+ return TRUE ;
+ }
+
+ if (!a_entry->wifi_ap_mac)
+ {
+ a_entry->wifi_ap_mac = g_new0 (guchar, WIFI_AP_MAC_ADDR_LEN) ;
+ }
+ g_return_val_if_fail (a_entry->wifi_ap_mac, FALSE) ;
+ memcpy (a_entry->wifi_ap_mac, a_address, WIFI_AP_MAC_ADDR_LEN) ;
+
+ return TRUE ;
+}
+
+/**
+ * moko_journal_entry_get_wifi_ap_mac_address:
+ * @entry: the current instance of journal entry
+ *
+ * Returns: the mac address of the wifi access point.
+ * It is a 48 bits long string of bytes. The calling code must
+ * *NOT* delete this pointer. This function can also return NULL if
+ * no wifi access point mac address has been set in the entry.
+ */
+const guchar*
+moko_journal_entry_get_wifi_ap_mac_address (MokoJournalEntry *a_entry)
+{
+ g_return_val_if_fail (a_entry, NULL) ;
+
+ return a_entry->wifi_ap_mac ;
+}
+
+/**
* moko_journal_entry_get_voice_info:
* @a_entry: the current instance of journal entry
* @a_info: the extra property set or NULL if info is not of type
@@ -1666,6 +1806,46 @@
return TRUE ;
}
+void
+moko_journal_voice_info_set_dialed_number (MokoJournalVoiceInfo *a_info,
+ gchar *a_number)
+{
+ g_return_if_fail (a_info) ;
+
+ if (a_info->dialed_number)
+ {
+ g_free (a_info->dialed_number) ;
+ a_info->dialed_number = NULL ;
+ }
+ if (a_number)
+ a_info->dialed_number = g_strdup (a_number) ;
+}
+
+const gchar*
+moko_journal_voice_info_get_dialed_number (MokoJournalVoiceInfo *a_info)
+{
+ g_return_val_if_fail (a_info, NULL) ;
+
+ return a_info->dialed_number ;
+}
+
+void
+moko_journal_voice_info_set_was_missed (MokoJournalVoiceInfo *a_info,
+ gboolean a_flag)
+{
+ g_return_if_fail (a_info) ;
+
+ a_info->was_missed = a_flag ;
+}
+
+gboolean
+moko_journal_voice_info_get_was_missed (MokoJournalVoiceInfo *a_info)
+{
+ g_return_val_if_fail (a_info, FALSE) ;
+
+ return a_info->was_missed ;
+}
+
/**
* moko_journal_entry_get_fax_info:
* @entry: the current instance of journal entry
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-26 16:09:48 UTC (rev 1849)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.h 2007-04-26 16:46:05 UTC (rev 1850)
@@ -373,7 +373,7 @@
const gchar *source) ;
/**
* moko_journal_entry_set_gsm_location:
- * @info: the current instance of voice call extra properties set
+ * @entry: the current instance of journal entry
* @location: the gsm location
*
* Returns: TRUE upon completion, FALSE otherwise
@@ -383,12 +383,36 @@
/**
* moko_journal_entry_get_gsm_location:
- * @info: the current instance of voice call extra properties set
+ * @entry: the current instance of journal entry
*
* Returns TRUE upon completion, FALSE otherwise
*/
gboolean moko_journal_entry_get_gsm_location (MokoJournalEntry *entry,
MokoGSMLocation *location);
+
+/**
+ * moko_journal_entry_set_wifi_ap_mac_address:
+ * @entry: the current instance of journal entry
+ *
+ * the mac address of the wifi access point.
+ * It is must be a 48 bits long string of bytes.
+ *
+ * Returns: TRUE in case of success, FALSE otherwise.
+ */
+gboolean moko_journal_entry_set_wifi_ap_mac_address (MokoJournalEntry *entry,
+ const guchar *address) ;
+
+/**
+ * moko_journal_entry_get_wifi_ap_mac_address:
+ * @entry: the current instance of journal entry
+ *
+ * Returns: the mac address of the wifi access point.
+ * It is a 48 bits long string of bytes. The calling code must
+ * *NOT* delete this pointer. This function can also return NULL if
+ * no wifi access point mac address has been set in the entry.
+ */
+const guchar *moko_journal_entry_get_wifi_ap_mac_address
+ (MokoJournalEntry *entry) ;
/*<voice call info>*/
/**
@@ -405,6 +429,23 @@
gboolean moko_journal_entry_get_voice_info (MokoJournalEntry *entry,
MokoJournalVoiceInfo **info) ;
+
+/**
+ * moko_journal_voice_info_set_dialed_number:
+ * @info: the current
+ * @info: the extra property set attached to the voice call
+ */
+void moko_journal_voice_info_set_dialed_number (MokoJournalVoiceInfo *info,
+ gchar *number) ;
+
+const gchar* moko_journal_voice_info_get_dialed_number
+ (MokoJournalVoiceInfo *info) ;
+
+void moko_journal_voice_info_set_was_missed (MokoJournalVoiceInfo *info,
+ gboolean a_flag) ;
+
+gboolean moko_journal_voice_info_get_was_missed (MokoJournalVoiceInfo *info) ;
+
/*</voice call info>*/
/*<fax call 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-26 16:09:48 UTC (rev 1849)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c 2007-04-26 16:46:05 UTC (rev 1850)
@@ -28,6 +28,7 @@
MokoJournal *journal=NULL ;
MokoJournalEntry *entry=NULL ;
MokoJournalEmailInfo *email_info=NULL ;
+ MokoJournalVoiceInfo *voice_info=NULL ;
MokoLocation loc ;
MokoGSMLocation gsm_loc ;
int result = 1 ;
@@ -90,6 +91,48 @@
*/
entry = NULL ;
+ /*create a journal entry of type 'voice call journal entry'*/
+ entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY) ;
+ if (!entry)
+ {
+ g_warning ("failed to create journal entry\n") ;
+ goto out ;
+ }
+
+ /*****************************
+ * <fill the entry with data>
+ *****************************/
+ moko_journal_entry_set_contact_uid (entry, "voicejournalentryuid") ;
+ moko_journal_entry_set_summary (entry, "this was a call") ;
+ moko_journal_entry_set_dtstart (entry, moko_time_new_today ()) ;
+ moko_journal_entry_set_direction (entry, DIRECTION_OUT) ;
+ loc.latitude = 43.386013;
+ loc.longitude = 15.082932;
+ moko_journal_entry_set_start_location (entry, &loc) ;
+ gsm_loc.lac = 67 ;
+ gsm_loc.cid = 200 ;
+ moko_journal_entry_set_gsm_location (entry, &gsm_loc) ;
+ if (!moko_journal_entry_get_voice_info (entry, &voice_info) || !voice_info)
+ {
+ g_warning ("failed to get voice extra info from journal entry\n") ;
+ goto out ;
+ }
+ /*****************************
+ * </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))
{
More information about the commitlog
mailing list