26
26
public class MonitorManager : Object
29
private static unowned MonitorManager? instance;
29
31
private HashTable<string, Monitor> monitors;
30
32
private HashTable<string, GenericArray<string>> connections;
34
// ref-counted singleton - it can get destroyed easily, but has
35
// singleton semantics as long as some top-level instance keeps
37
public static MonitorManager get_default ()
39
return instance ?? new MonitorManager ();
42
private MonitorManager ()
34
55
monitors = new HashTable<string, Monitor> (str_hash, str_equal);
35
56
connections = new HashTable<string, GenericArray<string>>
36
57
(str_hash, str_equal);
54
75
foreach (var owner in connections.get_keys())
77
// Don't disconnect monitors using service names
78
if (arg0 == owner && g_dbus_is_unique_name (arg0))
58
80
var paths = connections.lookup (arg0);
59
81
debug("Client disconnected %s", owner);
121
143
queued_notifications = new SList<QueuedNotification> ();
122
144
Bus.get_proxy<RemoteMonitor> (BusType.SESSION, peer,
123
object_path, DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
124
DBusProxyFlags.DO_NOT_CONNECT_SIGNALS,
146
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES
147
| DBusProxyFlags.DO_NOT_CONNECT_SIGNALS
148
| DBusProxyFlags.DO_NOT_AUTO_START,
125
149
null, (obj, res) =>
129
153
proxy_object = Bus.get_proxy.end (res);
154
// Process queued notifications...
155
flush_notifications ();
157
proxy_object.notify["g-name-owner"].connect (name_owner_changed);
131
159
catch (IOError err)
133
161
warning ("%s", err.message);
136
// Process queued notifications...
137
queued_notifications.reverse ();
138
foreach (unowned QueuedNotification notification
139
in queued_notifications)
141
notification.send (proxy_object);
143
queued_notifications = null;
146
165
event_templates = templates;
168
private void name_owner_changed ()
169
requires (proxy_object != null)
171
// FIXME: can we use this to actually remove the monitor?
172
// (instead of using NameOwnerChanged signal)
173
DBusProxy p = proxy_object as DBusProxy;
174
if (p.g_name_owner != null) flush_notifications ();
177
private void flush_notifications ()
179
queued_notifications.reverse ();
180
foreach (unowned QueuedNotification notification
181
in queued_notifications)
183
notification.send (proxy_object);
185
queued_notifications = null;
149
188
private bool matches (Event event)
151
190
if (event_templates.length == 0)
182
221
// between monitors?
183
222
Variant events_v = Events.to_variant (matching_events);
224
string? name_owner = null;
185
225
if (proxy_object != null)
227
DBusProxy p = proxy_object as DBusProxy;
228
if (p != null) name_owner = p.g_name_owner;
231
if (proxy_object != null && name_owner != null)
187
233
DBusProxy p = (DBusProxy) proxy_object;
188
234
debug ("Notifying %s about %d insertions",
189
235
p.get_name (), matching_events.length);
209
255
Variant time_v = intersect_tr.to_variant ();
257
string? name_owner = null;
211
258
if (proxy_object != null)
260
DBusProxy p = proxy_object as DBusProxy;
261
if (p != null) name_owner = p.g_name_owner;
264
if (proxy_object != null && name_owner != null)
213
266
proxy_object.notify_delete (time_v, event_ids);