~ubuntu-branches/ubuntu/raring/kdepim/raring-proposed

« back to all changes in this revision

Viewing changes to mailcommon/sendmdnhandler.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-07 07:56:38 UTC
  • mfrom: (0.2.27)
  • Revision ID: package-import@ubuntu.com-20120607075638-0luhdq11z7sgvs4m
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Copyright (C) 2010 Klarälvdalens Datakonsult AB,
3
 
        a KDAB Group company, info@kdab.net,
4
 
        author Tobias Koenig <tokoe@kdab.com>
5
 
 
6
 
    This library is free software; you can redistribute it and/or modify it
7
 
    under the terms of the GNU Library General Public License as published by
8
 
    the Free Software Foundation; either version 2 of the License, or (at your
9
 
    option) any later version.
10
 
 
11
 
    This library is distributed in the hope that it will be useful, but WITHOUT
12
 
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
 
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
14
 
    License for more details.
15
 
 
16
 
    You should have received a copy of the GNU Library General Public License
17
 
    along with this library; see the file COPYING.LIB.  If not, write to the
18
 
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
 
    02110-1301, USA.
 
2
  Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net,
 
3
     Author Tobias Koenig <tokoe@kdab.com>
 
4
 
 
5
  This library is free software; you can redistribute it and/or modify it
 
6
  under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation; either version 2 of the License, or (at your
 
8
  option) any later version.
 
9
 
 
10
  This library is distributed in the hope that it will be useful, but WITHOUT
 
11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
13
  License for more details.
 
14
 
 
15
  You should have received a copy of the GNU Library General Public License
 
16
  along with this library; see the file COPYING.LIB.  If not, write to the
 
17
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
  02110-1301, USA.
20
19
*/
21
20
 
22
21
#include "sendmdnhandler.h"
26
25
#include "mailutil.h"
27
26
#include "mdnadvicedialog.h"
28
27
 
29
 
#include <akonadi/collection.h>
30
 
#include <akonadi/item.h>
31
 
#include <akonadi/kmime/messageflags.h>
32
28
#include <messagecomposer/messagefactory.h>
33
29
#include <messagecomposer/messagesender.h>
34
30
#include <messagecore/messagehelpers.h>
35
31
#include <messageviewer/globalsettings.h>
36
32
 
37
 
#include <QtCore/QQueue>
38
 
#include <QtCore/QTimer>
 
33
#include <Akonadi/Collection>
 
34
#include <Akonadi/Item>
 
35
#include <Akonadi/KMime/MessageFlags>
 
36
 
 
37
#include <QQueue>
 
38
#include <QTimer>
39
39
 
40
40
using namespace MailCommon;
41
41
 
64
64
    // should we send an MDN?
65
65
    if ( MessageViewer::GlobalSettings::notSendWhenEncrypted() &&
66
66
         message()->encryptionState() != KMMsgNotEncrypted &&
67
 
         message()->encryptionState() != KMMsgEncryptionStateUnknown )
 
67
         message()->encryptionState() != KMMsgEncryptionStateUnknown ) {
68
68
      return;
 
69
    }
69
70
#else
70
71
    kDebug() << "AKONADI PORT: Disabled code in  " << Q_FUNC_INFO;
71
72
#endif
72
73
 
73
74
    const Akonadi::Collection collection = item.parentCollection();
74
75
    if ( collection.isValid() &&
75
 
         (CommonKernel->folderIsSentMailFolder( collection ) ||
76
 
          CommonKernel->folderIsTrash( collection ) ||
77
 
          CommonKernel->folderIsDraftOrOutbox( collection ) ||
78
 
          CommonKernel->folderIsTemplates( collection )) )
 
76
         ( CommonKernel->folderIsSentMailFolder( collection ) ||
 
77
           CommonKernel->folderIsTrash( collection ) ||
 
78
           CommonKernel->folderIsDraftOrOutbox( collection ) ||
 
79
           CommonKernel->folderIsTemplates( collection ) ) ) {
79
80
      continue;
 
81
    }
80
82
 
81
83
    const KMime::Message::Ptr message = MessageCore::Util::message( item );
82
 
    if ( !message )
 
84
    if ( !message ) {
83
85
      continue;
 
86
    }
84
87
 
85
 
    const QPair<bool, KMime::MDN::SendingMode> mdnSend = MDNAdviceHelper::instance()->checkAndSetMDNInfo( item, KMime::MDN::Displayed );
 
88
    const QPair<bool, KMime::MDN::SendingMode> mdnSend =
 
89
      MDNAdviceHelper::instance()->checkAndSetMDNInfo( item, KMime::MDN::Displayed );
86
90
    if ( mdnSend.first ) {
87
91
      const int quote =  MessageViewer::GlobalSettings::self()->quoteMessage();
88
92
 
90
94
      factory.setIdentityManager( mKernel->identityManager() );
91
95
      factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
92
96
 
93
 
      const KMime::Message::Ptr mdn = factory.createMDN( KMime::MDN::ManualAction, KMime::MDN::Displayed, mdnSend.second, quote );
 
97
      const KMime::Message::Ptr mdn =
 
98
        factory.createMDN( KMime::MDN::ManualAction, KMime::MDN::Displayed, mdnSend.second, quote );
94
99
      if ( mdn ) {
95
100
        if( !mKernel->msgSender()->send( mdn ) ) {
96
101
          kDebug() << "Sending failed.";
100
105
  }
101
106
}
102
107
 
103
 
 
104
108
SendMdnHandler::SendMdnHandler( IKernel *kernel, QObject *parent )
105
109
  : QObject( parent ), d( new Private( this, kernel ) )
106
110
{
115
119
 
116
120
void SendMdnHandler::setItem( const Akonadi::Item &item )
117
121
{
118
 
  if ( item.hasFlag( Akonadi::MessageFlags::Seen ) )
 
122
  if ( item.hasFlag( Akonadi::MessageFlags::Seen ) ) {
119
123
    return;
 
124
  }
120
125
 
121
126
  d->mTimer.stop();
122
127