Unverified Commit d295a76e authored by Erik Reider's avatar Erik Reider Committed by GitHub

Added GetSubscribeData to dbus daemon (#123)

* Added GetSubscribeData to dbus daemon * Updated client to use GetSubscribeData
parent f4ba9214
public struct SwayncDaemonData {
public bool dnd;
public bool cc_open;
public uint count;
}
[DBus (name = "org.erikreider.swaync.cc")] [DBus (name = "org.erikreider.swaync.cc")]
interface CcDaemon : GLib.Object { interface CcDaemon : GLib.Object {
...@@ -21,6 +27,9 @@ interface CcDaemon : GLib.Object { ...@@ -21,6 +27,9 @@ interface CcDaemon : GLib.Object {
public abstract void set_visibility (bool value) throws DBusError, IOError; public abstract void set_visibility (bool value) throws DBusError, IOError;
[DBus (name = "GetSubscribeData")]
public abstract SwayncDaemonData get_subscribe_data () throws Error;
public signal void subscribe (uint count, bool dnd, bool cc_open); public signal void subscribe (uint count, bool dnd, bool cc_open);
} }
...@@ -58,9 +67,8 @@ private void on_subscribe (uint count, bool dnd, bool cc_open) { ...@@ -58,9 +67,8 @@ private void on_subscribe (uint count, bool dnd, bool cc_open) {
private void print_subscribe () { private void print_subscribe () {
try { try {
on_subscribe (cc_daemon.notification_count (), SwayncDaemonData data = cc_daemon.get_subscribe_data ();
cc_daemon.get_dnd (), on_subscribe (data.count, data.dnd, data.cc_open);
cc_daemon.get_visibility ());
} catch (Error e) { } catch (Error e) {
on_subscribe (0, false, false); on_subscribe (0, false, false);
} }
...@@ -86,9 +94,8 @@ private void on_subscribe_waybar (uint count, bool dnd, bool cc_open) { ...@@ -86,9 +94,8 @@ private void on_subscribe_waybar (uint count, bool dnd, bool cc_open) {
private void print_subscribe_waybar () { private void print_subscribe_waybar () {
try { try {
on_subscribe_waybar (cc_daemon.notification_count (), SwayncDaemonData data = cc_daemon.get_subscribe_data ();
cc_daemon.get_dnd (), on_subscribe_waybar (data.count, data.dnd, data.cc_open);
cc_daemon.get_visibility ());
} catch (Error e) { } catch (Error e) {
on_subscribe_waybar (0, false, false); on_subscribe_waybar (0, false, false);
} }
......
namespace SwayNotificationCenter { namespace SwayNotificationCenter {
public struct Data {
public bool dnd;
public bool cc_open;
public uint count;
}
[DBus (name = "org.erikreider.swaync.cc")] [DBus (name = "org.erikreider.swaync.cc")]
public class SwayncDaemon : Object { public class SwayncDaemon : Object {
public StateCache cache_state; public StateCache cache_state;
...@@ -57,6 +63,16 @@ namespace SwayNotificationCenter { ...@@ -57,6 +63,16 @@ namespace SwayNotificationCenter {
} }
} }
/** Gets subscribe data but in one call */
[DBus (name = "GetSubscribeData")]
public Data get_subscribe_data () throws Error {
return Data () {
dnd = get_dnd (),
cc_open = get_visibility (),
count = notification_count (),
};
}
/** /**
* Called when Dot Not Disturb state changes and when * Called when Dot Not Disturb state changes and when
* notification gets added/removed * notification gets added/removed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment