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
a4bdb16f
Commit
a4bdb16f
authored
Apr 05, 2022
by
Laurent Montel
😁
Browse files
Fix open kmail when we click on button
parent
94ceb195
Pipeline
#159513
passed with stage
in 13 minutes and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
agents/newmailnotifier/CMakeLists.txt
View file @
a4bdb16f
...
...
@@ -46,6 +46,7 @@ target_link_libraries( akonadi_newmailnotifier_agent
KF5::Notifications
KF5::Service
KF5::I18n
KF5::KIOGui
)
if
(
Qt5TextToSpeech_FOUND
)
...
...
agents/newmailnotifier/newmailnotifiershowmessagejob.cpp
View file @
a4bdb16f
...
...
@@ -6,8 +6,10 @@
#include "newmailnotifiershowmessagejob.h"
#include "newmailnotifier_debug.h"
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KService>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
...
...
@@ -27,24 +29,27 @@ void NewMailNotifierShowMessageJob::start()
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
(
"showMail"
),
mId
);
}
else
{
qCWarning
(
NEWMAILNOTIFIER_LOG
)
<<
"Impossible to access to DBus interface"
;
// start the kmail application if it isn't running yet
const
auto
service
=
KService
::
serviceByDesktopName
(
QStringLiteral
(
"org.kde.kmail2"
));
if
(
!
service
)
{
qCDebug
(
NEWMAILNOTIFIER_LOG
)
<<
" Can not start kmail"
;
setError
(
UserDefinedError
);
setErrorText
(
i18n
(
"Unable to start KMail application."
));
emitResult
();
return
;
}
emitResult
();
auto
job
=
new
KIO
::
ApplicationLauncherJob
(
service
,
this
);
connect
(
job
,
&
KJob
::
finished
,
this
,
[
this
]()
{
const
QString
kmailInterface
=
QStringLiteral
(
"org.kde.kmail"
);
QDBusInterface
kmail
(
kmailInterface
,
QStringLiteral
(
"/KMail"
),
QStringLiteral
(
"org.kde.kmail.kmail"
));
if
(
kmail
.
isValid
())
{
kmail
.
call
(
QStringLiteral
(
"showMail"
),
mId
);
}
else
{
qCWarning
(
NEWMAILNOTIFIER_LOG
)
<<
"Impossible to access to DBus interface"
;
}
emitResult
();
});
job
->
start
();
}
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