diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-20 07:36:35 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-20 07:36:35 +0800 |
commit | d56dbcd9247a965250888c0486464f976e668057 (patch) | |
tree | 9ad294f7fafd65cb7c531d11586a910806b39ef5 /addressbook/conduit/address-conduit.c | |
parent | 862d1f25dea4fde774aca9b8e849f22b2e0b9d93 (diff) | |
download | gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.gz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.bz2 gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.lz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.xz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.zst gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.zip |
Changed this to use ECardSimple.
2000-08-19 Christopher James Lahey <clahey@helixcode.com>
* conduit/address-conduit.c, conduit/address-conduit.h: Changed
this to use ECardSimple.
* contact-editor/e-contact-editor.c: Fixed a memory leak.
* gui/component/addressbook.c: Added stuff to the right click
menu. Activated the new search dialog that doesn't quite work
yet.
* gui/minicard/e-minicard-view.c: Fixed some run time warnings.
svn path=/trunk/; revision=4882
Diffstat (limited to 'addressbook/conduit/address-conduit.c')
-rw-r--r-- | addressbook/conduit/address-conduit.c | 154 |
1 files changed, 84 insertions, 70 deletions
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 0c79daaaee..d863d22af4 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -18,7 +18,6 @@ #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-standard-abs.h> #include <address-conduit.h> -#include <libversit/vcc.h> #include "ebook/e-book-types.h" #include <bonobo.h> @@ -275,93 +274,106 @@ static ECard * ecard_from_remote_record(AddressbookConduitContext *ctxt, PilotRecord *remote) { - ECard *ecard; struct Address address; - VObject *vobj; - VObject *nameprop, *addressprop; + ECard *ecard; + ECardSimple *simple; int i; - char *temp; + char *string; + char *stringparts[4]; + char *commaparts[3]; + char *spaceparts[3]; + char *commastring, *spacestring; g_return_val_if_fail(remote!=NULL,NULL); memset (&address, 0, sizeof (struct Address)); unpack_Address (&address, remote->record, remote->length); - - vobj = newVObject (VCCardProp); - nameprop = addProp (vobj, VCNameProp); - -#define ADD_PROP(v,pilotprop,vprop) \ - if (address.entry [(pilotprop)]) \ - addPropValue ((v), (vprop), address.entry [(pilotprop)]) - - ADD_PROP (nameprop, entryFirstname, VCGivenNameProp); - ADD_PROP (nameprop, entryLastname, VCFamilyNameProp); - - addressprop = addProp (vobj, VCAdrProp); - - ADD_PROP (addressprop, entryAddress, VCStreetAddressProp); - ADD_PROP (addressprop, entryCity, VCCityProp); - ADD_PROP (addressprop, entryState, VCRegionProp); - ADD_PROP (addressprop, entryZip, VCPostalCodeProp); - ADD_PROP (addressprop, entryCountry, VCCountryNameProp); - ADD_PROP (vobj, entryTitle, VCTitleProp); - if (address.entry [entryCompany]) { - VObject *orgprop; - orgprop = addProp (vobj, VCOrgProp); - ADD_PROP (orgprop, entryCompany, VCOrgNameProp); - } + ecard = e_card_new(""); + simple = e_card_simple_new(ecard); + +#define get(pilotprop) \ + (address.entry [(pilotprop)]) +#define check(pilotprop) \ + (address.entry [(pilotprop)] && *address.entry [(pilotprop)]) + + i = 0; + if (check(entryFirstname)) + stringparts[i++] = get(entryFirstname); + if (check(entryLastname)) + stringparts[i++] = get(entryLastname); + stringparts[i] = NULL; + string = g_strjoinv(" ", stringparts); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FULL_NAME, string); + g_free(string); + + i = 0; + if (check (entryAddress)) + spaceparts[i++] = get (entryAddress); + if (check (entryZip)) + spaceparts[i++] = get (entryZip); + spaceparts[i] = 0; + spacestring = g_strjoinv(" ", spaceparts); + + i = 0; + if (check (entryCity)) + commaparts[i++] = get (entryCity); + if (spacestring && *spacestring) + commaparts[i++] = spacestring; + commaparts[i] = 0; + commastring = g_strjoinv(", ", commaparts); + + i = 0; + if (check (entryAddress)) + stringparts[i++] = get (entryAddress); + if (commastring && *commastring) + stringparts[i++] = commastring; + if (check (entryCountry)) + stringparts[i++] = get (entryCountry); + stringparts[i] = NULL; + string = g_strjoinv("\n", stringparts); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ADDRESS_HOME, string); + + g_free(spacestring); + g_free(commastring); + g_free(string); + + if (check (entryTitle)) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_TITLE, get (entryTitle)); + + if (check (entryCompany)) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ORG, get (entryCompany)); for (i = entryPhone1; i <= entryPhone5; i ++) { - if (address.entry [i]) { + if (address.entry [i] && *(address.entry [i])) { char *phonelabel = ctxt->ai.phoneLabels[address.phoneLabel[i - entryPhone1]]; - if (!strcmp (phonelabel, "E-mail")) { - VObject *emailprop = addPropValue (vobj, - VCEmailAddressProp, - address.entry[i]); - addProp (emailprop, VCInternetProp); - } - else { - const char* phone_type = VCHomeProp; - VObject *phoneprop = addPropValue (vobj, - VCTelephoneProp, - address.entry[i]); - - printf ("added '%s' phone entry %s\n", - phonelabel, - address.entry[i]); - - if (!strcmp (phonelabel, "Home")) - phone_type = VCHomeProp; - else if (!strcmp (phonelabel, "Work")) - phone_type = VCWorkProp; - else if (!strcmp (phonelabel, "Fax")) - phone_type = VCFaxProp; - else if (!strcmp (phonelabel, "Other")) - phone_type = VCHomeProp; /* XXX */ - else if (!strcmp (phonelabel, "Main")) { /* XXX */ - addProp (phoneprop, VCHomeProp); - phone_type = VCPreferredProp; - } - else if (!strcmp (phonelabel, "Pager")) - phone_type = VCPagerProp; - else if (!strcmp (phonelabel, "Mobile")) - phone_type = VCCellularProp; - addProp (phoneprop, phone_type); - } + if (!strcmp (phonelabel, "E-mail")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_EMAIL, address.entry[i]); + else if (!strcmp (phonelabel, "Home")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_HOME, address.entry[i]); + else if (!strcmp (phonelabel, "Work")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, address.entry[i]); + else if (!strcmp (phonelabel, "Fax")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, address.entry[i]); + else if (!strcmp (phonelabel, "Other")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_OTHER, address.entry[i]); + else if (!strcmp (phonelabel, "Main")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, address.entry[i]); + else if (!strcmp (phonelabel, "Pager")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PAGER, address.entry[i]); + else if (!strcmp (phonelabel, "Mobile")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_MOBILE, address.entry[i]); } } -#undef ADD_PROP - - temp = writeMemVObject (NULL, NULL, vobj); - ecard = e_card_new (temp); - free (temp); - cleanVObject (vobj); +#undef get +#undef set free_Address(&address); gtk_object_set (GTK_OBJECT(ecard), "pilot_id", remote->ID, NULL); + gtk_object_unref(GTK_OBJECT(simple)); + return ecard; } @@ -1186,7 +1198,9 @@ conduit_get_gpilot_conduit (guint32 pilotId) printf ("in address's conduit_get_gpilot_conduit\n"); #ifdef NEED_OAF_INIT_HACK +#ifndef NO_WARNINGS #warning "need a better way to do this" +#endif /* we need to find wombat with oaf, so make sure oaf is initialized here. once the desktop is converted to oaf and gpilotd is built with oaf, this can go away */ |