203 | 203 |
XAppSnWatcher *watcher = XAPP_SN_WATCHER (user_data);
|
204 | 204 |
|
205 | 205 |
g_debug ("Name acquired on dbus");
|
206 | |
|
|
206 |
sn_watcher_interface_set_protocol_version (watcher->skeleton, 0);
|
207 | 207 |
sn_watcher_interface_set_is_status_notifier_host_registered (watcher->skeleton,
|
208 | 208 |
TRUE);
|
209 | 209 |
g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (watcher->skeleton));
|
|
294 | 294 |
return TRUE;
|
295 | 295 |
}
|
296 | 296 |
|
|
297 |
typedef struct
|
|
298 |
{
|
|
299 |
XAppSnWatcher *watcher;
|
|
300 |
gchar *key;
|
|
301 |
gchar *path;
|
|
302 |
gchar *bus_name;
|
|
303 |
gchar *service;
|
|
304 |
} NewSnProxyData;
|
|
305 |
|
|
306 |
static void
|
|
307 |
sn_item_proxy_new_completed (GObject *source,
|
|
308 |
GAsyncResult *res,
|
|
309 |
gpointer user_data)
|
|
310 |
{
|
|
311 |
NewSnProxyData *data = (NewSnProxyData *) user_data;
|
|
312 |
XAppSnWatcher *watcher = data->watcher;
|
|
313 |
SnItem *item;
|
|
314 |
GError *error = NULL;
|
|
315 |
|
|
316 |
SnItemInterface *proxy;
|
|
317 |
|
|
318 |
proxy = sn_item_interface_proxy_new_finish (res, &error);
|
|
319 |
|
|
320 |
if (error != NULL)
|
|
321 |
{
|
|
322 |
g_debug ("Could not create new status notifier proxy item for item at %s: %s",
|
|
323 |
data->bus_name, error->message);
|
|
324 |
return;
|
|
325 |
}
|
|
326 |
|
|
327 |
item = sn_item_new ((GDBusProxy *) proxy,
|
|
328 |
g_str_has_prefix (data->path, APPINDICATOR_PATH_PREFIX));
|
|
329 |
|
|
330 |
g_hash_table_insert (watcher->items,
|
|
331 |
g_strdup (data->key),
|
|
332 |
item);
|
|
333 |
|
|
334 |
update_published_items (watcher);
|
|
335 |
|
|
336 |
sn_watcher_interface_emit_status_notifier_item_registered (watcher->skeleton,
|
|
337 |
data->service);
|
|
338 |
|
|
339 |
g_free (data->key);
|
|
340 |
g_free (data->path);
|
|
341 |
g_free (data->bus_name);
|
|
342 |
g_free (data->service);
|
|
343 |
g_slice_free (NewSnProxyData, data);
|
|
344 |
}
|
|
345 |
|
297 | 346 |
static gboolean
|
298 | 347 |
handle_register_item (SnWatcherInterface *skeleton,
|
299 | 348 |
GDBusMethodInvocation *invocation,
|
|
321 | 370 |
|
322 | 371 |
if (item == NULL)
|
323 | 372 |
{
|
324 | |
SnItemInterface *proxy;
|
|
373 |
NewSnProxyData *data;
|
325 | 374 |
error = NULL;
|
326 | 375 |
g_debug ("Key: '%s'", key);
|
327 | 376 |
|
328 | |
proxy = sn_item_interface_proxy_new_sync (watcher->connection,
|
329 | |
G_DBUS_PROXY_FLAGS_NONE,
|
330 | |
bus_name,
|
331 | |
path,
|
332 | |
NULL,
|
333 | |
&error);
|
334 | |
|
335 | |
if (error != NULL)
|
336 | |
{
|
337 | |
g_debug ("Could not create new status notifier proxy item for item at %s: %s", bus_name, error->message);
|
338 | |
|
339 | |
g_dbus_method_invocation_return_gerror (invocation, error);
|
340 | |
|
341 | |
return FALSE;
|
342 | |
}
|
343 | |
|
344 | |
item = sn_item_new ((GDBusProxy *) proxy,
|
345 | |
g_str_has_prefix (path, APPINDICATOR_PATH_PREFIX));
|
346 | |
|
347 | |
g_hash_table_insert (watcher->items,
|
348 | |
g_strdup (key),
|
349 | |
item);
|
350 | |
|
351 | |
update_published_items (watcher);
|
352 | |
|
353 | |
sn_watcher_interface_emit_status_notifier_item_registered (skeleton,
|
354 | |
service);
|
355 | |
}
|
356 | |
|
357 | |
sn_watcher_interface_complete_register_status_notifier_item (skeleton,
|
|
377 |
data = g_slice_new0 (NewSnProxyData);
|
|
378 |
data->watcher = watcher;
|
|
379 |
data->key = g_strdup (key);
|
|
380 |
data->path = g_strdup (path);
|
|
381 |
data->bus_name = g_strdup (bus_name);
|
|
382 |
data->service = g_strdup (service);
|
|
383 |
|
|
384 |
sn_item_interface_proxy_new (watcher->connection,
|
|
385 |
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
|
386 |
bus_name,
|
|
387 |
path,
|
|
388 |
NULL,
|
|
389 |
sn_item_proxy_new_completed,
|
|
390 |
data);
|
|
391 |
}
|
|
392 |
|
|
393 |
sn_watcher_interface_complete_register_status_notifier_item (watcher->skeleton,
|
358 | 394 |
invocation);
|
359 | 395 |
|
360 | 396 |
return TRUE;
|