2006-11-01 [colin] 2.5.6cvs18
authorColin Leroy <colin@colino.net>
Wed, 1 Nov 2006 21:48:45 +0000 (21:48 +0000)
committerColin Leroy <colin@colino.net>
Wed, 1 Nov 2006 21:48:45 +0000 (21:48 +0000)
* src/jpilot.c
Handle libpisock12 support. Probably
fixes bug 1046, 'jpilot AddressDB.pdb
import fail'

ChangeLog
PATCHSETS
configure.ac
src/jpilot.c

index d3fe4cef5aa0ba8274e3f41ab83851003b026160..d91633efa03237b9357b4a3ee67530a34fb3d555 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-01 [colin]     2.5.6cvs18
+
+       * src/jpilot.c
+               Handle libpisock12 support. Probably
+               fixes bug 1046, 'jpilot AddressDB.pdb 
+               import fail'
+
 2006-11-01 [colin]     2.5.6cvs17
 
        * src/folderutils.c
index 10a1b0ec626a4ba6c2a8a6920fd9a7155a2bf686..3737b46dd014d163a8ee91269d637d7b689bfca8 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.213.2.123 -r 1.213.2.124 src/folder.c;  cvs diff -u -r 1.87.2.31 -r 1.87.2.32 src/folder.h;  ) > 2.5.6cvs15.patchset
 ( cvs diff -u -r 1.5.10.3 -r 1.5.10.4 COPYING;  ) > 2.5.6cvs16.patchset
 ( cvs diff -u -r 1.3.2.12 -r 1.3.2.13 src/folderutils.c;  ) > 2.5.6cvs17.patchset
+( cvs diff -u -r 1.18.2.16 -r 1.18.2.17 src/jpilot.c;  ) > 2.5.6cvs18.patchset
index 588e209d8f000e3ed6330f0fe10e0b03622fb6d4..02b3559a29339d5a1f41751919fc1b276ff634cb 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=17
+EXTRA_VERSION=18
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -578,11 +578,11 @@ AC_ARG_ENABLE(jpilot,
 AC_MSG_CHECKING([whether to use JPilot])
 if test "$ac_cv_enable_jpilot" = yes; then
        AC_MSG_RESULT(yes)
-       AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h,
+       AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h pi-version.h,
                         [ AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ],
                         [ ac_cv_enable_jpilot=no ])
        if test "$ac_cv_enable_jpilot" = no; then
-               AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h,
+               AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h libpisock/pi-version.h,
                                 [ ac_cv_enable_jpilot=yes
                                   AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ])
        fi
index 1762045acd4a7a6591157ad30e90515e4e1e2dac..f3d43142a9b39c32ace2a436fed2106c338a1895 100644 (file)
 #  include <libpisock/pi-args.h>
 #  include <libpisock/pi-appinfo.h>
 #  include <libpisock/pi-address.h>
+#  include <libpisock/pi-version.h>
 #else
 #  include <pi-args.h>
 #  include <pi-appinfo.h>
 #  include <pi-address.h>
+#  include <pi-version.h>
 #endif
 
 #include "mgutils.h"
