2009-10-20 [colin] 3.7.3cvs3
authorColin Leroy <colin@colino.net>
Tue, 20 Oct 2009 06:37:05 +0000 (06:37 +0000)
committerColin Leroy <colin@colino.net>
Tue, 20 Oct 2009 06:37:05 +0000 (06:37 +0000)
* src/exportldif.c
* src/ldif.c
* src/ldif.h
Fix LDIF export. Patch by Michael Rasmussen

ChangeLog
PATCHSETS
configure.ac
src/exportldif.c
src/ldif.c
src/ldif.h

index 880d7e7878eb4584385db3a4fbc186c0f9308c12..19c53219ab2254a8be840dc051ba64547e26d7ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-20 [colin]     3.7.3cvs3
+
+       * src/exportldif.c
+       * src/ldif.c
+       * src/ldif.h
+               Fix LDIF export. Patch by Michael Rasmussen
+
 2009-10-18 [paul]      3.7.3cvs2
 
        * tools/claws.i18n.status.pl
index d18ba7d4a6237202f6c92205917617fd4d8d70a3..a2ad3490c3fde7bb0076895a17b420bca10580e4 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.207.2.214 -r 1.207.2.215 src/folderview.c;  cvs diff -u -r 1.20.2.25 -r 1.20.2.26 src/folderview.h;  cvs diff -u -r 1.274.2.302 -r 1.274.2.303 src/mainwindow.c;  ) > 3.7.2cvs49.patchset
 ( cvs diff -u -r 1.105.2.155 -r 1.105.2.156 src/prefs_account.c;  cvs diff -u -r 1.1.2.28 -r 1.1.2.29 src/prefs_compose_writing.c;  cvs diff -u -r 1.16.2.39 -r 1.16.2.40 src/prefs_customheader.c;  cvs diff -u -r 1.1.2.26 -r 1.1.2.27 src/prefs_receive.c;  cvs diff -u -r 1.1.2.62 -r 1.1.2.63 src/prefs_summaries.c;  cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/prefs_wrapping.c;  ) > 3.7.3cvs1.patchset
 ( cvs diff -u -r 1.1.2.21 -r 1.1.2.22 tools/claws.i18n.status.pl;  ) > 3.7.3cvs2.patchset
+( cvs diff -u -r 1.1.4.20 -r 1.1.4.21 src/exportldif.c;  cvs diff -u -r 1.12.2.21 -r 1.12.2.22 src/ldif.c;  cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/ldif.h;  ) > 3.7.3cvs3.patchset
index 4623ac4ab2c21aeb7411fedbd3e9702fea69398b..42f643bdab4743db6129f8a872e4594755706b97 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=2
+EXTRA_VERSION=3
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 04857521e8baf0a7a954b9e15d9217d044ae8b20..2bdb4f06bad8e041c3030cdb96410e3c5bf743e4 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
 
 /*
@@ -330,6 +330,57 @@ static gboolean exportldif_test_email( const ItemPerson *person )
        return retVal;
 }
 
+/**
+ * Format other attributes for person.
+ * \param person ItemPerson.
+ * \param stream Output stream.
+ */
+static void exportldif_fmt_other_attributes(ItemPerson* person, FILE* stream) {
+    UserAttribute* attr;
+    GList* attrList = NULL;
+    gchar* attrib;
+
+    if (! person)
+        return;
+    debug_print("cn: %s\n-----------------------------\n", ADDRITEM_NAME(person));
+    attrList = person->listAttrib;
+    while (attrList) {
+        attr = (UserAttribute *) attrList->data;
+        if (attr->uid) {
+            /* Native address book which does not conform to
+             * the LDAP schemas
+             */
+            attrib = g_strdup_printf("# %s", attr->name);
+        }
+        else {
+            attrib = g_strdup(attr->name);
+        }
+        debug_print("name: %s\nvalue: %s\n", attrib, attr->value);
+        ldif_write_value(stream, attrib, attr->value);
+        g_free(attrib);
+        attrList = g_list_next(attrList);
+    }
+    debug_print("-------------------------------\n");
+}
+
+/**
+ * Find persons displayName.
+ * \param person ItemPerson.
+ * \return displayName.
+ */
+static gchar* exportldif_find_displayName(ItemPerson* person) {
+       gchar* displayName;
+
+       if (! person)
+           return NULL;
+       
+       if (person->nickName && strlen(person->nickName) > 0)
+               displayName = g_strdup(person->nickName);
+       else
+               displayName = g_strdup(ADDRITEM_NAME(person));
+       return displayName;
+}
+
 /**
  * Format persons in an address book folder.
  * \param  ctl    Export control data.
@@ -342,6 +393,8 @@ static gboolean exportldif_fmt_person(
 {
        gboolean retVal = TRUE;
        const GList *node;
+       gchar* sn = NULL;
+       gchar* displayName = NULL;
 
        if( folder->listPerson == NULL ) return retVal;
 
@@ -401,15 +454,33 @@ static gboolean exportldif_fmt_person(
                        /* Format person attributes */
                        ldif_write_value(
                                stream, LDIF_TAG_COMMONNAME, ADDRITEM_NAME( person ) );
