Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37880099
en ru br
Репозитории ALT
S:3.7.0-alt0.6
4.1: 2.2.9-alt1.1
4.0: 2.2.9-alt1.1
3.0: 1.0.4-alt1
www.altlinux.org/Changes

Группа :: Сети/Почта
Пакет: sylpheed

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: sylpheed-0.8.6-alt-jpilotcharset.patch
Скачать


--- sylpheed-0.8.6/src/jpilot.h.jpilotcharset	Wed Dec 19 11:06:11 2001
+++ sylpheed-0.8.6/src/jpilot.h	Sun Nov 17 14:13:45 2002
@@ -50,6 +50,7 @@
 	gchar                 *name;
 	FILE                  *file;
 	gchar                 *path;
+	gchar    *charset;
 	AddressCache          *addressCache;
 	struct AddressAppInfo addrInfo;
 	gboolean              readMetadata;
@@ -75,6 +76,7 @@
 JPilotFile *jpilot_create_path		( const gchar *path );
 void jpilot_set_name			( JPilotFile* pilotFile, const gchar *value );
 void jpilot_set_file			( JPilotFile* pilotFile, const gchar *value );
+void jpilot_set_charset			( JPilotFile* pilotFile, const gchar *value );
 void jpilot_free			( JPilotFile *pilotFile );
 gint jpilot_get_status			( JPilotFile *pilotFile );
 gboolean jpilot_get_modified		( JPilotFile *pilotFile );
--- sylpheed-0.8.6/src/addrindex.c.jpilotcharset	Wed Mar 13 12:27:03 2002
+++ sylpheed-0.8.6/src/addrindex.c	Sun Nov 17 14:14:30 2002
@@ -74,6 +74,7 @@
 
 #define ATTAG_JPILOT_NAME     "name"
 #define ATTAG_JPILOT_FILE     "file"
+#define ATTAG_JPILOT_CHARSET  "charset"
 #define ATTAG_JPILOT_CUSTOM_1 "custom-1"
 #define ATTAG_JPILOT_CUSTOM_2 "custom-2"
 #define ATTAG_JPILOT_CUSTOM_3 "custom-3"
@@ -789,6 +790,9 @@
 		else if( strcmp( name, ATTAG_JPILOT_FILE ) == 0 ) {
 			jpilot_set_file( jpf, value );
 		}
+		else if( strcmp( name, ATTAG_JPILOT_CHARSET ) == 0 ) {
+			jpilot_set_charset( jpf, value );
+		}
 		else if( strcmp( name, ATTAG_JPILOT_CUSTOM_1 ) == 0 ) {
 			jpilot_add_custom_label( jpf, value );
 		}
@@ -816,6 +820,7 @@
 		addrindex_write_elem_s( fp, lvl, TAG_DS_JPILOT );
 		addrindex_write_attr( fp, ATTAG_JPILOT_NAME, jpf->name );
 		addrindex_write_attr( fp, ATTAG_JPILOT_FILE, jpf->path );
+		addrindex_write_attr( fp, ATTAG_JPILOT_CHARSET, jpf->charset );
 		node = customLbl;
 		ind = 1;
 		while( node ) {
--- sylpheed-0.8.6/src/jpilot.c.jpilotcharset	Wed Mar 13 12:27:03 2002
+++ sylpheed-0.8.6/src/jpilot.c	Sun Nov 17 15:12:48 2002
@@ -48,6 +48,7 @@
 #  include <pi-address.h>
 #endif
 
+#include "codeconv.h"
 #include "mgutils.h"
 #include "addritem.h"
 #include "addrcache.h"
@@ -156,6 +157,7 @@
 	pilotFile->name = NULL;
 	pilotFile->file = NULL;
 	pilotFile->path = NULL;
+	pilotFile->charset = NULL;
 	pilotFile->addressCache = addrcache_create();
 	pilotFile->readMetadata = FALSE;
 	pilotFile->customLabels = NULL;
@@ -190,6 +192,12 @@
 	pilotFile->readMetadata = FALSE;
 	pilotFile->path = mgu_replace_string( pilotFile->path, value );
 }
+void jpilot_set_charset( JPilotFile* pilotFile, const gchar *value ) {
+	g_return_if_fail( pilotFile != NULL );
+	addrcache_refresh( pilotFile->addressCache );
+	pilotFile->readMetadata = FALSE;
+	pilotFile->charset = mgu_replace_string( pilotFile->charset, value );
+}
 void jpilot_set_accessed( JPilotFile *pilotFile, const gboolean value ) {
 	g_return_if_fail( pilotFile != NULL );
 	pilotFile->accessFlag = value;
@@ -385,6 +393,7 @@
 	g_return_if_fail( pilotFile != NULL );
 
 	/* Free internal stuff */
+	g_free( pilotFile->charset );
 	g_free( pilotFile->path );
 
 	/* Release custom labels */
@@ -975,8 +984,24 @@
 	return MGU_SUCCESS;
 }
 
