Use qtpaths directly
[kdepim.git] / kmail / kmlaunchexternalcomponent.cpp
bloba7adf8327e53c1300c091eed2892f76a25f85eec
1 /*
2 Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
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.
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.
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
18 #include "kmlaunchexternalcomponent.h"
19 #include <KMessageBox>
20 #include <KLocalizedString>
21 #include <KRun>
23 #include "util.h"
24 #include "archivemailagentinterface.h"
25 #include "sendlateragentinterface.h"
26 #include "followupreminderinterface.h"
27 #include "MailCommon/FilterManager"
29 #include <QtDBus/QDBusInterface>
30 #include <QtDBus/QDBusReply>
31 #include <QProcess>
32 #include "kmail_debug.h"
33 #include <QStandardPaths>
34 #include <antispam-virus/antispamwizard.h>
36 KMLaunchExternalComponent::KMLaunchExternalComponent(QWidget *parentWidget, QObject *parent)
37 : QObject(parent),
38 mParentWidget(parentWidget)
43 KMLaunchExternalComponent::~KMLaunchExternalComponent()
48 void KMLaunchExternalComponent::slotConfigureAutomaticArchiving()
50 OrgFreedesktopAkonadiArchiveMailAgentInterface archiveMailInterface(QStringLiteral("org.freedesktop.Akonadi.ArchiveMailAgent"), QStringLiteral("/ArchiveMailAgent"), QDBusConnection::sessionBus(), this);
51 if (archiveMailInterface.isValid()) {
52 archiveMailInterface.showConfigureDialog((qlonglong)mParentWidget->winId());
53 } else {
54 KMessageBox::error(mParentWidget, i18n("Archive Mail Agent was not registered."));
58 void KMLaunchExternalComponent::slotConfigureSendLater()
60 OrgFreedesktopAkonadiSendLaterAgentInterface sendLaterInterface(QStringLiteral("org.freedesktop.Akonadi.SendLaterAgent"), QStringLiteral("/SendLaterAgent"), QDBusConnection::sessionBus(), this);
61 if (sendLaterInterface.isValid()) {
62 sendLaterInterface.showConfigureDialog((qlonglong)mParentWidget->winId());
63 } else {
64 KMessageBox::error(mParentWidget, i18n("Send Later Agent was not registered."));
68 void KMLaunchExternalComponent::slotConfigureFollowupReminder()
70 OrgFreedesktopAkonadiFollowUpReminderAgentInterface followUpInterface(QStringLiteral("org.freedesktop.Akonadi.FollowUpReminder"), QStringLiteral("/FollowUpReminder"), QDBusConnection::sessionBus(), this);
71 if (followUpInterface.isValid()) {
72 followUpInterface.showConfigureDialog((qlonglong)mParentWidget->winId());
73 } else {
74 KMessageBox::error(mParentWidget, i18n("Followup Reminder Agent was not registered."));
78 void KMLaunchExternalComponent::slotStartCertManager()
80 if (!QProcess::startDetached(QStringLiteral("kleopatra"))) {
81 KMessageBox::error(mParentWidget, i18n("Could not start certificate manager; "
82 "please check your installation."),
83 i18n("KMail Error"));
87 void KMLaunchExternalComponent::slotStartWatchGnuPG()
89 if (!QProcess::startDetached(QStringLiteral("kwatchgnupg"))) {
90 KMessageBox::error(mParentWidget, i18n("Could not start GnuPG LogViewer (kwatchgnupg); "
91 "please check your installation."),
92 i18n("KMail Error"));
96 void KMLaunchExternalComponent::slotImportWizard()
98 const QString path = QStandardPaths::findExecutable(QStringLiteral("importwizard"));
99 if (!QProcess::startDetached(path)) {
100 KMessageBox::error(mParentWidget, i18n("Could not start the import wizard. "
101 "Please check your installation."),
102 i18n("Unable to start import wizard"));
106 void KMLaunchExternalComponent::slotExportData()
108 const QString path = QStandardPaths::findExecutable(QStringLiteral("pimsettingexporter"));
109 if (!QProcess::startDetached(path)) {
110 KMessageBox::error(mParentWidget, i18n("Could not start \"PIM Setting Exporter\" program. "
111 "Please check your installation."),
112 i18n("Unable to start \"PIM Setting Exporter\" program"));
116 void KMLaunchExternalComponent::slotAddrBook()
118 KRun::runCommand(QStringLiteral("kaddressbook"), mParentWidget->window());
121 void KMLaunchExternalComponent::slotImport()
123 QStringList lst;
124 lst.append(QStringLiteral("--mode"));
125 lst.append(QStringLiteral("manual"));
126 const QString path = QStandardPaths::findExecutable(QStringLiteral("importwizard"));
127 if (!QProcess::startDetached(path, lst)) {
128 KMessageBox::error(mParentWidget, i18n("Could not start the ImportWizard. "
129 "Please check your installation."),
130 i18n("Unable to start ImportWizard"));
134 void KMLaunchExternalComponent::slotAccountWizard()
136 QStringList lst;
137 lst.append(QStringLiteral("--type"));
138 lst.append(QStringLiteral("message/rfc822"));
140 const QString path = QStandardPaths::findExecutable(QStringLiteral("accountwizard"));
141 if (!QProcess::startDetached(path, lst)) {
142 KMessageBox::error(mParentWidget, i18n("Could not start the account wizard. "
143 "Please check your installation."),
144 i18n("Unable to start account wizard"));
148 void KMLaunchExternalComponent::slotAntiSpamWizard()
150 KMail::AntiSpamWizard wiz(KMail::AntiSpamWizard::AntiSpam, mParentWidget);
151 wiz.exec();
154 void KMLaunchExternalComponent::slotAntiVirusWizard()
156 KMail::AntiSpamWizard wiz(KMail::AntiSpamWizard::AntiVirus, mParentWidget);
157 wiz.exec();
160 void KMLaunchExternalComponent::slotFilterLogViewer()
162 MailCommon::FilterManager::instance()->showFilterLogDialog((qlonglong)mParentWidget->winId());