diff options
Diffstat (limited to 'kresources/kolab/kabc')
-rw-r--r-- | kresources/kolab/kabc/contact.cpp | 72 | ||||
-rw-r--r-- | kresources/kolab/kabc/contact.h | 7 | ||||
-rw-r--r-- | kresources/kolab/kabc/kolab.desktop | 1 | ||||
-rw-r--r-- | kresources/kolab/kabc/resourcekolab.cpp | 64 | ||||
-rw-r--r-- | kresources/kolab/kabc/resourcekolab.h | 3 |
5 files changed, 92 insertions, 55 deletions
diff --git a/kresources/kolab/kabc/contact.cpp b/kresources/kolab/kabc/contact.cpp index fc9087316..26a91e679 100644 --- a/kresources/kolab/kabc/contact.cpp +++ b/kresources/kolab/kabc/contact.cpp @@ -35,6 +35,7 @@ #include <kabc/addressee.h> #include <kabc/stdaddressbook.h> +#include <libkcal/freebusyurlstore.h> #include <libkdepim/distributionlist.h> #include <kio/netaccess.h> #include <kdebug.h> @@ -222,15 +223,15 @@ TQString Contact::profession() const return mProfession; } -// void Contact::setJobTitle( const TQString& title ) -// { -// mJobTitle = title; -// } +void Contact::setJobTitle( const TQString& title ) +{ + mJobTitle = title; +} -// TQString Contact::jobTitle() const -// { -// return mJobTitle; -// } +TQString Contact::jobTitle() const +{ + return mJobTitle; +} void Contact::setManagerName( const TQString& name ) { @@ -485,6 +486,11 @@ void Contact::saveCustomAttributes( TQDomElement& element ) const if ( (*it).app == s_unhandledTagAppName ) { writeString( element, (*it).name, (*it).value ); } else { + // skip writing the freebusyurl as it is a hack we need to remove eventually + if ( (*it).name == TQString::fromLatin1( "FreeBusyURL" ) ) { + continue; + } + // Let's use attributes so that other tag-preserving-code doesn't need sub-elements TQDomElement e = element.ownerDocument().createElement( "x-custom" ); element.appendChild( e ); @@ -659,7 +665,7 @@ bool Contact::loadAttribute( TQDomElement& element ) case 'j': if ( tagName == "job-title" ) { // see saveAttributes: <job-title> is mapped to the Role field - setRole( element.text() ); + setJobTitle( element.text() ); return true; } break; @@ -766,7 +772,6 @@ bool Contact::saveAttributes( TQDomElement& element ) const { // Save the base class elements KolabBase::saveAttributes( element ); - if ( mIsDistributionList ) { writeString( element, "display-name", fullName() ); saveDistrListMembers( element ); @@ -779,11 +784,8 @@ bool Contact::saveAttributes( TQDomElement& element ) const writeString( element, "department", department() ); writeString( element, "office-location", officeLocation() ); writeString( element, "profession", profession() ); - // <role> is gone; jobTitle() is not shown in the addresseeeditor, - // so let's bind <job-title> to role() - //writeString( element, "role", role() ); - //writeString( element, "job-title", jobTitle() ); - writeString( element, "job-title", role() ); + writeString( element, "role", role() ); + writeString( element, "job-title", jobTitle() ); writeString( element, "manager-name", managerName() ); writeString( element, "assistant", assistant() ); writeString( element, "nick-name", nickName() ); @@ -891,28 +893,28 @@ static TQStringList phoneTypeToString( int /*KABC::PhoneNumber::Types*/ type ) type = type & ~KABC::PhoneNumber::Work; } - // To support both "home1" and "home2", map Home+Pref to home1 + // To support both "home1" and "home2", map Home+Pref to home2 if ( ( type & KABC::PhoneNumber::Home ) && ( type & KABC::PhoneNumber::Pref ) ) { - types << "home1"; + types << "home2"; type = type & ~KABC::PhoneNumber::Home; type = type & ~KABC::PhoneNumber::Pref; } - // To support both "business1" and "business2", map Work+Pref to business1 + // To support both "business1" and "business2", map Work+Pref to business2 if ( ( type & KABC::PhoneNumber::Work ) && ( type & KABC::PhoneNumber::Pref ) ) { - types << "business1"; + types << "business2"; type = type & ~KABC::PhoneNumber::Work; type = type & ~KABC::PhoneNumber::Pref; } if ( type & KABC::PhoneNumber::Home ) - types << "home2"; + types << "home1"; if ( type & KABC::PhoneNumber::Msg ) // Msg==messaging types << "company"; if ( type & KABC::PhoneNumber::Work ) - types << "business2"; + types << "business1"; if ( type & KABC::PhoneNumber::Pref ) types << "primary"; if ( type & KABC::PhoneNumber::Voice ) @@ -942,13 +944,13 @@ static int /*KABC::PhoneNumber::Types*/ phoneTypeFromString( const TQString& typ return KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax; if ( type == "businessfax" ) return KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax; - if ( type == "business1" ) - return KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref; if ( type == "business2" ) + return KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref; + if ( type == "business1" ) return KABC::PhoneNumber::Work; - if ( type == "home1" ) - return KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref; if ( type == "home2" ) + return KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref; + if ( type == "home1" ) return KABC::PhoneNumber::Home; if ( type == "company" ) return KABC::PhoneNumber::Msg; @@ -1019,11 +1021,15 @@ void Contact::setFields( const KABC::Addressee* addressee ) setOrganization( addressee->organization() ); setWebPage( addressee->url().url() ); setIMAddress( addressee->custom( "KADDRESSBOOK", "X-IMAddress" ) ); +#if KDE_IS_VERSION(3,5,8) + setDepartment( addressee->department()); +#else setDepartment( addressee->custom( "KADDRESSBOOK", "X-Department" ) ); +#endif setOfficeLocation( addressee->custom( "KADDRESSBOOK", "X-Office" ) ); setProfession( addressee->custom( "KADDRESSBOOK", "X-Profession" ) ); setRole( addressee->role() ); - //setJobTitle( addressee->title() ); + setJobTitle( addressee->title() ); setManagerName( addressee->custom( "KADDRESSBOOK", "X-ManagersName" ) ); setAssistant( addressee->custom( "KADDRESSBOOK", "X-AssistantsName" ) ); setNickName( addressee->nickName() ); @@ -1129,6 +1135,11 @@ void Contact::setFields( const KABC::Addressee* addressee ) } } + TQString url = KCal::FreeBusyUrlStore::self()->readUrl( addressee->preferredEmail() ); + if ( !url.isEmpty() ) { + setFreeBusyUrl( url ); + } + // Those fields, although defined in Addressee, are not used in KDE // (e.g. not visible in kaddressbook/addresseeeditorwidget.cpp) // So it doesn't matter much if we don't have them in the XML. @@ -1136,9 +1147,6 @@ void Contact::setFields( const KABC::Addressee* addressee ) // Things KAddressBook can't handle, so they are saved as unhandled tags: // initials, children, gender, language - - // TODO: Free/Busy URL. This is done rather awkward in KAddressBook - - // it stores it in a local file through a korganizer file :-( } // The loading is: xml -> Contact -> addressee, this is the second part @@ -1173,11 +1181,15 @@ void Contact::saveTo( KABC::Addressee* addressee ) addressee->setOrganization( organization() ); addressee->setUrl( webPage() ); addressee->insertCustom( "KADDRESSBOOK", "X-IMAddress", imAddress() ); +#if KDE_IS_VERSION(3,5,8) + addressee->setDepartment( department() ); +#else addressee->insertCustom( "KADDRESSBOOK", "X-Department", department() ); +#endif addressee->insertCustom( "KADDRESSBOOK", "X-Office", officeLocation() ); addressee->insertCustom( "KADDRESSBOOK", "X-Profession", profession() ); addressee->setRole( role() ); - //addressee->setTitle( jobTitle() ); + addressee->setTitle( jobTitle() ); addressee->insertCustom( "KADDRESSBOOK", "X-ManagersName", managerName() ); addressee->insertCustom( "KADDRESSBOOK", "X-AssistantsName", assistant() ); addressee->setNickName( nickName() ); diff --git a/kresources/kolab/kabc/contact.h b/kresources/kolab/kabc/contact.h index 39a235cc2..a9465642f 100644 --- a/kresources/kolab/kabc/contact.h +++ b/kresources/kolab/kabc/contact.h @@ -121,9 +121,8 @@ public: void setProfession( const TQString& profession ); TQString profession() const; - // not shown in the kaddressbook GUI - //void setJobTitle( const TQString& title ); - //TQString jobTitle() const; + void setJobTitle( const TQString& title ); + TQString jobTitle() const; void setManagerName( const TQString& name ); TQString managerName() const; @@ -245,7 +244,7 @@ private: TQString mDepartment; TQString mOfficeLocation; TQString mProfession; - //TQString mJobTitle; + TQString mJobTitle; TQString mManagerName; TQString mAssistant; TQString mNickName; diff --git a/kresources/kolab/kabc/kolab.desktop b/kresources/kolab/kabc/kolab.desktop index d75090a7a..8339f9c22 100644 --- a/kresources/kolab/kabc/kolab.desktop +++ b/kresources/kolab/kabc/kolab.desktop @@ -21,7 +21,6 @@ Name[hu]=IMAP-kiszolgálón tárolt címjegyzék a KMailen keresztül Name[is]=Vistfangaskrá á IMAP þjóni gegnum KMail Name[it]=Rubrica indirizzi su server IMAP via KMail Name[ja]=KMail 経由 IMAP サーバのアドレス帳 -Name[ka]=წიგნაკი IMAP-ის სერვერზე KMail-ის საშუალებით Name[kk]=KMail арқылы IMAP серверіндегі адрестік кітапша Name[km]=សៀវភៅអាសយដ្ឋានលើម៉ាស៊ីនបម្រើ IMAP តាមរយៈ KMail Name[lt]=Adresų knygelė IMAP serveryje per KMail diff --git a/kresources/kolab/kabc/resourcekolab.cpp b/kresources/kolab/kabc/resourcekolab.cpp index 034c32d78..ae8e225fb 100644 --- a/kresources/kolab/kabc/resourcekolab.cpp +++ b/kresources/kolab/kabc/resourcekolab.cpp @@ -79,9 +79,12 @@ static const char* s_inlineMimeType = "text/x-vcard"; KABC::ResourceKolab::ResourceKolab( const KConfig *config ) : KPIM::ResourceABC( config ), Kolab::ResourceKolabBase( "ResourceKolab-KABC" ), - mCachedSubresource( TQString::null ), mLocked( false ) + mCachedSubresource( TQString::null ), mCachedSubresourceNotFound( false ), mLocked( false ) { setType( "imap" ); + if ( !config ) { + setResourceName( i18n( "Kolab Server" ) ); + } } KABC::ResourceKolab::~ResourceKolab() @@ -124,14 +127,7 @@ bool KABC::ResourceKolab::doOpen() void KABC::ResourceKolab::doClose() { - KConfig config( configFile() ); - - Kolab::ResourceMap::ConstIterator it; - for ( it = mSubResources.begin(); it != mSubResources.end(); ++it ) { - config.setGroup( it.key() ); - config.writeEntry( "Active", it.data().active() ); - config.writeEntry( "CompletionWeight", it.data().completionWeight() ); - } + writeConfig(); } KABC::Ticket * KABC::ResourceKolab::requestSaveTicket() @@ -149,6 +145,7 @@ void KABC::ResourceKolab::releaseSaveTicket( Ticket* ticket ) { mLocked = false; mCachedSubresource = TQString::null; + mCachedSubresourceNotFound = false; delete ticket; } @@ -163,7 +160,11 @@ TQString KABC::ResourceKolab::loadContact( const TQString& contactData, contact.saveTo( &addr ); } else { KABC::VCardConverter converter; +#if defined(KABC_VCARD_ENCODING_FIX) + addr = converter.parseVCardRaw( contactData.utf8() ); +#else addr = converter.parseVCard( contactData ); +#endif } addr.setResource( this ); @@ -301,11 +302,11 @@ void AttachmentList::updatePictureAttachment( const TQImage& image, const TQStri { assert( !name.isEmpty() ); if ( !image.isNull() ) { - KTempFile* tempFile = new KTempFile; - image.save( tempFile->file(), "PNG" ); - tempFile->close(); + KTempFile tempFile; + image.save( tempFile.file(), "PNG" ); + tempFile.close(); KURL url; - url.setPath( tempFile->name() ); + url.setPath( tempFile.name() ); kdDebug(5650) << "picture saved to " << url.path() << endl; addAttachment( url.url(), name, "image/png" ); } else { @@ -317,11 +318,11 @@ void AttachmentList::updateAttachment( const TQByteArray& data, const TQString& { assert( !name.isEmpty() ); if ( !data.isNull() ) { - KTempFile* tempFile = new KTempFile; - tempFile->file()->writeBlock( data ); - tempFile->close(); + KTempFile tempFile; + tempFile.file()->writeBlock( data ); + tempFile.close(); KURL url; - url.setPath( tempFile->name() ); + url.setPath( tempFile.name() ); kdDebug(5650) << "data saved to " << url.path() << endl; addAttachment( url.url(), name, mimetype ); } else { @@ -342,14 +343,20 @@ bool KABC::ResourceKolab::kmailUpdateAddressee( const Addressee& addr ) } sernum = mUidMap[ uid ].serialNumber(); } else { - if ( !mCachedSubresource.isNull() ) { + if ( !mCachedSubresource.isNull() || mCachedSubresourceNotFound ) { subResource = mCachedSubresource; } else { - subResource = findWritableResource( mSubResources ); + subResource = findWritableResource( Kolab::Contacts, mSubResources ); // We were locked, remember the subresource we are working with until // we are unlocked - if ( mLocked ) + if ( mLocked ) { mCachedSubresource = subResource; + + // If the subresource is empty here, it means findWritableResource() failed, for example + // because the user cancelled the resource selection dialog. Remember that, so we avoid + // asking multiple times when locked. + mCachedSubresourceNotFound = subResource.isEmpty(); + } } if ( subResource.isEmpty() ) return false; @@ -374,7 +381,11 @@ bool KABC::ResourceKolab::kmailUpdateAddressee( const Addressee& addr ) } else { mimetype = s_inlineMimeType; KABC::VCardConverter converter; +#if defined(KABC_VCARD_ENCODING_FIX) + data = TQString::fromUtf8( converter.createVCardRaw( addr ) ); +#else data = converter.createVCard( addr ); +#endif subject.prepend( "vCard " ); // as per kolab1 spec } bool rc = kmailUpdate( subResource, sernum, data, mimetype, subject, @@ -652,6 +663,7 @@ void KABC::ResourceKolab::setSubresourceActive( const TQString &subresource, boo } else { kdDebug(5650) << "setSubresourceCompletionWeight: subresource " << subresource << " not found" << endl; } + writeConfig(); } @@ -667,4 +679,16 @@ bool KABC::ResourceKolab::removeSubresource( const TQString& id ) return kmailRemoveSubresource( id ); } +void KABC::ResourceKolab::writeConfig() +{ + KConfig config( configFile() ); + + Kolab::ResourceMap::ConstIterator it; + for ( it = mSubResources.constBegin(); it != mSubResources.constEnd(); ++it ) { + config.setGroup( it.key() ); + config.writeEntry( "Active", it.data().active() ); + config.writeEntry( "CompletionWeight", it.data().completionWeight() ); + } +} + #include "resourcekolab.moc" diff --git a/kresources/kolab/kabc/resourcekolab.h b/kresources/kolab/kabc/resourcekolab.h index 1da472015..9158375a1 100644 --- a/kresources/kolab/kabc/resourcekolab.h +++ b/kresources/kolab/kabc/resourcekolab.h @@ -164,9 +164,12 @@ protected: return Kolab::ResourceKolabBase::configFile( "kabc" ); } + void writeConfig(); + // The list of subresources Kolab::ResourceMap mSubResources; TQString mCachedSubresource; + bool mCachedSubresourceNotFound; bool mLocked; }; |