CVS: sylpheedclaws/sylpheed-claws/src jpilot.c,1.18.2.18,1.18.2.19

[email protected] Tue, 19 Dec 2006 18:08:50 +0000
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src
In directory sunsite.dk:/tmp/cvs-serv11541/src

Modified Files:
      Tag: gtk2
	jpilot.c 
Log Message:
2006-12-19 [colin]	2.6.1cvs54

	* src/jpilot.c
		Fix bug 1059, 'Better jpilot charset 
		handling'. Use libpisync's charset conversion
		if possible

Index: jpilot.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/jpilot.c,v
retrieving revision 1.18.2.18
retrieving revision 1.18.2.19
diff -u -d -r1.18.2.18 -r1.18.2.19
--- jpilot.c	2006/11/07 10:38:58	1.18.2.18
+++ jpilot.c	2006/12/19 18:08:45	1.18.2.19
@@ -38,11 +38,13 @@
 #include <netinet/in.h>
 
 #ifdef HAVE_LIBPISOCK_PI_ARGS_H
+#  include <libpisock/pi-util.h>
 #  include <libpisock/pi-args.h>
 #  include <libpisock/pi-appinfo.h>
 #  include <libpisock/pi-address.h>
 #  include <libpisock/pi-version.h>
 #else
+#  include <pi-util.h>
 #  include <pi-args.h>
 #  include <pi-appinfo.h>
 #  include <pi-address.h>
@@ -1102,11 +1104,17 @@
 			email = addritem_create_item_email();
 			addritem_email_set_address( email, node->data );
 			if (convert_charcode) {
-				gchar *convertBuff;
+				gchar *convertBuff = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+				convert_FromPilotChar(CS_INTERNAL, labelEntry, 
+						strlen(labelEntry), &convertBuff);
+#else
 				convertBuff = conv_codeset_strdup( labelEntry, 
 						conv_get_locale_charset_str_no_utf8(), 
 						CS_INTERNAL );
-				addritem_email_set_remarks( email, convertBuff );
+#endif
+				if (convertBuff)
+					addritem_email_set_remarks( email, convertBuff );
 				g_free( convertBuff );
 			}
 			else {
@@ -1201,11 +1209,17 @@
 	g_strstrip( fullName );
 
 	if( convert_charcode ) {
-		gchar *nameConv;
+		gchar *nameConv = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+		convert_FromPilotChar(CS_INTERNAL, fullName, 
+				strlen(fullName), &nameConv);
+#else
 		nameConv = conv_codeset_strdup( fullName, 
 				conv_get_locale_charset_str_no_utf8(), 
 				CS_INTERNAL );
-		strncpy2( fullName, nameConv, FULLNAME_BUFSIZE );
+#endif
+		if (nameConv)
+			strncpy2( fullName, nameConv, FULLNAME_BUFSIZE );
 		g_free( nameConv );
 	}
 
@@ -1366,15 +1380,20 @@
 			gint i;
 			for( i = 0; i < JPILOT_NUM_LABELS; i++ ) {
 				gchar *labelName = ai->labels[i];
-				gchar convertBuff[ JPILOT_LEN_LABEL ];
 
 				if( convert_charcode ) {
-					labelName = conv_codeset_strdup( labelName, 
+					gchar *convertBuff = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+					convert_FromPilotChar(CS_INTERNAL, labelName, 
+							strlen(labelName), &convertBuff);
+#else
+					convertBuff = conv_codeset_strdup( labelName, 
 							conv_get_locale_charset_str_no_utf8(), 
 							CS_INTERNAL );
-					strncpy2( convertBuff, labelName, JPILOT_LEN_LABEL );
-					g_free( labelName );
-					labelName = convertBuff;
+#endif
+					if (convertBuff) {
+						labelName = convertBuff;
+					}
 				}
 
 				if( g_utf8_collate( labelName, lbl ) == 0 ) {
@@ -1409,9 +1428,18 @@
 
 			if( labelName ) {
 				if( convert_charcode ) {
-					labelName = conv_codeset_strdup( labelName, 
+					gchar *convertBuff = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+					convert_FromPilotChar(CS_INTERNAL, labelName, 
+							strlen(labelName), &convertBuff);
+#else
+					convertBuff = conv_codeset_strdup( labelName, 
 							conv_get_locale_charset_str_no_utf8(), 
 							CS_INTERNAL );
+#endif
+					if (convertBuff) {
+						labelName = convertBuff;
+					}
 				}
 				else {
 					labelName = g_strdup( labelName );
@@ -1501,9 +1529,18 @@
 				g_strchug( labelName );
 				if( *labelName != '\0' ) {
 					if( convert_charcode ) {
-						labelName = conv_codeset_strdup( labelName, 
+						gchar *convertBuff = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+						convert_FromPilotChar(CS_INTERNAL, labelName, 
+								strlen(labelName), &convertBuff);
+#else
+						convertBuff = conv_codeset_strdup( labelName, 
 								conv_get_locale_charset_str_no_utf8(), 
 								CS_INTERNAL );
+#endif
+						if (convertBuff) {
+							labelName = convertBuff;
+						}
 					}
 					else {
 						labelName = g_strdup( labelName );
@@ -1558,12 +1595,21 @@
 		ItemFolder *folder = addritem_create_item_folder();
 
 		if( convert_charcode ) {
-			gchar *catName;
-			catName = conv_codeset_strdup( cat->name[i], 
+			gchar *convertBuff = NULL;
+#if (PILOT_LINK_MAJOR > 11)
+			convert_FromPilotChar(CS_INTERNAL, cat->name[i], 
+					strlen(cat->name[i]), &convertBuff);
+#else
+			convertBuff = conv_codeset_strdup( cat->name[i], 
 					conv_get_locale_charset_str_no_utf8(), 
 					CS_INTERNAL );
-			addritem_folder_set_name( folder, catName );
-			g_free( catName );
+#endif
+			if (convertBuff) {
+				addritem_folder_set_name( folder, convertBuff );
+				g_free( convertBuff );
+			} else {
+				addritem_folder_set_name( folder, cat->name[i] );
+			}
 		}
 		else {
 			addritem_folder_set_name( folder, cat->name[i] );