32
32
#define MIME_PATTERN "MimetypePattern"
34
34
#define PLACE_IFACE "com.canonical.Unity.Place"
35
#define ACTIVE_IFACE "com.canonical.Unity.Activation"
36
37
static void on_service_proxy_ready (GObject *source,
37
38
GAsyncResult *result,
217
217
on_service_proxy_ready,
220
if (_uri_regex || _mime_regex)
221
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
222
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
228
(GAsyncReadyCallback)PlaceRemote::OnActivationProxyReady,
221
232
std::vector<PlaceEntry *>&
245
256
if (g_str_has_prefix (group, ENTRY_PREFIX))
247
PlaceEntryRemote *entry = new PlaceEntryRemote (_dbus_name);
258
PlaceEntryRemote *entry = new PlaceEntryRemote (this, _dbus_name);
248
259
entry->InitFromKeyFile (key_file, group);
250
261
if (entry->IsValid ())
372
existing = new PlaceEntryRemote (_dbus_name);
383
existing = new PlaceEntryRemote (this, _dbus_name);
374
385
_entries.push_back (existing);
375
386
entry_added.emit (existing);
527
PlaceRemote::OnActivationResultReceived (GObject *source,
528
GAsyncResult *result,
532
GError *error = NULL;
535
args = g_dbus_proxy_call_finish ((GDBusProxy *)source, result, &error);
538
g_warning ("Unable to call Activate() on: %s",
540
g_error_free (error);
544
self->result_activated.emit (self->_active_uri.c_str (), (ActivationResult)ret);
546
g_variant_unref (args);
550
PlaceRemote::ActivateResult (const char *uri, const char *mimetype)
552
if (G_IS_DBUS_PROXY (_activation_proxy)
553
&& ((_uri_regex && g_regex_match (_uri_regex, uri, (GRegexMatchFlags)0, NULL))
554
|| (_mime_regex && g_regex_match (_mime_regex, mimetype, (GRegexMatchFlags)0, NULL))))
557
g_dbus_proxy_call (_activation_proxy,
559
g_variant_new ("(s)", uri),
560
G_DBUS_CALL_FLAGS_NONE,
563
(GAsyncReadyCallback)OnActivationResultReceived,
568
result_activated.emit (uri, FALLBACK);
573
PlaceRemote::OnActivationProxyReady (GObject *source,
574
GAsyncResult *result,
577
GError *error = NULL;
578
gchar *name_owner = NULL;
580
self->_activation_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
581
name_owner = g_dbus_proxy_get_name_owner (self->_activation_proxy);
583
if (error || !name_owner)
585
g_warning ("Unable to connect to PlaceRemote Activation %s: %s",
587
error ? error->message : "No name owner");
589
g_error_free (error);