1 /* 2 * GNOME Online Miners - crawls through your online content 3 * Copyright (C) 2012 Red Hat, Inc. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA. 19 * 20 * Author: Jasper St. Pierre <jstpierre@mecheye.net> 21 * 22 */ 23 24 #ifndef __GOM_MINER_H__ 25 #define __GOM_MINER_H__ 26 27 #include <glib-object.h> 28 #include <goa/goa.h> 29 30 #include "gom-tracker.h" 31 #include "gom-utils.h" 32 33 G_BEGIN_DECLS 34 35 #define GOM_TYPE_MINER (gom_miner_get_type ()) 36 37 #define GOM_MINER(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ 39 GOM_TYPE_MINER, GomMiner)) 40 41 #define GOM_MINER_CLASS(klass) \ 42 (G_TYPE_CHECK_CLASS_CAST ((klass), \ 43 GOM_TYPE_MINER, GomMinerClass)) 44 45 #define GOM_IS_MINER(obj) \ 46 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ 47 GOM_TYPE_MINER)) 48 49 #define GOM_IS_MINER_CLASS(klass) \ 50 (G_TYPE_CHECK_CLASS_TYPE ((klass), \ 51 GOM_TYPE_MINER)) 52 53 #define GOM_MINER_GET_CLASS(obj) \ 54 (G_TYPE_INSTANCE_GET_CLASS ((obj), \ 55 GOM_TYPE_MINER, GomMinerClass)) 56 57 typedef struct _GomMiner GomMiner; 58 typedef struct _GomMinerClass GomMinerClass; 59 typedef struct _GomMinerPrivate GomMinerPrivate; 60 61 typedef struct { 62 GomMiner *miner; 63 TrackerSparqlConnection *connection; 64 65 GoaAccount *account; 66 GHashTable *services; 67 GTask *task; 68 GTask *parent_task; 69 70 GHashTable *previous_resources; 71 gchar *datasource_urn; 72 gchar *root_element_urn; 73 } GomAccountMinerJob; 74 75 struct _GomMiner 76 { 77 GObject parent; 78 79 GomMinerPrivate *priv; 80 }; 81 82 struct _GomMinerClass 83 { 84 GObjectClass parent_class; 85 86 char *goa_provider_type; 87 char *miner_identifier; 88 gint version; 89 90 gpointer (*create_service) (GomMiner *self, GoaObject *object, const gchar *type); 91 92 GHashTable * (*create_services) (GomMiner *self, 93 GoaObject *object); 94 95 void (*destroy_service) (GomMiner *self, gpointer service); 96 97 void (*insert_shared_content) (GomMiner *self, 98 gpointer service, 99 TrackerSparqlConnection *connection, 100 const gchar *datasource_urn, 101 const gchar *shared_id, 102 const gchar *shared_type, 103 const gchar *source_urn, 104 GCancellable *cancellable, 105 GError **error); 106 107 void (*query) (GomAccountMinerJob *job, 108 TrackerSparqlConnection *connection, 109 GHashTable *previous_resources, 110 const gchar *datasource_urn, 111 GCancellable *cancellable, 112 GError **error); 113 }; 114 115 GType gom_miner_get_type (void); 116 117 const gchar * gom_miner_get_display_name (GomMiner *self); 118 119 void gom_miner_insert_shared_content_async (GomMiner *self, 120 const gchar *account_id, 121 const gchar *shared_id, 122 const gchar *shared_type, 123 const gchar *source_urn, 124 GCancellable *cancellable, 125 GAsyncReadyCallback callback, 126 gpointer user_data); 127 128 gboolean gom_miner_insert_shared_content_finish (GomMiner *self, GAsyncResult *res, GError **error); 129 130 void gom_miner_refresh_db_async (GomMiner *self, 131 GCancellable *cancellable, 132 GAsyncReadyCallback callback, 133 gpointer user_data); 134 135 gboolean gom_miner_refresh_db_finish (GomMiner *self, 136 GAsyncResult *res, 137 GError **error); 138 139 void gom_miner_set_index_types (GomMiner *self, const gchar **index_types); 140 141 const gchar ** gom_miner_get_index_types (GomMiner *self); 142 143 gboolean gom_miner_supports_type (GomMiner *self, gchar *type); 144 145 G_END_DECLS 146 147 #endif /* __GOM_MINER_H__ */ 148