static KABC::Addressee convertLdapAttributesToAddressee( const KLDAP::LdapAttrMap &attrs ) { KABC::Addressee addr; // name if ( !attrs.value( "cn" ).isEmpty() ) { addr.setNameFromString( asUtf8( attrs["cn"].first() ) ); } // email KLDAP::LdapAttrValue lst = attrs["mail"]; KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin(); bool pref = true; while ( it != lst.constEnd() ) { addr.insertEmail( asUtf8( *it ), pref ); pref = false; ++it; } if ( !attrs.value( "o" ).isEmpty() ) { addr.setOrganization( asUtf8( attrs[ "o" ].first() ) ); } if ( addr.organization().isEmpty() && !attrs.value( "Company" ).isEmpty() ) { addr.setOrganization( asUtf8( attrs[ "Company" ].first() ) ); } // Address KABC::Address workAddr( KABC::Address::Work ); if ( !attrs.value( "department" ).isEmpty() ) { addr.setDepartment( asUtf8( attrs[ "department" ].first() ) ); } if ( !workAddr.isEmpty() ) { addr.insertAddress( workAddr ); } // phone if ( !attrs.value( "homePhone" ).isEmpty() ) { KABC::PhoneNumber homeNr = asUtf8( attrs[ "homePhone" ].first() ); homeNr.setType( KABC::PhoneNumber::Home ); addr.insertPhoneNumber( homeNr ); } if ( !attrs.value( "telephoneNumber" ).isEmpty() ) { KABC::PhoneNumber workNr = asUtf8( attrs[ "telephoneNumber" ].first() ); workNr.setType( KABC::PhoneNumber::Work ); addr.insertPhoneNumber( workNr ); } if ( !attrs.value( "facsimileTelephoneNumber" ).isEmpty() ) { KABC::PhoneNumber faxNr = asUtf8( attrs[ "facsimileTelephoneNumber" ].first() ); faxNr.setType( KABC::PhoneNumber::Fax ); addr.insertPhoneNumber( faxNr ); } if ( !attrs.value( "mobile" ).isEmpty() ) { KABC::PhoneNumber cellNr = asUtf8( attrs[ "mobile" ].first() ); cellNr.setType( KABC::PhoneNumber::Cell ); addr.insertPhoneNumber( cellNr ); } if ( !attrs.value( "pager" ).isEmpty() ) { KABC::PhoneNumber pagerNr = asUtf8( attrs[ "pager" ].first() ); pagerNr.setType( KABC::PhoneNumber::Pager ); addr.insertPhoneNumber( pagerNr ); } return addr; }
static void setDepartment(const QString &value, KABC::Addressee &addressee) { addressee.setDepartment(value); }