]> www.fi.muni.cz Git - evince.git/commitdiff
[ev-daemon] Add FindDocument method to the daemon DBus interface
authorJose Aliste <jose.aliste@gmail.com>
Fri, 9 Jul 2010 07:17:00 +0000 (09:17 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Fri, 9 Jul 2010 07:17:00 +0000 (09:17 +0200)
It returns the name owner of the evince process for the given document
URI.

shell/ev-daemon.c

index b136369dfe8142e07f359d5758097469ba11213a..99b2924261162fed05a9b0ac87109cf96667c5d7 100644 (file)
@@ -317,7 +317,26 @@ method_call_cb (GDBusConnection       *connection,
                 ev_daemon_maybe_start_killtimer (user_data);
 
                 g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
-        }
+       } else if (g_strcmp0 (method_name, "FindDocument") == 0) {
+               EvDoc *doc;
+               const gchar *uri;
+
+               g_variant_get (parameters, "(&s)",  &uri);
+
+               LOG ("FindDocument '%s' \n", uri);
+
+               doc = ev_daemon_find_doc (uri);
+               if (doc == NULL) {
+                       LOG ("GetViewerForUri URI was not registered!\n");
+                       g_dbus_method_invocation_return_error_literal (invocation,
+                                                                      G_DBUS_ERROR,
+                                                                      G_DBUS_ERROR_INVALID_ARGS,
+                                                                      "URI not registered");
+                       return;
+               }
+
+               g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", doc->dbus_name));
+       }
 }
 
 static const char introspection_xml[] =
@@ -330,6 +349,10 @@ static const char introspection_xml[] =
       "<method name='UnregisterDocument'>"
         "<arg type='s' name='uri' direction='in'/>"
       "</method>"
+      "<method name='FindDocument'>"
+        "<arg type='s' name='uri' direction='in'/>"
+        "<arg type='s' name='owner' direction='out'/>"
+      "</method>"
     "</interface>"
   "</node>";