|
|
|
|
@ -75,8 +75,6 @@ using KMail::AccountManager; |
|
|
|
|
#include <ktemporaryfile.h> |
|
|
|
|
#include <kconfiggroup.h> |
|
|
|
|
#include "groupwareadaptor.h" |
|
|
|
|
#include "kmail_util.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace KMail; |
|
|
|
|
|
|
|
|
|
@ -110,9 +108,9 @@ static QString folderKolabMimeType( KMail::FolderContentsType type ) |
|
|
|
|
return s_folderContentsType[type].mimetype; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GroupwareAdaptor::StorageFormat KMailICalIfaceImpl::globalStorageFormat() const { |
|
|
|
|
StorageFormat KMailICalIfaceImpl::globalStorageFormat() const { |
|
|
|
|
return GlobalSettings::self()->theIMAPResourceStorageFormat() |
|
|
|
|
== GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ? GroupwareAdaptor::StorageXML : GroupwareAdaptor::StorageIcalVcard; |
|
|
|
|
== GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ? StorageXML : StorageIcalVcard; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static KMail::FolderContentsType folderContentsType( const QString& type ) |
|
|
|
|
@ -402,9 +400,9 @@ quint32 KMailICalIfaceImpl::addIncidenceKolab( KMFolder& folder, |
|
|
|
|
} |
|
|
|
|
// In case of the ical format, simply add the plain text content with the
|
|
|
|
|
// right content type
|
|
|
|
|
if ( storageFormat( &folder ) == GroupwareAdaptor::StorageXML ) { |
|
|
|
|
if ( storageFormat( &folder ) == StorageXML ) { |
|
|
|
|
setXMLContentTypeHeader( msg, plainTextBody ); |
|
|
|
|
} else if ( storageFormat( &folder ) == GroupwareAdaptor::StorageIcalVcard ) { |
|
|
|
|
} else if ( storageFormat( &folder ) == StorageIcalVcard ) { |
|
|
|
|
const KMail::FolderContentsType t = folder.storage()->contentsType(); |
|
|
|
|
setIcalVcardContentTypeHeader( msg, t ); |
|
|
|
|
msg->setBodyEncoded( plainTextBody.toUtf8() ); |
|
|
|
|
@ -442,7 +440,7 @@ quint32 KMailICalIfaceImpl::addIncidenceKolab( KMFolder& folder, |
|
|
|
|
<< sernum << endl; |
|
|
|
|
|
|
|
|
|
//debugBodyParts( "after addMsg", *msg );
|
|
|
|
|
addFolderChange( &folder,GroupwareAdaptor::Contents ); |
|
|
|
|
addFolderChange( &folder,Contents ); |
|
|
|
|
} else |
|
|
|
|
kError(5006) << "addIncidenceKolab(): Message *NOT* saved!\n"; |
|
|
|
|
|
|
|
|
|
@ -615,14 +613,14 @@ void KMailICalIfaceImpl::slotMessageRetrieved( KMMessage* msg ) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* list all available subresources */ |
|
|
|
|
QList<GroupwareAdaptor::SubResource> KMailICalIfaceImpl::subresourcesKolab( const QString& contentsType ) |
|
|
|
|
QList<SubResource> KMailICalIfaceImpl::subresourcesKolab( const QString& contentsType ) |
|
|
|
|
{ |
|
|
|
|
QList<GroupwareAdaptor::SubResource> subResources; |
|
|
|
|
QList<SubResource> subResources; |
|
|
|
|
|
|
|
|
|
// Add the default one
|
|
|
|
|
KMFolder* f = folderFromType( contentsType, QString() ); |
|
|
|
|
if ( f ) { |
|
|
|
|
subResources.append( GroupwareAdaptor::SubResource( f->location(), f->prettyUrl(), |
|
|
|
|
subResources.append( SubResource( f->location(), f->prettyUrl(), |
|
|
|
|
!f->isReadOnly(), folderIsAlarmRelevant( f ) ) ); |
|
|
|
|
kDebug(5006) << "Adding(1) folder " << f->location() << " " << |
|
|
|
|
( f->isReadOnly() ? "readonly" : "" ) << endl; |
|
|
|
|
@ -634,7 +632,7 @@ QList<GroupwareAdaptor::SubResource> KMailICalIfaceImpl::subresourcesKolab( cons |
|
|
|
|
for ( ; it.current(); ++it ){ |
|
|
|
|
f = it.current()->folder; |
|
|
|
|
if ( f && f->storage()->contentsType() == t ) { |
|
|
|
|
subResources.append( GroupwareAdaptor::SubResource( f->location(), f->prettyUrl(), |
|
|
|
|
subResources.append( SubResource( f->location(), f->prettyUrl(), |
|
|
|
|
!f->isReadOnly(), folderIsAlarmRelevant( f ) ) ); |
|
|
|
|
kDebug(5006) << "Adding(2) folder " << f->location() << " " << |
|
|
|
|
( f->isReadOnly() ? "readonly" : "" ) << endl; |
|
|
|
|
@ -649,8 +647,8 @@ QList<GroupwareAdaptor::SubResource> KMailICalIfaceImpl::subresourcesKolab( cons |
|
|
|
|
bool KMailICalIfaceImpl::triggerSync( const QString& contentsType ) |
|
|
|
|
{ |
|
|
|
|
kDebug(5006) << k_funcinfo << endl; |
|
|
|
|
QList<GroupwareAdaptor::SubResource> folderList = subresourcesKolab( contentsType ); |
|
|
|
|
for ( QList<GroupwareAdaptor::SubResource>::const_iterator it( folderList.begin() ), |
|
|
|
|
QList<SubResource> folderList = subresourcesKolab( contentsType ); |
|
|
|
|
for ( QList<SubResource>::const_iterator it( folderList.begin() ), |
|
|
|
|
end( folderList.end() ); |
|
|
|
|
it != end ; ++it ) { |
|
|
|
|
KMFolder * const f = findResourceFolder( (*it).location ); |
|
|
|
|
@ -685,9 +683,9 @@ bool KMailICalIfaceImpl::isWritableFolder( const QString& type, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Used by the resource to query the storage format of the folder. */ |
|
|
|
|
GroupwareAdaptor::StorageFormat KMailICalIfaceImpl::storageFormat( const QString& resource ) |
|
|
|
|
StorageFormat KMailICalIfaceImpl::storageFormat( const QString& resource ) |
|
|
|
|
{ |
|
|
|
|
GroupwareAdaptor::StorageFormat format; |
|
|
|
|
StorageFormat format; |
|
|
|
|
KMFolder* f = findResourceFolder( resource ); |
|
|
|
|
if ( f ) |
|
|
|
|
format = storageFormat( f ); |
|
|
|
|
@ -771,13 +769,13 @@ quint32 KMailICalIfaceImpl::update( const QString& resource, |
|
|
|
|
const bool messageWasIcalVcardFormat = ( type.toLower() == "text" && |
|
|
|
|
( subtype.toLower() == "calendar" || subtype.toLower() == "x-vcard" ) ); |
|
|
|
|
|
|
|
|
|
if ( storageFormat( f ) == GroupwareAdaptor::StorageIcalVcard ) { |
|
|
|
|
if ( storageFormat( f ) == StorageIcalVcard ) { |
|
|
|
|
//kDebug(5006) << k_funcinfo << " StorageFormatIcalVcard " << endl;
|
|
|
|
|
if ( !messageWasIcalVcardFormat ) { |
|
|
|
|
setIcalVcardContentTypeHeader( newMsg, t ); |
|
|
|
|
} |
|
|
|
|
newMsg->setBodyEncoded( plainTextBody.toUtf8() ); |
|
|
|
|
} else if ( storageFormat( f ) == GroupwareAdaptor::StorageXML ) { |
|
|
|
|
} else if ( storageFormat( f ) == StorageXML ) { |
|
|
|
|
if ( messageWasIcalVcardFormat ) { |
|
|
|
|
// this was originally an ical event, but the folder changed to xml,
|
|
|
|
|
// convert
|
|
|
|
|
@ -814,7 +812,7 @@ quint32 KMailICalIfaceImpl::update( const QString& resource, |
|
|
|
|
rc = newMsg->getMsgSerNum(); |
|
|
|
|
kDebug(5006) << "forget about " << sernum << ", it's " << rc << " now" << endl; |
|
|
|
|
} |
|
|
|
|
addFolderChange( f, GroupwareAdaptor::Contents ); |
|
|
|
|
addFolderChange( f, Contents ); |
|
|
|
|
} else { |
|
|
|
|
// Message not found - store it newly
|
|
|
|
|
rc = addIncidenceKolab( *f, subject, plainTextBody, customHeaders, |
|
|
|
|
@ -846,7 +844,7 @@ KUrl KMailICalIfaceImpl::getAttachment( const QString& resource, |
|
|
|
|
kError(5006) << "getAttachment(" << resource << ") : Not an IMAP resource folder" << endl; |
|
|
|
|
return KUrl(); |
|
|
|
|
} |
|
|
|
|
if ( storageFormat( f ) != GroupwareAdaptor::StorageXML ) { |
|
|
|
|
if ( storageFormat( f ) != StorageXML ) { |
|
|
|
|
kError(5006) << "getAttachment(" << resource << ") : Folder has wrong storage format " << storageFormat( f ) << endl; |
|
|
|
|
return KUrl(); |
|
|
|
|
} |
|
|
|
|
@ -932,15 +930,15 @@ void KMailICalIfaceImpl::slotIncidenceAdded( KMFolder* folder, |
|
|
|
|
if( msg->isComplete() ) { |
|
|
|
|
|
|
|
|
|
bool ok = false; |
|
|
|
|
GroupwareAdaptor::StorageFormat format = storageFormat( folder ); |
|
|
|
|
StorageFormat format = storageFormat( folder ); |
|
|
|
|
switch( format ) { |
|
|
|
|
case GroupwareAdaptor::StorageIcalVcard: |
|
|
|
|
case StorageIcalVcard: |
|
|
|
|
// Read the iCal or vCard
|
|
|
|
|
ok = vPartFoundAndDecoded( msg, s ); |
|
|
|
|
if ( ok ) |
|
|
|
|
vPartMicroParser( s, uid ); |
|
|
|
|
break; |
|
|
|
|
case GroupwareAdaptor::StorageXML: |
|
|
|
|
case StorageXML: |
|
|
|
|
// Read the XML from the attachment with the given mimetype
|
|
|
|
|
if ( kolabXMLFoundAndDecoded( *msg, |
|
|
|
|
folderKolabMimeType( folder->storage()->contentsType() ), s ) ) { |
|
|
|
|
@ -1009,13 +1007,13 @@ void KMailICalIfaceImpl::slotIncidenceDeleted( KMFolder* folder, |
|
|
|
|
KMMessage* msg = folder->getMsg( i ); |
|
|
|
|
QString uid( "UID" ); |
|
|
|
|
switch( storageFormat( folder ) ) { |
|
|
|
|
case GroupwareAdaptor::StorageIcalVcard: |
|
|
|
|
case StorageIcalVcard: |
|
|
|
|
if( vPartFoundAndDecoded( msg, s ) ) { |
|
|
|
|
vPartMicroParser( s, uid ); |
|
|
|
|
ok = true; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case GroupwareAdaptor::StorageXML: |
|
|
|
|
case StorageXML: |
|
|
|
|
if ( kolabXMLFoundAndDecoded( *msg, folderKolabMimeType( folder->storage()->contentsType() ), s ) ) { |
|
|
|
|
uid = msg->subject(); |
|
|
|
|
ok = true; |
|
|
|
|
@ -1241,7 +1239,7 @@ void KMailICalIfaceImpl::deleteMsg( KMMessage *msg ) |
|
|
|
|
assert(idx != -1); |
|
|
|
|
srcFolder->removeMsg(idx); |
|
|
|
|
delete msg; |
|
|
|
|
addFolderChange( srcFolder, GroupwareAdaptor::Contents ); |
|
|
|
|
addFolderChange( srcFolder, Contents ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void KMailICalIfaceImpl::folderContentsTypeChanged( KMFolder* folder, |
|
|
|
|
@ -1332,7 +1330,7 @@ KMFolder* KMailICalIfaceImpl::extraFolder( const QString& type, |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GroupwareAdaptor::StorageFormat KMailICalIfaceImpl::storageFormat( KMFolder* folder ) const |
|
|
|
|
StorageFormat KMailICalIfaceImpl::storageFormat( KMFolder* folder ) const |
|
|
|
|
{ |
|
|
|
|
FolderInfoMap::ConstIterator it = mFolderInfoMap.find( folder ); |
|
|
|
|
if ( it != mFolderInfoMap.end() ) |
|
|
|
|
@ -1340,25 +1338,25 @@ GroupwareAdaptor::StorageFormat KMailICalIfaceImpl::storageFormat( KMFolder* fol |
|
|
|
|
return globalStorageFormat(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void KMailICalIfaceImpl::setStorageFormat( KMFolder* folder, GroupwareAdaptor::StorageFormat format ) |
|
|
|
|
void KMailICalIfaceImpl::setStorageFormat( KMFolder* folder, StorageFormat format ) |
|
|
|
|
{ |
|
|
|
|
FolderInfoMap::Iterator it = mFolderInfoMap.find( folder ); |
|
|
|
|
if ( it != mFolderInfoMap.end() ) { |
|
|
|
|
(*it).mStorageFormat = format; |
|
|
|
|
} else { |
|
|
|
|
FolderInfo info( format, GroupwareAdaptor::NoChange ); |
|
|
|
|
FolderInfo info( format, NoChange ); |
|
|
|
|
mFolderInfoMap.insert( folder, info ); |
|
|
|
|
} |
|
|
|
|
KConfigGroup configGroup( kmkernel->config(), "GroupwareFolderInfo" ); |
|
|
|
|
configGroup.writeEntry( folder->idString() + "-storageFormat", |
|
|
|
|
format == GroupwareAdaptor::StorageXML ? "xml" : "icalvcard" ); |
|
|
|
|
format == StorageXML ? "xml" : "icalvcard" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void KMailICalIfaceImpl::addFolderChange( KMFolder* folder, GroupwareAdaptor::FolderChanges changes ) |
|
|
|
|
void KMailICalIfaceImpl::addFolderChange( KMFolder* folder, FolderChanges changes ) |
|
|
|
|
{ |
|
|
|
|
FolderInfoMap::Iterator it = mFolderInfoMap.find( folder ); |
|
|
|
|
if ( it != mFolderInfoMap.end() ) { |
|
|
|
|
(*it).mChanges = static_cast<GroupwareAdaptor::FolderChanges>( (*it).mChanges | changes ); |
|
|
|
|
(*it).mChanges = static_cast<FolderChanges>( (*it).mChanges | changes ); |
|
|
|
|
} else { // Otherwise, well, it's a folder we don't care about.
|
|
|
|
|
kDebug(5006) << "addFolderChange: nothing known about folder " << folder->location() << endl; |
|
|
|
|
} |
|
|
|
|
@ -1374,11 +1372,11 @@ KMailICalIfaceImpl::FolderInfo KMailICalIfaceImpl::readFolderInfo( const KMFolde |
|
|
|
|
if ( str == "unset" ) { |
|
|
|
|
info.mStorageFormat = globalStorageFormat(); |
|
|
|
|
configGroup.writeEntry( folder->idString() + "-storageFormat", |
|
|
|
|
info.mStorageFormat == GroupwareAdaptor::StorageXML ? "xml" : "icalvcard" ); |
|
|
|
|
info.mStorageFormat == StorageXML ? "xml" : "icalvcard" ); |
|
|
|
|
} else { |
|
|
|
|
info.mStorageFormat = ( str == "xml" ) ? GroupwareAdaptor::StorageXML : GroupwareAdaptor::StorageIcalVcard; |
|
|
|
|
info.mStorageFormat = ( str == "xml" ) ? StorageXML : StorageIcalVcard; |
|
|
|
|
} |
|
|
|
|
info.mChanges = (GroupwareAdaptor::FolderChanges) configGroup.readEntry( folder->idString() + "-changes", 0 ); |
|
|
|
|
info.mChanges = (FolderChanges) configGroup.readEntry( folder->idString() + "-changes", 0 ); |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1388,7 +1386,7 @@ void KMailICalIfaceImpl::folderSynced( KMFolder* folder, const KUrl& folderURL ) |
|
|
|
|
FolderInfoMap::Iterator it = mFolderInfoMap.find( folder ); |
|
|
|
|
if ( it != mFolderInfoMap.end() && (*it).mChanges ) { |
|
|
|
|
handleFolderSynced( folder, folderURL, (*it).mChanges ); |
|
|
|
|
(*it).mChanges = GroupwareAdaptor::NoChange; |
|
|
|
|
(*it).mChanges = NoChange; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1400,9 +1398,9 @@ void KMailICalIfaceImpl::handleFolderSynced( KMFolder* folder, |
|
|
|
|
// there could be 0, 1, or N kolab resources at this point.
|
|
|
|
|
// We can hack the N case, but not the 0 case.
|
|
|
|
|
// So the idea of a DCOP signal for this wouldn't work.
|
|
|
|
|
if ( ( _changes & GroupwareAdaptor::Contents ) || |
|
|
|
|
( _changes & GroupwareAdaptor::ACL ) ) { |
|
|
|
|
if ( storageFormat( folder ) == GroupwareAdaptor::StorageXML && folder->storage()->contentsType() == KMail::ContentsTypeCalendar ) |
|
|
|
|
if ( ( _changes & Contents ) || |
|
|
|
|
( _changes & ACL ) ) { |
|
|
|
|
if ( storageFormat( folder ) == StorageXML && folder->storage()->contentsType() == KMail::ContentsTypeCalendar ) |
|
|
|
|
triggerKolabFreeBusy( folderURL ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|