Репозитории 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 |
Группа :: Сети/Почта
Пакет: sylpheed
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: sylpheed-2.2.4-alt-jpilotcharset.patch
Скачать
Скачать
--- sylpheed/src/editjpilot.c.alt-jpilotcharset 2006-03-10 08:14:30 +0300
+++ sylpheed/src/editjpilot.c 2006-05-28 17:36:18 +0400
@@ -66,6 +66,7 @@ static struct _JPilotEdit {
GtkWidget *file_entry;
GtkWidget *custom_check[JPILOT_NUM_CUSTOM_LABEL];
GtkWidget *custom_label[JPILOT_NUM_CUSTOM_LABEL];
+ GtkWidget *charset_entry;
GtkWidget *hbbox;
GtkWidget *ok_btn;
GtkWidget *cancel_btn;
@@ -166,6 +167,7 @@ static void edit_jpilot_file_check( void
gchar *sFile;
gchar *sFSFile;
gchar *sMsg;
+ gchar *sCharset;
gboolean flg;
flg = FALSE;
@@ -176,6 +178,9 @@ static void edit_jpilot_file_check( void
/* Attempt to read file */
JPilotFile *jpf;
jpf = jpilot_create_path( sFSFile );
+ 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 */
@@ -232,6 +237,7 @@ static void addressbook_edit_jpilot_crea
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;
@@ -260,7 +266,7 @@ static void addressbook_edit_jpilot_crea
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);
@@ -292,6 +298,15 @@ static void addressbook_edit_jpilot_crea
/* 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);
@@ -341,6 +356,7 @@ static void addressbook_edit_jpilot_crea
jpilotedit.window = window;
jpilotedit.name_entry = name_entry;
jpilotedit.file_entry = file_entry;
+ jpilotedit.charset_entry = charset_entry;
jpilotedit.hbbox = hbbox;
jpilotedit.ok_btn = ok_btn;
jpilotedit.cancel_btn = cancel_btn;
@@ -357,6 +373,7 @@ AdapterDSource *addressbook_edit_jpilot(
gchar *sName;
gchar *sFile;
gchar *sFSFile;
+ gchar *sCharset;
AddressDataSource *ds = NULL;
JPilotFile *jpf = NULL;
gboolean fin;
@@ -378,6 +395,8 @@ AdapterDSource *addressbook_edit_jpilot(
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 );
}
@@ -400,6 +419,7 @@ AdapterDSource *addressbook_edit_jpilot(
sName = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.name_entry), 0, -1 );
sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 );
sFSFile = conv_filename_from_utf8( sFile );
+ sCharset = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.charset_entry), 0, -1 );
if( *sName == '\0' ) fin = TRUE;
if( *sFile == '\0' ) fin = TRUE;
if( ! sFSFile || *sFSFile == '\0' ) fin = TRUE;
@@ -413,8 +433,10 @@ AdapterDSource *addressbook_edit_jpilot(
addressbook_ads_set_name( ads, sName );
jpilot_set_name( jpf, sName );
jpilot_set_file( jpf, sFSFile );
+ jpilot_set_charset( jpf, sCharset );
edit_jpilot_read_check_box( jpf );
}
+ g_free( sCharset );
g_free( sFSFile );
g_free( sFile );
g_free( sName );
--- sylpheed/src/jpilot.c.alt-jpilotcharset 2005-08-08 11:07:19 +0400
+++ sylpheed/src/jpilot.c 2006-05-28 17:38:48 +0400
@@ -154,8 +154,6 @@ enum {
FAMILY_FIRST = 1
} name_order;
-gboolean convert_charcode;
-
/*
* Create new pilot file object.
*/
@@ -165,6 +163,7 @@ JPilotFile *jpilot_create() {
pilotFile->name = NULL;
pilotFile->file = NULL;
pilotFile->path = NULL;
+ pilotFile->charset = NULL;
pilotFile->addressCache = addrcache_create();
pilotFile->readMetadata = FALSE;
pilotFile->customLabels = NULL;
@@ -199,6 +198,12 @@ void jpilot_set_file( JPilotFile* pilotF
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;
@@ -394,6 +399,7 @@ void jpilot_free( JPilotFile *pilotFile
g_return_if_fail( pilotFile != NULL );
/* Free internal stuff */
+ g_free( pilotFile->charset );
g_free( pilotFile->path );
/* Release custom labels */
@@ -986,8 +992,43 @@ static gint jpilot_read_db_files( JPilot
return MGU_SUCCESS;
}
-#define FULLNAME_BUFSIZE 256
-#define EMAIL_BUFSIZE 256
+/*
+ * Convert string from the JPilot database encoding to internal encoding.
+ */
+static gchar *jpilot_convert( 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, CS_INTERNAL );
+ if (!result)
+ result = g_strdup( str );
+ return result;
+}
+
+/*
+ * Convert name part from the JPilot database representation to a string in the
+ * internal encoding.
+ */
+static gchar *jpilot_convert_name_part( JPilotFile *pilotFile, const gchar *data ) {
+ gchar *result = NULL;
+
+ if ( data ) {
+ gchar **fields = g_strsplit( data, "\01", 2 );
+ if ( fields ) {
+ result = jpilot_convert( pilotFile, fields[0] );
+ g_strfreev( fields );
+ }
+ }
+
+ return result ? result : g_strdup( "" );
+}
+
/*
* Unpack address, building new data inside cache.
*/
@@ -998,8 +1039,11 @@ static void jpilot_load_address( JPilotF
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;
@@ -1007,8 +1051,6 @@ static void jpilot_load_address( JPilotF
GList *node;
gchar* extID;
struct AddressAppInfo *ai;
- gchar **firstName = NULL;
- gchar **lastName = NULL;
/* Retrieve address */
num = unpack_Address( & addr, buf->buf, buf->size );
@@ -1018,48 +1060,30 @@ static void jpilot_load_address( JPilotF
unique_id = buf->unique_id;
cat_id = attrib & 0x0F;
- *fullName = *bufEMail = '\0';
-
- 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 );
- }
+ firstName = jpilot_convert_name_part( pilotFile, addrEnt[ IND_LABEL_FIRSTNAME ] );
+ lastName = jpilot_convert_name_part( pilotFile, addrEnt[ IND_LABEL_LASTNAME ] );
if( name_order == FAMILY_LAST ) {
- g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
- firstName ? firstName[0] : "",
- lastName ? lastName[0] : "" );
+ fullName = g_strdup_printf( "%s %s",
+ firstName, lastName );
}
else {
- g_snprintf( fullName, FULLNAME_BUFSIZE, "%s %s",
- lastName ? lastName[0] : "",
- firstName ? firstName[0] : "" );
- }
-
- if( firstName ) {
- g_strfreev( firstName );
- }
- if( lastName ) {
- g_strfreev( lastName );
+ fullName = g_strdup_printf( "%s %s",
+ lastName, firstName );
}
g_strstrip( fullName );
- if( convert_charcode ) {
- gchar *nameConv;
- nameConv = conv_codeset_strdup( fullName, CS_SHIFT_JIS, 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 ] );
+ addritem_person_set_first_name( person, firstName );
+ addritem_person_set_last_name( person, lastName );
addrcache_id_person( pilotFile->addressCache, person );
+ g_free( fullName );
+ g_free( firstName );
+ g_free( lastName );
+
extID = g_strdup_printf( "%d", unique_id );
addritem_person_set_external_id( person, extID );
g_free( extID );
@@ -1081,15 +1105,15 @@ static void jpilot_load_address( JPilotF
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( pilotFile, labelEntry );
+ g_strstrip( 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 );
}
}
}
@@ -1107,26 +1131,19 @@ static void jpilot_load_address( JPilotF
*/
labelEntry = addrEnt[ind];
if( labelEntry ) {
- strcpy( bufEMail, labelEntry );
- g_strchug( bufEMail );
- g_strchomp( bufEMail );
+ emailAddress = jpilot_convert( pilotFile, labelEntry );
+ g_strstrip( emailAddress );
email = addritem_create_item_email();
- addritem_email_set_address( email, bufEMail );
-
- if( convert_charcode ) {
- gchar *convertBuff;
- convertBuff = conv_codeset_strdup( ai->labels[ind], CS_SHIFT_JIS, CS_INTERNAL );
- addritem_email_set_remarks( email, convertBuff );
- g_free( convertBuff );
- }
- else {
- addritem_email_set_remarks( email, ai->labels[ind] );
- }
+ addritem_email_set_address( email, emailAddress );
+ tmp = jpilot_convert( 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 );
}
}
@@ -1282,16 +1299,10 @@ static gboolean jpilot_setup_labels( JPi
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, CS_SHIFT_JIS, CS_INTERNAL );
- strncpy2( convertBuff, labelName, JPILOT_LEN_LABEL );
- g_free( labelName );
- labelName = convertBuff;
- }
-
- if( g_ascii_strcasecmp( labelName, lbl ) == 0 ) {
+ gchar *converted = jpilot_convert( pilotFile, labelName );
+ int cmp_result = g_ascii_strcasecmp( labelName, lbl );
+ g_free( converted );
+ if ( cmp_result == 0 ) {
ind = i;
break;
}
@@ -1316,15 +1327,10 @@ GList *jpilot_load_label( JPilotFile *pi
struct AddressAppInfo *ai = & pilotFile->addrInfo;
for( i = 0; i < JPILOT_NUM_LABELS; i++ ) {
gchar *labelName = ai->labels[i];
+ gchar *converted = jpilot_convert( pilotFile, labelName );
- if( labelName ) {
- if( convert_charcode ) {
- labelName = conv_codeset_strdup( labelName, CS_SHIFT_JIS, CS_INTERNAL );
- }
- else {
- labelName = g_strdup( labelName );
- }
- labelList = g_list_append( labelList, labelName );
+ if( converted ) {
+ labelList = g_list_append( labelList, converted );
}
else {
labelList = g_list_append( labelList, g_strdup( "" ) );
@@ -1350,7 +1356,7 @@ gchar *jpilot_get_category_name( JPilotF
if( catID < 0 || catID > JPILOT_NUM_CATEG ) {
}
else {
- catName = g_strdup( cat->name[catID] );
+ catName = jpilot_convert( pilotFile, cat->name[catID] );
}
}
if( ! catName ) catName = g_strdup( "" );
@@ -1369,8 +1375,9 @@ GList *jpilot_load_phone_label( JPilotFi
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( pilotFile, labelName );
+ if( converted ) {
+ labelList = g_list_append( labelList, converted );
}
else {
labelList = g_list_append( labelList, g_strdup( "" ) );
@@ -1393,17 +1400,15 @@ GList *jpilot_load_custom_label( JPilotF
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' ) {
- if( convert_charcode ) {
- labelName = conv_codeset_strdup( labelName, CS_SHIFT_JIS, CS_INTERNAL );
- }
- else {
- labelName = g_strdup( labelName );
- }
- labelList = g_list_append( labelList, labelName );
+ gchar *converted = jpilot_convert( pilotFile, labelName );
+ if( converted ) {
+ g_strchomp( converted );
+ g_strchug( converted );
+ if( *converted != '\0' ) {
+ labelList = g_list_append( labelList, converted );
+ }
+ else {
+ g_free( converted );
}
}
}
@@ -1425,8 +1430,9 @@ GList *jpilot_get_category_list( JPilotF
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( pilotFile, catName );
+ if( converted ) {
+ catList = g_list_append( catList, converted );
}
else {
catList = g_list_append( catList, g_strdup( "" ) );
@@ -1446,16 +1452,10 @@ static void jpilot_build_category_list(
for( i = 0; i < JPILOT_NUM_CATEG; i++ ) {
ItemFolder *folder = addritem_create_item_folder();
+ gchar *name = jpilot_convert( pilotFile, cat->name[i] );
- if( convert_charcode ) {
- gchar *catName;
- catName = conv_codeset_strdup( cat->name[i], CS_SHIFT_JIS, CS_INTERNAL );
- addritem_folder_set_name( folder, catName );
- g_free( catName );
- }
- else {
- addritem_folder_set_name( folder, cat->name[i] );
- }
+ addritem_folder_set_name( folder, name );
+ g_free( name );
addrcache_id_folder( pilotFile->addressCache, folder );
addrcache_add_folder( pilotFile->addressCache, folder );
@@ -1507,16 +1507,16 @@ static void jpilot_remove_empty( JPilotF
* ============================================================================================
*/
gint jpilot_read_data( JPilotFile *pilotFile ) {
+ g_return_val_if_fail( pilotFile != NULL, -1 );
+
name_order = FAMILY_LAST;
- convert_charcode = FALSE;
if( conv_is_ja_locale() ) {
name_order = FAMILY_FIRST;
- convert_charcode = TRUE;
+ if ( !pilotFile->charset || !pilotFile->charset[0] )
+ jpilot_set_charset( pilotFile, CS_SHIFT_JIS );
}
- g_return_val_if_fail( pilotFile != NULL, -1 );
-
pilotFile->retVal = MGU_SUCCESS;
pilotFile->accessFlag = FALSE;
--- sylpheed/src/addrindex.c.alt-jpilotcharset 2005-08-08 11:07:19 +0400
+++ sylpheed/src/addrindex.c 2006-05-28 17:36:18 +0400
@@ -75,6 +75,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"
@@ -794,6 +795,9 @@ static AddressDataSource *addrindex_pars
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 );
}
@@ -821,6 +825,7 @@ static void addrindex_write_jpilot( FILE
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/src/jpilot.h.alt-jpilotcharset 2005-01-12 14:22:08 +0300
+++ sylpheed/src/jpilot.h 2006-05-28 17:36:18 +0400
@@ -50,6 +50,7 @@ struct _JPilotFile {
gchar *name;
FILE *file;
gchar *path;
+ gchar *charset;
AddressCache *addressCache;
struct AddressAppInfo addrInfo;
gboolean readMetadata;
@@ -75,6 +76,7 @@ JPilotFile *jpilot_create ( void );
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 );