Ignore:
Timestamp:
04/26/07 14:31:50 (6 years ago)
Author:
dodji
Message:

Added direction, gsmlocation, startlocation properties to journal entries.

  • 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.
  • src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c,h: re-organize the properties supported. Added "direction", "gsmlocation" and "startlocation" properties.
  • src/target/OM-2007/openmoko-libs/libmokojournal/tests/test-create.c: Update this to test the new properties.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c

    r1737 r1844  
    2222#include <strings.h> 
    2323#include <glib-object.h> 
     24#include <libical/icaltypes.h> 
    2425#include <libecal/e-cal.h> 
    2526#include <libecal/e-cal-component.h> 
     
    3536}; 
    3637 
     38struct _MokoJournalVoiceInfo 
     39{ 
     40  int nothing ; 
     41}; 
     42 
     43struct _MokoJournalFaxInfo 
     44{ 
     45  int nothing ; 
     46}; 
     47 
     48struct _MokoJournalDataInfo 
     49{ 
     50  int nothing ; 
     51}; 
     52 
    3753struct _MokoJournalEmailInfo 
    3854{ 
    39   gboolean was_sent ; 
     55  int nothing ; 
    4056}; 
    4157 
     58struct _MokoJournalSMSInfo 
     59{ 
     60  int nothing ; 
     61}; 
     62 
    4263struct _MokoJournalEntry 
    4364{ 
    44   MokoJournalEntryType type; 
     65  enum MokoJournalEntryType type; 
    4566  gchar *uid ; 
    4667  gchar *contact_uid ; 
    4768  gchar *summary ; 
     69  enum MessageDirection direction ; 
    4870  MokoTime *dtstart ; 
    4971  MokoTime *dtend ; 
     72  float start_longitude ; 
     73  float start_latitude ; 
     74  gchar *source ; 
     75  MokoGSMLocation gsm_loc ; 
    5076  union 
    5177  { 
    5278    MokoJournalEmailInfo *email_info ; 
    53   } extra_info ; 
     79    MokoJournalVoiceInfo *voice_info ; 
     80    MokoJournalFaxInfo *fax_info ; 
     81    MokoJournalDataInfo *data_info ; 
     82    MokoJournalSMSInfo *sms_info ; 
     83  } extra ; 
    5484}; 
    5585 
    5686struct _MokoJournalEntryInfo 
    5787{ 
    58   MokoJournalEntryType type; 
     88  enum MokoJournalEntryType type; 
    5989  const gchar *type_as_string ; 
    6090}; 
     
    6393static const MokoJournalEntryInfo entries_info[] = 
    6494{ 
     95  {VOICE_JOURNAL_ENTRY, "VOICEENTRY"}, 
    6596  {EMAIL_JOURNAL_ENTRY, "EMAILENTRY"}, 
    6697  {SMS_JOURNAL_ENTRY, "SMSENTRY"}, 
    67   {MMS_JOURNAL_ENTRY, "MMSENTRY"}, 
    68   {CALL_JOURNAL_ENTRY, "CALLENTRY"}, 
     98  {FAX_JOURNAL_ENTRY, "FAXENTRY"}, 
     99  {DATA_JOURNAL_ENTRY, "DATAENTRY"}, 
    69100  {0} 
    70101} ; 
    71102 
    72103static MokoJournal* moko_journal_alloc () ; 
     104static MokoJournalEmailInfo* moko_journal_email_info_new () ; 
     105static MokoJournalVoiceInfo* moko_journal_voice_info_new () ; 
     106static MokoJournalFaxInfo* moko_journal_fax_info_new () ; 
     107static MokoJournalSMSInfo* moko_journal_sms_info_new () ; 
     108static void moko_journal_voice_info_free (MokoJournalVoiceInfo *a_info) ; 
     109static void moko_journal_fax_info_free (MokoJournalFaxInfo *a_info) ; 
     110static void moko_journal_data_info_free (MokoJournalDataInfo *a_info) ; 
     111static void moko_journal_email_info_free (MokoJournalEmailInfo *a_info) ; 
     112static void moko_journal_sms_info_free (MokoJournalSMSInfo *a_info) ; 
     113static MokoJournalDataInfo* moko_journal_data_info_new () ; 
    73114static gboolean moko_journal_find_entry_from_uid (MokoJournal *a_journal, 
    74115                                                  const gchar *a_uid, 
    75116                                                  MokoJournalEntry **a_entry, 
    76117                                                  int *a_offset) ; 
    77 static const gchar* entry_type_to_string (MokoJournalEntryType a_type) ; 
    78 static MokoJournalEntryType entry_type_from_string (const gchar* a_str) ; 
    79 static gboolean moko_journal_entry_type_is_valid (MokoJournalEntryType a_type) ; 
     118static const gchar* entry_type_to_string (enum MokoJournalEntryType a_type) ; 
     119static enum MokoJournalEntryType entry_type_from_string (const gchar* a_str) ; 
     120static gboolean moko_journal_entry_type_is_valid 
     121                                          (enum MokoJournalEntryType a_type) ; 
    80122static gboolean moko_journal_entry_to_icalcomponent (MokoJournalEntry *a_entry, 
    81123                                                     icalcomponent **a_comp) ; 
    82 static gboolean icalcomponent_to_j_entry (icalcomponent *a_comp, 
     124static gboolean icalcomponent_to_entry (icalcomponent *a_comp, 
    83125                                          MokoJournalEntry **a_entry) ; 
    84126static gboolean icalcomponent_find_property (const icalcomponent *a_comp, 
     
    99141 
    100142static const gchar* 
    101 entry_type_to_string (MokoJournalEntryType a_type) 
     143entry_type_to_string (enum MokoJournalEntryType a_type) 
    102144{ 
    103145  MokoJournalEntryInfo *cur ; 
     
    111153} 
    112154 
    113 static MokoJournalEntryType 
     155static enum MokoJournalEntryType 
    114156entry_type_from_string (const gchar* a_str) 
    115157{ 
     
    201243} 
    202244 
    203 MokoJournalEmailInfo* 
     245static MokoJournalEmailInfo* 
    204246moko_journal_email_info_new () 
    205247{ 
     
    207249} 
    208250 
    209 void 
     251static MokoJournalVoiceInfo* 
     252moko_journal_voice_info_new () 
     253{ 
     254  return g_new0 (MokoJournalVoiceInfo, 1) ; 
     255} 
     256 
     257static MokoJournalFaxInfo* 
     258moko_journal_fax_info_new () 
     259{ 
     260  return g_new0 (MokoJournalFaxInfo, 1) ; 
     261} 
     262 
     263static MokoJournalDataInfo* 
     264moko_journal_data_info_new () 
     265{ 
     266  return g_new0 (MokoJournalDataInfo, 1) ; 
     267} 
     268 
     269static MokoJournalSMSInfo* 
     270moko_journal_sms_info_new () 
     271{ 
     272  return g_new0 (MokoJournalSMSInfo, 1) ; 
     273} 
     274 
     275static void 
    210276moko_journal_email_info_free (MokoJournalEmailInfo *a_info) 
    211277{ 
     
    214280} 
    215281 
     282static void 
     283moko_journal_voice_info_free (MokoJournalVoiceInfo *a_info) 
     284{ 
     285  g_return_if_fail (a_info) ; 
     286  g_free (a_info) ; 
     287} 
     288 
     289static void 
     290moko_journal_fax_info_free (MokoJournalFaxInfo *a_info) 
     291{ 
     292  g_return_if_fail (a_info) ; 
     293  g_free (a_info) ; 
     294} 
     295 
     296static void 
     297moko_journal_data_info_free (MokoJournalDataInfo *a_info) 
     298{ 
     299  g_return_if_fail (a_info) ; 
     300  g_free (a_info) ; 
     301} 
     302 
     303static void 
     304moko_journal_sms_info_free (MokoJournalSMSInfo *a_info) 
     305{ 
     306  g_return_if_fail (a_info) ; 
     307  g_free (a_info) ; 
     308} 
     309 
    216310static MokoJournalEntry* 
    217311moko_journal_entry_alloc () 
     
    253347    a_entry->dtend = NULL ; 
    254348  } 
     349  if (a_entry->source) 
     350  { 
     351    g_free (a_entry->source) ; 
     352    a_entry->source = NULL ; 
     353  } 
    255354 
    256355  switch (a_entry->type) 
    257356  { 
    258357    case EMAIL_JOURNAL_ENTRY: 
    259       if (a_entry->extra_info.email_info) 
     358      if (a_entry->extra.email_info) 
    260359      { 
    261         moko_journal_email_info_free (a_entry->extra_info.email_info) ; 
    262         a_entry->extra_info.email_info = NULL ; 
     360        moko_journal_email_info_free (a_entry->extra.email_info) ; 
     361        a_entry->extra.email_info = NULL ; 
    263362      } 
    264363      break ; 
     364    case VOICE_JOURNAL_ENTRY: 
     365      if (a_entry->extra.voice_info) 
     366      { 
     367        moko_journal_voice_info_free (a_entry->extra.voice_info) ; 
     368        a_entry->extra.voice_info = NULL ; 
     369      } 
     370      break ; 
     371    case FAX_JOURNAL_ENTRY: 
     372      if (a_entry->extra.fax_info) 
     373      { 
     374        moko_journal_fax_info_free (a_entry->extra.fax_info) ; 
     375        a_entry->extra.fax_info = NULL; 
     376      } 
     377      break ; 
     378    case DATA_JOURNAL_ENTRY: 
     379      if (a_entry->extra.data_info) 
     380      { 
     381        moko_journal_data_info_free (a_entry->extra.data_info) ; 
     382        a_entry->extra.data_info = NULL ; 
     383      } 
     384      break ; 
    265385    case SMS_JOURNAL_ENTRY: 
    266       break ; 
    267     case MMS_JOURNAL_ENTRY: 
    268       break ; 
    269     case CALL_JOURNAL_ENTRY: 
    270          break ; 
     386      if (a_entry->extra.sms_info) 
     387      { 
     388        moko_journal_sms_info_free (a_entry->extra.sms_info) ; 
     389        a_entry->extra.sms_info = NULL ; 
     390      } 
     391      break ; 
    271392    default: 
    272          g_warning ("unknown journal entry type. This is a leak!\n") ; 
    273          break ; 
     393      g_warning ("unknown journal entry type. This is a leak!\n") ; 
     394      break ; 
    274395  } 
    275396  g_free (a_entry) ; 
     
    277398 
    278399static gboolean 
    279 moko_journal_entry_type_is_valid (MokoJournalEntryType a_type) 
     400moko_journal_entry_type_is_valid (enum MokoJournalEntryType a_type) 
    280401{ 
    281402  if (a_type > 0 && a_type < NB_OF_ENTRY_TYPES) 
     
    291412  icalproperty *prop = NULL ; 
    292413  gboolean result = FALSE ; 
     414  gchar *str=NULL ; 
     415  enum MessageDirection dir = DIRECTION_IN ; 
    293416 
    294417  g_return_val_if_fail (a_entry, FALSE) ; 
     
    315438  icalcomponent_add_property (comp, prop) ; 
    316439 
     440  /*add direction*/ 
     441  if (!moko_journal_entry_get_direction (a_entry, &dir)) 
     442  { 
     443    g_warning ("failed to get entry direction") ; 
     444    goto out ; 
     445  } 
     446  if (dir == DIRECTION_IN) 
     447  { 
     448    prop = icalproperty_new_x ("IN") ; 
     449  } 
     450  else 
     451  { 
     452    prop = icalproperty_new_x ("OUT") ; 
     453  } 
     454  icalproperty_set_x_name (prop, "X-OPENMOKO-ENTRY-DIRECTION") ; 
     455  icalcomponent_add_property (comp, prop) ; 
     456 
    317457  /*add dtstart*/ 
    318458  const MokoTime *date = moko_journal_entry_get_dtstart (a_entry) ; 
    319   prop = NULL ; 
    320459  if (!date) 
    321460    goto out ; 
    322  
    323461  prop = icalproperty_new_dtstart (date->t) ; 
    324462  icalcomponent_add_property (comp, prop) ; 
    325463 
     464  /*add location start*/ 
     465  struct icalgeotype geo; 
     466  if (moko_journal_entry_get_start_location (a_entry, (MokoLocation*)&geo)) 
     467  { 
     468    prop = icalproperty_new_geo (geo) ; 
     469    icalcomponent_add_property (comp, prop) ; 
     470  } 
     471 
     472  /*add source*/ 
     473  if (moko_journal_entry_get_source (a_entry)) 
     474    prop = icalproperty_new_x (moko_journal_entry_get_source (a_entry)) ; 
     475  else 
     476    prop = icalproperty_new_x ("null") ; 
     477  icalproperty_set_x_name (prop, "X-OPENMOKO-ENTRY-SOURCE") ; 
     478  icalcomponent_add_property (comp, prop) ; 
     479 
     480  /* 
     481   * add gsm location (pair of "local area code" and "cell id". 
     482   * gsm location is stored in an 
     483   * x-property named X-OPENMOKO-ENTRY-GSM-LOCATION that has the form: 
     484   * X-OPENMOKO-GSMLOCATION;LAC="<int16>";CID=<int 16>: dummy 
     485   */ 
     486  prop = icalproperty_new_x ("dummy") ; 
     487  icalproperty_set_x_name (prop, "X-OPENMOKO-ENTRY-GSM-LOCATION") ; 
     488  str = g_strdup_printf ("%d", a_entry->gsm_loc.lac); 
     489  icalproperty_set_parameter_from_string (prop, "X-LAC", str) ; 
     490  g_free (str) ; 
     491  str = g_strdup_printf ("%d", a_entry->gsm_loc.cid); 
     492  icalproperty_set_parameter_from_string (prop, "X-CID", str) ; 
     493  g_free (str) ; 
     494  icalcomponent_add_property (comp, prop) ; 
    326495  /*add entry type*/ 
    327496  prop = icalproperty_new_x 
     
    336505      return FALSE ; 
    337506    case EMAIL_JOURNAL_ENTRY: 
    338       { 
    339         MokoJournalEmailInfo *info=NULL ; 
    340         if (!moko_journal_entry_get_email_info (a_entry, &info) || !info) 
    341           goto out ; 
    342         if (moko_journal_email_info_get_was_sent (info)) 
    343           prop = icalproperty_new_x ("YES") ; 
    344         else 
    345           prop = icalproperty_new_x ("NO") ; 
    346         icalproperty_set_x_name (prop, "X-OPENMOKO-EMAIL-WAS-SENT") ; 
    347         icalcomponent_add_property (comp, prop) ; 
    348       } 
     507      break ; 
     508    case VOICE_JOURNAL_ENTRY: 
     509      break ; 
     510    case FAX_JOURNAL_ENTRY: 
     511      break ; 
     512    case DATA_JOURNAL_ENTRY: 
    349513      break ; 
    350514    case SMS_JOURNAL_ENTRY: 
    351       break ; 
    352     case MMS_JOURNAL_ENTRY: 
    353       break ; 
    354     case CALL_JOURNAL_ENTRY: 
    355515      break ; 
    356516    default: 
     
    373533 
    374534static gboolean 
    375 icalcomponent_to_j_entry (icalcomponent *a_comp, 
    376                           MokoJournalEntry **a_entry) 
    377 { 
    378   icalproperty *prop = NULL ; 
    379   gchar *prop_name = NULL ; 
    380   MokoJournalEntry *entry = NULL; 
     535icalcomponent_to_entry (icalcomponent *a_comp, 
     536                        MokoJournalEntry **a_entry) 
     537{ 
     538  icalproperty *prop=NULL ; 
     539  gchar *prop_name=NULL, *prop_value=NULL ; 
     540  MokoJournalEntry *entry=NULL; 
    381541 
    382542  g_return_val_if_fail (a_comp, FALSE) ; 
     
    386546  entry = moko_journal_entry_alloc () ; 
    387547 
    388   /*iterate through properties to scan core properties*/ 
     548  /*get the type*/ 
     549  if (icalcomponent_find_property_as_string (a_comp, "X-OPENMOKO-ENTRY-TYPE", 
     550                                             &prop_value)) 
     551  { 
     552    enum MokoJournalEntryType entry_type = UNDEF_ENTRY ; 
     553    if (!prop_value) 
     554    { 
     555      g_warning ("could not get entry type") ; 
     556      goto out ; 
     557    } 
     558    entry_type = entry_type_from_string (prop_value) ; 
     559    if (entry_type == UNDEF_ENTRY) 
     560    { 
     561      g_warning ("Could not recognize type of entry from: %s\n", prop_value); 
     562      goto out ; 
     563    } 
     564    entry->type = entry_type ; 
     565  } 
     566  /*make sure we got the type*/ 
     567  if (entry->type == UNDEF_ENTRY || entry->type >= NB_OF_ENTRY_TYPES) 
     568  { 
     569    g_warning ("bad entry type") ; 
     570    goto out ; 
     571  } 
     572 
     573  /*look for the x-properties we may have*/ 
     574  if (icalcomponent_find_property_as_string 
     575                                    (a_comp, "X-OPENMOKO-ENTRY-DIRECTION", 
     576                                     &prop_value)) 
     577  { 
     578    if (prop_value && !strcmp (prop_value, "IN")) 
     579      moko_journal_entry_set_direction (entry, DIRECTION_IN) ; 
     580    else 
     581      moko_journal_entry_set_direction (entry, DIRECTION_OUT) ; 
     582  } 
     583  if (icalcomponent_find_property_as_string 
     584                                    (a_comp, "X-OPENMOKO-ENTRY-SOURCE", 
     585                                     &prop_value)) 
     586  { 
     587    if (!prop_value || (prop_value && !strcmp (prop_value, "null"))) 
     588    { 
     589      moko_journal_entry_set_source (entry, NULL) ; 
     590    } 
     591    else 
     592    { 
     593      moko_journal_entry_set_source (entry, prop_value) ; 
     594    } 
     595  } 
     596 
     597  if (icalcomponent_find_property (a_comp, 
     598                                   "X-OPENMOKO-ENTRY-GSM-LOCATION", 
     599                                   &prop)) 
     600  { 
     601    if (prop ) 
     602    { 
     603      gchar *str=NULL ; 
     604      gint code=0 ; 
     605      str = (gchar*)icalproperty_get_parameter_as_string (prop, "X-LAC") ; 
     606      code = atoi (str) ; 
     607      entry->gsm_loc.lac = (gushort)code ; 
     608      str = (gchar*)icalproperty_get_parameter_as_string (prop, "X-CID") ; 
     609      code = atoi (str) ; 
     610      entry->gsm_loc.cid = (gushort)code ; 
     611    } 
     612  } 
     613 
     614 
     615  /*now iterate through properties to scan core properties*/ 
    389616  for (prop = icalcomponent_get_first_property (a_comp, ICAL_ANY_PROPERTY); 
    390617       prop ; 
     
    412639    { 
    413640      moko_journal_entry_set_dtstart 
    414       (entry, 
    415        moko_time_new_from_icaltimetype (icalproperty_get_dtstart (prop))); 
    416     } 
    417     else if (icalproperty_get_x_name (prop) 
    418              && !strcmp (icalproperty_get_x_name (prop), 
    419                          "X-OPENMOKO-ENTRY-TYPE")) 
    420     { 
    421       MokoJournalEntryType entry_type = UNDEF_ENTRY ; 
    422       const char *x_val = icalproperty_get_value_as_string (prop) ; 
    423       if (!x_val) 
    424         continue ; 
    425       entry_type = entry_type_from_string (x_val) ; 
    426       if (entry_type == UNDEF_ENTRY) 
    427       { 
    428         g_warning ("Could not recognize type of entry from: %s\n", x_val); 
    429         continue ; 
    430       } 
    431       entry->type = entry_type ; 
    432     } 
    433   } 
    434  
    435   if (entry->type == UNDEF_ENTRY || entry->type >= NB_OF_ENTRY_TYPES) 
    436   { 
    437     g_warning ("bad entry type") ; 
    438     goto out ; 
     641        (entry, 
     642         moko_time_new_from_icaltimetype (icalproperty_get_dtstart (prop))); 
     643    } 
     644    else if (icalproperty_isa (prop) == ICAL_GEO_PROPERTY) 
     645    { 
     646      struct icalgeotype geo = icalproperty_get_geo (prop); 
     647      moko_journal_entry_set_start_location (entry, (MokoLocation*)&geo) ; 
     648    } 
    439649  } 
    440650 
     
    442652  switch (entry->type) 
    443653  { 
     654    case VOICE_JOURNAL_ENTRY: 
     655      { 
     656      } 
     657      break ; 
     658    case FAX_JOURNAL_ENTRY: 
     659      break ; 
     660    case DATA_JOURNAL_ENTRY: 
     661      break ; 
     662    case SMS_JOURNAL_ENTRY: 
     663      break ; 
    444664    case EMAIL_JOURNAL_ENTRY: 
    445       { 
    446         MokoJournalEmailInfo *info=NULL ; 
    447         gchar *prop_value = NULL ; 
    448         if (!moko_journal_entry_get_email_info (entry, &info)) 
    449         { 
    450           g_warning ("failed to get email info") ; 
    451           goto out ; 
    452         } 
    453         if (icalcomponent_find_property_as_string 
    454                                             (a_comp, 
    455                                              "X-OPENMOKO-EMAIL-WAS-SENT", 
    456                                              &prop_value)) 
    457         { 
    458           if (prop_value && !strcmp (prop_value, "YES")) 
    459             moko_journal_email_info_set_was_sent (info, TRUE) ; 
    460           else 
    461             moko_journal_email_info_set_was_sent (info, FALSE) ; 
    462         } 
    463       } 
    464       break ; 
    465     case SMS_JOURNAL_ENTRY: 
    466       break ; 
    467     case MMS_JOURNAL_ENTRY: 
    468       break ; 
    469     case CALL_JOURNAL_ENTRY: 
    470665      break ; 
    471666    default: 
     
    9451140     */ 
    9461141    ical_comp = cur_entry->data ; 
    947     if (!icalcomponent_to_j_entry (ical_comp, &entry) || !entry) 
     1142    if (!icalcomponent_to_entry (ical_comp, &entry) || !entry) 
    9481143    { 
    9491144      if (entry) 
     
    9801175      if (!moko_journal_remove_entry_by_uid (a_journal, cur->data)) 
    9811176      { 
    982         g_message ("failed to remove entry of uid %s\n", cur->data) ; 
     1177        g_message ("failed to remove entry of uid %s\n", 
     1178                   (const char*)cur->data) ; 
    9831179      } 
    9841180    } 
     
    10611257      if (!icalcomponent_isa (cur->data)) 
    10621258        continue ; 
    1063       if (icalcomponent_to_j_entry (cur->data, &entry) && entry) 
     1259      if (icalcomponent_to_entry (cur->data, &entry) && entry) 
    10641260      { 
    10651261        moko_journal_add_entry (a_journal, entry) ; 
     
    10951291 */ 
    10961292MokoJournalEntry* 
    1097 moko_journal_entry_new (MokoJournalEntryType a_type) 
     1293moko_journal_entry_new (enum MokoJournalEntryType a_type) 
    10981294{ 
    10991295  MokoJournalEntry *result ; 
     
    11251321 * Return value: the type of the journal entry 
    11261322 */ 
    1127 MokoJournalEntryType 
     1323enum MokoJournalEntryType 
    11281324moko_journal_entry_get_type (MokoJournalEntry *a_entry) 
    11291325{ 
     
    11431339void 
    11441340moko_journal_entry_set_type (MokoJournalEntry *a_entry, 
    1145                              MokoJournalEntryType a_type) 
     1341                             enum MokoJournalEntryType a_type) 
    11461342{ 
    11471343  g_return_if_fail (a_entry) ; 
     
    12671463 
    12681464/** 
     1465 * moko_journal_entry_get_start_location: 
     1466 * @a_entry: the current instance of journal entry 
     1467 * @a_location: the requested location 
     1468 * 
     1469 * Get the location at which the message got received or sent. 
     1470 * 
     1471 * Returns: TRUE upon sucessful completion, FALSE otherwise. 
     1472 */ 
     1473gboolean 
     1474moko_journal_entry_get_start_location (MokoJournalEntry *a_entry, 
     1475                                       MokoLocation *a_location) 
     1476{ 
     1477  g_return_val_if_fail (a_entry, FALSE) ; 
     1478  g_return_val_if_fail (a_location, FALSE) ; 
     1479 
     1480  a_location->longitude = a_entry->start_longitude ; 
     1481  a_location->latitude = a_entry->start_latitude ; 
     1482 
     1483  return TRUE ; 
     1484} 
     1485 
     1486/** 
     1487 * moko_journal_entry_set_location: 
     1488 * @a_entry: the current intance of journal entry 
     1489 * @a_location: the new location 
     1490 * 
     1491 * Set a new location to the journal entry 
     1492 * Location represents the longitude/latitude at which a call or message 
     1493 * occured. 
     1494 * 
     1495 * Returns: TRUE upon successful completion, FALSE otherwise. 
     1496 */ 
     1497gboolean 
     1498moko_journal_entry_set_start_location (MokoJournalEntry *a_entry, 
     1499                                       MokoLocation *a_location) 
     1500{ 
     1501  g_return_val_if_fail (a_entry, FALSE) ; 
     1502  g_return_val_if_fail (a_location, FALSE) ; 
     1503 
     1504  a_entry->start_longitude = a_location->longitude ; 
     1505  a_entry->start_latitude = a_location->latitude ; 
     1506  return TRUE ; 
     1507} 
     1508 
     1509/** 
     1510 * moko_journal_entry_get_direction: 
     1511 * @entry: the current instance of journal entry 
     1512 * @direction: either DIRECTION_IN for a received message or DIRECTION_OUT 
     1513 * for a sent message. 
     1514 * 
     1515 * get the direction of the message 
     1516 * 
     1517 * Returns: TRUE in case of success, FALSE otherwise. 
     1518 */ 
     1519gboolean 
     1520moko_journal_entry_get_direction (MokoJournalEntry *a_entry, 
     1521                                  enum MessageDirection *a_direction) 
     1522{ 
     1523  g_return_val_if_fail (a_entry, FALSE) ; 
     1524  g_return_val_if_fail (a_direction, FALSE) ; 
     1525 
     1526  *a_direction = a_entry->direction ; 
     1527  return TRUE ; 
     1528} 
     1529 
     1530/** 
     1531 * moko_journal_entry_set_direction: 
     1532 * @entry: the current instance of journal entry 
     1533 * @direction: the new message direction to set 
     1534 * 
     1535 * set message direction 
     1536 * 
     1537 */ 
     1538void moko_journal_entry_set_direction (MokoJournalEntry *a_entry, 
     1539                                       enum MessageDirection direction) 
     1540{ 
     1541  g_return_if_fail (a_entry) ; 
     1542  g_return_if_fail (direction) ; 
     1543 
     1544  a_entry->direction = direction ; 
     1545} 
     1546 
     1547/** 
    12691548 * moko_journal_entry_set_dtstart: 
    12701549 * @entry: the current instance of journal entry 
     
    12841563  if (a_dtstart) 
    12851564    a_entry->dtstart = a_dtstart ; 
     1565} 
     1566 
     1567/** 
     1568 * moko_journal_entry_get_source: 
     1569 * @a_entry: the current instance of journal entry 
     1570 * 
     1571 * Returns: the source property. It is an arbitrary string representing 
     1572 * the application that was the source of the entry (like mokodialer) 
     1573 */ 
     1574const gchar* 
     1575moko_journal_entry_get_source (MokoJournalEntry *a_entry) 
     1576{ 
     1577  g_return_val_if_fail (a_entry, NULL) ; 
     1578 
     1579  return a_entry->source ; 
     1580} 
     1581 
     1582/** 
     1583 * moko_journal_entry_set_source: 
     1584 * @a_entry: the current instance of journal entry 
     1585 * @a_source: the new source to set 
     1586 * 
     1587 * Set the source property. It is an arbitrary string representing 
     1588 * the application that was the source of the entry (like mokodialer) 
     1589 */ 
     1590void 
     1591moko_journal_entry_set_source (MokoJournalEntry *a_entry, 
     1592                               const gchar *a_source) 
     1593{ 
     1594  g_return_if_fail (a_entry) ; 
     1595 
     1596  if (a_entry->source) 
     1597  { 
     1598    g_free (a_entry->source) ; 
     1599    a_entry->source = NULL ; 
     1600  } 
     1601  if (a_source) 
     1602    a_entry->source = g_strdup (a_source) ; 
     1603} 
     1604 
     1605/** 
     1606 * moko_journal_entry_set_gsm_location: 
     1607 * @a_entry: the current instance of voice call extra properties set 
     1608 * @a_location: the gsm location 
     1609 * 
     1610 * Returns: TRUE upon completion, FALSE otherwise 
     1611 */ 
     1612gboolean 
     1613moko_journal_entry_set_gsm_location (MokoJournalEntry *a_entry, 
     1614                                     MokoGSMLocation *a_location) 
     1615{ 
     1616  g_return_val_if_fail (a_entry, FALSE) ; 
     1617  g_return_val_if_fail (a_location, FALSE) ; 
     1618 
     1619  memcpy (&a_entry->gsm_loc, a_location, sizeof (MokoGSMLocation)) ; 
     1620  return TRUE ; 
     1621} 
     1622 
     1623/** 
     1624 * moko_journal_entry_get_gsm_location: 
     1625 * @a_entry: the current instance of voice call extra properties set 
     1626 * @a_location: the gsm location 
     1627 * 
     1628 * Returns TRUE upon completion, FALSE otherwise 
     1629 */ 
     1630gboolean 
     1631moko_journal_entry_get_gsm_location (MokoJournalEntry *a_info, 
     1632                                     MokoGSMLocation *a_location) 
     1633{ 
     1634  g_return_val_if_fail (a_info, FALSE) ; 
     1635  g_return_val_if_fail (a_info, FALSE) ; 
     1636 
     1637  memset (a_location, &a_info->gsm_loc, sizeof (MokoGSMLocation)) ; 
     1638  return TRUE ; 
     1639} 
     1640 
     1641/** 
     1642 * moko_journal_entry_get_voice_info: 
     1643 * @a_entry: the current instance of journal entry 
     1644 * @a_info: the extra property set or NULL if info is not of type 
     1645 * VOICE_JOURNAL_ENTRY 
     1646 * 
     1647 * Returns the specific property set associated to instance of MokoJournalEntry 
     1648 * of type VOICE_JOURNAL_ENTRY. 
     1649 * 
     1650 * Returns: TRUE upon successful completion, FALSE otherwise. 
     1651 */ 
     1652gboolean 
     1653moko_journal_entry_get_voice_info (MokoJournalEntry *a_entry, 
     1654                                   MokoJournalVoiceInfo **a_info) 
     1655{ 
     1656  g_return_val_if_fail (a_entry, FALSE) ; 
     1657  g_return_val_if_fail (a_entry->type == VOICE_JOURNAL_ENTRY, FALSE) ; 
     1658  g_return_val_if_fail (a_info, FALSE) ; 
     1659 
     1660  if (!a_entry->extra.voice_info) 
     1661  { 
     1662    a_entry->extra.voice_info = moko_journal_voice_info_new (); 
     1663  } 
     1664  g_return_val_if_fail (a_entry->extra.voice_info, FALSE) ; 
     1665  *a_info = a_entry->extra.voice_info ; 
     1666  return TRUE ; 
     1667} 
     1668 
     1669/** 
     1670 * moko_journal_entry_get_fax_info: 
     1671 * @entry: the current instance of journal entry 
     1672 * @info: the fax info properties set 
     1673 * 
     1674 * get the extra properties set associated to journal entries of 
     1675 * type FAX_JOURNAL_ENTRY 
     1676 * 
     1677 * Returns: TRUE in case of success, FALSE otherwise. 
     1678 */ 
     1679gboolean 
     1680moko_journal_entry_get_fax_info (MokoJournalEntry *a_entry, 
     1681                                 MokoJournalFaxInfo **a_info) 
     1682{ 
     1683  g_return_val_if_fail (a_entry, FALSE) ; 
     1684  g_return_val_if_fail (a_entry->type == FAX_JOURNAL_ENTRY, FALSE) ; 
     1685  g_return_val_if_fail (a_info, FALSE) ; 
     1686 
     1687  if (!a_entry->extra.fax_info) 
     1688  { 
     1689    a_entry->extra.fax_info = moko_journal_fax_info_new () ; 
     1690  } 
     1691  g_return_val_if_fail (a_entry->extra.fax_info, FALSE) ; 
     1692  *a_info = a_entry->extra.fax_info ; 
     1693  return FALSE ; 
     1694} 
     1695 
     1696/** 
     1697 * moko_journal_entry_get_data_info: 
     1698 * @a_entry: the current instance of journal entry 
     1699 * @a_info: the resulting properties set 
     1700 * 
     1701 * Get the extra properties set associated to journal entries of type 
     1702 * DATA_JOURNAL_ENTRY 
     1703 * 
     1704 * Returns: TRUE in case of success, FALSE otherwise. 
     1705 */ 
     1706gboolean moko_journal_entry_get_data_info (MokoJournalEntry *a_entry, 
     1707                                           MokoJournalDataInfo **a_info) 
     1708{ 
     1709  g_return_val_if_fail (a_entry, FALSE) ; 
     1710  g_return_val_if_fail (a_entry->type == DATA_JOURNAL_ENTRY, FALSE) ; 
     1711  g_return_val_if_fail (a_info, FALSE) ; 
     1712 
     1713  if (!a_entry->extra.data_info) 
     1714  { 
     1715    a_entry->extra.data_info = moko_journal_data_info_new () ; 
     1716  } 
     1717  g_return_val_if_fail (a_entry->extra.data_info, FALSE) ; 
     1718  *a_info = a_entry->extra.data_info ; 
     1719  return TRUE ; 
     1720} 
     1721 
     1722/** 
     1723 * moko_journal_entry_get_sms_info: 
     1724 * @a_entry: the current instance of journal entry 
     1725 * @a_info: the resulting properties set 
     1726 * 
     1727 * Get the extra properties set associated to journal entries of type 
     1728 * SMS_JOURNAL_ENTRY 
     1729 */ 
     1730gboolean 
     1731moko_journal_entry_get_sms_info (MokoJournalEntry *a_entry, 
     1732                                 MokoJournalSMSInfo **a_info) 
     1733{ 
     1734  g_return_val_if_fail (a_entry, FALSE) ; 
     1735  g_return_val_if_fail (a_entry->type == SMS_JOURNAL_ENTRY, FALSE) ; 
     1736  g_return_val_if_fail (a_info, FALSE) ; 
     1737 
     1738  if (a_entry->extra.sms_info) 
     1739  { 
     1740    a_entry->extra.sms_info = moko_journal_sms_info_new () ; 
     1741  } 
     1742  g_return_val_if_fail (a_entry->extra.sms_info, FALSE) ; 
     1743  *a_info = a_entry->extra.sms_info ; 
     1744  return TRUE ; 
    12861745} 
    12871746 
     
    13021761  g_return_val_if_fail (a_entry->type == EMAIL_JOURNAL_ENTRY, FALSE) ; 
    13031762 
    1304   if (!a_entry->extra_info.email_info) 
    1305   { 
    1306     a_entry->extra_info.email_info = moko_journal_email_info_new () ; 
    1307   } 
    1308   g_return_val_if_fail (a_entry->extra_info.email_info, FALSE) ; 
    1309  
    1310   *a_info = a_entry->extra_info.email_info ; 
     1763  if (!a_entry->extra.email_info) 
     1764  { 
     1765    a_entry->extra.email_info = moko_journal_email_info_new () ; 
     1766  } 
     1767  g_return_val_if_fail (a_entry->extra.email_info, FALSE) ; 
     1768 
     1769  *a_info = a_entry->extra.email_info ; 
    13111770  return TRUE ; 
    13121771} 
    13131772 
    1314 /** 
    1315  * moko_journal_email_info_get_was_sent: 
    1316  * @info: the current instance of email info 
    1317  * 
    1318  * Get a boolean property stating if the email was sent or received. 
    1319  * 
    1320  * Return value: TRUE if the email was sent, false if it was received 
    1321  */ 
    1322 gboolean 
    1323 moko_journal_email_info_get_was_sent (MokoJournalEmailInfo *a_info) 
    1324 { 
    1325   g_return_val_if_fail (a_info, FALSE) ; 
    1326   return a_info->was_sent ; 
    1327 } 
    1328  
    1329 /** 
    1330  * moko_journal_email_info_set_was_sent: 
    1331  * @info: the current instance of email info 
    1332  * @was_sent: TRUE if the email was sent, FALSE if it was received 
    1333  * 
    1334  * Set a boolean property stating if the email was sent or received 
    1335  */ 
    1336 void 
    1337 moko_journal_email_info_set_was_sent (MokoJournalEmailInfo *a_info, 
    1338                                 gboolean a_was_sent) 
    1339 { 
    1340   g_return_if_fail (a_info) ; 
    1341   a_info->was_sent = a_was_sent ; 
    1342 } 
    1343  
    13441773/*</public funcs>*/ 
Note: See TracChangeset for help on using the changeset viewer.