17
17
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
22
#include "IndicatorObjectFactoryRemote.h"
24
#include "IndicatorObjectProxyRemote.h"
25
#include "IndicatorObjectEntryProxyRemote.h"
26
#include "IndicatorObjectEntryProxy.h"
20
#include "DBusIndicators.h"
28
28
#include "Nux/Nux.h"
29
29
#include "Nux/WindowThread.h"
30
30
#include "NuxGraphics/GLWindowManager.h"
34
#define S_NAME "com.canonical.Unity.Panel.Service"
35
#define S_PATH "/com/canonical/Unity/Panel/Service"
36
#define S_IFACE "com.canonical.Unity.Panel.Service"
33
#include "GLibWrapper.h"
41
// This anonymous namespace holds the DBus callback methods.
45
SyncData(DBusIndicators::Impl* self_)
47
, cancel(g_cancellable_new())
54
g_cancellable_cancel(cancel);
55
g_object_unref(cancel);
62
g_object_unref(cancel);
67
DBusIndicators::Impl* self;
71
typedef boost::shared_ptr<SyncData> SyncDataPtr;
73
const char* const S_NAME = "com.canonical.Unity.Panel.Service";
74
const char* const S_PATH = "/com/canonical/Unity/Panel/Service";
75
const char* const S_IFACE = "com.canonical.Unity.Panel.Service";
51
static void on_proxy_ready_cb (GObject *source,
55
static void on_proxy_signal_received (GDBusProxy *proxy,
59
IndicatorObjectFactoryRemote *remote);
61
static void on_proxy_name_owner_changed (GDBusProxy *proxy,
63
IndicatorObjectFactoryRemote *remote);
65
static void on_sync_ready_cb (GObject *source,
69
static bool run_local_panel_service ();
70
static bool reconnect_to_service (gpointer data);
87
bool run_local_panel_service();
88
gboolean reconnect_to_service(gpointer data);
89
void on_proxy_ready_cb(GObject* source, GAsyncResult* res, gpointer data);
90
void on_proxy_name_owner_changed(GDBusProxy* proxy, GParamSpec* pspec,
91
DBusIndicators::Impl* remote);
92
void on_proxy_signal_received(GDBusProxy* proxy,
93
char* sender_name, char* signal_name,
95
DBusIndicators::Impl* remote);
96
void request_sync(GDBusProxy* proxy, const char* method, GVariant* name,
98
void on_sync_ready_cb(GObject* source, GAsyncResult* res, gpointer data);
100
bool send_show_entry(ShowEntryData *data);
102
} // anonymous namespace
105
// Connects to the remote panel service (unity-panel-service) and translates
106
// that into something that the panel can show
107
class DBusIndicators::Impl
110
Impl(DBusIndicators* owner);
113
void OnRemoteProxyReady(GDBusProxy *proxy);
115
void RequestSyncAll();
116
void RequestSyncIndicator(std::string const& name);
117
void Sync(GVariant* args, SyncData* data);
118
void SyncGeometries(std::string const& name,
119
EntryLocationMap const& locations);
121
virtual void OnEntryScroll(std::string const& entry_id, int delta);
122
virtual void OnEntryShowMenu(std::string const& entry_id,
123
int x, int y, int timestamp, int button);
125
std::string name() const;
126
std::string owner_name() const;
127
bool using_local_service() const;
129
DBusIndicators* owner_;
131
guint32 proxy_signal_id_;
132
guint32 proxy_name_id_;
133
typedef std::vector<SyncDataPtr> PendingSyncs;
134
PendingSyncs pending_syncs_;
73
IndicatorObjectFactoryRemote::IndicatorObjectFactoryRemote ()
79
IndicatorObjectFactoryRemote::~IndicatorObjectFactoryRemote ()
81
if (G_IS_OBJECT (_proxy))
83
g_signal_handler_disconnect (_proxy, _proxy_signal_id);
84
g_signal_handler_disconnect (_proxy, _proxy_name_id);
85
g_object_unref (_proxy);
90
std::vector<IndicatorObjectProxy*>::iterator it;
91
for (it = _indicators.begin(); it != _indicators.end(); it++)
93
IndicatorObjectProxyRemote *remote = static_cast<IndicatorObjectProxyRemote *> (*it);
96
_indicators.erase (_indicators.begin (), _indicators.end ());
99
{ // We cancel all our async callbacks from pending Sync() calls
100
std::vector<SyncData *>::iterator it, eit = _sync_cancellables.end ();
101
for (it = _sync_cancellables.begin (); it != eit; ++it)
103
SyncData *data = (*it);
104
g_cancellable_cancel (data->_cancel);
107
_sync_cancellables.erase (_sync_cancellables.begin (), _sync_cancellables.end ());
111
std::vector<IndicatorObjectProxy *>&
112
IndicatorObjectFactoryRemote::GetIndicatorObjects ()
118
IndicatorObjectFactoryRemote::ForceRefresh ()
123
IndicatorObjectFactoryRemote::Reconnect ()
125
g_spawn_command_line_sync ("killall unity-panel-service", NULL, NULL, NULL, NULL);
139
DBusIndicators::Impl::Impl(DBusIndicators* owner)
146
DBusIndicators::Impl::~Impl()
148
if (G_IS_OBJECT (proxy_))
150
g_signal_handler_disconnect(proxy_, proxy_signal_id_);
151
g_signal_handler_disconnect(proxy_, proxy_name_id_);
152
g_object_unref(proxy_);
156
void DBusIndicators::Impl::Reconnect()
158
g_spawn_command_line_sync("killall unity-panel-service",
159
NULL, NULL, NULL, NULL);
127
161
if (g_getenv ("PANEL_USE_LOCAL_SERVICE"))
129
run_local_panel_service ();
130
g_timeout_add_seconds (1, (GSourceFunc)reconnect_to_service, this);
163
run_local_panel_service();
164
g_timeout_add_seconds(1, reconnect_to_service, this);
134
168
// We want to grab the Panel Service object. This is async, which is fine
135
reconnect_to_service (this);
169
reconnect_to_service(this);
140
IndicatorObjectFactoryRemote::OnRemoteProxyReady (GDBusProxy *proxy)
173
void DBusIndicators::Impl::OnRemoteProxyReady(GDBusProxy *proxy)
144
177
// We've been connected before; We don't need new proxy, just continue
145
178
// rocking with the old one.
146
g_object_unref (proxy);
179
g_object_unref(proxy);
152
184
// Connect to interesting signals
153
_proxy_signal_id = g_signal_connect (_proxy, "g-signal",
154
G_CALLBACK (on_proxy_signal_received), this);
155
_proxy_name_id = g_signal_connect (_proxy, "notify::g-name-owner",
156
G_CALLBACK (on_proxy_name_owner_changed), this);
185
proxy_signal_id_ = g_signal_connect(proxy_, "g-signal",
186
G_CALLBACK(on_proxy_signal_received),
188
proxy_name_id_ = g_signal_connect(proxy_, "notify::g-name-owner",
189
G_CALLBACK(on_proxy_name_owner_changed),
159
SyncData * data = new SyncData (this);
160
_sync_cancellables.push_back (data);
161
g_dbus_proxy_call (_proxy,
164
G_DBUS_CALL_FLAGS_NONE,
172
send_show_entry (ShowEntryData *data)
174
g_return_val_if_fail (data != NULL, FALSE);
175
g_return_val_if_fail (G_IS_DBUS_PROXY (data->proxy), FALSE);
177
/* Re-flush 'cos X is crap like that */
178
Display* d = nux::GetThreadGLWindow()->GetX11Display();
181
g_dbus_proxy_call (data->proxy,
183
g_variant_new ("(suiii)",
189
G_DBUS_CALL_FLAGS_NONE,
195
g_free (data->entry_id);
196
g_slice_free (ShowEntryData, data);
201
IndicatorObjectFactoryRemote::OnShowMenuRequestReceived (const char *entry_id,
207
Display* d = nux::GetThreadGLWindow()->GetX11Display();
195
void DBusIndicators::Impl::RequestSyncAll()
197
SyncDataPtr data(new SyncData(this));
198
pending_syncs_.push_back(data);
199
request_sync(proxy_, "Sync", NULL, data.get());
202
void DBusIndicators::Impl::RequestSyncIndicator(std::string const& name)
204
SyncDataPtr data(new SyncData(this));
205
pending_syncs_.push_back(data);
206
// The ownership of this variant is taken by the g_dbus_proxy_call.
207
GVariant* v_name = g_variant_new("(s)", name.c_str());
208
request_sync(proxy_, "SyncOne", v_name, data.get());
212
void DBusIndicators::Impl::OnEntryShowMenu(std::string const& entry_id,
213
int x, int y, int timestamp, int button)
215
Display* d = nux::GetGraphicsDisplay()->GetX11Display();
208
216
XUngrabPointer(d, CurrentTime);
211
// We have to do this because on certain systems X won't have time to
219
// We have to do this because on certain systems X won't have time to
212
220
// respond to our request for XUngrabPointer and this will cause the
213
221
// menu not to show
214
ShowEntryData *data = g_slice_new0 (ShowEntryData);
215
data->proxy = _proxy;
216
data->entry_id = g_strdup (entry_id);
222
ShowEntryData* data = new ShowEntryData();
223
data->proxy = proxy_;
224
data->entry_id = entry_id;
219
227
data->timestamp = timestamp;
220
228
data->button = button;
222
g_timeout_add (0, (GSourceFunc)send_show_entry, data);
230
g_timeout_add(0, (GSourceFunc)send_show_entry, data);
224
232
// --------------------------------------------------------------------------
225
233
// FIXME: This is a workaround until the non-paired events issue is fixed in
244
252
// --------------------------------------------------------------------------
248
IndicatorObjectFactoryRemote::OnScrollReceived (const char *entry_id,
251
g_dbus_proxy_call (_proxy,
253
g_variant_new ("(si)",
256
G_DBUS_CALL_FLAGS_NONE,
263
// We need to unset the last active entry and set the new one as active
265
IndicatorObjectFactoryRemote::OnEntryActivated (const char *entry_id)
267
std::vector<IndicatorObjectProxy*>::iterator it;
269
for (it = _indicators.begin(); it != _indicators.end(); ++it)
271
IndicatorObjectProxyRemote *object = static_cast<IndicatorObjectProxyRemote *> (*it);
272
std::vector<IndicatorObjectEntryProxy*>::iterator it2;
274
for (it2 = object->GetEntries ().begin(); it2 != object->GetEntries ().end(); ++it2)
276
IndicatorObjectEntryProxyRemote *entry = static_cast<IndicatorObjectEntryProxyRemote *> (*it2);
278
entry->SetActive (g_strcmp0 (entry_id, entry->GetId ()) == 0);
282
IndicatorObjectFactory::OnEntryActivated.emit (entry_id);
286
IndicatorObjectFactoryRemote::OnEntryActivateRequestReceived (const gchar *entry_id)
288
OnEntryActivateRequest.emit (entry_id);
292
IndicatorObjectFactoryRemote::OnEntryShowNowChanged (const char *entry_id, bool show_now_state)
294
std::vector<IndicatorObjectProxy*>::iterator it;
296
for (it = _indicators.begin(); it != _indicators.end(); ++it)
298
IndicatorObjectProxyRemote *object = static_cast<IndicatorObjectProxyRemote *> (*it);
299
std::vector<IndicatorObjectEntryProxy*>::iterator it2;
301
for (it2 = object->GetEntries ().begin(); it2 != object->GetEntries ().end(); ++it2)
303
IndicatorObjectEntryProxyRemote *entry = static_cast<IndicatorObjectEntryProxyRemote *> (*it2);
305
if (g_strcmp0 (entry_id, entry->GetId ()) == 0)
307
entry->OnShowNowChanged (show_now_state);
314
IndicatorObjectProxyRemote *
315
IndicatorObjectFactoryRemote::IndicatorForID (const char *id)
317
IndicatorObjectProxyRemote *remote = NULL;
318
std::vector<IndicatorObjectProxy*>::iterator it;
320
for (it = _indicators.begin(); it != _indicators.end(); it++)
322
IndicatorObjectProxyRemote *r = static_cast<IndicatorObjectProxyRemote *> (*it);
324
if (g_strcmp0 (id, r->GetName ().c_str ()) == 0)
334
remote = new IndicatorObjectProxyRemote (id);
335
remote->OnShowMenuRequest.connect (sigc::mem_fun (this,
336
&IndicatorObjectFactoryRemote::OnShowMenuRequestReceived));
337
remote->OnScroll.connect (sigc::mem_fun (this,
338
&IndicatorObjectFactoryRemote::OnScrollReceived));
340
_indicators.push_back (remote);
342
OnObjectAdded.emit (remote);
349
IndicatorObjectFactoryRemote::Sync (GVariant *args)
255
void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)
257
g_dbus_proxy_call(proxy_, "ScrollEntry",
258
g_variant_new("(si)", entry_id.c_str(), delta),
259
G_DBUS_CALL_FLAGS_NONE,
260
-1, NULL, NULL, NULL);
263
void DBusIndicators::Impl::Sync(GVariant *args, SyncData* data)
351
265
GVariantIter *iter = NULL;
352
266
gchar *indicator_id = NULL;
353
267
gchar *entry_id = NULL;
377
293
&image_sensitive,
380
if (g_strcmp0 (current_proxy_id, indicator_id) != 0)
383
current_proxy->EndSync ();
384
g_free (current_proxy_id);
386
current_proxy_id = g_strdup (indicator_id);
387
current_proxy = IndicatorForID (indicator_id);
388
current_proxy->BeginSync ();
391
/* NULL entries (id == "") are just padding */
392
if (g_strcmp0 (entry_id, "") != 0)
393
current_proxy->AddEntry (entry_id,
403
current_proxy->EndSync ();
405
g_free (current_proxy_id);
406
g_variant_iter_free (iter);
408
/* Notify listeners we have new data */
413
IndicatorObjectFactoryRemote::AddProperties (GVariantBuilder *builder)
418
g_object_get (_proxy,
420
"g-name-owner", &uname,
423
g_variant_builder_add (builder, "{sv}", "backend", g_variant_new_string ("remote"));
424
g_variant_builder_add (builder, "{sv}", "service-name", g_variant_new_string (name));
425
g_variant_builder_add (builder, "{sv}", "service-unique-name", g_variant_new_string (uname));
426
g_variant_builder_add (builder, "{sv}", "using-local-service", g_variant_new_boolean (g_getenv ("PANEL_USE_LOCAL_SERVICE") == NULL ? FALSE : TRUE));
433
IndicatorObjectFactoryRemote::GetRemoteProxy ()
439
// C callbacks, they just link to class methods and aren't interesting
443
reconnect_to_service (gpointer data)
445
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
446
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
296
// NULL entries (entry_id == "") are just padding.
297
std::string entry(entry_id);
298
// The reason for the padding is to provide the ordering for the
299
// indicators... so we must record the order of the indicators provided
300
// even if they only have padding entries.
301
indicator_order.push_back(indicator_id);
304
Indicator::Entries& entries = indicators[indicator_id];
305
Entry::Ptr e(new Entry(entry,
313
entries.push_back(e);
316
g_variant_iter_free(iter);
318
// Now update each of the entries.
319
std::string curr_indicator;
320
for (std::vector<std::string>::iterator i = indicator_order.begin(), end = indicator_order.end();
323
std::string const& indicator_name = *i;
324
if (curr_indicator != indicator_name) {
325
curr_indicator = indicator_name;
326
owner_->GetIndicator(curr_indicator).Sync(indicators[curr_indicator]);
330
// Clean up the SyncData. NOTE: don't use find when passing in a raw
331
// pointer due to explicit construction of the shared pointer. Could write
332
// a predicate, but often a for loop is easier to understand.
333
data->SyncComplete();
334
for (PendingSyncs::iterator i = pending_syncs_.begin(), end = pending_syncs_.end();
337
if (i->get() == data)
339
pending_syncs_.erase(i);
344
// Notify listeners we have new data
345
owner_->on_synced.emit();
348
void DBusIndicators::Impl::SyncGeometries(std::string const& name,
349
EntryLocationMap const& locations)
355
g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssiiii))"));
356
g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssiiii)"));
358
for (EntryLocationMap::const_iterator i = locations.begin(), end = locations.end();
361
nux::Rect const& rect = i->second;
362
g_variant_builder_add(&b, "(ssiiii)",
371
g_variant_builder_close (&b);
372
g_dbus_proxy_call(proxy_, "SyncGeometries",
373
g_variant_builder_end(&b),
374
G_DBUS_CALL_FLAGS_NONE,
381
std::string DBusIndicators::Impl::name() const
385
"g-name", name.AsOutParam(),
390
std::string DBusIndicators::Impl::owner_name() const
392
glib::String owner_name;
394
"g-name-owner", owner_name.AsOutParam(),
396
return owner_name.Str();
399
bool DBusIndicators::Impl::using_local_service() const
401
return g_getenv("PANEL_USE_LOCAL_SERVICE") != NULL;
405
DBusIndicators::DBusIndicators()
406
: pimpl(new Impl(this))
410
DBusIndicators::~DBusIndicators()
415
void DBusIndicators::SyncGeometries(std::string const& name,
416
EntryLocationMap const& locations)
418
pimpl->SyncGeometries(name, locations);
421
void DBusIndicators::OnEntryScroll(std::string const& entry_id, int delta)
423
pimpl->OnEntryScroll(entry_id, delta);
426
void DBusIndicators::OnEntryShowMenu(std::string const& entry_id,
427
int x, int y, int timestamp, int button)
429
pimpl->OnEntryShowMenu(entry_id, x, y, timestamp, button);
432
std::string DBusIndicators::name() const
434
return pimpl->name();
437
std::string DBusIndicators::owner_name() const
439
return pimpl->owner_name();
442
bool DBusIndicators::using_local_service() const
444
return pimpl->using_local_service();
450
// Initialise DBus for the panel service, and let us know when it is
451
// ready. The unused bool return is to fit with the GSourceFunc.
452
gboolean reconnect_to_service(gpointer data)
454
g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
455
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
459
on_proxy_ready_cb (GObject *source,
466
// Make sure the proxy object exists and has a name, and if so, pass
467
// that on to the DBusIndicators.
468
void on_proxy_ready_cb(GObject* source, GAsyncResult* res, gpointer data)
463
IndicatorObjectFactoryRemote *remote = static_cast<IndicatorObjectFactoryRemote *> (data);
465
GError *error = NULL;
470
DBusIndicators::Impl* remote = reinterpret_cast<DBusIndicators::Impl*>(data);
471
GError* error = NULL;
472
GDBusProxy* proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
466
474
static bool force_tried = false;
469
proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
470
name_owner = g_dbus_proxy_get_name_owner (proxy);
472
if (G_IS_DBUS_PROXY (proxy) && name_owner)
475
char* name_owner = g_dbus_proxy_get_name_owner(proxy);
477
if (G_IS_DBUS_PROXY(proxy) && name_owner)
474
remote->OnRemoteProxyReady (G_DBUS_PROXY (proxy));
479
remote->OnRemoteProxyReady(G_DBUS_PROXY(proxy));
489
494
force_tried = true;
490
run_local_panel_service ();
492
g_timeout_add_seconds (2, (GSourceFunc)reconnect_to_service, remote);
495
run_local_panel_service();
496
g_timeout_add_seconds (2, reconnect_to_service, remote);
496
500
g_object_unref (proxy);
500
run_local_panel_service ()
504
bool run_local_panel_service()
502
GError *error = NULL;
506
GError* error = NULL;
504
508
// This is obviously hackish, but this part of the code is mostly hackish...
505
509
// Let's attempt to run it from where we expect it to be
506
char *cmd = g_strdup_printf ("%s/lib/unity/unity-panel-service", PREFIXDIR);
507
printf ("\nWARNING: Couldn't load panel from installed services, so trying to"
508
"load panel from known location: %s\n", cmd);
510
std::string cmd = PREFIXDIR + std::string("/lib/unity/unity-panel-service");
511
std::cerr << "\nWARNING: Couldn't load panel from installed services, "
512
<< "so trying to load panel from known location: "
510
g_spawn_command_line_async (cmd, &error);
515
g_spawn_command_line_async(cmd.c_str(), &error);
515
printf ("\nWARNING: Unable to launch remote service manually: %s\n", error->message);
516
g_error_free (error);
518
std::cerr << "\nWARNING: Unable to launch remote service manually: "
519
<< error->message << "\n";
523
on_proxy_signal_received (GDBusProxy *proxy,
526
GVariant *parameters,
527
IndicatorObjectFactoryRemote *remote)
526
void on_proxy_signal_received(GDBusProxy* proxy,
527
char* sender_name, char* signal_name_,
528
GVariant* parameters,
529
DBusIndicators::Impl* remote)
529
if (g_strcmp0 (signal_name, "EntryActivated") == 0)
531
remote->OnEntryActivated (g_variant_get_string (g_variant_get_child_value (parameters, 0), NULL));
533
else if (g_strcmp0 (signal_name, "EntryActivateRequest") == 0)
535
remote->OnEntryActivateRequestReceived (g_variant_get_string (g_variant_get_child_value (parameters, 0), NULL));
537
else if (g_strcmp0 (signal_name, "ReSync") == 0)
539
const gchar *id = g_variant_get_string (g_variant_get_child_value (parameters, 0), NULL);
540
bool sync_one = !g_strcmp0 (id, "") == 0;
542
SyncData *data = new SyncData (remote);
543
remote->_sync_cancellables.push_back (data);
545
g_dbus_proxy_call (proxy,
546
sync_one ? "SyncOne" : "Sync",
547
sync_one ? g_variant_new ("(s)", id) : NULL,
548
G_DBUS_CALL_FLAGS_NONE,
554
else if (g_strcmp0 (signal_name, "ActiveMenuPointerMotion") == 0)
531
std::string signal_name(signal_name_);
532
if (signal_name == "EntryActivated")
534
const char* entry_name = g_variant_get_string(g_variant_get_child_value(parameters, 0), NULL);
536
remote->owner_->ActivateEntry(entry_name);
539
else if (signal_name == "EntryActivateRequest")
541
const char* entry_name = g_variant_get_string(g_variant_get_child_value(parameters, 0), NULL);
543
remote->owner_->on_entry_activate_request.emit(entry_name);
546
else if (signal_name == "ReSync")
548
const char* id = g_variant_get_string(g_variant_get_child_value(parameters, 0), NULL);
549
bool sync_one = !g_strcmp0 (id, "") == 0;
552
remote->RequestSyncIndicator(id);
555
remote->RequestSyncAll();
558
else if (signal_name == "ActiveMenuPointerMotion")
558
562
g_variant_get (parameters, "(ii)", &x, &y);
560
remote->OnMenuPointerMoved.emit (x, y);
563
remote->owner_->on_menu_pointer_moved.emit(x, y);
562
else if (g_strcmp0 (signal_name, "EntryShowNowChanged") == 0)
565
else if (signal_name == "EntryShowNowChanged")
564
567
gchar *id = NULL;
565
gboolean show_now_state;
567
g_variant_get (parameters, "(sb)", &id, &show_now_state);
569
remote->OnEntryShowNowChanged (id, show_now_state ? true : false);
570
g_variant_get (parameters, "(sb)", &id, &show_now);
571
remote->owner_->SetEntryShowNow(id, show_now);
576
on_proxy_name_owner_changed (GDBusProxy *proxy,
578
IndicatorObjectFactoryRemote *remote)
577
void on_proxy_name_owner_changed(GDBusProxy* proxy, GParamSpec* pspec,
578
DBusIndicators::Impl* remote)
582
name_owner = g_dbus_proxy_get_name_owner (proxy);
580
char* name_owner = g_dbus_proxy_get_name_owner(proxy);
584
582
if (name_owner == NULL)
586
// The panel service has stopped for some reason. Restart it if not in dev mode
587
if (! g_getenv ("UNITY_DEV_MODE"))
588
remote->Reconnect ();
584
// The panel service has stopped for some reason. Restart it if not in
586
if (!g_getenv("UNITY_DEV_MODE"))
591
590
g_free (name_owner);
595
on_sync_ready_cb (GObject *source,
599
SyncData *sync_data = (SyncData *)data;
600
IndicatorObjectFactoryRemote *remote = (IndicatorObjectFactoryRemote*)sync_data->_self;
602
GError *error = NULL;
604
args = g_dbus_proxy_call_finish ((GDBusProxy*)source, res, &error);
593
void request_sync(GDBusProxy* proxy, const char* method, GVariant* name, SyncData* data)
595
g_dbus_proxy_call(proxy, method, name, G_DBUS_CALL_FLAGS_NONE,
596
-1, data->cancel, on_sync_ready_cb, data);
599
void on_sync_ready_cb(GObject* source, GAsyncResult* res, gpointer data)
601
SyncData* sync_data = reinterpret_cast<SyncData*>(data);
602
GError* error = NULL;
604
GVariant* args = g_dbus_proxy_call_finish((GDBusProxy*)source, res, &error);
606
606
if (args == NULL)
608
g_warning ("Unable to perform Sync() on panel service: %s", error->message);
609
g_error_free (error);
615
std::vector<SyncData *>::iterator it = std::find (remote->_sync_cancellables.begin (),
616
remote->_sync_cancellables.end (),
618
if (it != remote->_sync_cancellables.end ())
619
remote->_sync_cancellables.erase (it);
621
g_variant_unref (args);
608
g_warning("Unable to perform Sync() on panel service: %s", error->message);
613
sync_data->self->Sync(args, sync_data);
614
g_variant_unref(args);
617
bool send_show_entry(ShowEntryData *data)
619
g_return_val_if_fail (data != NULL, FALSE);
620
g_return_val_if_fail (G_IS_DBUS_PROXY (data->proxy), FALSE);
622
/* Re-flush 'cos X is crap like that */
623
Display* d = nux::GetGraphicsDisplay()->GetX11Display();
626
g_dbus_proxy_call(data->proxy,
628
g_variant_new("(suiii)",
629
data->entry_id.c_str(),
634
G_DBUS_CALL_FLAGS_NONE,
643
} // anonymous namespace
645
} // namespace indicator