Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Runtime
Commits
5320597c
Commit
5320597c
authored
Jun 29, 2021
by
Laurent Montel
😁
Browse files
Add job for replying message
parent
c8130bd7
Changes
3
Hide whitespace changes
Inline
Side-by-side
agents/newmailnotifier/CMakeLists.txt
View file @
5320597c
...
...
@@ -22,6 +22,7 @@ target_sources(akonadi_newmailnotifier_agent PRIVATE
newmailnotifieragent.cpp
specialnotifierjob.cpp
newmailnotifiershowmessagejob.cpp
newmailnotifierreplymessagejob.cpp
${
newmailnotifier_common_SRCS
}
${
newmailnotifieragent_SRCS
}
)
...
...
agents/newmailnotifier/newmailnotifierreplymessagejob.cpp
0 → 100644
View file @
5320597c
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "newmailnotifierreplymessagejob.h"
#include "newmailnotifier_debug.h"
#include <KLocalizedString>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QDBusReply>
NewMailNotifierReplyMessageJob
::
NewMailNotifierReplyMessageJob
(
Akonadi
::
Item
::
Id
id
,
QObject
*
parent
)
:
KJob
(
parent
)
,
mId
(
id
)
{
}
NewMailNotifierReplyMessageJob
::~
NewMailNotifierReplyMessageJob
()
{
}
void
NewMailNotifierReplyMessageJob
::
start
()
{
if
(
mId
<
0
)
{
emitResult
();
return
;
}
const
QString
kmailInterface
=
QStringLiteral
(
"org.kde.kmail"
);
QDBusReply
<
bool
>
reply
=
QDBusConnection
::
sessionBus
().
interface
()
->
isServiceRegistered
(
kmailInterface
);
if
(
!
reply
.
isValid
()
||
!
reply
.
value
())
{
// Program is not already running, so start it
QString
errmsg
;
if
(
!
QDBusConnection
::
sessionBus
().
interface
()
->
startService
(
QStringLiteral
(
"org.kde.kmail2"
)).
isValid
())
{
qCDebug
(
NEWMAILNOTIFIER_LOG
)
<<
" Can not start kmail"
;
setError
(
UserDefinedError
);
setErrorText
(
i18n
(
"Unable to start KMail application."
));
emitResult
();
return
;
}
}
QDBusInterface
kmail
(
kmailInterface
,
QStringLiteral
(
"/KMail"
),
QStringLiteral
(
"org.kde.kmail.kmail"
));
if
(
kmail
.
isValid
())
{
kmail
.
call
(
QStringLiteral
(
"replyMail"
),
mId
,
mReplyToAll
);
}
else
{
qCWarning
(
NEWMAILNOTIFIER_LOG
)
<<
"Impossible to access to DBus interface"
;
}
emitResult
();
}
bool
NewMailNotifierReplyMessageJob
::
replyToAll
()
const
{
return
mReplyToAll
;
}
void
NewMailNotifierReplyMessageJob
::
setReplyToAll
(
bool
newReplyToAll
)
{
mReplyToAll
=
newReplyToAll
;
}
agents/newmailnotifier/newmailnotifierreplymessagejob.h
0 → 100644
View file @
5320597c
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <AkonadiCore/Item>
#include <KJob>
class
NewMailNotifierReplyMessageJob
:
public
KJob
{
Q_OBJECT
public:
explicit
NewMailNotifierReplyMessageJob
(
Akonadi
::
Item
::
Id
id
,
QObject
*
parent
=
nullptr
);
~
NewMailNotifierReplyMessageJob
()
override
;
void
start
()
override
;
Q_REQUIRED_RESULT
bool
replyToAll
()
const
;
void
setReplyToAll
(
bool
newReplyToAll
);
private:
const
Akonadi
::
Item
::
Id
mId
;
bool
mReplyToAll
=
false
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment