summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2012-04-18 16:51:06 (GMT)
committerMontel Laurent <montel@kde.org>2012-04-18 16:55:21 (GMT)
commitd4da0039e83bd2e33b74fc08b5b4681155f1698d (patch)
treedea0114e837b5ac0a358e3389634d65832b613b5
parent44a3eb070b74414256f8f8ef58f73fd67678f5e4 (diff)
Fix bug when we reply and it doesn't take good identity when we use
default identity from account. David reported me it and it was reported to Bug 297912 - 'Reply to' uses wrong identity if not explicitly set in 'folder properties' FIXED-IN: 4.8.3 BUG: 297912 (cherry picked from commit 4477bc411acba4a68c4d85fabf7f4c5328709abe) Conflicts: mailcommon/mailutil.cpp
-rw-r--r--kmail/kmcommands.cpp16
-rw-r--r--kmail/kmmainwidget.cpp2
-rw-r--r--kmail/util.cpp6
-rw-r--r--kmail/util.h1
-rw-r--r--mailcommon/mailutil.cpp22
-rw-r--r--mailcommon/mailutil.h1
6 files changed, 27 insertions, 21 deletions
diff --git a/kmail/kmcommands.cpp b/kmail/kmcommands.cpp
index 1dadf72..9a13a43 100644
--- a/kmail/kmcommands.cpp
+++ b/kmail/kmcommands.cpp
@@ -444,7 +444,7 @@ KMCommand::Result KMMailtoReplyCommand::execute()
KMime::Message::Ptr msg = MessageCore::Util::message( item );
if ( !msg )
return Failed;
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
factory.setMailingListAddresses( KMail::Util::mailingListsFromMessage( item ) );
@@ -477,7 +477,7 @@ KMCommand::Result KMMailtoForwardCommand::execute()
KMime::Message::Ptr msg = MessageCore::Util::message( item );
if ( !msg )
return Failed;
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
KMime::Message::Ptr fmsg = factory.createForward();
@@ -804,7 +804,7 @@ KMCommand::Result KMReplyCommand::execute()
KMime::Message::Ptr msg = MessageCore::Util::message( item );
if ( !msg )
return Failed;
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
factory.setMailingListAddresses( KMail::Util::mailingListsFromMessage( item ) );
@@ -851,7 +851,7 @@ KMCommand::Result KMForwardCommand::createComposer(const Akonadi::Item& item)
#ifndef QT_NO_CURSOR
MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
#endif
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
if ( !mTemplate.isEmpty() )
@@ -886,7 +886,7 @@ KMCommand::Result KMForwardCommand::execute()
if ( answer == KMessageBox::Yes ) {
Akonadi::Item firstItem( msgList.first() );
- MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), firstItem.parentCollection() );
+ MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( firstItem ) );
@@ -940,7 +940,7 @@ KMCommand::Result KMForwardAttachedCommand::execute()
{
QList<Akonadi::Item> msgList = retrievedMsgs();
Akonadi::Item firstItem( msgList.first() );
- MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), firstItem.parentCollection() );
+ MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( firstItem ) );
@@ -988,7 +988,7 @@ KMCommand::Result KMRedirectCommand::execute()
if ( !msg )
return Failed;
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
@@ -1484,7 +1484,7 @@ KMCommand::Result KMResendMessageCommand::execute()
if ( !msg )
return Failed;
- MessageFactory factory( msg, item.id(), item.parentCollection() );
+ MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
KMime::Message::Ptr newMsg = factory.createResend();
diff --git a/kmail/kmmainwidget.cpp b/kmail/kmmainwidget.cpp
index ee512ea..49b0160 100644
--- a/kmail/kmmainwidget.cpp
+++ b/kmail/kmmainwidget.cpp
@@ -3935,7 +3935,7 @@ void KMMainWidget::updateMessageActionsDelayed()
updateMoveAction( (mCurrentFolder&& mCurrentFolder->isValid()) ? mCurrentFolder->statistics().count() : 0 );
- const qint64 nbMsgOutboxCollection = KMail::Util::updatedCollection( CommonKernel->outboxCollectionFolder() ).statistics().count();
+ const qint64 nbMsgOutboxCollection = MailCommon::Util::updatedCollection( CommonKernel->outboxCollectionFolder() ).statistics().count();
actionCollection()->action( "send_queued" )->setEnabled( nbMsgOutboxCollection > 0 );
actionCollection()->action( "send_queued_via" )->setEnabled( nbMsgOutboxCollection > 0 );
diff --git a/kmail/util.cpp b/kmail/util.cpp
index a9bec37..d6cbf95 100644
--- a/kmail/util.cpp
+++ b/kmail/util.cpp
@@ -211,9 +211,3 @@ void KMail::Util::mailingListHelp( const QSharedPointer<MailCommon::FolderCollec
KMail::Util::mailingListsHandleURL( fd->mailingList().helpUrls(),fd );
}
-Akonadi::Collection KMail::Util::updatedCollection( const Akonadi::Collection& col )
-{
- const QModelIndex idx = Akonadi::EntityTreeModel::modelIndexForCollection( KMKernel::self()->collectionModel(), CommonKernel->outboxCollectionFolder() );
- const Akonadi::Collection collection = idx.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
- return collection;
-}
diff --git a/kmail/util.h b/kmail/util.h
index 52bb427..13f0674 100644
--- a/kmail/util.h
+++ b/kmail/util.h
@@ -109,7 +109,6 @@ namespace Util {
void mailingListUnsubscribe( const QSharedPointer<MailCommon::FolderCollection> &fd );
void mailingListArchives( const QSharedPointer<MailCommon::FolderCollection> &fd );
void mailingListHelp( const QSharedPointer<MailCommon::FolderCollection> &fd );
- Akonadi::Collection updatedCollection( const Akonadi::Collection& col );
}
}
diff --git a/mailcommon/mailutil.cpp b/mailcommon/mailutil.cpp
index 541df11..9c48c8b 100644
--- a/mailcommon/mailutil.cpp
+++ b/mailcommon/mailutil.cpp
@@ -403,8 +403,14 @@ bool MailCommon::Util::createEventFromMail( const Akonadi::Item &mailItem )
uint MailCommon::Util::folderIdentity(const Akonadi::Item& item)
{
uint id = 0;
- if( item.isValid() && item.parentCollection().isValid() ) {
- const QSharedPointer<FolderCollection> fd = FolderCollection::forCollection( item.parentCollection(),false );
+ if ( item.isValid() && item.parentCollection().isValid() ) {
+ Akonadi::Collection col = item.parentCollection();
+ if( col.resource().isEmpty()) {
+ col = parentCollectionFromItem(item);
+ }
+ const QSharedPointer<FolderCollection> fd =
+ FolderCollection::forCollection( col, false );
+
id = fd->identity();
}
return id;
@@ -508,9 +514,7 @@ QModelIndex MailCommon::Util::nextUnreadCollection( QAbstractItemModel *model, c
Akonadi::Collection MailCommon::Util::parentCollectionFromItem(const Akonadi::Item& item)
{
- const QModelIndex idx = Akonadi::EntityTreeModel::modelIndexForCollection( KernelIf->collectionModel(), item.parentCollection() );
- const Akonadi::Collection parentCollection = idx.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
- return parentCollection;
+ return updatedCollection(item.parentCollection());
}
@@ -535,3 +539,11 @@ void MailCommon::Util::expireOldMessages( const Akonadi::Collection& collection,
ScheduledExpireTask* task = new ScheduledExpireTask(collection, immediate);
KernelIf->jobScheduler()->registerTask( task );
}
+
+Akonadi::Collection MailCommon::Util::updatedCollection( const Akonadi::Collection& col )
+{
+ const QModelIndex idx = Akonadi::EntityTreeModel::modelIndexForCollection( KernelIf->collectionModel(), col );
+ const Akonadi::Collection collection = idx.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
+ return collection;
+}
+
diff --git a/mailcommon/mailutil.h b/mailcommon/mailutil.h
index 06794cb..203c888 100644
--- a/mailcommon/mailutil.h
+++ b/mailcommon/mailutil.h
@@ -113,6 +113,7 @@ namespace Util {
MAILCOMMON_EXPORT QColor defaultQuotaColor();
MAILCOMMON_EXPORT void expireOldMessages( const Akonadi::Collection& collection, bool immediate );
+ MAILCOMMON_EXPORT Akonadi::Collection updatedCollection( const Akonadi::Collection& col );
}
}