tracker-private.h 12.9 KB
Newer Older
1
/*
2 3
 * Copyright (C) 2010, Nokia <ivan.frade@nokia.com>
 * Copyright (C) 2019, Red Hat Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */
20 21
#ifndef __TRACKER_PRIVATE_H__
#define __TRACKER_PRIVATE_H__
22

23 24 25
#include <libtracker-sparql/tracker-version-generated.h>
#include <libtracker-sparql/tracker-cursor.h>
#include <libtracker-sparql/tracker-endpoint-dbus.h>
26

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
typedef struct _TrackerSparqlConnectionClass TrackerSparqlConnectionClass;

struct _TrackerSparqlConnectionClass
{
	GObjectClass parent_class;

        TrackerSparqlCursor * (* query) (TrackerSparqlConnection  *connection,
                                         const gchar              *sparql,
                                         GCancellable             *cancellable,
                                         GError                  **error);
	void (* query_async) (TrackerSparqlConnection *connection,
	                      const gchar             *sparql,
	                      GCancellable            *cancellable,
	                      GAsyncReadyCallback      callback,
	                      gpointer                 user_data);
        TrackerSparqlCursor * (* query_finish) (TrackerSparqlConnection  *connection,
                                                GAsyncResult             *res,
                                                GError                  **error);
        void (* update) (TrackerSparqlConnection  *connection,
                         const gchar              *sparql,
                         GCancellable             *cancellable,
                         GError                  **error);
        void (* update_async) (TrackerSparqlConnection *connection,
                               const gchar             *sparql,
                               GCancellable            *cancellable,
                               GAsyncReadyCallback      callback,
                               gpointer                 user_data);
        void (* update_finish) (TrackerSparqlConnection  *connection,
                                GAsyncResult             *res,
                                GError                  **error);
        void (* update_array_async) (TrackerSparqlConnection  *connection,
                                     gchar                   **sparql,
                                     gint                      sparql_length,
                                     GCancellable             *cancellable,
                                     GAsyncReadyCallback       callback,
                                     gpointer                  user_data);
        gboolean (* update_array_finish) (TrackerSparqlConnection  *connection,
                                          GAsyncResult             *res,
                                          GError                  **error);
        GVariant* (* update_blank) (TrackerSparqlConnection  *connection,
                                    const gchar              *sparql,
                                    GCancellable             *cancellable,
                                    GError                  **error);
        void (* update_blank_async) (TrackerSparqlConnection *connection,
                                     const gchar             *sparql,
                                     GCancellable            *cancellable,
                                     GAsyncReadyCallback      callback,
                                     gpointer                 user_data);
        GVariant* (* update_blank_finish) (TrackerSparqlConnection  *connection,
                                           GAsyncResult             *res,
                                           GError                  **error);
        TrackerNamespaceManager * (* get_namespace_manager) (TrackerSparqlConnection *connection);
        TrackerSparqlStatement * (* query_statement) (TrackerSparqlConnection  *connection,
                                                      const gchar              *sparql,
                                                      GCancellable             *cancellable,
                                                      GError                  **error);
83
	TrackerNotifier * (* create_notifier) (TrackerSparqlConnection *connection);
84 85

	void (* close) (TrackerSparqlConnection *connection);
86 87 88 89 90 91 92
        void (* close_async) (TrackerSparqlConnection *connection,
                              GCancellable            *cancellable,
                              GAsyncReadyCallback      callback,
                              gpointer                 user_data);
        gboolean (* close_finish) (TrackerSparqlConnection  *connection,
                                   GAsyncResult             *res,
                                   GError                  **error);
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

	gboolean (* update_resource) (TrackerSparqlConnection  *connection,
				      const gchar              *graph,
				      TrackerResource          *resource,
				      GCancellable             *cancellable,
				      GError                  **error);
	void (* update_resource_async) (TrackerSparqlConnection *connection,
					const gchar             *graph,
					TrackerResource         *resource,
					GCancellable            *cancellable,
					GAsyncReadyCallback      callback,
					gpointer                 user_data);
	gboolean (* update_resource_finish) (TrackerSparqlConnection  *connection,
					     GAsyncResult             *res,
					     GError                  **error);
108
	TrackerBatch * (* create_batch) (TrackerSparqlConnection *connection);
109 110 111 112 113 114

	gboolean (* lookup_dbus_service) (TrackerSparqlConnection  *connection,
	                                  const gchar              *dbus_name,
	                                  const gchar              *dbus_path,
	                                  gchar                   **name,
	                                  gchar                   **path);
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
};

typedef struct _TrackerSparqlCursorClass TrackerSparqlCursorClass;

struct _TrackerSparqlCursorClass
{
	GObjectClass parent_class;

	TrackerSparqlValueType (* get_value_type) (TrackerSparqlCursor *cursor,
	                                           gint                 column);
        const gchar* (* get_variable_name) (TrackerSparqlCursor *cursor,
                                            gint                 column);
	const gchar* (* get_string) (TrackerSparqlCursor *cursor,
	                             gint                 column,
	                             glong               *length);
        gboolean (* next) (TrackerSparqlCursor  *cursor,
                           GCancellable         *cancellable,
                           GError              **error);
        void (* next_async) (TrackerSparqlCursor *cursor,
                             GCancellable        *cancellable,
                             GAsyncReadyCallback  callback,
                             gpointer             user_data);
        gboolean (* next_finish) (TrackerSparqlCursor  *cursor,
                                  GAsyncResult         *res,
                                  GError              **error);
        void (* rewind) (TrackerSparqlCursor* cursor);
        void (* close) (TrackerSparqlCursor* cursor);
        gint64 (* get_integer) (TrackerSparqlCursor *cursor,
                                gint                 column);
        gdouble (* get_double) (TrackerSparqlCursor *cursor,
                                gint                 column);
        gboolean (* get_boolean) (TrackerSparqlCursor *cursor,
                                  gint                 column);
        gboolean (* is_bound) (TrackerSparqlCursor *cursor,
                               gint                 column);
        gint (* get_n_columns) (TrackerSparqlCursor *cursor);
};

