• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • job
manageserversidesubscriptionjob.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "manageserversidesubscriptionjob.h"
19 #include <KLocalizedString>
20 #include <QDBusInterface>
21 #include <QDBusPendingCall>
22 #include <QDBusPendingReply>
23 #include "kmkernel.h"
24 #include <akonadi/dbusconnectionpool.h>
25 #include <KDebug>
26 #include <KMessageBox>
27 
28 ManageServerSideSubscriptionJob::ManageServerSideSubscriptionJob(QObject *parent)
29  : QObject(parent),
30  mParentWidget(0)
31 {
32 
33 }
34 
35 ManageServerSideSubscriptionJob::~ManageServerSideSubscriptionJob()
36 {
37 
38 }
39 
40 void ManageServerSideSubscriptionJob::start()
41 {
42  if (!mCurrentFolder) {
43  qDebug()<<" currentFolder not defined";
44  deleteLater();
45  return;
46  }
47  bool isImapOnline = false;
48  if ( kmkernel->isImapFolder( mCurrentFolder->collection(), isImapOnline ) ) {
49  QDBusInterface iface(
50  QLatin1String( "org.freedesktop.Akonadi.Resource.")+mCurrentFolder->collection().resource(),
51  QLatin1String( "/" ), QLatin1String( "org.kde.Akonadi.ImapResourceBase" ),
52  Akonadi::DBusConnectionPool::threadConnection(), this );
53  if ( !iface.isValid() ) {
54  kDebug()<<"Cannot create imap dbus interface";
55  deleteLater();
56  return;
57  }
58  QDBusPendingCall call = iface.asyncCall( QLatin1String( "configureSubscription" ), (qlonglong)mParentWidget->winId() );
59  QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
60  connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(slotConfigureSubscriptionFinished(QDBusPendingCallWatcher*)));
61  }
62 }
63 
64 void ManageServerSideSubscriptionJob::slotConfigureSubscriptionFinished(QDBusPendingCallWatcher* watcher)
65 {
66  QDBusPendingReply<int> reply = *watcher;
67  if ( reply.isValid() ) {
68  if (reply == -2 ){
69  KMessageBox::error(mParentWidget,i18n("IMAP server not configured yet. Please configure the server in the IMAP account before setting up server-side subscription."));
70  } else if (reply == -1) {
71  KMessageBox::error(mParentWidget,i18n("Log in failed, please configure the IMAP account before setting up server-side subscription."));
72  }
73  }
74  watcher->deleteLater();
75  watcher = 0;
76  deleteLater();
77 }
78 
79 void ManageServerSideSubscriptionJob::setParentWidget(QWidget *parentWidget)
80 {
81  mParentWidget = parentWidget;
82 }
83 
84 void ManageServerSideSubscriptionJob::setCurrentFolder(const QSharedPointer<MailCommon::FolderCollection> &currentFolder)
85 {
86  mCurrentFolder = currentFolder;
87 }
88 
89 
QWidget
ManageServerSideSubscriptionJob::ManageServerSideSubscriptionJob
ManageServerSideSubscriptionJob(QObject *parent=0)
Definition: manageserversidesubscriptionjob.cpp:28
QDBusPendingCallWatcher
ManageServerSideSubscriptionJob::start
void start()
Definition: manageserversidesubscriptionjob.cpp:40
QSharedPointer< MailCommon::FolderCollection >
QDBusPendingReply
QObject
QDBusPendingCall
ManageServerSideSubscriptionJob::setParentWidget
void setParentWidget(QWidget *parentWidget)
Definition: manageserversidesubscriptionjob.cpp:79
QWidget::winId
WId winId() const
QObject::deleteLater
void deleteLater()
kmkernel
#define kmkernel
Definition: kmkernel.h:24
QDBusInterface
ManageServerSideSubscriptionJob::setCurrentFolder
void setCurrentFolder(const QSharedPointer< MailCommon::FolderCollection > &currentFolder)
Definition: manageserversidesubscriptionjob.cpp:84
kmkernel.h
QLatin1String
QDBusPendingReply::isValid
bool isValid() const
manageserversidesubscriptionjob.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
ManageServerSideSubscriptionJob::~ManageServerSideSubscriptionJob
~ManageServerSideSubscriptionJob()
Definition: manageserversidesubscriptionjob.cpp:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal