aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja8
-rw-r--r--src/ldif.c94
-rw-r--r--src/ldif.h3
4 files changed, 89 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e55cf25..10fb9823 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-12
+
+ * src/ldif.[ch]: supported base64 encoded entries.
+ Supported "mozillaNickname" entry.
+ Use cn for display name if exists.
+ Reverse first and last name on Japanese locale.
+
2006-09-06
* src/messageview.c
diff --git a/ChangeLog.ja b/ChangeLog.ja
index dc89ecb9..6a7daf50 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,11 @@
+2006-09-12
+
+ * src/ldif.[ch]: base64 エンコードされたエントリに対応。
+ "mozillaNickname" エントリに対応。
+ cn エントリが存在する場合は表示名に使用するようにした。
+ 日本語ロケールの場合はファーストネームとラストネームを入れ替える
+ ようにした。
+
2006-09-06
* src/messageview.c
diff --git a/src/ldif.c b/src/ldif.c
index 91daf0d7..b2a74278 100644
--- a/src/ldif.c
+++ b/src/ldif.c
@@ -32,6 +32,7 @@
#include "addrcache.h"
#include "base64.h"
+#include "codeconv.h"
#include "utils.h"
/*
@@ -384,6 +385,7 @@ static void ldif_build_items( LdifFile *ldifFile, Ldif_ParsedRec *rec, AddressCa
gint iLen = 0, iLenT = 0;
ItemPerson *person;
ItemEMail *email;
+ gboolean familyFirst = FALSE;
nodeAddress = rec->listAddress;
if( nodeAddress == NULL ) return;
@@ -408,22 +410,45 @@ static void ldif_build_items( LdifFile *ldifFile, Ldif_ParsedRec *rec, AddressCa
if( rec->listLName ) {
lastName = rec->listLName->data;
}
-
- if( firstName ) {
- if( lastName ) {
- fullName = g_strdup_printf( "%s %s", firstName, lastName );
- }
- else {
- fullName = g_strdup_printf( "%s", firstName );
- }
+ if( rec->listCName ) {
+ fullName = g_strdup((gchar *)rec->listCName->data);
}
- else {
- if( lastName ) {
- fullName = g_strdup_printf( "%s", lastName );
+
+ familyFirst = conv_is_ja_locale();
+
+ if( fullName == NULL ) {
+ if( familyFirst ) {
+ if( lastName ) {
+ if( firstName ) {
+ fullName = g_strdup_printf( "%s %s", lastName, firstName );
+ }
+ else {
+ fullName = g_strdup_printf( "%s", lastName );
+ }
+ }
+ else {
+ if( firstName ) {
+ fullName = g_strdup_printf( "%s", firstName );
+ }
+ }
+ } else {
+ if( firstName ) {
+ if( lastName ) {
+ fullName = g_strdup_printf( "%s %s", firstName, lastName );
+ }
+ else {
+ fullName = g_strdup_printf( "%s", firstName );
+ }
+ }
+ else {
+ if( lastName ) {
+ fullName = g_strdup_printf( "%s", lastName );
+ }
+ }
}
}
if( fullName ) {
- g_strchug( fullName ); g_strchomp( fullName );
+ g_strstrip( fullName );
}
if( rec->listNName ) {
@@ -511,7 +536,8 @@ static void ldif_add_value( Ldif_ParsedRec *rec, gchar *tagName, gchar *tagValue
else if( g_ascii_strcasecmp( nm, LDIF_TAG_LASTNAME ) == 0 ) {
rec->listLName = g_slist_append( rec->listLName, val );
}
- else if( g_ascii_strcasecmp( nm, LDIF_TAG_NICKNAME ) == 0 ) {
+ else if( g_ascii_strcasecmp( nm, LDIF_TAG_NICKNAME ) == 0 ||
+ g_ascii_strcasecmp( nm, LDIF_TAG_XNICKNAME ) == 0 ) {
rec->listNName = g_slist_append( rec->listNName, val );
}
else if( g_ascii_strcasecmp( nm, LDIF_TAG_EMAIL ) == 0 ) {
@@ -598,21 +624,43 @@ static void ldif_dump_b64( gchar *buf ) {
gchar outBuf[8192];
gint len;
- printf( "base-64 : inbuf : %s\n", buf );
+ g_print( "base-64 : inbuf : %s\n", buf );
decoder = base64_decoder_new();
len = base64_decoder_decode( decoder, buf, outBuf );
if (len < 0) {
- printf( "base-64 : Bad BASE64 content\n" );
+ g_print( "base-64 : Bad BASE64 content\n" );
}
else {
outBuf[len] = '\0';
- printf( "base-64 : %d : %s\n\n", len, outBuf );
+ g_print( "base-64 : %d : %s\n\n", len, outBuf );
}
base64_decoder_free( decoder );
decoder = NULL;
}
#endif
+static gchar *ldif_conv_base64( gchar *buf ) {
+ gchar *outbuf;
+ gint len;
+
+ outbuf = g_malloc(strlen(buf) + 1);
+ len = base64_decode(outbuf, buf, -1);
+ outbuf[len] = '\0';
+ if (g_utf8_validate(outbuf, -1, NULL))
+ return outbuf;
+ else {
+ gchar *utf8str;
+
+ if (conv_is_ja_locale())
+ utf8str = conv_codeset_strdup(outbuf, NULL, NULL);
+ else
+ utf8str = conv_localetodisp(outbuf, NULL);
+
+ g_free(outbuf);
+ return utf8str;
+ }
+}
+
/*
* Read file data into address cache.
* Note that one LDIF record identifies one entity uniquely with the
@@ -663,11 +711,12 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
fullValue = mgu_list_coalesce( listValue );
/* Base-64 encoded data */
- /*
if( last64 ) {
- ldif_dump_b64( fullValue );
+ gchar *decValue;
+ decValue = ldif_conv_base64( fullValue );
+ g_free( fullValue );
+ fullValue = decValue;
}
- */
ldif_add_value( rec, lastTag, fullValue, hashField );
/* ldif_print_record( rec, stdout ); */
@@ -700,11 +749,12 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
/* Save data */
fullValue = mgu_list_coalesce( listValue );
/* Base-64 encoded data */
- /*
if( last64 ) {
- ldif_dump_b64( fullValue );
+ gchar *decValue;
+ decValue = ldif_conv_base64( fullValue );
+ g_free( fullValue );
+ fullValue = decValue;
}
- */
ldif_add_value( rec, lastTag, fullValue, hashField );
g_free( lastTag );
diff --git a/src/ldif.h b/src/ldif.h
index 5ec2643c..90e3e563 100644
--- a/src/ldif.h
+++ b/src/ldif.h
@@ -38,7 +38,8 @@
#define LDIF_TAG_COMMONNAME "cn"
#define LDIF_TAG_FIRSTNAME "givenname"
#define LDIF_TAG_LASTNAME "sn"
-#define LDIF_TAG_NICKNAME "xmozillanickname"
+#define LDIF_TAG_NICKNAME "mozillanickname"
+#define LDIF_TAG_XNICKNAME "xmozillanickname"
#define LDIF_TAG_EMAIL "mail"
#define LDIF_SEP_TAG ':'