Hello,

on my way getting a resync between Evolution and Palm Tungsten E working
I applied some patches to plugins/palm_sync/src/vcard.c, perhaps these
are useful for others working with both evolution and palm devices?

Here are some comments, the full diff is at the end of the mail:

@@ -145,6 +146,9 @@

As described in my mail from 2004-01-05: Just take the summary of the
event as the description for the alarm (this is the default behaviour
from evolution).


@@ -693,12 +697,54 @@

(Be warned: I am very unexercised in programming in C (in general I use
java), so check my code. Perhaps the strncpy-stuff could be solved much
smarter using string functions from gtk-api?)

With this patch I generate a FN property within the vcard, simply by
combining firstname and lastname. This provides a better synchronization
with evolution!


@@ -743,8 +789,8 @@

Just swap the sequence of "WORK" and "FAX".


@@ -773,7 +819,7 @@

Put the streetname into "STREET" and not into "EXT ADD"


@@ -943,17 +989,22 @@

Now the values of the "ADR" property are used to fill the address fields
in palm's address db.


@@ -970,7 +1021,7 @@

Added "LABEL" to the list of ignored properties





Now the complete diff:


[EMAIL PROTECTED]:~/palmprg/multisync> cvs diff -uw plugins/palm_sync/src/vcard.c
Index: plugins/palm_sync/src/vcard.c
===================================================================
RCS file: /cvsroot/multisync/multisync/plugins/palm_sync/src/vcard.c,v
retrieving revision 1.16
diff -u -w -r1.16 vcard.c
--- plugins/palm_sync/src/vcard.c       29 Nov 2003 14:14:43 -0000      1.16
+++ plugins/palm_sync/src/vcard.c       25 Jan 2004 15:48:31 -0000
@@ -145,6 +146,9 @@
                                break;
                }

+                if (appointment.description)
+                       addPropValueO(prop, VCDescriptionPropO, 
appointment.description);
+
                prop = addPropValueO(prop, VCTriggerPropO, buffer);
                addPropValueO(prop, VCRelatedPropO, "START");
                addPropValueO(prop, VCValuePropO, "DURATION");
@@ -693,12 +697,54 @@
        GString *vcardstr;
        char *vcardptr;
        gchar *label = NULL;
+       int firstnamelength = 0, lastnamelength = 0;

        palm_debug(conn, 2, "Converting address to vcard");

        vcard = newVObjectO(VCCardPropO);
        addPropValueO(vcard, VCVersionPropO, "2.1");

+
+       if (address.entry[0])
+               lastnamelength = strlen(address.entry[0]);
+
+       if (address.entry[1])
+               firstnamelength= strlen(address.entry[1]);
+
+       // if we have first- or lastname compose a fullname
+       if (firstnamelength + lastnamelength > 0) {
+               char *tmp;
+               char *fname = NULL;
+
+               if (firstnamelength > 0) {
+                       // we have firstname, so allocate place for firstname, 
lastname, a space
+                       // and trailing zero (we don't need the space, if we have no 
lastname, but
+                       // I don't mind, do you?
+
+                       fname = malloc(firstnamelength + lastnamelength + 2);
+                       strncpy(fname, address.entry[1], firstnamelength + 1);
+
+                       if (lastnamelength > 0) {
+                               // now append lastname
+                               fname[firstnamelength] = ' ';
+                               strncpy(fname + firstnamelength + 1, address.entry[0], 
lastnamelength + 1);
+                       }
+               } else {
+                       // no firstname, so allocate place for lastname and trailing 
zero
+                       fname = malloc(lastnamelength + 1);
+                       strncpy(fname, address.entry[0], lastnamelength + 1);
+               }
+
+               // do the conversion and use converted string
+               tmp = g_convert(fname, strlen(fname), "utf8", "cp1252", NULL, NULL, 
NULL);
+               free(fname);
+               fname = tmp;
+
+               addPropValueO(vcard, VCFullNamePropO, fname);
+       }
+
+
+
        for (i = 0; i < 19; i++) {
                if (address.entry[i]) {
                        char *tmp;
@@ -743,8 +789,8 @@
                                                        break;
                                                case 2:
                                                        prop = addPropValueO(vcard, 
"TEL", address.entry[i]);
-                                                       addPropO(prop, "FAX");
                                                        addPropO(prop, "WORK");
+                                                       addPropO(prop, "FAX");
                                                        break;
                                                case 3:
                                                        prop = addPropValueO(vcard, 
"TEL", address.entry[i]);
@@ -773,7 +819,7 @@
                                                addrprop = addPropO(vcard, "ADR");
                                                addPropValueO(addrprop, "ENCODING", 
"QUOTED-PRINTABLE");
                                        }
-                                       addPropValueO(addrprop, "EXT ADD", 
address.entry[i]);
+                                       addPropValueO(addrprop, "STREET", 
address.entry[i]);
                                        break;
                                case 9:
                                        if (!addrprop) {
@@ -943,17 +989,22 @@
                        goto next;
                }

-               //Address
-               //TODO
-               if (!strcmp(attributes, "LABEL")) {
-                       if (isAPropertyOfO(v, "WORK"))
-                               entry->address.entry[8] = 
fakeCStringO(vObjectUStringZValueO(v));
-                       if (!entry->address.entry[8])
-                               entry->address.entry[8] = 
fakeCStringO(vObjectUStringZValueO(v));
-                       goto next;
-               }
-
                if (!strcmp(attributes, "ADR")) {
+                       if (prop = isAPropertyOfO(v, VCStreetAddressPropO)) {
+                               entry->address.entry[8] = 
fakeCStringO(vObjectUStringZValueO(prop));
+                       }
+                       if (prop = isAPropertyOfO(v, VCCityPropO)) {
+                               entry->address.entry[9] = 
fakeCStringO(vObjectUStringZValueO(prop));
+                       }
+                       if (prop = isAPropertyOfO(v, VCRegionPropO)) {
+                               entry->address.entry[10] = 
fakeCStringO(vObjectUStringZValueO(prop));
+                       }
+                       if (prop = isAPropertyOfO(v, VCPostalCodePropO)) {
+                               entry->address.entry[11] = 
fakeCStringO(vObjectUStringZValueO(prop));
+                       }
+                       if (prop = isAPropertyOfO(v, VCCountryNamePropO)) {
+                               entry->address.entry[12] = 
fakeCStringO(vObjectUStringZValueO(prop));
+                       }
                        goto next;
                }

@@ -970,7 +1021,7 @@
                }

                //Ignore these
-               if (!strcmp(attributes, "FN") || !strcmp(attributes, "VERSION") || 
!strcmp(attributes, "X-EVOLUTION-FILE-AS") || !strcmp(attributes, "UID"))
+               if (!strcmp(attributes, "LABEL") || !strcmp(attributes, "FN") || 
!strcmp(attributes, "VERSION") || !strcmp(attributes, "X-EVOLUTION-FILE-AS") || 
!strcmp(attributes, "UID"))
                        goto next;

                //Catch all


Regards,
Thomas
-- 
Thomas Stieler <[EMAIL PROTECTED]>



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Multisync-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/multisync-devel

Reply via email to