+                       sn = g_strdup(person->lastName);
+                       if (classPerson || classInetP) {
+                               if(! sn || strcmp("", sn) == 0 || strcmp(" ", sn) == 0) {
+                                       g_free(sn);
+                                       sn = g_strdup("Some SN");
+                               }
+                       }
                        ldif_write_value(
-                               stream, LDIF_TAG_LASTNAME, person->lastName );
+                               stream, LDIF_TAG_LASTNAME, sn );
+                       g_free(sn);
+                       sn = NULL;
                        ldif_write_value(
                                stream, LDIF_TAG_FIRSTNAME, person->firstName );
-                       ldif_write_value(
-                               stream, LDIF_TAG_NICKNAME, person->nickName );
+
+                       if (! person->externalID)
+                               displayName = exportldif_find_displayName(person);
+                       else
+                               displayName = g_strdup(person->nickName);
+                       ldif_write_value(stream, LDIF_TAG_NICKNAME, displayName);
+                       g_free(displayName);
+                       displayName = NULL;
 
                        /* Format E-Mail */
                        exportldif_fmt_email( person, stream );
+                       
+                       /* Handle other attributes */
+                       exportldif_fmt_other_attributes(person, stream);
 
                        /* End record */
                        ldif_write_eor( stream );
index aa7c73cebea2884b1226398889cf69f04767cda6..c82b4a56f4b865e0c137975b6c223c0983b920f6 100644 (file)
@@ -295,7 +295,7 @@ static gchar *ldif_get_tagname( char* line, gboolean *flag64 ) {
        gchar *tag = NULL;
        gchar *lptr = line;
        gchar *sptr = NULL;
-       gchar *down = NULL;
+       
        while( *lptr++ ) {
                /* Check for language tag */
                if( *lptr == LDIF_LANG_TAG ) {
@@ -316,9 +316,7 @@ static gchar *ldif_get_tagname( char* line, gboolean *flag64 ) {
 
                        tag = g_strndup( line, len+1 );
                        tag[ len ] = '\0';
-                       down = g_utf8_strdown( tag, -1 );
-                       g_free(tag);
-                       return down;
+                        return tag;
                }
        }
        return tag;
index 2ff58f3233603c7781033c7baeed6f60f65bb60a..2dc1ef6fed49a18090845f9833e7e8032b05df2d 100644 (file)
 /* Common tag names - for address book import/export */
 #define        LDIF_TAG_DN            "dn"
 #define        LDIF_TAG_COMMONNAME    "cn"
-#define        LDIF_TAG_FIRSTNAME     "givenname"
+#define        LDIF_TAG_FIRSTNAME     "givenName"
 #define        LDIF_TAG_LASTNAME      "sn"
-#define LDIF_TAG_NICKNAME      "xmozillanickname"
+#define        LDIF_TAG_NICKNAME      "displayName"
 #define        LDIF_TAG_EMAIL         "mail"
-#define        LDIF_TAG_OBJECTCLASS   "objectclass"
+#define        LDIF_TAG_OBJECTCLASS   "objectClass"
 
 /* Object classes */
-#define LDIF_CLASS_PERSON      "person"
-#define LDIF_CLASS_INET_PERSON "inetOrgPerson"
+#define        LDIF_CLASS_PERSON      "person"
+#define        LDIF_CLASS_INET_PERSON "inetOrgPerson"
 
 /*
 * Typical LDIF entry (similar to that generated by Netscape):