@@ -1144,122 +1146,136 @@ static void jpilot_load_address(
        struct AddressAppInfo *ai;
        gchar **firstName = NULL;
        gchar **lastName = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+       pi_buffer_t *RecordBuffer;
+#endif /* PILOT_LINK_0_12 */
 
        /* Retrieve address */
-       num = unpack_Address( & addr, buf->buf, buf->size );
-       if( num > 0 ) {
-               addrEnt = addr.entry;
-               attrib = buf->attrib;
-               unique_id = buf->unique_id;
-               cat_id = attrib & 0x0F;
+#if (PILOT_LINK_MAJOR < 12)
+       num = unpack_Address(&addr, buf->buf, buf->size);
+       if (num <= 0) {
+               return;
+       }
+#else /* PILOT_LINK_0_12 */
+       RecordBuffer = pi_buffer_new(buf->size);
+       memcpy(RecordBuffer->data, buf->buf, buf->size);
+       RecordBuffer->used = buf->size;
+       if (unpack_Address(&addr, RecordBuffer, address_v1) == -1) {
+               pi_buffer_free(RecordBuffer);
+               return;
+       }
+       pi_buffer_free(RecordBuffer);
+#endif
+       addrEnt = addr.entry;
+       attrib = buf->attrib;
+       unique_id = buf->unique_id;
+       cat_id = attrib & 0x0F;
 
-               *fullName = '\0';
+       *fullName = '\0';
+       if( addrEnt[ IND_LABEL_FIRSTNAME ] ) {
+               firstName = g_strsplit( addrEnt[ IND_LABEL_FIRSTNAME ], "\01", 2 );
+       }
 
-               if( addrEnt[ IND_LABEL_FIRSTNAME ] ) {
-                       firstName = g_strsplit( addrEnt[ IND_LABEL_FIRSTNAME ], "\01", 2 );
-               }
+       if( addrEnt[ IND_LABEL_LASTNAME ] ) {
+               lastName = g_strsplit( addrEnt[ IND_LABEL_LASTNAME ], "\01", 2 );
+       }
 
-               if( addrEnt[ IND_LABEL_LASTNAME ] ) {
-                       lastName = g_strsplit( addrEnt[ IND_LABEL_LASTNAME ], "\01", 2 );
-               }
+       if( name_order == FAMILY_LAST ) {
+               g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
+                           firstName ? firstName[0] : "",
+                           lastName ? lastName[0] : "" );
+       }
+       else {
+               g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
+                           lastName ? lastName[0] : "",
+                           firstName ? firstName[0] : "" );
+       }
 
-               if( name_order == FAMILY_LAST ) {
-                       g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
-                                   firstName ? firstName[0] : "",
-                                   lastName ? lastName[0] : "" );
-               }
-               else {
-                       g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
-                                   lastName ? lastName[0] : "",
-                                   firstName ? firstName[0] : "" );
-               }
+       if( firstName ) {
+               g_strfreev( firstName );
+       }
+       if( lastName ) {
+               g_strfreev( lastName );
+       }
 
-               if( firstName ) {
-                       g_strfreev( firstName );
-               }
-               if( lastName ) {
-                       g_strfreev( lastName );
-               }
+       g_strstrip( fullName );
 
-               g_strstrip( fullName );
+       if( convert_charcode ) {
+               gchar *nameConv;
+               nameConv = conv_codeset_strdup( fullName, 
+                               conv_get_locale_charset_str_no_utf8(), 
+                               CS_INTERNAL );
+               strncpy2( fullName, nameConv, FULLNAME_BUFSIZE );
+               g_free( nameConv );
+       }
 
-               if( convert_charcode ) {
-                       gchar *nameConv;
-                       nameConv = conv_codeset_strdup( fullName, 
-                                       conv_get_locale_charset_str_no_utf8(), 
-                                       CS_INTERNAL );
-                       strncpy2( fullName, nameConv, FULLNAME_BUFSIZE );
-                       g_free( nameConv );
-               }
+       person = addritem_create_item_person();
+       addritem_person_set_common_name( person, fullName );
+       addritem_person_set_first_name( person, addrEnt[ IND_LABEL_FIRSTNAME ] );
+       addritem_person_set_last_name( person, addrEnt[ IND_LABEL_LASTNAME ] );
+       addrcache_id_person( pilotFile->addressCache, person );
 
-               person = addritem_create_item_person();
-               addritem_person_set_common_name( person, fullName );
-               addritem_person_set_first_name( person, addrEnt[ IND_LABEL_FIRSTNAME ] );
-               addritem_person_set_last_name( person, addrEnt[ IND_LABEL_LASTNAME ] );
-               addrcache_id_person( pilotFile->addressCache, person );
+       extID = g_strdup_printf( "%d", unique_id );
+       addritem_person_set_external_id( person, extID );
+       g_free( extID );
+       extID = NULL;
 
