[gnome-photos/wip/rishi/online-miners: 3/3] Add PhotosOnlineMinerProcess




commit f63a6e4c9bf862283339d0b74e797b6875164625
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 19 16:14:47 2021 +0100

    Add PhotosOnlineMinerProcess
    
    This is the application-facing interface to the online miner process.

 src/meson.build                   |   1 +
 src/photos-online-miner-process.c | 163 ++++++++++++++++++++++++++++++++++++++
 src/photos-online-miner-process.h |  43 ++++++++++
 3 files changed, 207 insertions(+)
---
diff --git a/src/meson.build b/src/meson.build
index 04db4229..156c9891 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -157,6 +157,7 @@ sources = common_sources + files(
   'photos-offset-import-controller.c',
   'photos-offset-overview-controller.c',
   'photos-offset-search-controller.c',
+  'photos-online-miner-process.c',
   'photos-organize-collection-dialog.c',
   'photos-organize-collection-model.c',
   'photos-organize-collection-view.c',
diff --git a/src/photos-online-miner-process.c b/src/photos-online-miner-process.c
new file mode 100644
index 00000000..f09f30bb
--- /dev/null
+++ b/src/photos-online-miner-process.c
@@ -0,0 +1,163 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2021 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "config.h"
+
+#include "photos-debug.h"
+#include "photos-online-miner-dbus.h"
+#include "photos-online-miner-process.h"
+
+
+struct _PhotosOnlineMinerProcess
+{
+  GObject parent_instance;
+  GDBusConnection *connection;
+  PhotosOnlineMinerDBus *online_miner;
+  gchar *name;
+  gchar *object_path;
+};
+
+enum
+{
+  PROP_0,
+  PROP_NAME,
+  PROP_OBJECT_PATH
+};
+
+
+G_DEFINE_TYPE_WITH_CODE (PhotosOnlineMinerProcess, photos_online_miner_process, G_TYPE_OBJECT);
+
+
+static void
+photos_online_miner_process_dispose (GObject *object)
+{
+  PhotosOnlineMinerProcess *self = PHOTOS_ONLINE_MINER_PROCESS (object);
+
+  g_clear_object (&self->connection);
+  g_clear_object (&self->online_miner);
+
+  G_OBJECT_CLASS (photos_online_miner_process_parent_class)->dispose (object);
+}
+
+
+static void
+photos_online_miner_process_finalize (GObject *object)
+{
+  PhotosOnlineMinerProcess *self = PHOTOS_ONLINE_MINER_PROCESS (object);
+
+  g_free (name);
+  g_free (object_path);
+
+  G_OBJECT_CLASS (photos_online_miner_process_parent_class)->finalize (object);
+}
+
+
+static void
+photos_online_miner_process_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec 
*pspec)
+{
+  PhotosOnlineMinerProcess *self = PHOTOS_ONLINE_MINER_PROCESS (object);
+
+  switch (prop_id)
+    {
+    case PROP_NAME:
+      self->name = g_value_dup_string (value);
+      break;
+
+    case PROP_OBJECT_PATH:
+      priv->object_path = g_value_dup_string (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_online_miner_process_init (PhotosOnlineMinerProcess *self)
+{
+}
+
+
+static void
+photos_online_miner_process_class_init (PhotosOnlineMinerProcessClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = photos_online_miner_process_dispose;
+  object_class->finalize = photos_online_miner_process_finalize;
+  object_class->set_property = photos_online_miner_process_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_NAME,
+                                   g_param_spec_string ("name",
+                                                        "Name",
+                                                        "D-Bus name",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY
+                                                        | G_PARAM_STATIC_STRINGS
+                                                        | G_PARAM_WRITABLE));
+
+  g_object_class_install_property (object_class,
+                                   PROP_OBJECT_PATH,
+                                   g_param_spec_string ("object-path",
+                                                        "Object path",
+                                                        "D-Bus object path",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY
+                                                        | G_PARAM_STATIC_STRINGS
+                                                        | G_PARAM_WRITABLE));
+}
+
+
+PhotosOnlineMinerProcess *
+photos_online_miner_process_new (const gchar *name, const gchar *object_path)
+{
+  g_return_val_if_fail (name != NULL && name[0] != '\0', NULL);
+  g_return_val_if_fail (object_path != NULL && object_path[0] != '\0', NULL);
+
+  return g_object_new (PHOTOS_TYPE_ONLINE_MINER_PROCESS, "name", name, "object-path", object_path, NULL);
+}
+
+
+void
+photos_online_miner_process_refresh_db_async (PhotosOnlineMinerProcess *self,
+                                              GCancellable *cancellable,
+                                              GAsyncReadyCallback callback,
+                                              gpointer user_data)
+{
+  g_return_if_fail (PHOTOS_IS_ONLINE_MINER_PROCESS (self));
+  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+}
+
+
+gboolean
+photos_online_miner_process_refresh_db_finish (PhotosOnlineMinerProcess *self, GAsyncResult *res, GError 
**error)
+{
+  GTask *task;
+
+  g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
+  task = G_TASK (res);
+
+  g_return_val_if_fail (g_task_get_source_tag (task) == photos_online_miner_process_refresh_db_async, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  return g_task_propagate_boolean (task, error);
+}
diff --git a/src/photos-online-miner-process.h b/src/photos-online-miner-process.h
new file mode 100644
index 00000000..33e3582e
--- /dev/null
+++ b/src/photos-online-miner-process.h
@@ -0,0 +1,43 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2021 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PHOTOS_ONLINE_MINER_PROCESS_H
+#define PHOTOS_ONLINE_MINER_PROCESS_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_ONLINE_MINER_PROCESS (photos_online_miner_process_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosOnlineMinerProcess, photos_online_miner_process, PHOTOS, ONLINE_MINER_PROCESS, 
GObject);
+
+PhotosOnlineMinerProcess  *photos_online_miner_process_new                  (const gchar *name,
+                                                                             const gchar *object_path);
+
+void                       photos_online_miner_process_refresh_db_async     (PhotosOnlineMinerProcess *self,
+                                                                             GCancellable *cancellable,
+                                                                             GAsyncReadyCallback callback,
+                                                                             gpointer user_data);
+
+gboolean                   photos_online_miner_process_refresh_db_finish    (PhotosOnlineMinerProcess *self,
+                                                                             GAsyncResult *res,
+                                                                             GError **error);
+
+G_END_DECLS
+
+#endif /* PHOTOS_ONLINE_MINER_PROCESS_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]