-#define FULLNAME_BUFSIZE	256
-#define EMAIL_BUFSIZE		256
+
+static gchar *jpilot_convert_to_local( JPilotFile *pilotFile, const gchar *str )
+{
+	gchar *result;
+
+	if (!str)
+		return NULL;
+
+	if (!pilotFile->charset || !pilotFile->charset[0])
+		return g_strdup( str );
+
+	result = conv_codeset_strdup( str, pilotFile->charset,
+				      conv_get_current_charset_str() );
+	if (!result)
+		result = g_strdup( str );
+	return result;
+}
+
 /*
  * Unpack address, building new data inside cache.
  */
@@ -987,8 +1012,11 @@
 	gint cat_id = 0;
 	guint unique_id;
 	guchar attrib;
-	gchar fullName[ FULLNAME_BUFSIZE ];
-	gchar bufEMail[ EMAIL_BUFSIZE ];
+	gchar *firstName;
+	gchar *lastName;
+	gchar *fullName;
+	gchar *emailAddress;
+	gchar *tmp;
 	ItemPerson *person;
 	ItemEMail *email;
 	gint *indPhoneLbl;
@@ -1005,22 +1033,25 @@
 		unique_id = buf->unique_id;
 		cat_id = attrib & 0x0F;
 
-		*fullName = *bufEMail = '\0';
-		if( addrEnt[ IND_LABEL_FIRSTNAME ] ) {
-			strcat( fullName, addrEnt[ IND_LABEL_FIRSTNAME ] );
-		}
-
-		if( addrEnt[ IND_LABEL_LASTNAME ] ) {
-			strcat( fullName, " " );
-			strcat( fullName, addrEnt[ IND_LABEL_LASTNAME ] );
+		firstName = jpilot_convert_to_local( pilotFile, addrEnt[ IND_LABEL_FIRSTNAME ]);
+		lastName = jpilot_convert_to_local( pilotFile, addrEnt[ IND_LABEL_LASTNAME ]);
+		fullName = NULL;
+		if( firstName ) {
+			fullName = g_strdup( firstName );
+		}
+		if( lastName ) {
+			tmp = g_strconcat( fullName ? fullName : "",
+					   " ", lastName, NULL );
+			g_free( fullName );
+			fullName = tmp;
 		}
 		g_strchug( fullName );
 		g_strchomp( fullName );
 
 		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 ] );
+		addritem_person_set_first_name( person, firstName );
+		addritem_person_set_last_name( person, lastName );
 		addrcache_id_person( pilotFile->addressCache, person );
 
 		extID = g_strdup_printf( "%d", unique_id );
@@ -1043,15 +1074,16 @@
 			if( indPhoneLbl[k] == IND_PHONE_EMAIL ) {
 				labelEntry = addrEnt[ OFFSET_PHONE_LABEL + k ];
 				if( labelEntry ) {
-					strcpy( bufEMail, labelEntry );
-					g_strchug( bufEMail );
-					g_strchomp( bufEMail );
+					emailAddress = jpilot_convert_to_local( pilotFile, labelEntry );
+					g_strchug( emailAddress );
+					g_strchomp( emailAddress );
 
 					email = addritem_create_item_email();
-					addritem_email_set_address( email, bufEMail );
+					addritem_email_set_address( email, emailAddress );
 					addrcache_id_email( pilotFile->addressCache, email );
 					addrcache_person_add_email
 						( pilotFile->addressCache, person, email );
+					g_free( emailAddress );
 				}
 			}
 		}
@@ -1068,16 +1100,19 @@
 				*/
 				labelEntry = addrEnt[ind];
 				if( labelEntry ) {
-					strcpy( bufEMail, labelEntry );
-					g_strchug( bufEMail );
-					g_strchomp( bufEMail );
+					emailAddress = jpilot_convert_to_local( pilotFile, labelEntry );
+					g_strchug( emailAddress );
+					g_strchomp( emailAddress );
 
 					email = addritem_create_item_email();
-					addritem_email_set_address( email, bufEMail );
-					addritem_email_set_remarks( email, ai->labels[ind] );
+					addritem_email_set_address( email, emailAddress );
+					tmp = jpilot_convert_to_local( pilotFile, ai->labels[ind] );
+					addritem_email_set_remarks( email, tmp );
+					g_free( tmp );
 					addrcache_id_email( pilotFile->addressCache, email );
 					addrcache_person_add_email
 						( pilotFile->addressCache, person, email );
+					g_free( emailAddress );
 				}
 			}
 
@@ -1097,6 +1132,10 @@
 			addritem_free_item_person( person );
 			person = NULL;
 		}
