summaryrefslogtreecommitdiff
path: root/src/notifd.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/notifd.vala')
-rw-r--r--src/notifd.vala55
1 files changed, 5 insertions, 50 deletions
diff --git a/src/notifd.vala b/src/notifd.vala
index 220278c..55d910b 100644
--- a/src/notifd.vala
+++ b/src/notifd.vala
@@ -8,23 +8,8 @@ public class Notifd : Object {
private Daemon daemon;
private DaemonProxy proxy;
- private HashTable<uint, Notification> notifs =
- new HashTable<uint, Notification>((i) => i, (a, b) => a == b);
-
public signal void active(ActiveType type);
- public string cache_directory {
- owned get {
- return proxy != null ? proxy.cache_directory : daemon.cache_directory;
- }
- set {
- if (proxy != null)
- proxy.cache_directory = value;
- else
- daemon.cache_directory = value;
- }
- }
-
public bool ignore_timeout {
get {
return proxy != null ? proxy.ignore_timeout : daemon.ignore_timeout;
@@ -50,7 +35,7 @@ public class Notifd : Object {
}
public List<weak Notification> notifications {
- owned get { return notifs.get_values(); }
+ owned get { return proxy != null ? proxy.notifications : daemon.notifications; }
}
public uint[] notification_ids() throws Error {
@@ -58,33 +43,15 @@ public class Notifd : Object {
}
public Notification get_notification(uint id) {
- return notifs.get(id);
+ return proxy != null ? proxy.get_notification(id) : daemon.get_notification(id);
}
public string get_notification_json(uint id) {
- return notifs.get(id).to_json_string();
- }
-
- public signal void notified(uint id) {
- add_notification(id);
+ return get_notification(id).to_json_string();
}
- public signal void resolved(uint id, ClosedReason reason) {
- notifs.remove(id);
- }
-
- private void add_notification(uint id) {
- try {
- if (proxy != null) {
- var json = proxy.get_notification_json(id);
- notifs.set(id, Notification.from_json_string(json));
- } else {
- notifs.set(id, daemon.get_notification(id));
- }
- } catch (Error err) {
- warning("could not add notification: %s", err.message);
- }
- }
+ public signal void notified(uint id);
+ public signal void resolved(uint id, ClosedReason reason);
construct {
Bus.own_name(
@@ -112,23 +79,11 @@ public class Notifd : Object {
notify_property(prop.name);
}
});
- foreach (var n in daemon.notifications) {
- notifs.set(n.id, n);
- }
}
private void try_proxy() {
proxy = new DaemonProxy();
if (proxy.start()) {
- try {
- foreach (var id in proxy.notification_ids()) {
- add_notification(id);
- }
- }
- catch (Error err) {
- warning("could not get notification ids: %s", err.message);
- }
-
active(ActiveType.PROXY);
} else {
return;