[shotwell/wip/phako/enhanced-faces: 36/136] Using DBus activation for facedetect
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/phako/enhanced-faces: 36/136] Using DBus activation for facedetect
- Date: Thu, 11 Oct 2018 09:56:15 +0000 (UTC)
commit 84412d79876636651ca2035e9e644965713f3956
Author: NarendraMA <narendra_m_a yahoo com>
Date: Sun Jul 22 10:32:59 2018 +0530
Using DBus activation for facedetect
facedetect/org.gnome.shotwell.faces.service | 3 +++
src/AppDirs.vala | 6 +-----
src/faces/Face.vala | 14 +-------------
src/faces/FaceDetect.vala | 20 ++++++++++++--------
4 files changed, 17 insertions(+), 26 deletions(-)
---
diff --git a/facedetect/org.gnome.shotwell.faces.service b/facedetect/org.gnome.shotwell.faces.service
new file mode 100644
index 00000000..ae2f7377
--- /dev/null
+++ b/facedetect/org.gnome.shotwell.faces.service
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.shotwell.faces
+Exec=/home/naren/Code/shotwell/build/facedetect/shotwell-facedetect
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 4d0714fa..331a3f30 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -348,11 +348,7 @@ class AppDirs {
}
public static File get_openface_dnn_file() {
- File f =
File.new_for_path(AppDirs.get_exec_dir().get_parent().get_parent().get_child("facedetect").get_child("openface.nn4.small2.v1.t7").get_path());
- if (f.query_exists()) {//testing meson builddir
- return f;
- }
- return get_resources_dir().get_child("openface.nn4.small2.v1.t7");
+ return get_data_subdir("data").get_child("openface.nn4.small2.v1.t7");
}
#endif
diff --git a/src/faces/Face.vala b/src/faces/Face.vala
index 2f5ce6a8..66968c58 100644
--- a/src/faces/Face.vala
+++ b/src/faces/Face.vala
@@ -379,20 +379,8 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
#if ENABLE_FACES
private static void start_facedetect_process() {
message("Launching facedetect process: %s", AppDirs.get_facedetect_bin().get_path());
- // Start the watcher
+ // Start the watcher, process started via DBus service
FaceDetect.init(AppDirs.get_openface_dnn_file().get_path());
- // Start the background process
- string[] argv = {AppDirs.get_facedetect_bin().get_path()};
- int child_pid;
- try {
- GLib.Process.spawn_async(null, argv, null, GLib.SpawnFlags.SEARCH_PATH |
- GLib.SpawnFlags.DO_NOT_REAP_CHILD, null, out child_pid);
- message("Spawned facedetect, child pid: %d", (int)child_pid);
- } catch (Error e) {
- debug("Error spawning process: %s", e.message);
- if (child_pid != 0)
- GLib.Process.close_pid(child_pid);
- }
}
#endif
diff --git a/src/faces/FaceDetect.vala b/src/faces/FaceDetect.vala
index f97ef491..25086069 100644
--- a/src/faces/FaceDetect.vala
+++ b/src/faces/FaceDetect.vala
@@ -48,19 +48,13 @@ public class FaceDetect {
public const string DBUS_PATH = "/org/gnome/shotwell/faces";
public static bool connected = false;
public static string net_file;
+ public const string ERROR_MESSAGE = "Unable to connect to facedetect service";
public static FaceDetectInterface interface;
public static void create_interface(DBusConnection connection, string bus_name, string owner) {
- message("Dbus name %s available", bus_name);
if (bus_name == DBUS_NAME) {
- try {
- interface = Bus.get_proxy_sync (BusType.SESSION, DBUS_NAME, DBUS_PATH);
- interface.load_net(net_file);
- connected = true;
- } catch(IOError e) {
- } catch(DBusError e) {
- }
+ message("Dbus name %s available", bus_name);
}
}
@@ -73,5 +67,15 @@ public class FaceDetect {
FaceDetect.net_file = net_file;
Bus.watch_name(BusType.SESSION, DBUS_NAME, BusNameWatcherFlags.NONE,
create_interface, interface_gone);
+ try {
+ // Service file should automatically run the facedetect binary
+ interface = Bus.get_proxy_sync (BusType.SESSION, DBUS_NAME, DBUS_PATH);
+ interface.load_net(net_file);
+ } catch(IOError e) {
+ AppWindow.error_message(ERROR_MESSAGE);
+ } catch(DBusError e) {
+ AppWindow.error_message(ERROR_MESSAGE);
+ }
+ connected = true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]