+
+		g_free( firstName );
+		g_free( lastName );
+		g_free( fullName );
 	}
 }
 
@@ -1231,7 +1270,10 @@
 			gint i;
 			for( i = 0; i < JPILOT_NUM_LABELS; i++ ) {
 				gchar *labelName = ai->labels[i];
-				if( g_strcasecmp( labelName, lbl ) == 0 ) {
+				gchar *converted = jpilot_convert_to_local( pilotFile, labelName );
+				int cmp_result = g_strcasecmp( converted, lbl );
+				g_free( converted );
+				if( cmp_result == 0 ) {
 					ind = i;
 					break;
 				}
@@ -1256,8 +1298,9 @@
 		struct AddressAppInfo *ai = & pilotFile->addrInfo;
 		for( i = 0; i < JPILOT_NUM_LABELS; i++ ) {
 			gchar *labelName = ai->labels[i];
-			if( labelName ) {
-				labelList = g_list_append( labelList, g_strdup( labelName ) );
+			gchar *converted = jpilot_convert_to_local( pilotFile, labelName );
+			if( converted ) {
+				labelList = g_list_append( labelList, converted );
 			}
 			else {
 				labelList = g_list_append( labelList, g_strdup( "" ) );
@@ -1283,7 +1326,7 @@
 		if( catID < 0 || catID > JPILOT_NUM_CATEG ) {
 		}
 		else {
-			catName = g_strdup( cat->name[catID] );
+			catName = jpilot_convert_to_local( pilotFile, cat->name[catID] );
 		}
 	}
 	if( ! catName ) catName = g_strdup( "" );
@@ -1302,8 +1345,9 @@
 		struct AddressAppInfo *ai = & pilotFile->addrInfo;
 		for( i = 0; i < JPILOT_NUM_PHONELABELS; i++ ) {
 			gchar	*labelName = ai->phoneLabels[i];
-			if( labelName ) {
-				labelList = g_list_append( labelList, g_strdup( labelName ) );
+			gchar	*converted = jpilot_convert_to_local( pilotFile, labelName );
+			if( converted ) {
+				labelList = g_list_append( labelList, converted );
 			}
 			else {
 				labelList = g_list_append( labelList, g_strdup( "" ) );
@@ -1326,12 +1370,14 @@
 		struct AddressAppInfo *ai = & pilotFile->addrInfo;
 		for( i = 0; i < NUM_CUSTOM_LABEL; i++ ) {
 			gchar *labelName = ai->labels[i+IND_CUSTOM_LABEL];
-			if( labelName ) {
-				g_strchomp( labelName );
-				g_strchug( labelName );
-				if( *labelName != '\0' ) {
-					labelList = g_list_append( labelList, g_strdup( labelName ) );
+			gchar *converted = jpilot_convert_to_local( pilotFile, labelName );
+			if( converted ) {
+				g_strchomp( converted );
+				g_strchug( converted );
+				if( *converted != '\0' ) {
+					labelList = g_list_append( labelList, g_strdup( converted ) );
 				}
+				g_free( converted );
 			}
 		}
 	}
@@ -1352,8 +1398,9 @@
 		struct CategoryAppInfo *cat = &	ai->category;
 		for( i = 0; i < JPILOT_NUM_CATEG; i++ ) {
 			gchar *catName = cat->name[i];
-			if( catName ) {
-				catList = g_list_append( catList, g_strdup( catName ) );
+			gchar *converted = jpilot_convert_to_local( pilotFile, catName );
+			if( converted ) {
+				catList = g_list_append( catList, converted );
 			}
 			else {
 				catList = g_list_append( catList, g_strdup( "" ) );
@@ -1373,7 +1420,9 @@
 
 	for( i = 0; i < JPILOT_NUM_CATEG; i++ ) {
 		ItemFolder *folder = addritem_create_item_folder();
-		addritem_folder_set_name( folder, cat->name[i] );
+		gchar *name = jpilot_convert_to_local( pilotFile, cat->name[i] );
+		addritem_folder_set_name( folder, name );
+		g_free( name );
 		addrcache_id_folder( pilotFile->addressCache, folder );
 		addrcache_add_folder( pilotFile->addressCache, folder );
 	}
--- sylpheed-0.8.6/src/editjpilot.c.jpilotcharset	Sun Sep 30 10:22:56 2001
+++ sylpheed-0.8.6/src/editjpilot.c	Sun Nov 17 15:21:15 2002
@@ -57,6 +57,7 @@
 	GtkWidget *file_entry;
 	GtkWidget *custom_check[JPILOT_NUM_CUSTOM_LABEL];
 	GtkWidget *custom_label[JPILOT_NUM_CUSTOM_LABEL];
+	GtkWidget *charset_entry;
 	GtkWidget *ok_btn;
 	GtkWidget *cancel_btn;
 	GtkWidget *statusbar;
@@ -156,6 +157,7 @@
 	gint t = -1;
 	gchar *sFile;
 	gchar *sMsg;
+	gchar *sCharset;
 	gboolean flg;
 
 	flg = FALSE;
@@ -165,6 +167,9 @@
 		if( *sFile != '\0' ) {
 			/* Attempt to read file */
 			JPilotFile *jpf = jpilot_create_path( sFile );
+			sCharset = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.charset_entry), 0, -1 );
+			jpilot_set_charset( jpf, sCharset );
+			g_free( sCharset );
 			t = jpilot_read_data( jpf );
 			if( t == MGU_SUCCESS ) {
 				/* Set check boxes */
@@ -256,6 +261,7 @@
 	GtkWidget *frame_custom;
 	GtkWidget *custom_check[JPILOT_NUM_CUSTOM_LABEL];
 	GtkWidget *custom_label[JPILOT_NUM_CUSTOM_LABEL];
+	GtkWidget *charset_entry;
 	GtkWidget *hlbox;
 	GtkWidget *hbbox;
 	GtkWidget *hsep;
@@ -268,7 +274,6 @@
 	gint top, i;
 
 	window = gtk_window_new(GTK_WINDOW_DIALOG);
-	gtk_widget_set_usize(window, 450, -1);
 	gtk_container_set_border_width(GTK_CONTAINER(window), 0);
 	gtk_window_set_title(GTK_WINDOW(window), _("Edit JPilot Entry"));
 	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
@@ -284,7 +289,7 @@
 	gtk_container_add(GTK_CONTAINER(window), vbox);
 	gtk_container_set_border_width( GTK_CONTAINER(vbox), 0 );
 
-	table = gtk_table_new(2 + JPILOT_NUM_CUSTOM_LABEL, 3, FALSE);
+	table = gtk_table_new(3 + JPILOT_NUM_CUSTOM_LABEL, 3, FALSE);
 	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
 	gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
 	gtk_table_set_row_spacings(GTK_TABLE(table), 8);
@@ -316,6 +321,15 @@
 
 	/* Third row */
 	top = 2;
+	label = gtk_label_new(_("JPilot charset"));
+	gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+	charset_entry = gtk_entry_new();
+	gtk_table_attach(GTK_TABLE(table), charset_entry, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+
+	/* Fourth row */
+	top = 3;
 	frame_custom = gtk_frame_new(_("Additional e-Mail address item(s)"));
 	gtk_table_attach(GTK_TABLE(table), frame_custom, 1, 2, top, (top + JPILOT_NUM_CUSTOM_LABEL), GTK_FILL, 0, 0, 0);
 
@@ -364,6 +378,7 @@
 	jpilotedit.window     = window;
 	jpilotedit.name_entry = name_entry;
 	jpilotedit.file_entry = file_entry;
+	jpilotedit.charset_entry = charset_entry;
 	jpilotedit.ok_btn     = ok_btn;
 	jpilotedit.cancel_btn = cancel_btn;
 	jpilotedit.statusbar  = statusbar;
@@ -378,6 +393,7 @@
 	static gboolean cancelled;
 	gchar *sName;
 	gchar *sFile;
+	gchar *sCharset;
 	AddressDataSource *ds = NULL;
 	JPilotFile *jpf = NULL;
 	gboolean fin;
@@ -397,6 +413,8 @@
 			gtk_entry_set_text(GTK_ENTRY(jpilotedit.name_entry), jpf->name);
 		if (jpf->path)
 			gtk_entry_set_text(GTK_ENTRY(jpilotedit.file_entry), jpf->path);
+		if (jpf->charset)
+			gtk_entry_set_text(GTK_ENTRY(jpilotedit.charset_entry), jpf->charset);
 		gtk_window_set_title( GTK_WINDOW(jpilotedit.window), _("Edit JPilot Entry"));
 		edit_jpilot_fill_check_box( jpf );
 	}
@@ -418,6 +436,7 @@
 	fin = FALSE;
 	sName = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.name_entry), 0, -1 );
 	sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 );
+	sCharset = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.charset_entry), 0, -1 );
 	if( *sName == '\0' ) fin = TRUE;
 	if( *sFile == '\0' ) fin = TRUE;
 
@@ -430,10 +449,12 @@
 		addressbook_ads_set_name( ads, sName );
 		jpilot_set_name( jpf, sName );
 		jpilot_set_file( jpf, sFile );
+		jpilot_set_charset( jpf, sCharset );
 		edit_jpilot_read_check_box( jpf );
 	}
 	g_free( sName );
 	g_free( sFile );
+	g_free( sCharset );
 
 	return ads;
 }
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin