No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | tracker-writeback-module.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * Copyright (C) 2009, Nokia <ivan.frade@nokia.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21
22 #include <gmodule.h>
23
24 #include "tracker-writeback-module.h"
25
26 static TrackerMinerManager *manager = NULL;
27
28 static gboolean writeback_module_load (GTypeModule *module);
29 static void writeback_module_unload (GTypeModule *module);
30
31 G_DEFINE_TYPE (TrackerWritebackModule, tracker_writeback_module, G_TYPE_TYPE_MODULE)
32
33 G_DEFINE_ABSTRACT_TYPE (TrackerWriteback, tracker_writeback, G_TYPE_OBJECT)
34
35
36 static void
37 tracker_writeback_module_class_init (TrackerWritebackModuleClass *klass)
38 {
39 GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
40
41 module_class->load = writeback_module_load;
42 module_class->unload = writeback_module_unload;
43 }
44
45 static void
46 tracker_writeback_module_init (TrackerWritebackModule *module)
47 {
48 }
49
50 static gboolean
51 writeback_module_load (GTypeModule *module)
52 {
53 TrackerWritebackModule *writeback_module;
54 gchar *path;
55
56 writeback_module = TRACKER_WRITEBACK_MODULE (module);
57
58 path = g_build_filename (WRITEBACK_MODULES_DIR, writeback_module->name, NULL);
59 writeback_module->module = g_module_open (path, G_MODULE_BIND_LOCAL);
60 g_free (path);
61
62 if (G_UNLIKELY (!writeback_module->module)) {
63 g_warning ("Could not load writeback module '%s': %s\n",
64 writeback_module->name,
65 g_module_error ());
66
67 return FALSE;
68 }
69
70 g_module_make_resident (writeback_module->module);
71
72 if (!g_module_symbol (writeback_module->module, "writeback_module_create",
73 (gpointer *) &writeback_module->create) ||
74 !g_module_symbol (writeback_module->module, "writeback_module_get_rdf_types",
75 (gpointer *) &writeback_module->get_rdf_types)) {
76 g_warning ("Could not load module symbols for '%s': %s",
77 writeback_module->name,
78 g_module_error ());
79
80 return FALSE;
81 }
82
83 g_message ("Loaded module:'%s'", writeback_module->name);
84
85 return TRUE;
86 }
87
88 static void
89 writeback_module_unload (GTypeModule *module)
90 {
91 TrackerWritebackModule *writeback_module;
92
93 writeback_module = TRACKER_WRITEBACK_MODULE (module);
94
95 g_module_close (writeback_module->module);
96 writeback_module->module = NULL;
97
98 g_message ("Unloaded module:'%s'", writeback_module->name);
99 }
100
101 TrackerWritebackModule *
102 tracker_writeback_module_get (const gchar *name)
103 {
104 static GHashTable *modules = NULL;
105 TrackerWritebackModule *module;
106
107 g_return_val_if_fail (name != NULL, NULL);
108
109 if (G_UNLIKELY (!modules)) {
110 modules = g_hash_table_new (g_str_hash, g_str_equal);
111 }
112
113 module = g_hash_table_lookup (modules, name);
114
115 if (G_UNLIKELY (!module)) {
116 module = g_object_new (TRACKER_TYPE_WRITEBACK_MODULE, NULL);
117 g_type_module_set_name (G_TYPE_MODULE (module), name);
118 module->name = g_strdup (name);
119
120 g_hash_table_insert (modules, module->name, module);
121 }
122
123 if (!g_type_module_use (G_TYPE_MODULE (module))) {
124 return NULL;
125 }
126
127 return module;
128 }
129
130 GList *
131 tracker_writeback_modules_list (void)
132 {
133 GError *error = NULL;
134 const gchar *name;
135 GList *list = NULL;
136 GDir *dir;
137
138 dir = g_dir_open (WRITEBACK_MODULES_DIR, 0, &error);
139
140 if (error) {
141 g_critical ("Could not get writeback modules list: %s", error->message);
142 g_error_free (error);
143 return NULL;
144 }
145
146 while ((name = g_dir_read_name (dir)) != NULL) {
147 if (!g_str_has_suffix (name, G_MODULE_SUFFIX)) {
148 continue;
149 }
150
151 list = g_list_prepend (list, g_strdup (name));
152 }
153
154 g_dir_close (dir);
155
156 return g_list_reverse (list);
157 }
158
159 TrackerWriteback *
160 tracker_writeback_module_create (TrackerWritebackModule *module)
161 {
162 return (module->create) (G_TYPE_MODULE (module));
163 }
164
165 const gchar * const *
166 tracker_writeback_module_get_rdf_types (TrackerWritebackModule *module)
167 {
168 return (module->get_rdf_types) ();
169 }
170
171 static void
172 tracker_writeback_class_init (TrackerWritebackClass *klass)
173 {
174 }
175
176 static void
177 tracker_writeback_init (TrackerWriteback *writeback)
178 {
179 }
180
181 gboolean
182 tracker_writeback_update_metadata (TrackerWriteback *writeback,
183 GPtrArray *values,
184 TrackerSparqlConnection *connection,
185 GCancellable *cancellable,
186 GError **error)
187 {
188 g_return_val_if_fail (TRACKER_IS_WRITEBACK (writeback), FALSE);
189 g_return_val_if_fail (values != NULL, FALSE);
190
191 if (TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata) {
192 return TRACKER_WRITEBACK_GET_CLASS (writeback)->update_metadata (writeback,
193 values,
194 connection,
195 cancellable,
196 error);
197 }
198
199 return FALSE;
200 }
201
202 TrackerMinerManager*
203 tracker_writeback_get_miner_manager (void)
204 {
205 if (!manager) {
206 manager = tracker_miner_manager_new ();
207 }
208
209 return manager;
210 }