typedef struct _TrackerEndpointClass TrackerEndpointClass;

struct _TrackerEndpointClass {
	GObjectClass parent_class;
};

159 160 161 162 163 164 165 166 167 168 169 170
typedef struct _TrackerEndpointDBus TrackerEndpointDBus;

struct _TrackerEndpointDBus {
	TrackerEndpoint parent_instance;
	GDBusConnection *dbus_connection;
	gchar *object_path;
	guint register_id;
	GDBusNodeInfo *node_info;
	GCancellable *cancellable;
	TrackerNotifier *notifier;
};

171 172
typedef struct _TrackerEndpointDBusClass TrackerEndpointDBusClass;

173 174 175 176 177
typedef enum {
	TRACKER_OPERATION_TYPE_SELECT,
	TRACKER_OPERATION_TYPE_UPDATE,
} TrackerOperationType;

178 179
struct _TrackerEndpointDBusClass {
	struct _TrackerEndpointClass parent_class;
180 181 182 183 184 185 186

	gboolean (* forbid_operation) (TrackerEndpointDBus   *endpoint_dbus,
	                               GDBusMethodInvocation *invocation,
	                               TrackerOperationType   operation_type);
	gboolean (* filter_graph) (TrackerEndpointDBus *endpoint_dbus,
	                           const gchar         *graph_name);
	gchar * (* add_prologue) (TrackerEndpointDBus *endpoint_dbus);
187 188
};

189 190 191 192 193 194
typedef struct _TrackerEndpointHttpClass TrackerEndpointHttpClass;

struct _TrackerEndpointHttpClass {
	struct _TrackerEndpointClass parent_class;
};

195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
typedef struct _TrackerResourceClass TrackerResourceClass;

struct _TrackerResourceClass
{
	GObjectClass parent_class;
};

typedef struct _TrackerSparqlStatementClass TrackerSparqlStatementClass;

struct _TrackerSparqlStatementClass
{
	GObjectClass parent_class;

        void (* bind_int) (TrackerSparqlStatement *stmt,
                           const gchar            *name,
                           gint64                  value);
        void (* bind_boolean) (TrackerSparqlStatement *stmt,
                               const gchar            *name,
                               gboolean                value);
        void (* bind_string) (TrackerSparqlStatement *stmt,
                              const gchar            *name,
                              const gchar            *value);
        void (* bind_double) (TrackerSparqlStatement *stmt,
                              const gchar            *name,
                              gdouble                 value);

        TrackerSparqlCursor * (* execute) (TrackerSparqlStatement  *stmt,
                                           GCancellable            *cancellable,
                                           GError                 **error);
        void (* execute_async) (TrackerSparqlStatement *stmt,
                                GCancellable           *cancellable,
                                GAsyncReadyCallback     callback,
                                gpointer                user_data);
        TrackerSparqlCursor * (* execute_finish) (TrackerSparqlStatement  *stmt,
                                                  GAsyncResult            *res,
                                                  GError                 **error);
	void (* clear_bindings) (TrackerSparqlStatement *stmt);
};

typedef struct _TrackerNotifierClass TrackerNotifierClass;

struct _TrackerNotifierClass {
	GObjectClass parent_class;

	void (* events) (TrackerNotifier *notifier,
	                 const GPtrArray *events);
};

243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
typedef struct _TrackerBatchClass TrackerBatchClass;

struct _TrackerBatchClass {
	GObjectClass parent_class;

	void (* add_sparql) (TrackerBatch *batch,
			     const gchar  *sparql);
	void (* add_resource) (TrackerBatch    *batch,
			       const gchar     *graph,
			       TrackerResource *resource);
	gboolean (* execute) (TrackerBatch  *batch,
			      GCancellable  *cancellable,
			      GError       **error);
	void (* execute_async) (TrackerBatch        *batch,
				GCancellable        *cancellable,
				GAsyncReadyCallback  callback,
				gpointer             user_data);
	gboolean (* execute_finish) (TrackerBatch  *batch,
				     GAsyncResult  *res,
				     GError       **error);
};

265 266 267 268 269 270
typedef struct _TrackerSerializerClass TrackerSerializerClass;

struct _TrackerSerializerClass {
	GInputStreamClass parent_class;
};

271 272 273 274 275 276
gboolean
tracker_sparql_connection_lookup_dbus_service (TrackerSparqlConnection  *connection,
                                               const gchar              *dbus_name,
                                               const gchar              *dbus_path,
                                               gchar                   **name,
                                               gchar                   **path);
277 278
void tracker_sparql_cursor_set_connection (TrackerSparqlCursor     *cursor,
                                           TrackerSparqlConnection *connection);
279
GError * _translate_internal_error (GError *error);
280

281
#endif /* __TRACKER_PRIVATE_H__ */