From 6dc2652f706f148223bf921d77929bf7b607321c Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 20 Dec 2000 00:41:48 +0000 Subject: Remove pointless comment 2000-12-19 JP Rosevear * conduits/calendar/calendar-conduit.c: Remove pointless comment * conduits/todo/todo-conduit.c (is_empty_time): add utility function (comp_from_remote_record): use it 2000-12-19 JP Rosevear *conduit/address-conduit.c (ecard_from_remote_record): Convert pilot strings to utf for the e-cards. svn path=/trunk/; revision=7093 --- addressbook/ChangeLog | 5 ++ addressbook/conduit/address-conduit.c | 106 ++++++++++++++++---------- calendar/ChangeLog | 7 ++ calendar/conduits/calendar/calendar-conduit.c | 1 - calendar/conduits/todo/todo-conduit.c | 16 ++-- 5 files changed, 89 insertions(+), 46 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index af3bbbbabd..88b7961580 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,8 @@ +2000-12-19 JP Rosevear + + *conduit/address-conduit.c (ecard_from_remote_record): Convert + pilot strings to utf for the e-cards. + 2000-12-19 JP Rosevear * conduit/address-conduit.c (local_record_from_ecard): Convert ecard diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 87d95bd55a..909e4b20a9 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -245,6 +245,15 @@ map_name (EAddrConduitContext *ctxt) return filename; } +static char * +get_entry_text (struct Address address, int field) +{ + if (address.entry[field]) + return e_pilot_utf8_from_pchar (address.entry[field]); + + return strdup (""); +} + static void compute_status (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char *uid) { @@ -377,79 +386,96 @@ ecard_from_remote_record(EAddrConduitContext *ctxt, ECardSimple *simple; ECardDeliveryAddress delivery; char *string; - char *stringparts[4]; + char *stringparts[3]; int i; g_return_val_if_fail(remote!=NULL,NULL); memset (&address, 0, sizeof (struct Address)); unpack_Address (&address, remote->record, remote->length); - if (in_card == NULL) { + if (in_card == NULL) ecard = e_card_new(""); - } else { + else ecard = e_card_duplicate (in_card); - } simple = e_card_simple_new (ecard); -#define get(pilotprop) \ - (address.entry [(pilotprop)]) -#define check(pilotprop) \ - (address.entry [(pilotprop)] && *address.entry [(pilotprop)]) - + /* Name and company */ i = 0; - if (check(entryFirstname)) - stringparts[i++] = get(entryFirstname); - if (check(entryLastname)) - stringparts[i++] = get(entryLastname); + if (address.entry[entryFirstname] && *address.entry[entryFirstname]) + stringparts[i++] = address.entry[entryFirstname]; + if (address.entry[entryLastname] && *address.entry[entryLastname]) + stringparts[i++] = address.entry[entryLastname]; stringparts[i] = NULL; + string = g_strjoinv(" ", stringparts); - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FULL_NAME, string); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FULL_NAME, e_pilot_utf8_from_pchar (string)); g_free(string); - if (check (entryTitle)) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_TITLE, get (entryTitle)); + if (address.entry[entryTitle]) { + char *txt = get_entry_text (address, entryTitle); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_TITLE, txt); + free (txt); + } - if (check (entryCompany)) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ORG, get (entryCompany)); + if (address.entry[entryCompany]) { + char *txt = get_entry_text (address, entryCompany); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ORG, txt); + free (txt); + } + /* Address */ memset (&delivery, 0, sizeof (ECardDeliveryAddress)); delivery.flags = E_CARD_ADDR_HOME; - if (check (entryAddress)) - delivery.street = get (entryAddress); - if (check (entryCity)) - delivery.city = get (entryCity); - if (check (entryState)) - delivery.region = get (entryState); - if (check (entryCountry)) - delivery.country = get (entryCountry); - if (check (entryZip)) - delivery.code = get (entryZip); + if (address.entry[entryAddress]) + delivery.street = get_entry_text (address, entryAddress); + if (address.entry[entryCity]) + delivery.city = get_entry_text (address, entryCity); + if (address.entry[entryState]) + delivery.region = get_entry_text (address, entryState); + if (address.entry[entryCountry]) + delivery.country = get_entry_text (address, entryCountry); + if (address.entry[entryZip]) + delivery.code = address.entry[entryZip]; + string = e_card_delivery_address_to_string (&delivery); e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_ADDRESS_HOME, string); g_free (string); - + + if (address.entry[entryAddress]) + free (delivery.street); + if (address.entry[entryCity]) + free (delivery.city); + if (address.entry[entryState]) + free (delivery.region); + if (address.entry[entryCountry]) + free (delivery.country); + if (address.entry[entryZip]) + free (delivery.code); + + /* Phone numbers */ for (i = entryPhone1; i <= entryPhone5; i++) { char *phonelabel = ctxt->ai.phoneLabels[address.phoneLabel[i - entryPhone1]]; - + char *phonenum = get_entry_text (address, i); + if (!strcmp (phonelabel, "E-mail")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_EMAIL, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_EMAIL, phonenum); else if (!strcmp (phonelabel, "Home")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_HOME,address.entry[i] ? address.entry[i] : "" ); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_HOME, phonenum); else if (!strcmp (phonelabel, "Work")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, phonenum); else if (!strcmp (phonelabel, "Fax")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, phonenum); else if (!strcmp (phonelabel, "Other")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_OTHER, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_OTHER, phonenum); else if (!strcmp (phonelabel, "Main")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, phonenum); else if (!strcmp (phonelabel, "Pager")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PAGER, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PAGER, phonenum); else if (!strcmp (phonelabel, "Mobile")) - e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_MOBILE, address.entry[i] ? address.entry[i] : ""); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_MOBILE, phonenum); + + free (phonenum); } -#undef get -#undef check e_card_simple_sync_card (simple); gtk_object_unref(GTK_OBJECT(simple)); diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 3dd356e39d..fdba46e897 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2000-12-19 JP Rosevear + + * conduits/calendar/calendar-conduit.c: Remove pointless comment + + * conduits/todo/todo-conduit.c (is_empty_time): add utility function + (comp_from_remote_record): use it + 2000-12-19 JP Rosevear * conduits/calendar/calendar-conduit.c (local_record_from_comp): diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 45f4aa0a08..009b508399 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -248,7 +248,6 @@ get_pilot_day (icalrecurrencetype_weekday wd) } } -/* FIX ME Is there a better way to see if no start time set? */ static gboolean is_empty_time (struct tm time) { diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 09676cee73..7db0f39861 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -206,6 +206,16 @@ map_name (EToDoConduitContext *ctxt) return filename; } +static gboolean +is_empty_time (struct tm time) +{ + if (time.tm_sec || time.tm_min || time.tm_hour + || time.tm_mday || time.tm_mon || time.tm_year) + return FALSE; + + return TRUE; +} + static GList * next_changed_item (EToDoConduitContext *ctxt, GList *changes) { @@ -434,11 +444,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, cal_component_set_percent (comp, &percent); } - /* FIX ME This is a bit hackish, how else can we tell if there is - * no due date set? - */ - if (todo.due.tm_sec || todo.due.tm_min || todo.due.tm_hour - || todo.due.tm_mday || todo.due.tm_mon || todo.due.tm_year) { + if (is_empty_time (todo.due)) { due = icaltime_from_timet (mktime (&todo.due), FALSE, TRUE); dt.value = &due; cal_component_set_due (comp, &dt); -- cgit