- Timestamp:
- 04/26/07 14:31:50 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007/openmoko-libs/libmokojournal/src/moko-journal.c
r1737 r1844 22 22 #include <strings.h> 23 23 #include <glib-object.h> 24 #include <libical/icaltypes.h> 24 25 #include <libecal/e-cal.h> 25 26 #include <libecal/e-cal-component.h> … … 35 36 }; 36 37 38 struct _MokoJournalVoiceInfo 39 { 40 int nothing ; 41 }; 42 43 struct _MokoJournalFaxInfo 44 { 45 int nothing ; 46 }; 47 48 struct _MokoJournalDataInfo 49 { 50 int nothing ; 51 }; 52 37 53 struct _MokoJournalEmailInfo 38 54 { 39 gboolean was_sent;55 int nothing ; 40 56 }; 41 57 58 struct _MokoJournalSMSInfo 59 { 60 int nothing ; 61 }; 62 42 63 struct _MokoJournalEntry 43 64 { 44 MokoJournalEntryType type;65 enum MokoJournalEntryType type; 45 66 gchar *uid ; 46 67 gchar *contact_uid ; 47 68 gchar *summary ; 69 enum MessageDirection direction ; 48 70 MokoTime *dtstart ; 49 71 MokoTime *dtend ; 72 float start_longitude ; 73 float start_latitude ; 74 gchar *source ; 75 MokoGSMLocation gsm_loc ; 50 76 union 51 77 { 52 78 MokoJournalEmailInfo *email_info ; 53 } extra_info ; 79 MokoJournalVoiceInfo *voice_info ; 80 MokoJournalFaxInfo *fax_info ; 81 MokoJournalDataInfo *data_info ; 82 MokoJournalSMSInfo *sms_info ; 83 } extra ; 54 84 }; 55 85 56 86 struct _MokoJournalEntryInfo 57 87 { 58 MokoJournalEntryType type;88 enum MokoJournalEntryType type; 59 89 const gchar *type_as_string ; 60 90 }; … … 63 93 static const MokoJournalEntryInfo entries_info[] = 64 94 { 95 {VOICE_JOURNAL_ENTRY, "VOICEENTRY"}, 65 96 {EMAIL_JOURNAL_ENTRY, "EMAILENTRY"}, 66 97 {SMS_JOURNAL_ENTRY, "SMSENTRY"}, 67 { MMS_JOURNAL_ENTRY, "MMSENTRY"},68 { CALL_JOURNAL_ENTRY, "CALLENTRY"},98 {FAX_JOURNAL_ENTRY, "FAXENTRY"}, 99 {DATA_JOURNAL_ENTRY, "DATAENTRY"}, 69 100 {0} 70 101 } ; 71 102 72 103 static MokoJournal* moko_journal_alloc () ; 104 static MokoJournalEmailInfo* moko_journal_email_info_new () ; 105 static MokoJournalVoiceInfo* moko_journal_voice_info_new () ; 106 static MokoJournalFaxInfo* moko_journal_fax_info_new () ; 107 static MokoJournalSMSInfo* moko_journal_sms_info_new () ; 108 static void moko_journal_voice_info_free (MokoJournalVoiceInfo *a_info) ; 109 static void moko_journal_fax_info_free (MokoJournalFaxInfo *a_info) ; 110 static void moko_journal_data_info_free (MokoJournalDataInfo *a_info) ; 111 static void moko_journal_email_info_free (MokoJournalEmailInfo *a_info) ; 112 static void moko_journal_sms_info_free (MokoJournalSMSInfo *a_info) ; 113 static MokoJournalDataInfo* moko_journal_data_info_new () ; 73 114 static gboolean moko_journal_find_entry_from_uid (MokoJournal *a_journal, 74 115 const gchar *a_uid, 75 116 MokoJournalEntry **a_entry, 76 117 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) ; 118 static const gchar* entry_type_to_string (enum MokoJournalEntryType a_type) ; 119 static enum MokoJournalEntryType entry_type_from_string (const gchar* a_str) ; 120 static gboolean moko_journal_entry_type_is_valid 121 (enum MokoJournalEntryType a_type) ; 80 122 static gboolean moko_journal_entry_to_icalcomponent (MokoJournalEntry *a_entry, 81 123 icalcomponent **a_comp) ; 82 static gboolean icalcomponent_to_ j_entry (icalcomponent *a_comp,124 static gboolean icalcomponent_to_entry (icalcomponent *a_comp, 83 125 MokoJournalEntry **a_entry) ; 84 126 static gboolean icalcomponent_find_property (const icalcomponent *a_comp, … … 99 141 100 142 static const gchar* 101 entry_type_to_string ( MokoJournalEntryType a_type)143 entry_type_to_string (enum MokoJournalEntryType a_type) 102 144 { 103 145 MokoJournalEntryInfo *cur ; … … 111 153 } 112 154 113 static MokoJournalEntryType155 static enum MokoJournalEntryType 114 156 entry_type_from_string (const gchar* a_str) 115 157 { … … 201 243 } 202 244 203 MokoJournalEmailInfo*245 static MokoJournalEmailInfo* 204 246 moko_journal_email_info_new () 205 247 { … … 207 249 } 208 250 209 void 251 static MokoJournalVoiceInfo* 252 moko_journal_voice_info_new () 253 { 254 return g_new0 (MokoJournalVoiceInfo, 1) ; 255 } 256 257 static MokoJournalFaxInfo* 258 moko_journal_fax_info_new () 259 { 260 return g_new0 (MokoJournalFaxInfo, 1) ; 261 } 262 263 static MokoJournalDataInfo* 264 moko_journal_data_info_new () 265 { 266 return g_new0 (MokoJournalDataInfo, 1) ; 267 } 268 269 static MokoJournalSMSInfo* 270 moko_journal_sms_info_new () 271 { 272 return g_new0 (MokoJournalSMSInfo, 1) ; 273 } 274 275 static void 210 276 moko_journal_email_info_free (MokoJournalEmailInfo *a_info) 211 277 { … … 214 280 } 215 281 282 static void 283 moko_journal_voice_info_free (MokoJournalVoiceInfo *a_info) 284 { 285 g_return_if_fail (a_info) ; 286 g_free (a_info) ; 287 } 288 289 static void 290 moko_journal_fax_info_free (MokoJournalFaxInfo *a_info) 291 { 292 g_return_if_fail (a_info) ; 293 g_free (a_info) ; 294 } 295 296 static void 297 moko_journal_data_info_free (MokoJournalDataInfo *a_info) 298 { 299 g_return_if_fail (a_info) ; 300 g_free (a_info) ; 301 } 302 303 static void 304 moko_journal_sms_info_free (MokoJournalSMSInfo *a_info) 305 { 306 g_return_if_fail (a_info) ; 307 g_free (a_info) ; 308 } 309 216 310 static MokoJournalEntry* 217 311 moko_journal_entry_alloc () … … 253 347 a_entry->dtend = NULL ; 254 348 } 349 if (a_entry->source) 350 { 351 g_free (a_entry->source) ; 352 a_entry->source = NULL ; 353 } 255 354 256 355 switch (a_entry->type) 257 356 { 258 357 case EMAIL_JOURNAL_ENTRY: 259 if (a_entry->extra _info.email_info)358 if (a_entry->extra.email_info) 260 359 { 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 ; 263 362 } 264 363 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 ; 265 385 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 ; 271 392 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 ; 274 395 } 275 396 g_free (a_entry) ; … … 277 398 278 399 static gboolean 279 moko_journal_entry_type_is_valid ( MokoJournalEntryType a_type)400 moko_journal_entry_type_is_valid (enum MokoJournalEntryType a_type) 280 401 { 281 402 if (a_type > 0 && a_type < NB_OF_ENTRY_TYPES) … … 291 412 icalproperty *prop = NULL ; 292 413 gboolean result = FALSE ; 414 gchar *str=NULL ; 415 enum MessageDirection dir = DIRECTION_IN ; 293 416 294 417 g_return_val_if_fail (a_entry, FALSE) ; … … 315 438 icalcomponent_add_property (comp, prop) ; 316 439 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 317 457 /*add dtstart*/ 318 458 const MokoTime *date = moko_journal_entry_get_dtstart (a_entry) ; 319 prop = NULL ;320 459 if (!date) 321 460 goto out ; 322 323 461 prop = icalproperty_new_dtstart (date->t) ; 324 462 icalcomponent_add_property (comp, prop) ; 325 463 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) ; 326 495 /*add entry type*/ 327 496 prop = icalproperty_new_x … … 336 505 return FALSE ; 337 506 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: 349 513 break ; 350 514 case SMS_JOURNAL_ENTRY: 351 break ;352 case MMS_JOURNAL_ENTRY:353 break ;354 case CALL_JOURNAL_ENTRY:355 515 break ; 356 516 default: … … 373 533 374 534 static 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;535 icalcomponent_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; 381 541 382 542 g_return_val_if_fail (a_comp, FALSE) ; … … 386 546 entry = moko_journal_entry_alloc () ; 387 547 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*/ 389 616 for (prop = icalcomponent_get_first_property (a_comp, ICAL_ANY_PROPERTY); 390 617 prop ; … … 412 639 { 413 640 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 } 439 649 } 440 650 … … 442 652 switch (entry->type) 443 653 { 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 ; 444 664 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_string454 (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 else461 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:470 665 break ; 471 666 default: … … 945 1140 */ 946 1141 ical_comp = cur_entry->data ; 947 if (!icalcomponent_to_ j_entry (ical_comp, &entry) || !entry)1142 if (!icalcomponent_to_entry (ical_comp, &entry) || !entry) 948 1143 { 949 1144 if (entry) … … 980 1175 if (!moko_journal_remove_entry_by_uid (a_journal, cur->data)) 981 1176 { 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) ; 983 1179 } 984 1180 } … … 1061 1257 if (!icalcomponent_isa (cur->data)) 1062 1258 continue ; 1063 if (icalcomponent_to_ j_entry (cur->data, &entry) && entry)1259 if (icalcomponent_to_entry (cur->data, &entry) && entry) 1064 1260 { 1065 1261 moko_journal_add_entry (a_journal, entry) ; … … 1095 1291 */ 1096 1292 MokoJournalEntry* 1097 moko_journal_entry_new ( MokoJournalEntryType a_type)1293 moko_journal_entry_new (enum MokoJournalEntryType a_type) 1098 1294 { 1099 1295 MokoJournalEntry *result ; … … 1125 1321 * Return value: the type of the journal entry 1126 1322 */ 1127 MokoJournalEntryType1323 enum MokoJournalEntryType 1128 1324 moko_journal_entry_get_type (MokoJournalEntry *a_entry) 1129 1325 { … … 1143 1339 void 1144 1340 moko_journal_entry_set_type (MokoJournalEntry *a_entry, 1145 MokoJournalEntryType a_type)1341 enum MokoJournalEntryType a_type) 1146 1342 { 1147 1343 g_return_if_fail (a_entry) ; … … 1267 1463 1268 1464 /** 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 */ 1473 gboolean 1474 moko_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 */ 1497 gboolean 1498 moko_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 */ 1519 gboolean 1520 moko_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 */ 1538 void 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 /** 1269 1548 * moko_journal_entry_set_dtstart: 1270 1549 * @entry: the current instance of journal entry … … 1284 1563 if (a_dtstart) 1285 1564 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 */ 1574 const gchar* 1575 moko_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 */ 1590 void 1591 moko_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 */ 1612 gboolean 1613 moko_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 */ 1630 gboolean 1631 moko_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 */ 1652 gboolean 1653 moko_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 */ 1679 gboolean 1680 moko_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 */ 1706 gboolean 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 */ 1730 gboolean 1731 moko_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 ; 1286 1745 } 1287 1746 … … 1302 1761 g_return_val_if_fail (a_entry->type == EMAIL_JOURNAL_ENTRY, FALSE) ; 1303 1762 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 ; 1311 1770 return TRUE ; 1312 1771 } 1313 1772 1314 /**1315 * moko_journal_email_info_get_was_sent:1316 * @info: the current instance of email info1317 *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 received1321 */1322 gboolean1323 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 info1332 * @was_sent: TRUE if the email was sent, FALSE if it was received1333 *1334 * Set a boolean property stating if the email was sent or received1335 */1336 void1337 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 1344 1773 /*</public funcs>*/
Note: See TracChangeset
for help on using the changeset viewer.
