Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
f47bedff
Unverified
Commit
f47bedff
authored
4 years ago
by
Nicolas Werner
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #388 from LorenDB/fixBorkedDbus
Keep DBUS from blocking
parents
b5ead0e8
2605ce9a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#440
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/notifications/Manager.h
+0
-1
0 additions, 1 deletion
src/notifications/Manager.h
src/notifications/ManagerLinux.cpp
+36
-40
36 additions, 40 deletions
src/notifications/ManagerLinux.cpp
with
36 additions
and
41 deletions
src/notifications/Manager.h
+
0
−
1
View file @
f47bedff
...
...
@@ -47,7 +47,6 @@ public:
private:
QDBusInterface
dbus
;
uint
showNotification
(
const
QString
summary
,
const
QString
text
,
const
QImage
image
);
void
closeNotification
(
uint
id
);
// notification ID to (room ID, event ID)
...
...
This diff is collapsed.
Click to expand it.
src/notifications/ManagerLinux.cpp
+
36
−
40
View file @
f47bedff
#include
"notifications/Manager.h"
#include
<QDBusConnection>
#include
<QDBusMessage>
#include
<QDBusMetaType>
#include
<QDBusPendingCallWatcher>
#include
<QDBusPendingReply>
#include
<QDebug>
#include
<QImage>
#include
<QtDBus/QDBusConnection>
#include
<QtDBus/QDBusMessage>
#include
<QtDBus/QDBusMetaType>
NotificationsManager
::
NotificationsManager
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -36,6 +38,12 @@ NotificationsManager::NotificationsManager(QObject *parent)
SLOT
(
notificationReplied
(
uint
,
QString
)));
}
/**
* This function is based on code from
* https://github.com/rohieb/StratumsphereTrayIcon
* Copyright (C) 2012 Roland Hieber <rohieb@rohieb.name>
* Licensed under the GNU General Public License, version 3
*/
void
NotificationsManager
::
postNotification
(
const
QString
&
roomid
,
const
QString
&
eventid
,
...
...
@@ -43,30 +51,16 @@ NotificationsManager::postNotification(const QString &roomid,
const
QString
&
sender
,
const
QString
&
text
,
const
QImage
&
icon
)
{
uint
id
=
showNotification
(
roomname
,
sender
+
": "
+
text
,
icon
);
notificationIds
[
id
]
=
roomEventId
{
roomid
,
eventid
};
}
/**
* This function is based on code from
* https://github.com/rohieb/StratumsphereTrayIcon
* Copyright (C) 2012 Roland Hieber <rohieb@rohieb.name>
* Licensed under the GNU General Public License, version 3
*/
uint
NotificationsManager
::
showNotification
(
const
QString
summary
,
const
QString
text
,
const
QImage
image
)
{
QVariantMap
hints
;
hints
[
"image-data"
]
=
i
mage
;
hints
[
"image-data"
]
=
i
con
;
hints
[
"sound-name"
]
=
"message-new-instant"
;
QList
<
QVariant
>
argumentList
;
argumentList
<<
"nheko"
;
// app_name
argumentList
<<
(
uint
)
0
;
// replace_id
argumentList
<<
""
;
// app_icon
argumentList
<<
summary
;
// summary
argumentList
<<
text
;
// body
argumentList
<<
"nheko"
;
// app_name
argumentList
<<
(
uint
)
0
;
// replace_id
argumentList
<<
""
;
// app_icon
argumentList
<<
roomname
;
// summary
argumentList
<<
sender
+
": "
+
text
;
// body
// The list of actions has always the action name and then a localized version of that
// action. Currently we just use an empty string for that.
// TODO(Nico): Look into what to actually put there.
...
...
@@ -79,31 +73,33 @@ NotificationsManager::showNotification(const QString summary,
static
QDBusInterface
notifyApp
(
"org.freedesktop.Notifications"
,
"/org/freedesktop/Notifications"
,
"org.freedesktop.Notifications"
);
QDBusMessage
reply
=
notifyApp
.
callWithArgumentList
(
QDBus
::
AutoDetect
,
"Notify"
,
argumentList
);
if
(
reply
.
type
()
==
QDBusMessage
::
ErrorMessage
)
{
qDebug
()
<<
"D-Bus Error:"
<<
reply
.
errorMessage
();
return
0
;
}
else
{
return
reply
.
arguments
().
first
().
toUInt
();
}
return
true
;
QDBusPendingCall
call
=
notifyApp
.
asyncCallWithArgumentList
(
"Notify"
,
argumentList
);
auto
watcher
=
new
QDBusPendingCallWatcher
{
call
,
this
};
connect
(
watcher
,
&
QDBusPendingCallWatcher
::
finished
,
this
,
[
watcher
,
this
,
roomid
,
eventid
]()
{
if
(
watcher
->
reply
().
type
()
==
QDBusMessage
::
ErrorMessage
)
qDebug
()
<<
"D-Bus Error:"
<<
watcher
->
reply
().
errorMessage
();
else
notificationIds
[
watcher
->
reply
().
arguments
().
first
().
toUInt
()]
=
roomEventId
{
roomid
,
eventid
};
watcher
->
deleteLater
();
});
}
void
NotificationsManager
::
closeNotification
(
uint
id
)
{
QList
<
QVariant
>
argumentList
;
argumentList
<<
(
uint
)
id
;
// replace_id
static
QDBusInterface
closeCall
(
"org.freedesktop.Notifications"
,
"/org/freedesktop/Notifications"
,
"org.freedesktop.Notifications"
);
QDBusMessage
reply
=
closeCall
.
callWithArgumentList
(
QDBus
::
AutoDetect
,
"CloseNotification"
,
argumentList
);
if
(
reply
.
type
()
==
QDBusMessage
::
ErrorMessage
)
{
qDebug
()
<<
"D-Bus Error:"
<<
reply
.
errorMessage
();
}
auto
call
=
closeCall
.
asyncCall
(
"CloseNotification"
,
(
uint
)
id
);
// replace_id
auto
watcher
=
new
QDBusPendingCallWatcher
{
call
,
this
};
connect
(
watcher
,
&
QDBusPendingCallWatcher
::
finished
,
this
,
[
watcher
,
this
]()
{
if
(
watcher
->
reply
().
type
()
==
QDBusMessage
::
ErrorMessage
)
{
qDebug
()
<<
"D-Bus Error:"
<<
watcher
->
reply
().
errorMessage
();
};
watcher
->
deleteLater
();
});
}
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment