Files | |
file | qof-address.c |
QOF address definitions for pilot-link. | |
file | qof-address.h |
QOF address definitions for pilot-link. | |
Data Structures | |
struct | QofAddress |
Example of QOF wrapping an existing object. More... | |
Packing and unpacking objects. | |
Each pilot-link object has a structure that reflects the relevant database on the Palm in a binary form that can be easily manipulated. This binary format needs to be converted (packed) before it can be understood by the Palm and converted back (unpacked) before to be usable in pilot-qof. Each object therefore needs to be packed (prior to writing to the Palm) and unpacked (after reading from the Palm) using it's own specialised functions. QOF uses a generic function pointer to call the correct function for the current QOF object and this function then calls the correct pack or unpack function for the underlying pilot-link object. | |
static gint | address_pack (QofEntity *ent, gpointer user_data) |
Pack an Address object for the Palm. | |
static gint | address_unpack (QofEntity *ent, gpointer user_data) |
Unpack and Address object from the Palm. | |
static gint | addr_appinfo_unpack (QofEntity *ent, gpointer user_data) |
unpack the application information from the Palm database. | |
static gint | qof_address_free (QofEntity *ent, gpointer user_data) |
free the memory associated with the pilot-link object. | |
Defines | |
#define | ADDRESS_VERSION address_v1 |
#define | QOF_ADDRESS_DESC "Pilot-link QOF address" |
#define | PQ_MOD_ADDRESS "pilotqof-address" |
#define | PILOT_LINK_QOF_ADDRESS "pilot_address" |
#define | ADDR_LAST_NAME "entryLastname" |
#define | ADDR_FIRST_NAME "entryFirstname" |
#define | ADDR_COMPANY "entryCompany" |
#define | ADDR_PHONE_ONE "entryPhone1" |
#define | ADDR_PHONE_TWO "entryPhone2" |
#define | ADDR_PHONE_THREE "entryPhone3" |
#define | ADDR_PHONE_FOUR "entryPhone4" |
#define | ADDR_PHONE_FIVE "entryPhone5" |
#define | ADDR_ADDRESS "entryAddress" |
#define | ADDR_CITY "entryCity" |
#define | ADDR_STATE "entryState" |
#define | ADDR_ZIP "entryZip" |
#define | ADDR_COUNTRY "entryCountry" |
#define | ADDR_TITLE "entryTitle" |
#define | ADDR_CUSTOM_ONE "entryCustom1" |
#define | ADDR_CUSTOM_TWO "entryCustom2" |
#define | ADDR_CUSTOM_THREE "entryCustom3" |
#define | ADDR_CUSTOM_FOUR "entryCustom4" |
#define | ADDR_NOTE "entryNote" |
#define | ADDR_CATEGORY "category" |
Functions | |
static QofAddress * | address_create (QofBook *book) |
create a new address | |
static gchar * | addr_getLastname (QofAddress *a) |
static gchar * | addr_getFirstname (QofAddress *a) |
static gchar * | addr_getCompany (QofAddress *a) |
static gchar * | addr_getPhoneOne (QofAddress *a) |
static gchar * | addr_getPhoneTwo (QofAddress *a) |
static gchar * | addr_getPhoneThree (QofAddress *a) |
static gchar * | addr_getPhoneFour (QofAddress *a) |
static gchar * | addr_getPhoneFive (QofAddress *a) |
static gchar * | addr_getCity (QofAddress *a) |
static gchar * | addr_getState (QofAddress *a) |
static gchar * | addr_getZip (QofAddress *a) |
static gchar * | addr_getCountry (QofAddress *a) |
static gchar * | addr_getTitle (QofAddress *a) |
static gchar * | addr_getAddress (QofAddress *a) |
static gchar * | addr_getCustomOne (QofAddress *a) |
static gchar * | addr_getCustomTwo (QofAddress *a) |
static gchar * | addr_getCustomThree (QofAddress *a) |
static gchar * | addr_getCustomFour (QofAddress *a) |
static gchar * | addr_getNote (QofAddress *a) |
static gchar * | addr_getCategory (QofAddress *a) |
static void | addr_setLastname (QofAddress *a, gchar *h) |
static void | addr_setFirstname (QofAddress *a, gchar *h) |
static void | addr_setCompany (QofAddress *a, gchar *h) |
static void | addr_setPhoneOne (QofAddress *a, gchar *h) |
static void | addr_setPhoneTwo (QofAddress *a, gchar *h) |
static void | addr_setPhoneThree (QofAddress *a, gchar *h) |
static void | addr_setPhoneFour (QofAddress *a, gchar *h) |
static void | addr_setPhoneFive (QofAddress *a, gchar *h) |
static void | addr_setAddress (QofAddress *a, gchar *h) |
static void | addr_setCity (QofAddress *a, gchar *h) |
static void | addr_setState (QofAddress *a, gchar *h) |
static void | addr_setZip (QofAddress *a, gchar *h) |
static void | addr_setCountry (QofAddress *a, gchar *h) |
static void | addr_setTitle (QofAddress *a, gchar *h) |
static void | addr_setCustomOne (QofAddress *a, gchar *h) |
static void | addr_setCustomTwo (QofAddress *a, gchar *h) |
static void | addr_setCustomThree (QofAddress *a, gchar *h) |
static void | addr_setCustomFour (QofAddress *a, gchar *h) |
static void | addr_setNote (QofAddress *a, gchar *h) |
static void | addr_setCategory (QofAddress *a, gchar *h) |
gboolean | AddressRegister (void) |
Extended for pilot-link. | |
Variables | |
static QofLogModule | log_module = "pilotqof-objects" |
#define ADDR_LAST_NAME "entryLastname" |
Hack alert: Because these are strings (for QOF), the macros CANNOT be used directly in the enum!
Definition at line 44 of file qof-address.h.
Referenced by AddressRegister().
static gint addr_appinfo_unpack | ( | QofEntity * | ent, | |
gpointer | user_data | |||
) | [static] |
unpack the application information from the Palm database.
The application information contains the list of category names and other elements that are consistent for all records in the database.
Definition at line 577 of file qof-address.c.
References PQContext_s::app_buf, PQContext_s::names, PQContext_s::pi_cat, and PQ_DEF_BUFSZ.
00578 { 00579 AddressAppInfo_t app_a; 00580 PQContext *context; 00581 gint name_count; 00582 00583 /* There is never an entity at this stage */ 00584 context = (PQContext *) user_data; 00585 g_return_val_if_fail (context != NULL, -1); 00586 ENTER (" "); 00587 unpack_AddressAppInfo (&app_a, context->app_buf->data, PQ_DEF_BUFSZ); 00588 for (name_count = 0; name_count < 16; name_count++) 00589 { 00590 g_sprintf (context->names[name_count], "%s", 00591 app_a.category.name[name_count]); 00592 } 00593 context->pi_cat = &app_a.category; 00594 LEAVE (" "); 00595 return 0; 00596 }
static QofAddress* address_create | ( | QofBook * | book | ) | [static] |
create a new address
Hack alert: This routine specifically sets a blank value in entry[19] - using g_new0() externally is not the same.
Definition at line 63 of file qof-address.c.
References QofAddress::inst, PILOT_LINK_QOF_ADDRESS, and QofAddress::wrap.
00064 { 00065 Address_t *qa; 00066 QofAddress *obj; 00067 QofCollection *coll; 00068 GList *all; 00069 00070 obj = g_new0 (QofAddress, 1); 00071 qof_instance_init (&obj->inst, PILOT_LINK_QOF_ADDRESS, book); 00072 coll = qof_book_get_collection (book, PILOT_LINK_QOF_ADDRESS); 00073 all = qof_collection_get_data (coll); 00074 all = g_list_prepend (all, obj); 00075 qof_collection_set_data (coll, all); 00076 qa = &obj->wrap; 00077 qa->entry[19] = strdup (""); 00078 return obj; 00079 }
static gint address_pack | ( | QofEntity * | ent, | |
gpointer | user_data | |||
) | [static] |
Pack an Address object for the Palm.
Convert the pilot-link object into a form suitable for HotSync to the Palm.
Definition at line 525 of file qof-address.c.
References ADDRESS_VERSION, PQContext_s::pi_buf, and QofAddress::wrap.
00526 { 00527 PQContext *context; 00528 Address_t *qa; 00529 QofAddress *obj; 00530 gint size; 00531 00532 size = 0; 00533 context = (PQContext *) user_data; 00534 g_return_val_if_fail ((context || ent), -1); 00535 obj = (QofAddress *) ent; 00536 qa = &obj->wrap; 00537 size = pack_Address (qa, context->pi_buf, ADDRESS_VERSION); 00538 PINFO (" result=%d", size); 00539 return size; 00540 }
static gint address_unpack | ( | QofEntity * | ent, | |
gpointer | user_data | |||
) | [static] |
Unpack and Address object from the Palm.
Convert the record read from the Palm HotSync into a usable pilot-link object - itself contained within a QOF object.
Definition at line 549 of file qof-address.c.
References addr_setCategory(), ADDRESS_VERSION, PQContext_s::ent_category, PQContext_s::names, PQContext_s::pi_buf, PQContext_s::pi_cat, and QofAddress::wrap.
00550 { 00551 pi_buffer_t *pi_buf; 00552 Address_t *qa; 00553 PQContext *context; 00554 QofAddress *obj; 00555 gint size; 00556 00557 context = (PQContext *) user_data; 00558 g_return_val_if_fail (context != NULL, -1); 00559 g_return_val_if_fail (ent != NULL, -1); 00560 obj = (QofAddress *) ent; 00561 qa = &obj->wrap; 00562 pi_buf = (pi_buffer_t *) context->pi_buf; 00563 size = 0; 00564 size = unpack_Address (qa, pi_buf, ADDRESS_VERSION); 00565 PINFO (" category=%s", context->pi_cat->name[context->ent_category]); 00566 addr_setCategory (obj, context->names[context->ent_category]); 00567 return size; 00568 }
gboolean AddressRegister | ( | void | ) |
Extended for pilot-link.
Uses the standard QOF registration but adds a pilot_pack registration that tells QOF how to deal with the pilot-link objects contained within the QOF objects.
Definition at line 663 of file qof-address.c.
References ADDR_ADDRESS, ADDR_CATEGORY, ADDR_CITY, ADDR_COMPANY, ADDR_COUNTRY, ADDR_CUSTOM_FOUR, ADDR_CUSTOM_ONE, ADDR_CUSTOM_THREE, ADDR_CUSTOM_TWO, ADDR_FIRST_NAME, addr_getAddress(), addr_getCategory(), addr_getCity(), addr_getCompany(), addr_getCountry(), addr_getCustomFour(), addr_getCustomOne(), addr_getCustomThree(), addr_getCustomTwo(), addr_getFirstname(), addr_getLastname(), addr_getNote(), addr_getPhoneFive(), addr_getPhoneFour(), addr_getPhoneOne(), addr_getPhoneThree(), addr_getPhoneTwo(), addr_getState(), addr_getTitle(), addr_getZip(), ADDR_LAST_NAME, ADDR_NOTE, ADDR_PHONE_FIVE, ADDR_PHONE_FOUR, ADDR_PHONE_ONE, ADDR_PHONE_THREE, ADDR_PHONE_TWO, addr_setAddress(), addr_setCategory(), addr_setCity(), addr_setCompany(), addr_setCountry(), addr_setCustomFour(), addr_setCustomOne(), addr_setCustomThree(), addr_setCustomTwo(), addr_setFirstname(), addr_setLastname(), addr_setNote(), addr_setPhoneFive(), addr_setPhoneFour(), addr_setPhoneOne(), addr_setPhoneThree(), addr_setPhoneTwo(), addr_setState(), addr_setTitle(), addr_setZip(), ADDR_STATE, ADDR_TITLE, ADDR_ZIP, address_object_def, address_pack_def, PILOT_LINK_QOF_ADDRESS, and pilot_qof_pack_register().
Referenced by pilot_qof_init().
00664 { 00665 static QofParam params[] = { 00666 {ADDR_LAST_NAME, QOF_TYPE_STRING, (QofAccessFunc) addr_getLastname, 00667 (QofSetterFunc) addr_setLastname}, 00668 {ADDR_FIRST_NAME, QOF_TYPE_STRING, 00669 (QofAccessFunc) addr_getFirstname, 00670 (QofSetterFunc) addr_setFirstname}, 00671 {ADDR_COMPANY, QOF_TYPE_STRING, (QofAccessFunc) addr_getCompany, 00672 (QofSetterFunc) addr_setCompany}, 00673 {ADDR_PHONE_ONE, QOF_TYPE_STRING, (QofAccessFunc) addr_getPhoneOne, 00674 (QofSetterFunc) addr_setPhoneOne}, 00675 {ADDR_PHONE_TWO, QOF_TYPE_STRING, (QofAccessFunc) addr_getPhoneTwo, 00676 (QofSetterFunc) addr_setPhoneTwo}, 00677 {ADDR_PHONE_THREE, QOF_TYPE_STRING, 00678 (QofAccessFunc) addr_getPhoneThree, 00679 (QofSetterFunc) addr_setPhoneThree}, 00680 {ADDR_PHONE_FOUR, QOF_TYPE_STRING, 00681 (QofAccessFunc) addr_getPhoneFour, 00682 (QofSetterFunc) addr_setPhoneFour}, 00683 {ADDR_PHONE_FIVE, QOF_TYPE_STRING, 00684 (QofAccessFunc) addr_getPhoneFive, 00685 (QofSetterFunc) addr_setPhoneFive}, 00686 {ADDR_ADDRESS, QOF_TYPE_STRING, (QofAccessFunc) addr_getAddress, 00687 (QofSetterFunc) addr_setAddress}, 00688 {ADDR_CITY, QOF_TYPE_STRING, (QofAccessFunc) addr_getCity, 00689 (QofSetterFunc) addr_setCity}, 00690 {ADDR_STATE, QOF_TYPE_STRING, (QofAccessFunc) addr_getState, 00691 (QofSetterFunc) addr_setState}, 00692 {ADDR_ZIP, QOF_TYPE_STRING, (QofAccessFunc) addr_getZip, 00693 (QofSetterFunc) addr_setZip}, 00694 {ADDR_COUNTRY, QOF_TYPE_STRING, (QofAccessFunc) addr_getCountry, 00695 (QofSetterFunc) addr_setCountry}, 00696 {ADDR_TITLE, QOF_TYPE_STRING, (QofAccessFunc) addr_getTitle, 00697 (QofSetterFunc) addr_setTitle}, 00698 {ADDR_CUSTOM_ONE, QOF_TYPE_STRING, 00699 (QofAccessFunc) addr_getCustomOne, 00700 (QofSetterFunc) addr_setCustomOne}, 00701 {ADDR_CUSTOM_TWO, QOF_TYPE_STRING, 00702 (QofAccessFunc) addr_getCustomTwo, 00703 (QofSetterFunc) addr_setCustomTwo}, 00704 {ADDR_CUSTOM_THREE, QOF_TYPE_STRING, 00705 (QofAccessFunc) addr_getCustomThree, 00706 (QofSetterFunc) addr_setCustomThree}, 00707 {ADDR_CUSTOM_FOUR, QOF_TYPE_STRING, 00708 (QofAccessFunc) addr_getCustomFour, 00709 (QofSetterFunc) addr_setCustomFour}, 00710 {ADDR_NOTE, QOF_TYPE_STRING, (QofAccessFunc) addr_getNote, 00711 (QofSetterFunc) addr_setNote}, 00712 {ADDR_CATEGORY, QOF_TYPE_STRING, (QofAccessFunc) addr_getCategory, 00713 (QofSetterFunc) addr_setCategory}, 00714 {QOF_PARAM_BOOK, QOF_ID_BOOK, 00715 (QofAccessFunc) qof_instance_get_book, NULL}, 00716 {QOF_PARAM_GUID, QOF_TYPE_GUID, 00717 (QofAccessFunc) qof_instance_get_guid, NULL}, 00718 {NULL}, 00719 }; 00720 00721 qof_class_register (PILOT_LINK_QOF_ADDRESS, NULL, params); 00722 00723 pilot_qof_pack_register (&address_pack_def); 00724 00725 return qof_object_register (&address_object_def); 00726 }
static gint qof_address_free | ( | QofEntity * | ent, | |
gpointer | user_data | |||
) | [static] |
free the memory associated with the pilot-link object.
Use specialised pilot-link functions to free the underlying object. The QOF entity can then be freed without problems.
Definition at line 604 of file qof-address.c.
References QofAddress::wrap.
00605 { 00606 Address_t *qa; 00607 QofAddress *obj; 00608 00609 g_return_val_if_fail (ent != NULL, -1); 00610 ENTER (" "); 00611 obj = (QofAddress *) ent; 00612 qa = &obj->wrap; 00613 free_Address (qa); 00614 LEAVE (" "); 00615 return 0; 00616 }