Bug 115219 - kaddressbook uses X-KADDRESSBOOK-X-Department where ORG:organization;department should be used
Summary: kaddressbook uses X-KADDRESSBOOK-X-Department where ORG:organization;departme...
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kab3
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Tobias Koenig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-27 20:47 UTC by Nabil Sayegh
Modified: 2009-08-05 16:27 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nabil Sayegh 2005-10-27 20:47:48 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Debian testing/unstable Packages

kaddressbook uses the special property X-KADDRESSBOOK-X-Department, but according to http://www.faqs.org/rfcs/rfc2426.html ORG:organization;department should be used.

Additionally, other applications use ORG:organization;department and kaddressbook displays "organization;department" in the organization field.

[QUOTE]
3.5.5 ORG Type Definition

   To: ietf-mime-directory@imc.org

   Subject: Registration of text/directory MIME type ORG

   Type name: ORG

   Type purpose: To specify the organizational name and units associated
   with the vCard.

   Type encoding: 8bit

   Type value: A single structured text value consisting of components
   separated the SEMI-COLON character (ASCII decimal 59).

   Type special notes: The type is based on the X.520 Organization Name
   and Organization Unit attributes. The type value is a structured type
   consisting of the organization name, followed by one or more levels
   of organizational unit names.

   Type example: A type value consisting of an organizational name,
   organizational unit #1 name and organizational unit #2 name.

        ORG:ABC\, Inc.;North American Division;Marketing
[/QUOTE]
Comment 1 Juha Tuomala 2007-08-16 14:34:10 UTC
We confirm this from opensync.org. vconvert debugging tool is able to compose proper internal XML format data from valid RFC vcard30, but not from one that kaddressbook creates.

$ cat Steve_Ballmer.invalid.vcf
BEGIN:VCARD
CATEGORIES:Business
CLASS:PUBLIC
FN:Steve Ballmer
N:Ballmer;Steve;;;
ORG:Micro Soft\, Inc.
TEL;TYPE=CELL:+445551234
UID:i5McZbI28a
VERSION:3.0
X-KADDRESSBOOK-X-Department:North American Division; Marketing
END:VCARD



$ vconvert Steve_Ballmer.invalid.vcf --to-xmlformat
<?xml version="1.0"?>
<contact>
  <Categories>
    <Category>Business</Category>
  </Categories>
  <Class>
    <Content>PUBLIC</Content>
  </Class>
  <FormattedName>
    <Content>Steve Ballmer</Content>
  </FormattedName>
  <Name>
    <LastName>Ballmer</LastName>
    <FirstName>Steve</FirstName>
  </Name>
  <Organization>
    <Name>Micro Soft, Inc.</Name>
  </Organization>
  <Telephone Type="Cellular">
    <Content>+445551234</Content>
  </Telephone>
  <Uid>
    <Content>i5McZbI28a</Content>
  </Uid>
</contact>



$ cat Steve_Ballmer.valid.vcf
BEGIN:VCARD
CATEGORIES:Business
CLASS:PUBLIC
FN:Steve Ballmer
N:Ballmer;Steve;;;
ORG:Micro Soft\, Inc.;North American Division;Marketing
TEL;TYPE=CELL:+445551234
UID:i5McZbI28a
VERSION:3.0
END:VCARD

vconvert Steve_Ballmer.valid.vcf --to-xmlformat
<?xml version="1.0"?>
<contact>
  <Categories>
    <Category>Business</Category>
  </Categories>
  <Class>
    <Content>PUBLIC</Content>
  </Class>
  <FormattedName>
    <Content>Steve Ballmer</Content>
  </FormattedName>
  <Name>
    <LastName>Ballmer</LastName>
    <FirstName>Steve</FirstName>
  </Name>
  <Organization>
    <Name>Micro Soft, Inc.</Name>
    <Unit>North American Division</Unit>
    <Unit>Marketing</Unit>
  </Organization>
  <Telephone Type="Cellular">
    <Content>+445551234</Content>
  </Telephone>
  <Uid>
    <Content>i5McZbI28a</Content>
  </Uid>
</contact>


Even having both valid ORG and proprietary X-KADDRESSBOOK-X-Department in the same card works fine with opensync vconversion.

Basically that causes synchronizations to break into conflicts when doing the second sync with same actual data.

