[tracker/wip/carlosg/domain-ontologies: 7/21] libtracker-miner: Add TrackerMiner::connection property



commit 3a33372adaa3631c5104831f1ac09deb314df419
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jun 20 00:05:57 2017 +0200

    libtracker-miner: Add TrackerMiner::connection property
    
    So it is possible to use TrackerMiner facilities in-process using
    a dedicated TrackerSparqlConnection. Basically store and mining
    handled by the client app.

 src/libtracker-miner/tracker-miner-object.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-object.c b/src/libtracker-miner/tracker-miner-object.c
index 487a331..ec54de4 100644
--- a/src/libtracker-miner/tracker-miner-object.c
+++ b/src/libtracker-miner/tracker-miner-object.c
@@ -78,6 +78,7 @@ enum {
        PROP_STATUS,
        PROP_PROGRESS,
        PROP_REMAINING_TIME,
+       PROP_CONNECTION
 };
 
 enum {
@@ -258,6 +259,14 @@ tracker_miner_class_init (TrackerMinerClass *klass)
                                                           G_MAXINT,
                                                           -1,
                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+       g_object_class_install_property (object_class,
+                                        PROP_CONNECTION,
+                                        g_param_spec_object ("connection",
+                                                             "Connection",
+                                                             "SPARQL Connection",
+                                                             TRACKER_SPARQL_TYPE_CONNECTION,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_CONSTRUCT_ONLY));
 
        g_type_class_add_private (object_class, sizeof (TrackerMinerPrivate));
 }
@@ -276,8 +285,11 @@ miner_initable_init (GInitable     *initable,
        TrackerMiner *miner = TRACKER_MINER (initable);
        GError *inner_error = NULL;
 
-       /* Try to get SPARQL connection... */
-       miner->priv->connection = tracker_sparql_connection_get (NULL, &inner_error);
+       if (!miner->priv->connection) {
+               /* Try to get SPARQL connection... */
+               miner->priv->connection = tracker_sparql_connection_get (NULL, &inner_error);
+       }
+
        if (!miner->priv->connection) {
                g_propagate_error (error, inner_error);
                return FALSE;
@@ -429,6 +441,10 @@ miner_set_property (GObject      *object,
                }
                break;
        }
+       case PROP_CONNECTION: {
+               miner->priv->connection = g_value_dup_object (value);
+               break;
+       }
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;
@@ -453,6 +469,8 @@ miner_get_property (GObject    *object,
        case PROP_REMAINING_TIME:
                g_value_set_int (value, miner->priv->remaining_time);
                break;
+       case PROP_CONNECTION:
+               g_value_set_object (value, miner->priv->connection);
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;


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