From: Colin Leroy Date: Wed, 1 Nov 2006 21:48:45 +0000 (+0000) Subject: 2006-11-01 [colin] 2.5.6cvs18 X-Git-Tag: rel_2_6_0~5 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=db6a6c5262d20f0b7cd6b71b83759b2c19c4beba;hp=6ac7778ff00cfdd7a69030041d890ca97ab3a784 2006-11-01 [colin] 2.5.6cvs18 * src/jpilot.c Handle libpisock12 support. Probably fixes bug 1046, 'jpilot AddressDB.pdb import fail' --- diff --git a/ChangeLog b/ChangeLog index d3fe4cef5..d91633efa 100644 --- 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 diff --git a/PATCHSETS b/PATCHSETS index 10a1b0ec6..3737b46dd 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2020,3 +2020,4 @@ ( 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 diff --git a/configure.ac b/configure.ac index 588e209d8..02b3559a2 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/jpilot.c b/src/jpilot.c index 1762045ac..f3d43142a 100644 --- a/src/jpilot.c +++ b/src/jpilot.c @@ -41,10 +41,12 @@ # include # include # include +# include #else # include # include # include +# include #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 ); } /**