diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kresources/kolab/knotes | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/kolab/knotes')
-rw-r--r-- | kresources/kolab/knotes/kolabresource.desktop | 1 | ||||
-rw-r--r-- | kresources/kolab/knotes/note.cpp | 41 | ||||
-rw-r--r-- | kresources/kolab/knotes/resourcekolab.cpp | 92 | ||||
-rw-r--r-- | kresources/kolab/knotes/resourcekolab.h | 3 |
4 files changed, 92 insertions, 45 deletions
diff --git a/kresources/kolab/knotes/kolabresource.desktop b/kresources/kolab/knotes/kolabresource.desktop index d74e3f59b..317032d17 100644 --- a/kresources/kolab/knotes/kolabresource.desktop +++ b/kresources/kolab/knotes/kolabresource.desktop @@ -21,7 +21,6 @@ Name[hu]=IMAP-kiszolgáló a KMailen keresztül Name[is]=IMAP þjónn gegnum KMail Name[it]=Server IMAP via KMail Name[ja]=KMail 経由 IMAP サーバ -Name[ka]= IMAP-ს სერვერთან დაშვება KMail-ის საშუალებით Name[kk]=KMail арқылы IMAP сервері Name[km]=ម៉ាស៊ីនបម្រើ IMAP តាមរយៈ KMail Name[lt]=IMAP serveris per KMail diff --git a/kresources/kolab/knotes/note.cpp b/kresources/kolab/knotes/note.cpp index 66556aaf8..168dae562 100644 --- a/kresources/kolab/knotes/note.cpp +++ b/kresources/kolab/knotes/note.cpp @@ -108,7 +108,6 @@ bool Note::richText() const bool Note::loadAttribute( TQDomElement& element ) { TQString tagName = element.tagName(); - if ( tagName == "summary" ) setSummary( element.text() ); else if ( tagName == "foreground-color" ) @@ -136,8 +135,10 @@ bool Note::saveAttributes( TQDomElement& element ) const #endif writeString( element, "summary", summary() ); - writeString( element, "foreground-color", colorToString( foregroundColor() ) ); - writeString( element, "background-color", colorToString( backgroundColor() ) ); + if ( foregroundColor().isValid() ) + writeString( element, "foreground-color", colorToString( foregroundColor() ) ); + if ( backgroundColor().isValid() ) + writeString( element, "background-color", colorToString( backgroundColor() ) ); writeString( element, "knotes-richtext", mRichText ? "true" : "false" ); return true; @@ -183,11 +184,27 @@ void Note::setFields( const KCal::Journal* journal ) { KolabBase::setFields( journal ); - // TODO: background and foreground setSummary( journal->summary() ); - setBackgroundColor( journal->customProperty( "KNotes", "BgColor" ) ); - setForegroundColor( journal->customProperty( "KNotes", "FgColor" ) ); - setRichText( journal->customProperty( "KNotes", "RichText" ) == "true" ); + + TQString property = journal->customProperty( "KNotes", "BgColor" ); + if ( !property.isNull() ) { + setBackgroundColor( property ); + } else { + setBackgroundColor( "yellow" ); + } + property = journal->customProperty( "KNotes", "FgColor" ); + if ( !property.isNull() ) { + setForegroundColor( property ); + } else { + setForegroundColor( "black" ); + } + + property = journal->customProperty( "KNotes", "RichText" ); + if ( !property.isNull() ) { + setRichText( property == "true" ? true : false ); + } else { + setRichText( "false" ); + } } void Note::saveTo( KCal::Journal* journal ) @@ -196,10 +213,12 @@ void Note::saveTo( KCal::Journal* journal ) // TODO: background and foreground journal->setSummary( summary() ); - journal->setCustomProperty( "KNotes", "FgColor", - colorToString( foregroundColor() ) ); - journal->setCustomProperty( "KNotes", "BgColor", - colorToString( backgroundColor() ) ); + if ( foregroundColor().isValid() ) + journal->setCustomProperty( "KNotes", "FgColor", + colorToString( foregroundColor() ) ); + if ( backgroundColor().isValid() ) + journal->setCustomProperty( "KNotes", "BgColor", + colorToString( backgroundColor() ) ); journal->setCustomProperty( "KNotes", "RichText", richText() ? "true" : "false" ); } diff --git a/kresources/kolab/knotes/resourcekolab.cpp b/kresources/kolab/knotes/resourcekolab.cpp index 1d633b62a..d917d0ac2 100644 --- a/kresources/kolab/knotes/resourcekolab.cpp +++ b/kresources/kolab/knotes/resourcekolab.cpp @@ -41,6 +41,7 @@ #include <kdebug.h> #include <kglobal.h> +#include <klocale.h> using namespace Kolab; @@ -53,6 +54,9 @@ ResourceKolab::ResourceKolab( const KConfig *config ) : ResourceNotes( config ), ResourceKolabBase( "ResourceKolab-KNotes" ), mCalendar( TQString::fromLatin1("UTC") ) { + if ( !config ) { + setResourceName( i18n( "Kolab Server" ) ); + } setType( "imap" ); } @@ -73,7 +77,7 @@ bool ResourceKolab::doOpen() // Make the resource map from the folder list TQValueList<KMailICalIface::SubResource>::ConstIterator it; mSubResources.clear(); - for ( it = subResources.begin(); it != subResources.end(); ++it ) { + for ( it = subResources.constBegin(); it != subResources.constEnd(); ++it ) { const TQString subResource = (*it).location; const bool active = config.readBoolEntry( subResource, true ); mSubResources[ subResource ] = Kolab::SubResource( active, (*it).writable, (*it).label ); @@ -87,7 +91,7 @@ void ResourceKolab::doClose() KConfig config( configFile() ); config.setGroup( configGroupName ); Kolab::ResourceMap::ConstIterator it; - for ( it = mSubResources.begin(); it != mSubResources.end(); ++it ) + for ( it = mSubResources.constBegin(); it != mSubResources.constEnd(); ++it ) config.writeEntry( it.key(), it.data().active() ); } @@ -113,8 +117,8 @@ bool ResourceKolab::loadSubResource( const TQString& subResource, // Populate with the new entries const bool silent = mSilent; mSilent = true; - TQMap<Q_UINT32, TQString>::Iterator it; - for ( it = lst.begin(); it != lst.end(); ++it ) { + TQMap<Q_UINT32, TQString>::ConstIterator it; + for ( it = lst.constBegin(); it != lst.constEnd(); ++it ) { KCal::Journal* journal = addNote( it.data(), subResource, it.key(), mimetype ); if ( !journal ) kdDebug(5500) << "loading note " << it.key() << " failed" << endl; @@ -134,7 +138,7 @@ bool ResourceKolab::load() bool rc = true; Kolab::ResourceMap::ConstIterator itR; - for ( itR = mSubResources.begin(); itR != mSubResources.end(); ++itR ) { + for ( itR = mSubResources.constBegin(); itR != mSubResources.constEnd(); ++itR ) { if ( !itR.data().active() ) // This subResource is disabled continue; @@ -162,25 +166,35 @@ bool ResourceKolab::addNote( KCal::Journal* journal ) KCal::Journal* ResourceKolab::addNote( const TQString& data, const TQString& subresource, Q_UINT32 sernum, const TQString &mimetype ) { - KCal::Journal* journal = 0; - // FIXME: This does not take into account the time zone! + KCal::Journal *journal = 0; + + // FIXME: This does not take into account the time zone! KCal::ICalFormat formatter; - if ( mimetype == attachmentMimeType ) + if ( mimetype == attachmentMimeType ) { journal = Note::xmlToJournal( data ); - else + } else { journal = static_cast<KCal::Journal*>( formatter.fromString( data ) ); - + } Q_ASSERT( journal ); - if( journal && !mUidMap.contains( journal->uid() ) ) - if ( addNote( journal, subresource, sernum ) ) - return journal; - else - delete journal; - return 0; + + bool addedOk = journal && + !mUidMap.contains( journal->uid() ) && + addNote( journal, subresource, sernum ); + + // for debugging + if ( journal && mUidMap.contains( journal->uid() ) ) { + kdDebug(5500) << "mUidMap already contains " << journal->uid() << endl; + } + + if ( !addedOk ) { + delete journal; + journal = 0; + } + + return journal; } -bool ResourceKolab::addNote( KCal::Journal* journal, - const TQString& subresource, Q_UINT32 sernum ) +bool ResourceKolab::addNote( KCal::Journal *journal, const TQString &subresource, Q_UINT32 sernum ) { kdDebug(5500) << "ResourceKolab::addNote( KCal::Journal*, '" << subresource << "', " << sernum << " )\n"; @@ -188,12 +202,15 @@ bool ResourceKolab::addNote( KCal::Journal* journal, // Find out if this note was previously stored in KMail bool newNote = subresource.isEmpty(); - mCalendar.addJournal( journal ); + if ( !mCalendar.addJournal( journal ) ) { + return false; + } - TQString resource = - newNote ? findWritableResource( mSubResources ) : subresource; - if ( resource.isEmpty() ) // canceled + TQString resource = newNote ? findWritableResource( Kolab::Notes, mSubResources ) : subresource; + if ( resource.isEmpty() ) { + // canceled return false; + } if ( !mSilent ) { TQString xml = Note::journalToXML( journal ); @@ -209,7 +226,6 @@ bool ResourceKolab::addNote( KCal::Journal* journal, mUidMap[ journal->uid() ] = StorageReference( resource, sernum ); return true; } - return false; } @@ -225,9 +241,7 @@ bool ResourceKolab::deleteNote( KCal::Journal* journal ) mUidMap[ uid ].serialNumber() ); } mUidMap.remove( uid ); - manager()->deleteNote( journal ); - mCalendar.deleteJournal( journal ); - return true; + return mCalendar.deleteJournal( journal ); } KCal::Alarm::List ResourceKolab::alarms( const TQDateTime& from, const TQDateTime& to ) @@ -239,7 +253,7 @@ KCal::Alarm::List ResourceKolab::alarms( const TQDateTime& from, const TQDateTim { TQDateTime preTime = from.addSecs( -1 ); KCal::Alarm::List::ConstIterator it; - for( it = (*note)->alarms().begin(); it != (*note)->alarms().end(); ++it ) + for( it = (*note)->alarms().constBegin(); it != (*note)->alarms().constEnd(); ++it ) { if ( (*it)->enabled() ) { @@ -261,7 +275,7 @@ void ResourceKolab::incidenceUpdated( KCal::IncidenceBase* i ) subResource = mUidMap[ i->uid() ].resource(); sernum = mUidMap[ i->uid() ].serialNumber(); } else { // can this happen? - subResource = findWritableResource( mSubResources ); + subResource = findWritableResource( Kolab::Notes, mSubResources ); if ( subResource.isEmpty() ) // canceled return; sernum = 0; @@ -313,8 +327,11 @@ void ResourceKolab::fromKMailDelIncidence( const TQString& type, const bool silent = mSilent; mSilent = true; KCal::Journal* j = mCalendar.journal( uid ); - if( j ) - deleteNote( j ); + if ( j ) { + if ( deleteNote( j ) ) { + manager()->deleteNote( j ); + } + } mSilent = silent; } @@ -370,7 +387,7 @@ void ResourceKolab::fromKMailDelSubresource( const TQString& type, // Make a list of all uids to remove Kolab::UidMap::ConstIterator mapIt; TQStringList uids; - for ( mapIt = mUidMap.begin(); mapIt != mUidMap.end(); ++mapIt ) + for ( mapIt = mUidMap.constBegin(); mapIt != mUidMap.constEnd(); ++mapIt ) if ( mapIt.data().resource() == subResource ) // We have a match uids << mapIt.key(); @@ -380,7 +397,7 @@ void ResourceKolab::fromKMailDelSubresource( const TQString& type, const bool silent = mSilent; mSilent = true; TQStringList::ConstIterator it; - for ( it = uids.begin(); it != uids.end(); ++it ) { + for ( it = uids.constBegin(); it != uids.constEnd(); ++it ) { KCal::Journal* j = mCalendar.journal( *it ); if( j ) deleteNote( j ); @@ -405,7 +422,7 @@ void ResourceKolab::fromKMailAsyncLoadResult( const TQMap<Q_UINT32, TQString>& m mimetype = attachmentMimeType; else mimetype = inlineMimeType; - for( TQMap<Q_UINT32, TQString>::ConstIterator it = map.begin(); it != map.end(); ++it ) { + for( TQMap<Q_UINT32, TQString>::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it ) { KCal::Journal* journal = addNote( it.data(), folder, it.key(), mimetype ); if ( !journal ) kdDebug(5500) << "loading note " << it.key() << " failed" << endl; @@ -433,5 +450,14 @@ bool ResourceKolab::subresourceActive( const TQString& res ) const return true; } +bool ResourceKolab::subresourceWritable( const TQString& res ) const +{ + if ( mSubResources.contains( res ) ) { + return mSubResources[ res ].writable(); + } + + // Safe default bet: + return false; +} #include "resourcekolab.moc" diff --git a/kresources/kolab/knotes/resourcekolab.h b/kresources/kolab/knotes/resourcekolab.h index a738a30a5..6ff994ccf 100644 --- a/kresources/kolab/knotes/resourcekolab.h +++ b/kresources/kolab/knotes/resourcekolab.h @@ -102,6 +102,9 @@ public: /** Is this subresource active? */ bool subresourceActive( const TQString& ) const; + /** Is this subresource writable? */ + bool subresourceWritable( const TQString& ) const; + signals: void signalSubresourceAdded( Resource*, const TQString&, const TQString& ); void signalSubresourceRemoved( Resource*, const TQString&, const TQString& ); |