-               extID = g_strdup_printf( "%d", unique_id );
-               addritem_person_set_external_id( person, extID );
-               g_free( extID );
-               extID = NULL;
+       /* Pointer to address metadata. */
+       ai = & pilotFile->addrInfo;
 
-               /* Pointer to address metadata. */
-               ai = & pilotFile->addrInfo;
+       /* Add entry for each email address listed under phone labels. */
+       indPhoneLbl = addr.phoneLabel;
+       for( k = 0; k < JPILOT_NUM_ADDR_PHONE; k++ ) {
+               gint ind;
 
-               /* Add entry for each email address listed under phone labels. */
-               indPhoneLbl = addr.phoneLabel;
-               for( k = 0; k < JPILOT_NUM_ADDR_PHONE; k++ ) {
-                       gint ind;
+               ind = indPhoneLbl[k];
+               /*
+               * fprintf( stdout, "%d : %d : %20s : %s\n", k, ind,
+               * ai->phoneLabels[ind], addrEnt[3+k] );
+               */
+               if( indPhoneLbl[k] == IND_PHONE_EMAIL ) {
+                       labelEntry = addrEnt[ OFFSET_PHONE_LABEL + k ];
+                       jpilot_parse_label( pilotFile, labelEntry, person );
+               }
+       }
+
+       /* Add entry for each custom label */
+       node = pilotFile->labelInd;
+       while( node ) {
+               gint ind;
 
-                       ind = indPhoneLbl[k];
+               ind = GPOINTER_TO_INT( node->data );
+               if( ind > -1 ) {
                        /*
-                       * fprintf( stdout, "%d : %d : %20s : %s\n", k, ind,
-                       * ai->phoneLabels[ind], addrEnt[3+k] );
+                       * fprintf( stdout, "%d : %20s : %s\n", ind, ai->labels[ind],
+                       * addrEnt[ind] );
                        */
-                       if( indPhoneLbl[k] == IND_PHONE_EMAIL ) {
-                               labelEntry = addrEnt[ OFFSET_PHONE_LABEL + k ];
-                               jpilot_parse_label( pilotFile, labelEntry, person );
-                       }
+                       labelEntry = addrEnt[ind];
+                       jpilot_parse_label( pilotFile, labelEntry, person );
                }
 
-               /* Add entry for each custom label */
-               node = pilotFile->labelInd;
-               while( node ) {
-                       gint ind;
-
-                       ind = GPOINTER_TO_INT( node->data );
-                       if( ind > -1 ) {
-                               /*
-                               * fprintf( stdout, "%d : %20s : %s\n", ind, ai->labels[ind],
-                               * addrEnt[ind] );
-                               */
-                               labelEntry = addrEnt[ind];
-                               jpilot_parse_label( pilotFile, labelEntry, person );
-                       }
-
-                       node = g_list_next( node );
-               }
+               node = g_list_next( node );
+       }
 
-               if( person->listEMail ) {
-                       if( cat_id > -1 && cat_id < JPILOT_NUM_CATEG ) {
-                               /* Add to specified category */
-                               addrcache_folder_add_person(
-                                       pilotFile->addressCache,
-                                       folderInd[cat_id], person );
-                       }
-                       else {
-                               /* Add to root folder */
-                               addrcache_add_person(
-                                       pilotFile->addressCache, person );
-                       }
+       if( person->listEMail ) {
+               if( cat_id > -1 && cat_id < JPILOT_NUM_CATEG ) {
+                       /* Add to specified category */
+                       addrcache_folder_add_person(
+                               pilotFile->addressCache,
+                               folderInd[cat_id], person );
                }
                else {
-                       addritem_free_item_person( person );
-                       person = NULL;
+                       /* Add to root folder */
+                       addrcache_add_person(
+                               pilotFile->addressCache, person );
                }
-               /* Free up pointer allocated inside address */
-               free_Address( & addr );
        }
+       else {
+               addritem_free_item_person( person );
+               person = NULL;
+       }
+       /* Free up pointer allocated inside address */
+       free_Address( & addr );
 }
 
 /**