Home | History | Annotate | Download | only in patches
      1 --- acinclude.m4-orig	2006-11-17 15:22:46.943233000 +0800
      2 +++ acinclude.m4	2006-11-17 14:08:23.872472000 +0800
      3 @@ -268,3 +268,119 @@
      4    AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
      5    AM_CONDITIONAL(GTK_DOC_USE_LIBTOOL, test -n "$LIBTOOL")
      6  ])
      7 +
      8 +# PILOT_LINK_CHECK
      9 +# Adds --with-pisock and determines the verion of the pisock
     10 +#
     11 +
     12 +AC_SUBST(PISOCK_CFLAGS)
     13 +AC_SUBST(PISOCK_LIBS)
     14 +
     15 +AC_DEFUN([PILOT_LINK_HOOK],[
     16 +	AC_ARG_WITH(pisock,
     17 +	[  --with-pisock            Specify prefix for pisock files],[
     18 +	if test x$withval = xyes; then
     19 +	    dnl Note that an empty true branch is not valid sh syntax.
     20 +	    ifelse([$1], [], :, [$1])
     21 +	else
     22 +	    PISOCK_CFLAGS="-I$withval/include"
     23 +	    incdir="$withval/include"
     24 +	    PISOCK_LIBS="-L$withval/lib -lpisock -lpisync"
     25 +	    AC_MSG_CHECKING("for existance of $withval/lib/libpisock.so")
     26 +	    if test -r $withval/lib/libpisock.so; then
     27 +		AC_MSG_RESULT(yes)
     28 +	    else
     29 +		AC_MSG_ERROR([Unable to find libpisock. Try  http://www.pilot-link.org.])
     30 +	    fi
     31 +	fi
     32 +	])
     33 +
     34 +	if test x$PISOCK_CFLAGS = x; then
     35 +	    AC_CHECK_HEADER(pi-version.h, [incdir="/usr/include"], [
     36 +	    AC_CHECK_HEADER(libpisock/pi-version.h, [PISOCK_CFLAGS="-I/usr/include/libpisock"
     37 +	                                             piversion_include="libpisock/pi-version.h"
     38 +						     incdir="/usr/include/libpisock"
     39 +                                                    ], [
     40 +	    AC_CHECK_HEADER($prefix/include/pi-version.h, [PISOCK_CFLAGS="-I$prefix/include/libpisock"
     41 +	                                                   piversion_include="$prefix/include/pi-version.h"
     42 +						           if test x$PISOCK_LIBDIR = x; then
     43 +							      incdir="$prefix/include"
     44 +							      PISOCK_LIBS="-L$prefix/lib -lpisock -lpisync"
     45 +                                                           fi							  ],
     46 +	    AC_MSG_ERROR([Unable to find pi-version.h])) 
     47 +	    ])
     48 +	    ])
     49 +	fi
     50 +		
     51 +	if test "x$PISOCK_LIBS" = "x"; then
     52 +		AC_CHECK_LIB(pisock, pi_accept, [ PISOCK_LIBS="-lpisock -lpisync"], 
     53 +			[ AC_MSG_ERROR([Unable to find libpisock. Try http://www.pilot-link.org.]) ])
     54 +	fi
     55 +	
     56 +	AC_ARG_ENABLE(pilotlinktest,
     57 +		[  --enable-pilotlinktest   Test for correct version of pilot-link],
     58 +		[testplversion=$enableval],
     59 +		[ testplversion=yes ]
     60 +	)
     61 +
     62 +	if test x$piversion_include = x; then
     63 +		piversion_include="pi-version.h"
     64 +	fi
     65 +
     66 +	pi_major=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_VERSION'|sed 's/#define PILOT_LINK_VERSION \([[0-9]]*\)/\1/'`
     67 +	pi_minor=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_MAJOR'|sed 's/#define PILOT_LINK_MAJOR \([[0-9]]*\)/\1/'`
     68 +	pi_micro=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_MINOR'|sed 's/#define PILOT_LINK_MINOR \([[0-9]]*\)/\1/'`
     69 +	pi_patch=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_PATCH'|sed 's/#define PILOT_LINK_PATCH \"\(.*\)\"/\1/'`
     70 +
     71 +	PILOT_LINK_MAJOR="$pi_major"
     72 +	PILOT_LINK_MINOR="$pi_minor"
     73 +	PILOT_LINK_MICRO="$pi_micro"
     74 +	PILOT_LINK_PATCH="$pi_patch"
     75 +	PILOT_LINK_VERSION="$pi_major.$pi_minor.$pi_micro$pi_patch"
     76 +
     77 +	if test x$testplversion = xyes; then
     78 +		AC_MSG_CHECKING([for pilot-link version >= $1])
     79 +		pl_ma=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
     80 +		pl_mi=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
     81 +		pl_mc=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
     82 +		CFLAGS_save="$CFLAGS"
     83 +		CFLAGS="$CFLAGS $PISOCK_CFLAGS"
     84 +		AC_TRY_RUN(
     85 +			[
     86 +			#include <$piversion_include>
     87 +			int main(int argc,char *argv[]) {
     88 +				if (PILOT_LINK_VERSION == $pl_ma) {
     89 +					if (PILOT_LINK_MAJOR == $pl_mi) {
     90 +						if (PILOT_LINK_MINOR >= $pl_mc) {
     91 +							return 0;
     92 +				       	  	}
     93 +					} else if (PILOT_LINK_MAJOR > $pl_mi) {
     94 +						return 0;
     95 +					}
     96 +				} else if (PILOT_LINK_VERSION > $pl_ma) {
     97 +					return 0;
     98 +				}
     99 +				return 1;
    100 +			}
    101 +			],
    102 +			[AC_MSG_RESULT([yes (found $PILOT_LINK_VERSION)])],
    103 +			[AC_MSG_ERROR([pilot-link >= $1 required])],
    104 +			[AC_MSG_WARN([No action taken for crosscompile])]
    105 +		)
    106 +		CFLAGS="$CFLAGS_save"
    107 +	fi
    108 +
    109 +	unset piversion_include
    110 +	unset pi_verion
    111 +	unset pi_major
    112 +	unset pi_minor
    113 +	unset pi_patch
    114 +	unset incdir
    115 +	unset pl_mi
    116 +	unset pl_ma
    117 +	unset pl_ve
    118 +])
    119 +
    120 +AC_DEFUN([PILOT_LINK_CHECK],[
    121 +	PILOT_LINK_HOOK($1,[],nofailure)
    122 +])
    123 --- configure.in-orig	2006-11-17 15:23:02.816596000 +0800
    124 +++ configure.in	2006-11-17 14:09:59.220305000 +0800
    125 @@ -606,8 +606,24 @@
    126  	fi
    127  fi
    128  AM_CONDITIONAL(ENABLE_PILOT_CONDUITS, test "x$enable_pilot_conduits" = "xyes")
    129 +
    130 ++dnl ******************************
    131 ++dnl If pilot conduits are enabled, check version of pilot-link
    132 ++dnl ******************************
    133 +
    134  if test x$enable_pilot_conduits = xyes; then
    135     msg_pilot=yes
    136 +
    137 +   PILOT_LINK_CHECK(0.11.4)
    138 +   AC_SUBST(PILOT_LINK_MAJOR)
    139 +   AC_SUBST(PILOT_LINK_MINOR)
    140 +   AC_SUBST(PILOT_LINK_MICRO)
    141 +   AC_SUBST(PILOT_LINK_PATCH)
    142 +   AC_SUBST(PILOT_LINK_VERSION)
    143 +
    144 +   if test $PILOT_LINK_MINOR -ge 12; then
    145 +      AC_DEFINE(PILOT_LINK_0_12,,[Building against pilot-link 0.12.0 or greater])
    146 +   fi
    147  else
    148     msg_pilot=no
    149  fi
    150 --- addressbook/conduit/address-conduit.c-orig	2006-11-17 15:23:24.637554000 +0800
    151 +++ addressbook/conduit/address-conduit.c	2006-11-17 15:19:48.662053000 +0800
    152 @@ -462,6 +462,9 @@
    153  {
    154  	static char buff[ 4096 ];
    155  	struct Address addr;
    156 +#ifdef PILOT_LINK_0_12
    157 +	pi_buffer_t * buffer;
    158 +#endif
    159  
    160  	if (remote == NULL) {
    161  		sprintf (buff, "[NULL]");
    162 @@ -469,7 +472,21 @@
    163  	}
    164  
    165  	memset (&addr, 0, sizeof (struct Address));
    166 +#ifdef PILOT_LINK_0_12
    167 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    168 +	if(buffer == NULL){
    169 +		sprintf (buff, "[NULL]");
    170 +		return buff;
    171 +	}
    172 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    173 +		sprintf (buff, "[NULL]");
    174 +		return buff;
    175 +	}
    176 +	unpack_Address (&addr, buffer, address_v1);
    177 +	pi_buffer_free(buffer);
    178 +#else
    179  	unpack_Address (&addr, remote->record, remote->length);
    180 +#endif
    181  
    182  	g_snprintf (buff, 4096, "['%s' '%s' '%s']",
    183  		    addr.entry[entryLastname] ?
    184 @@ -792,6 +809,9 @@
    185  {
    186  	GnomePilotRecord p;
    187  	static char record[0xffff];
    188 +#ifdef PILOT_LINK_0_12
    189 +	pi_buffer_t * buffer;
    190 +#endif
    191  	
    192  	g_assert (local->addr != NULL );
    193  	
    194 @@ -804,9 +824,25 @@
    195  	p.secret = local->local.secret;
    196  
    197  	/* Generate pilot record structure */
    198 +
    199 +#ifdef PILOT_LINK_0_12
    200 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    201 +	if(buffer == NULL){
    202 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    203 +		return p;
    204 +	}
    205 +
    206 +	pack_Address (local->addr, buffer, address_v1);
    207 +
    208 +	p.record = g_new0(unsigned char, buffer->used);
    209 +	p.length = buffer->used;
    210 +	memcpy(p.record, buffer->data, buffer->used);
    211 +
    212 +	pi_buffer_free(buffer);
    213 +#else
    214  	p.record = record;
    215  	p.length = pack_Address (local->addr, p.record, 0xffff);
    216 -
    217 +#endif
    218  	return p;	
    219  }
    220  
    221 @@ -834,16 +870,34 @@
    222  	 */
    223  	if (local->local.ID != 0) {
    224  		struct Address addr;
    225 -		char record[0xffff];
    226  		int cat = 0;
    227 +#ifdef PILOT_LINK_0_12
    228 +		pi_buffer_t * record;
    229 +		record = pi_buffer_new(DLP_BUF_SIZE);
    230 +		if(record == NULL){
    231 +			pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    232 +			return;
    233 +		}
    234 +#else
    235 +		char record[0xffff];
    236 +#endif
    237  		
    238  		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
    239  					ctxt->dbi->db_handle,
    240 +#ifdef PILOT_LINK_0_12
    241 +					local->local.ID, record, 
    242 +					NULL, NULL, &cat) > 0) {
    243 +#else
    244  					local->local.ID, &record, 
    245  					NULL, NULL, NULL, &cat) > 0) {
    246 +#endif
    247  			local->local.category = cat;
    248  			memset (&addr, 0, sizeof (struct Address));
    249 +#ifdef PILOT_LINK_0_12
    250 +			unpack_Address (&addr, record, address_v1);
    251 +#else
    252  			unpack_Address (&addr, record, 0xffff);
    253 +#endif
    254  			for (i = 0; i < 5; i++) {
    255  				if (addr.entry[entryPhone1 + i])
    256  					local->addr->entry[entryPhone1 + i] = 
    257 @@ -858,6 +912,9 @@
    258  			}
    259  			free_Address (&addr);
    260  		}
    261 +#ifdef PILOT_LINK_0_12
    262 +		pi_buffer_free (record);
    263 +#endif
    264  	}
    265  
    266  	local->addr->entry[entryFirstname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
    267 @@ -1019,11 +1076,27 @@
    268  	EContactField next_mail, next_home, next_work, next_fax;
    269  	EContactField next_other, next_main, next_pager, next_mobile;
    270  	int i;
    271 -
    272 +#ifdef PILOT_LINK_0_12
    273 +	pi_buffer_t * buffer;
    274 +#endif
    275  	g_return_val_if_fail(remote!=NULL,NULL);
    276  	memset (&address, 0, sizeof (struct Address));
    277 -	unpack_Address (&address, remote->record, remote->length);
    278 +#ifdef PILOT_LINK_0_12
    279 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    280 +	if(buffer == NULL){
    281 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    282 +		return NULL;
    283 +	}
    284  
    285 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    286 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    287 +		return NULL;
    288 +	}
    289 +	unpack_Address (&address, buffer, address_v1);
    290 +	pi_buffer_free(buffer);
    291 +#else
    292 +	unpack_Address (&address, remote->record, remote->length);
    293 +#endif
    294  	if (in_contact == NULL)
    295  		contact = e_contact_new ();
    296  	else
    297 @@ -1217,6 +1290,9 @@
    298  	char *change_id;
    299  	char *auth;
    300  	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
    301 +#ifdef PILOT_LINK_0_12
    302 +	pi_buffer_t *buffer;
    303 +#endif
    304  
    305  	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
    306  
    307 @@ -1302,10 +1378,19 @@
    308    	gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
    309    	gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
    310  
    311 +#ifdef PILOT_LINK_0_12
    312 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    313 +	if(buffer == NULL){
    314 +		return pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    315 +	}
    316 +	
    317 +	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    318 +			      DLP_BUF_SIZE, buffer);
    319 +#else
    320  	buf = (unsigned char*)g_malloc (0xffff);
    321  	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    322  			      (unsigned char *)buf, 0xffff);
    323 -	
    324 +#endif	
    325  	if (len < 0) {
    326  		WARN (_("Could not read pilot's Address application block"));
    327  		WARN ("dlp_ReadAppBlock(...) = %d", len);
    328 @@ -1313,9 +1398,13 @@
    329  					   _("Could not read pilot's Address application block"));
    330  		return -1;
    331  	}
    332 +#ifdef PILOT_LINK_0_12
    333 +	unpack_AddressAppInfo (&(ctxt->ai), buffer->data, len);
    334 +	pi_buffer_free (buffer);
    335 +#else
    336  	unpack_AddressAppInfo (&(ctxt->ai), buf, len);
    337  	g_free (buf);
    338 -
    339 +#endif
    340    	check_for_slow_setting (conduit, ctxt);
    341  	if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
    342  	    || ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyFromPilot)
    343 --- calendar/conduits/calendar/calendar-conduit.c-orig	2006-11-17 15:23:59.887142000 +0800
    344 +++ calendar/conduits/calendar/calendar-conduit.c	2006-11-17 15:19:16.026169000 +0800
    345 @@ -413,6 +413,9 @@
    346  {
    347  	static char buff[ 4096 ];
    348  	struct Appointment appt;
    349 +#ifdef PILOT_LINK_0_12
    350 +	pi_buffer_t * buffer;
    351 +#endif
    352  
    353  	if (remote == NULL) {
    354  		sprintf (buff, "[NULL]");
    355 @@ -420,8 +423,22 @@
    356  	}
    357  
    358  	memset (&appt, 0, sizeof (struct Appointment));
    359 +#ifdef PILOT_LINK_0_12
    360 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    361 +	if(buffer == NULL){
    362 +		sprintf (buff, "[NULL]");
    363 +		return buff;
    364 +	}
    365 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    366 +		sprintf (buff, "[NULL]");
    367 +		return buff;
    368 +	}
    369 +	
    370 +	unpack_Appointment (&appt, buffer, datebook_v1);
    371 +	pi_buffer_free(buffer);
    372 +#else
    373  	unpack_Appointment (&appt, remote->record, remote->length);
    374 -
    375 +#endif
    376  	g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
    377  		    mktime (&appt.begin),
    378  		    mktime (&appt.end),
    379 @@ -819,6 +836,9 @@
    380  {
    381  	GnomePilotRecord p;
    382  	static char record[0xffff];
    383 +#ifdef PILOT_LINK_0_12
    384 +	pi_buffer_t * buffer;
    385 +#endif
    386  
    387  	g_assert (local->comp != NULL);
    388  	g_assert (local->appt != NULL );
    389 @@ -830,9 +850,23 @@
    390  	p.secret = local->local.secret;
    391  
    392  	/* Generate pilot record structure */
    393 +#ifdef PILOT_LINK_0_12
    394 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    395 +	if(buffer == NULL){
    396 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    397 +		return p;
    398 +	}
    399 +	
    400 +	pack_Appointment (local->appt, buffer, datebook_v1);
    401 +	p.record = g_new0(unsigned char, buffer->used);
    402 +	p.length = buffer->used;
    403 +	memcpy(p.record, buffer->data, buffer->used);
    404 +	
    405 +	pi_buffer_free(buffer); 
    406 +#else
    407  	p.record = record;
    408  	p.length = pack_Appointment (local->appt, p.record, 0xffff);
    409 -
    410 +#endif
    411  	return p;	
    412  }
    413  
    414 @@ -867,22 +901,44 @@
    415           * we don't overwrite them 
    416  	 */
    417  	if (local->local.ID != 0) {
    418 +		int cat = 0;
    419 +#ifdef PILOT_LINK_0_12
    420 +		struct Appointment appt;
    421 +		pi_buffer_t * record;
    422 +	
    423 +		record = pi_buffer_new(DLP_BUF_SIZE);
    424 +		if(record == NULL){
    425 +			pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    426 +			return;
    427 +		}
    428 +#else
    429  		struct Appointment appt;		
    430  		char record[0xffff];
    431 -		int cat = 0;
    432 -		
    433 +#endif	
    434  		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
    435  					ctxt->dbi->db_handle,
    436 +#ifdef PILOT_LINK_0_12
    437 +					local->local.ID, record, 
    438 +					NULL, NULL, &cat) > 0) {
    439 +#else
    440  					local->local.ID, &record, 
    441  					NULL, NULL, NULL, &cat) > 0) {
    442 +#endif
    443  			local->local.category = cat;
    444  			memset (&appt, 0, sizeof (struct Appointment));
    445 +#ifdef PILOT_LINK_0_12
    446 +			unpack_Appointment (&appt, record, datebook_v1);
    447 +#else
    448  			unpack_Appointment (&appt, record, 0xffff);
    449 +#endif
    450  			local->appt->alarm = appt.alarm;
    451  			local->appt->advance = appt.advance;
    452  			local->appt->advanceUnits = appt.advanceUnits;
    453  			free_Appointment (&appt);
    454  		}
    455 +#ifdef PILOT_LINK_0_12
    456 +		pi_buffer_free (record);
    457 +#endif
    458  	}
    459  
    460  	/* STOP: don't replace these with g_strdup, since free_Appointment
    461 @@ -1140,12 +1196,28 @@
    462  	GSList *edl = NULL;	
    463  	char *txt;
    464  	int pos, i;
    465 -	
    466 +#ifdef PILOT_LINK_0_12
    467 +	pi_buffer_t * buffer;
    468 +#endif
    469  	g_return_val_if_fail (remote != NULL, NULL);
    470  
    471 +#ifdef PILOT_LINK_0_12
    472 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    473 +	if(buffer == NULL){
    474 +		return NULL;
    475 +	}
    476 +	
    477 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    478 +		return NULL;
    479 +	}
    480 +
    481 +	unpack_Appointment (&appt, buffer, datebook_v1);
    482 +	pi_buffer_free(buffer);
    483 +
    484 +#else
    485  	memset (&appt, 0, sizeof (struct Appointment));
    486  	unpack_Appointment (&appt, remote->record, remote->length);
    487 -
    488 +#endif
    489  	if (in_comp == NULL) {
    490  		comp = e_cal_component_new ();
    491  		e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
    492 @@ -1413,7 +1485,9 @@
    493  	char *filename, *change_id;
    494  	icalcomponent *icalcomp;
    495  	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
    496 -
    497 +#ifdef PILOT_LINK_0_12
    498 +	pi_buffer_t * buffer;
    499 +#endif
    500  	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
    501  
    502  	LOG (g_message ( "---------------------------------------------------------\n" ));
    503 @@ -1521,10 +1595,21 @@
    504  	gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
    505  	gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
    506  
    507 +#ifdef PILOT_LINK_0_12
    508 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    509 +	if(buffer == NULL){
    510 +		pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    511 +		return -1;
    512 +	}
    513 +
    514 + 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    515 +				DLP_BUF_SIZE,
    516 +				buffer);
    517 +#else
    518  	buf = (unsigned char*)g_malloc (0xffff);
    519  	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    520  			      (unsigned char *)buf, 0xffff);
    521 -	
    522 +#endif
    523  	if (len < 0) {
    524  		WARN (_("Could not read pilot's Calendar application block"));
    525  		WARN ("dlp_ReadAppBlock(...) = %d", len);
    526 @@ -1532,6 +1617,11 @@
    527  					   _("Could not read pilot's Calendar application block"));
    528  		return -1;
    529  	}
    530 +#ifdef PILOT_LINK_0_12
    531 +	buf = g_new0 (unsigned char,buffer->used);
    532 +	memcpy(buf, buffer->data, buffer->used);
    533 +	pi_buffer_free(buffer);
    534 +#endif
    535  	unpack_AppointmentAppInfo (&(ctxt->ai), buf, len);
    536  	g_free (buf);
    537  
    538 --- calendar/conduits/todo/todo-conduit.c-orig	2006-11-17 15:24:27.040351000 +0800
    539 +++ calendar/conduits/todo/todo-conduit.c	2006-11-17 15:18:41.902434000 +0800
    540 @@ -402,15 +402,30 @@
    541  {
    542  	static char buff[ 4096 ];
    543  	struct ToDo todo;
    544 -
    545 +#ifdef PILOT_LINK_0_12
    546 +	pi_buffer_t * buffer;
    547 +#endif
    548  	if (remote == NULL) {
    549  		sprintf (buff, "[NULL]");
    550  		return buff;
    551  	}
    552  
    553  	memset (&todo, 0, sizeof (struct ToDo));
    554 +#ifdef PILOT_LINK_0_12
    555 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    556 +	if(buffer == NULL){
    557 +		sprintf (buff, "[NULL]");
    558 +		return buff;
    559 +	}
    560 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    561 +		sprintf (buff, "[NULL]");
    562 +		return buff;
    563 +	}
    564 +	unpack_ToDo (&todo, buffer, todo_v1);
    565 +	pi_buffer_free(buffer);
    566 +#else
    567  	unpack_ToDo (&todo, remote->record, remote->length);
    568 -
    569 +#endif
    570  	g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s' %d]",
    571  		    todo.indefinite,
    572  		    mktime (&todo.due),
    573 @@ -594,7 +609,11 @@
    574  			      EToDoConduitContext *ctxt)
    575  {
    576  	GnomePilotRecord p;
    577 +#ifdef PILOT_LINK_0_12
    578 +	pi_buffer_t * buffer;
    579 +#else
    580  	static char record[0xffff];
    581 +#endif
    582  
    583  	g_assert (local->comp != NULL);
    584  	g_assert (local->todo != NULL );
    585 @@ -607,10 +626,24 @@
    586  	p.archived = local->local.archived;
    587  	p.secret = local->local.secret;
    588  
    589 -	/* Generate pilot record structure */
    590 +	/* Generate pilot record structure */
    591 +#ifdef PILOT_LINK_0_12
    592 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    593 +	if(buffer == NULL){
    594 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    595 +		return p;
    596 +	}
    597 +
    598 +	pack_ToDo (local->todo, buffer, todo_v1);
    599 +	p.record = g_new0(unsigned char, buffer->used);
    600 +	p.length = buffer->used;
    601 +	memcpy(p.record, buffer->data, buffer->used);
    602 +
    603 +	pi_buffer_free(buffer); 
    604 +#else
    605  	p.record = record;
    606  	p.length = pack_ToDo (local->todo, p.record, 0xffff);
    607 -
    608 +#endif
    609  	return p;	
    610  }
    611  
    612 @@ -696,15 +729,32 @@
    613  
    614  	/* Don't overwrite the category */
    615  	if (local->local.ID != 0) {
    616 -		char record[0xffff];
    617  		int cat = 0;
    618 +#ifdef PILOT_LINK_0_12
    619 +		pi_buffer_t * record;
    620 +		record = pi_buffer_new(DLP_BUF_SIZE);
    621 +		if(record == NULL){
    622 +			pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    623 +			return;
    624 +		}
    625 +#else
    626 +		char record[0xffff];
    627 +#endif
    628  		
    629  		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
    630  					ctxt->dbi->db_handle,
    631 +#ifdef PILOT_LINK_0_12
    632 +					local->local.ID, record, 
    633 +					NULL, NULL, &cat) > 0) {
    634 +#else
    635  					local->local.ID, &record, 
    636  					NULL, NULL, NULL, &cat) > 0) {
    637 +#endif
    638  			local->local.category = cat;
    639  		}
    640 +#ifdef PILOT_LINK_0_12
    641 +		pi_buffer_free(record);
    642 +#endif
    643  	}
    644  	
    645  	/*
    646 @@ -860,11 +910,28 @@
    647  	int priority;
    648  	char *txt;
    649  	char *category;
    650 +#ifdef PILOT_LINK_0_12
    651 +	pi_buffer_t * buffer;
    652 +#endif
    653  	
    654  	g_return_val_if_fail (remote != NULL, NULL);
    655  
    656 +#ifdef PILOT_LINK_0_12
    657 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    658 +	if(buffer == NULL){
    659 +		return NULL;
    660 +	}
    661 +
    662 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    663 +		return NULL;
    664 +	}
    665 +
    666 +	unpack_ToDo (&todo, buffer, todo_v1);
    667 +	pi_buffer_free(buffer);
    668 +#else
    669  	memset (&todo, 0, sizeof (struct ToDo));
    670  	unpack_ToDo (&todo, remote->record, remote->length);
    671 +#endif
    672  
    673  	utc_zone = icaltimezone_get_utc_timezone ();
    674  	now = icaltime_from_timet_with_zone (time (NULL), FALSE, 
    675 @@ -1018,6 +1085,9 @@
    676  	char *filename, *change_id;
    677  	icalcomponent *icalcomp;
    678  	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
    679 +#ifdef PILOT_LINK_0_12
    680 +	pi_buffer_t * buffer;
    681 +#endif
    682  
    683  	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
    684  
    685 @@ -1104,10 +1174,20 @@
    686  	g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
    687  			num_records, add_records, mod_records, del_records);
    688  
    689 +#ifdef PILOT_LINK_0_12
    690 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    691 +	if(buffer == NULL){
    692 +		pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    693 +		return -1;
    694 +	}
    695 + 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    696 +				DLP_BUF_SIZE,
    697 +				buffer);
    698 +#else
    699  	buf = (unsigned char*)g_malloc (0xffff);
    700  	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    701  			      (unsigned char *)buf, 0xffff);
    702 -	
    703 +#endif	
    704  	if (len < 0) {
    705  		WARN (_("Could not read pilot's ToDo application block"));
    706  		WARN ("dlp_ReadAppBlock(...) = %d", len);
    707 @@ -1115,6 +1195,12 @@
    708  					   _("Could not read pilot's ToDo application block"));
    709  		return -1;
    710  	}
    711 +
    712 +#ifdef PILOT_LINK_0_12
    713 +	buf = g_new0 (unsigned char,buffer->used);
    714 +	memcpy(buf, buffer->data,buffer->used);
    715 +	pi_buffer_free(buffer);
    716 +#endif
    717  	unpack_ToDoAppInfo (&(ctxt->ai), buf, len);
    718  	g_free (buf);
    719  	
    720 --- calendar/conduits/memo/memo-conduit.c-orig	2006-11-17 15:24:47.093344000 +0800
    721 +++ calendar/conduits/memo/memo-conduit.c	2006-11-17 14:51:21.654921000 +0800
    722 @@ -331,6 +331,9 @@
    723  {
    724  	static char buff[ 64 ];
    725  	struct Memo memo;
    726 +#ifdef PILOT_LINK_0_12
    727 +	pi_buffer_t *buffer;
    728 +#endif
    729  
    730  	if (remote == NULL) {
    731  		sprintf (buff, "[NULL]");
    732 @@ -338,8 +341,22 @@
    733  	}
    734  
    735  	memset (&memo, 0, sizeof (struct Memo));
    736 -	unpack_Memo (&memo, remote->record, remote->length);
    737 +#ifdef PILOT_LINK_0_12
    738 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    739 +	if(buffer == NULL){
    740 +		sprintf (buff, "[NULL]");
    741 +		return buff;
    742 +	}
    743 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    744 +		sprintf (buff, "[NULL]");
    745 +		return buff;
    746 +	}
    747 +	unpack_Memo (&memo, buffer, memo_v1);
    748  
    749 +	pi_buffer_free(buffer);
    750 +#else
    751 +	unpack_Memo (&memo, remote->record, remote->length);
    752 +#endif
    753  	g_snprintf (buff, 64, "['%s']",
    754  		    memo.text ?
    755  		    memo.text : "");
    756 @@ -452,6 +469,9 @@
    757  {
    758  	GnomePilotRecord p;
    759  	static char record[0xffff];
    760 +#ifdef PILOT_LINK_0_12
    761 +	pi_buffer_t * buffer;
    762 +#endif
    763  
    764  	g_assert (local->comp != NULL);
    765  	g_assert (local->memo != NULL );
    766 @@ -465,9 +485,23 @@
    767  	p.secret = local->local.secret;
    768  
    769  	/* Generate pilot record structure */
    770 +#ifdef PILOT_LINK_0_12
    771 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    772 +	if(buffer == NULL){
    773 +		pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    774 +		return p;
    775 +	}
    776 +
    777 +	pack_Memo (local->memo, buffer, memo_v1);
    778 +	p.record = g_new0(unsigned char, buffer->used);
    779 +	p.length = buffer->used;
    780 +	memcpy(p.record, buffer->data, buffer->used);
    781 +
    782 +	pi_buffer_free(buffer);
    783 +#else
    784  	p.record = record;
    785  	p.length = pack_Memo (local->memo, p.record, 0xffff);
    786 -
    787 +#endif
    788  	return p;	
    789  }
    790  
    791 @@ -568,16 +602,41 @@
    792  
    793  	/* Don't overwrite the category */
    794  	if (local->local.ID != 0) {
    795 +#ifdef PILOT_LINK_0_12
    796 +		struct Memo memo;
    797 +		pi_buffer_t * record;
    798 +#else
    799  		char record[0xffff];
    800 +#endif
    801  		int cat = 0;
    802  		
    803 +#ifdef PILOT_LINK_0_12
    804 +		record = pi_buffer_new(DLP_BUF_SIZE);
    805 +		if(record == NULL){
    806 +			pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    807 +			return;
    808 +		}
    809 +#endif
    810 +
    811  		LOG(fprintf(stderr, "local_record_from_comp: calling dlp_ReadRecordById\n"));
    812  		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
    813  					ctxt->dbi->db_handle,
    814 +#ifdef PILOT_LINK_0_12
    815 +					local->local.ID, record, 
    816 +					NULL, NULL, &cat) > 0) {
    817 +			local->local.category = cat;
    818 +			memset (&memo, 0, sizeof (struct Memo));
    819 +			unpack_Memo (&memo, record, memo_v1);
    820 +			local->memo->text = strdup (memo.text);
    821 +			free_Memo (&memo);
    822 +		}
    823 +		pi_buffer_free (record);
    824 +#else
    825  					local->local.ID, &record, 
    826  					NULL, NULL, NULL, &cat) > 0) {
    827  			local->local.category = cat;
    828 -		}
    829 +		}	
    830 +#endif
    831  		LOG(fprintf(stderr, "local_record_from_comp: done calling dlp_ReadRecordById\n"));
    832  	}
    833  	
    834 @@ -704,11 +763,27 @@
    835  	char *txt, *txt2, *txt3;
    836  	char *category;
    837  	int i;
    838 -	
    839 +#ifdef PILOT_LINK_0_12
    840 +	pi_buffer_t * buffer;
    841 +#endif
    842  	g_return_val_if_fail (remote != NULL, NULL);
    843  
    844 +#ifdef PILOT_LINK_0_12
    845 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    846 +	if(buffer == NULL){
    847 +		return NULL;
    848 +	}
    849 +	
    850 +	if(pi_buffer_append(buffer, remote->record, remote->length)==NULL){
    851 +		return NULL;
    852 +	}
    853 +	
    854 +	unpack_Memo (&memo, buffer, memo_v1);
    855 +	pi_buffer_free(buffer);
    856 +#else
    857  	memset (&memo, 0, sizeof (struct Memo));
    858  	unpack_Memo (&memo, remote->record, remote->length);
    859 +#endif
    860  
    861  	utc_zone = icaltimezone_get_utc_timezone ();
    862  	now = icaltime_from_timet_with_zone (time (NULL), FALSE, 
    863 @@ -840,6 +915,9 @@
    864  	char *filename, *change_id;
    865  	icalcomponent *icalcomp;
    866  	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
    867 +#ifdef PILOT_LINK_0_12
    868 +	pi_buffer_t * buffer;
    869 +#endif
    870  
    871  	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
    872  
    873 @@ -929,10 +1007,21 @@
    874  	g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
    875  		num_records, add_records, mod_records, del_records);
    876  
    877 +#ifdef PILOT_LINK_0_12
    878 +	buffer = pi_buffer_new(DLP_BUF_SIZE);
    879 +	if(buffer == NULL){
    880 +		pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
    881 +		return -1;
    882 +	}
    883 +
    884 + 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    885 +				DLP_BUF_SIZE,
    886 +				buffer);
    887 +#else
    888  	buf = (unsigned char*)g_malloc (0xffff);
    889  	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
    890  			      (unsigned char *)buf, 0xffff);
    891 -	
    892 +#endif
    893  	if (len < 0) {
    894  		WARN (_("Could not read pilot's Memo application block"));
    895  		WARN ("dlp_ReadAppBlock(...) = %d", len);
    896 @@ -940,7 +1029,15 @@
    897  					   _("Could not read pilot's Memo application block"));
    898  		return -1;
    899  	}
    900 +#ifdef PILOT_LINK_0_12
    901 +	buf = g_new0 (unsigned char,buffer->used);
    902 +	memcpy(buf, buffer->data, buffer->used);
    903 + 	unpack_MemoAppInfo (&(ctxt->ai), buf, len);
    904 +	pi_buffer_free(buffer);
    905 +#else
    906  	unpack_MemoAppInfo (&(ctxt->ai), buf, len);
    907 +#endif
    908 +
    909  	g_free (buf);
    910  	
    911  	lastDesktopUniqueID = 128;
    912