Is there any change to get this fixed for 3.5.x branch? 4.0 is close but not cigar yet. It can be hacked into kdepim-sync plugin at opensync end, but it doesn't change the fact that data ends into wrong place.
Comment 2 Hasso Tepper 2007-08-16 15:01:48 UTC
*** This bug has been confirmed by popular vote. ***
Comment 3 Juha Tuomala 2007-08-16 15:09:58 UTC
The format in question is VCARD 3.0, here is the RFC:

http://www.rfc-editor.org/cgi-bin/rfcdoctype.pl?loc=RFC&letsgo=2426&type=ftp&file_format=txt
Comment 5 Bruno Virlet 2007-08-20 13:15:26 UTC
Fixed by http://websvn.kde.org/?view=rev&revision=702252
Comment 6 Bruno Virlet 2007-08-20 13:43:58 UTC
SVN commit 702317 by bvirlet:

Port fix (r702252) to KDE4

CCBUG: 115219


 M  +8 -2      ldifconverter.cpp  
 M  +1 -0      scripts/entrylist  
 M  +12 -4     vcardtool.cpp  


--- trunk/KDE/kdepimlibs/kabc/ldifconverter.cpp #702316:702317
@@ -145,7 +145,13 @@
   ldif_out( t, "o", addr.organization() );
   ldif_out( t, "organization", addr.organization() );
   ldif_out( t, "organizationname", addr.organization() );
-  ldif_out( t, "department", addr.custom( "KADDRESSBOOK", "X-Department" ) );
+
+  // Compatibility with older kabc versions.
+  if ( addr.department().isEmpty() )
+    ldif_out( t, "department", addr.department() );
+  else
+    ldif_out( t, "department", addr.custom("KADDRESSBOOK", "X-Department") );
+
   ldif_out( t, "workurl", addr.url().prettyUrl() );
   ldif_out( t, "homeurl", addr.url().prettyUrl() );
   ldif_out( t, "description", addr.note() );
@@ -459,7 +465,7 @@
   }
 
   if ( fieldname == QLatin1String( "department" ) ) {
-    a.insertCustom( "KADDRESSBOOK", "X-Department", value );
+    a.setDepartment( value );
     return true;
   }
 
--- trunk/KDE/kdepimlibs/kabc/scripts/entrylist #702316:702317
@@ -63,6 +63,7 @@
 ALFE,title,a person's title,QString,title,Organization
 ALFE,role,of a person in an organization,QString,role,Organization
 ALFE,organization,,QString,organization,Organization
+ALFE,department,,QString,department,Organization
 
 ALFE,note,,QString,note
 
--- trunk/KDE/kdepimlibs/kabc/vcardtool.cpp #702316:702317
@@ -238,8 +238,12 @@
     card.addLine( noteLine );
 
     // ORG
-    VCardLine orgLine( "ORG", (*addrIt).organization() );
-    if ( version == VCard::v2_1 && needsEncoding( (*addrIt).organization() ) ) {
+    QStringList organization;
+    organization.append( ( *addrIt ).organization().replace( ';', "\\;" ) );
+    if ( !( *addrIt ).department().isEmpty() )
+      organization.append( ( *addrIt ).department().replace( ';', "\\;" ) );
+    VCardLine orgLine( "ORG", organization.join( ";" ) );
+    if ( version == VCard::v2_1 && needsEncoding( organization.join( ";" ) ) ) {
       orgLine.addParameter( "charset", "UTF-8" );
       orgLine.addParameter( "encoding", "QUOTED-PRINTABLE" );
     }
@@ -529,9 +533,13 @@
 
         // ORGANIZATION
         else if ( identifier == "org" ) {
-          addr.setOrganization( (*lineIt).value().toString() );
+          const QStringList orgParts = splitString( semicolonSep, (*lineIt).value().toString() );
+          if ( orgParts.count() > 0 )
+            addr.setOrganization( orgParts[ 0 ] );
+          if ( orgParts.count() > 1 )
+            addr.setDepartment( orgParts[ 1 ] );
         }
-
+ 
         // PHOTO
         else if ( identifier == "photo" ) {
           addr.setPhoto( parsePicture( *lineIt ) );
Comment 7 Juha Tuomala 2007-08-20 14:07:55 UTC
Thanks a lot for quick reaction :)
Comment 8 Bruno Virlet 2007-08-20 14:13:13 UTC
SVN commit 702333 by bvirlet:

Fix (thank you Christian).

CCBUG: 115219


 M  +13 -13    ldifconverter.cpp  


--- branches/KDE/3.5/kdelibs/kabc/ldifconverter.cpp #702332:702333
@@ -143,7 +143,7 @@
   ldif_out( t, "organizationname", addr.organization() );
 
   // Compatibility with older kabc versions.
-  if ( addr.department().isEmpty() )
+  if ( !addr.department().isEmpty() )
     ldif_out( t, "department", addr.department() );
   else
     ldif_out( t, "department", addr.custom("KADDRESSBOOK", "X-Department") );
@@ -179,7 +179,7 @@
   QByteArray data;
   Addressee a;
   Address homeAddr, workAddr;
-  
+
   data.setRawData( latinstr, latinstrlen );
   ldif.setLDIF( data );
   if (!dt.isValid())
@@ -187,7 +187,7 @@
   a.setRevision(dt);
   homeAddr = Address( Address::Home );
   workAddr = Address( Address::Work );
-  
+
   do {
     ret = ldif.nextItem();
     switch ( ret ) {
@@ -199,7 +199,7 @@
       }
       case LDIF::EndEntry:
       // if the new address is not empty, append it
-        if ( !a.formattedName().isEmpty() || !a.name().isEmpty() || 
+        if ( !a.formattedName().isEmpty() || !a.name().isEmpty() ||
           !a.familyName().isEmpty() ) {
           if ( !homeAddr.isEmpty() )
             a.insertAddress( homeAddr );
@@ -213,10 +213,10 @@
         workAddr = Address( Address::Work );
         break;
       case LDIF::MoreData: {
-        if ( endldif ) 
+        if ( endldif )
           end = true;
         else {
-          ldif.endLDIF();  
+          ldif.endLDIF();
           endldif = true;
           break;
         }
@@ -227,7 +227,7 @@
   } while ( !end );
 
   data.resetRawData( latinstr, latinstrlen );
-  
+
   return true;
 }
 
@@ -254,7 +254,7 @@
     return true;
   }
 
-  if ( fieldname == QString::fromLatin1( "xmozillanickname") || 
+  if ( fieldname == QString::fromLatin1( "xmozillanickname") ||
        fieldname == QString::fromLatin1( "nickname") ) {
     a.setNickName( value );
     return true;
@@ -291,7 +291,7 @@
     return true;
   }
 
-  if ( fieldname == QString::fromLatin1( "o" ) || 
+  if ( fieldname == QString::fromLatin1( "o" ) ||
        fieldname == QString::fromLatin1( "organization" ) ||      // Exchange
        fieldname == QString::fromLatin1( "organizationname" ) ) { // Exchange
     a.setOrganization( value );
@@ -325,7 +325,7 @@
     // TODO: change this with KDE 4
   }
 
-  if ( fieldname == QString::fromLatin1( "homephone" ) ) { 
+  if ( fieldname == QString::fromLatin1( "homephone" ) ) {
     a.insertPhoneNumber( PhoneNumber( value, PhoneNumber::Home ) );
     return true;
   }
@@ -486,7 +486,7 @@
     }
   }
 
-  if ( fieldname == QString::fromLatin1( "objectclass" ) ) // ignore 
+  if ( fieldname == QString::fromLatin1( "objectclass" ) ) // ignore
     return true;
 
   kdWarning() << QString("LDIFConverter: Unknown field for '%1': '%2=%3'\n")
@@ -531,7 +531,7 @@
   if (formatStr.find(':') == -1)
     formatStr.append(": %1\n");
 
-  // check if base64-encoding is needed 
+  // check if base64-encoding is needed
   bool printable = true;
   unsigned int i, len;
   len = value.length();
@@ -545,7 +545,7 @@
   if (printable) // always encode if we find special chars...
     printable = (value.find('\n') == -1);
 
-  if (!printable && allowEncode) { 
+  if (!printable && allowEncode) {
     // encode to base64
     value = KCodecs::base64Encode( value.utf8() );
     int p = formatStr.find(':');
Comment 9 Tobias Koenig 2009-08-05 16:27:46 UTC
The development of the old KAddressBook will be discontinued for KDE 4.4.
Since the new application has the same name, but a completly new code base we close all bug reports against the old version and ask the submitters to resend there reports against the new product.