Commit d458f27f authored by Martyn Russell's avatar Martyn Russell

tracker-extract: Make it possible to switch by cmdline use of LSA

parent 09ffcd55
......@@ -153,7 +153,8 @@ tracker_dbus_shutdown (void)
}
gboolean
tracker_dbus_register_objects (gboolean disable_shutdown)
tracker_dbus_register_objects (gboolean disable_shutdown,
gboolean internal_extractors)
{
gpointer object;
......@@ -163,7 +164,8 @@ tracker_dbus_register_objects (gboolean disable_shutdown)
}
/* Add org.freedesktop.Tracker1.Extract */
object = tracker_extract_new (disable_shutdown);
object = tracker_extract_new (disable_shutdown,
internal_extractors);
if (!object) {
g_critical ("Could not create TrackerExtract object to register");
return FALSE;
......
......@@ -30,7 +30,8 @@ G_BEGIN_DECLS
gboolean tracker_dbus_init (void);
void tracker_dbus_shutdown (void);
gboolean tracker_dbus_register_objects (gboolean disable_shutdown);
gboolean tracker_dbus_register_objects (gboolean disable_shutdown,
gboolean force_internal_extractors);
GObject *tracker_dbus_get_object (GType type);
G_END_DECLS
......
......@@ -48,6 +48,7 @@ typedef struct {
GArray *specific_extractors;
GArray *generic_extractors;
gboolean disable_shutdown;
gboolean force_internal_extractors;
} TrackerExtractPrivate;
typedef struct {
......@@ -116,7 +117,8 @@ tracker_extract_finalize (GObject *object)
}
TrackerExtract *
tracker_extract_new (gboolean disable_shutdown)
tracker_extract_new (gboolean disable_shutdown,
gboolean force_internal_extractors)
{
TrackerExtract *object;
TrackerExtractPrivate *priv;
......@@ -141,9 +143,14 @@ tracker_extract_new (gboolean disable_shutdown)
}
#ifdef HAVE_LIBSTREAMANALYZER
g_message ("Adding extractor for libstreamanalyzer");
g_message (" Generic match for ALL (tried first before our module)");
g_message (" Specific match for NONE (fallback to our modules)");
if (!force_internal_extractors) {
g_message ("Adding extractor for libstreamanalyzer");
g_message (" Generic match for ALL (tried first before our module)");
g_message (" Specific match for NONE (fallback to our modules)");
} else {
g_message ("Not using libstreamanalyzer");
g_message (" It is available but disabled by command line");
}
#endif /* HAVE_STREAMANALYZER */
specific_extractors = g_array_new (FALSE,
TRUE,
......@@ -209,6 +216,7 @@ tracker_extract_new (gboolean disable_shutdown)
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
priv->disable_shutdown = disable_shutdown;
priv->force_internal_extractors = force_internal_extractors;
priv->specific_extractors = specific_extractors;
priv->generic_extractors = generic_extractors;
......@@ -222,24 +230,32 @@ get_file_metadata (TrackerExtract *extract,
const gchar *uri,
const gchar *mime)
{
TrackerExtractPrivate *priv;
TrackerSparqlBuilder *statements;
gchar *mime_used = NULL;
gchar *content_type = NULL;
priv = TRACKER_EXTRACT_GET_PRIVATE (extract);
/* Create hash table to send back */
statements = tracker_sparql_builder_new_update ();
tracker_sparql_builder_insert_open (statements);
#ifdef HAVE_LIBSTREAMANALYZER
tracker_dbus_request_comment (request_id,
" Extracting with libstreamanalyzer...");
tracker_topanalyzer_extract (uri, statements, &content_type);
if (tracker_sparql_builder_get_length (statements) > 0) {
tracker_sparql_builder_insert_close (statements);
return statements;
if (!priv->force_internal_extractors) {
tracker_dbus_request_comment (request_id,
" Extracting with libstreamanalyzer...");
tracker_topanalyzer_extract (uri, statements, &content_type);
if (tracker_sparql_builder_get_length (statements) > 0) {
tracker_sparql_builder_insert_close (statements);
return statements;
}
} else {
tracker_dbus_request_comment (request_id,
" Extracting with internal extractors ONLY...");
}
#endif /* HAVE_LIBSTREAMANALYZER */
......@@ -298,11 +314,8 @@ get_file_metadata (TrackerExtract *extract,
* data we need from the extractors.
*/
if (mime_used) {
TrackerExtractPrivate *priv;
guint i;
priv = TRACKER_EXTRACT_GET_PRIVATE (extract);
for (i = 0; i < priv->specific_extractors->len; i++) {
const TrackerExtractData *edata;
ModuleData mdata;
......
......@@ -50,7 +50,8 @@ struct TrackerExtractClass {
};
GType tracker_extract_get_type (void);
TrackerExtract *tracker_extract_new (gboolean disable_shutdown);
TrackerExtract *tracker_extract_new (gboolean disable_shutdown,
gboolean force_internal_extractors);
void tracker_extract_get_pid (TrackerExtract *object,
DBusGMethodInvocation *context,
GError **error);
......
......@@ -70,10 +70,12 @@ static GMainLoop *main_loop;
static guint quit_timeout_id = 0;
static gboolean version;
static gboolean disable_shutdown;
static gint verbosity = -1;
static gchar *filename;
static gchar *mime_type;
static gboolean disable_shutdown;
static gboolean force_internal_extractors;
static TrackerFTSConfig *fts_config;
static GOptionEntry entries[] = {
......@@ -100,7 +102,10 @@ static GOptionEntry entries[] = {
G_OPTION_ARG_NONE, &disable_shutdown,
N_("Disable shutting down after 30 seconds of inactivity"),
NULL },
{ "force-internal-extractors", 'i', 0,
G_OPTION_ARG_NONE, &force_internal_extractors,
N_("Force internal extractors over 3rd parties like libstreamanalyzer"),
NULL },
{ NULL }
};
......@@ -353,7 +358,8 @@ main (int argc, char *argv[])
GFile *file;
gchar *uri;
extract = tracker_extract_new (disable_shutdown);
extract = tracker_extract_new (disable_shutdown,
force_internal_extractors);
if (!extract) {
return EXIT_FAILURE;
}
......@@ -390,7 +396,8 @@ main (int argc, char *argv[])
g_free (log_filename);
/* Make Tracker available for introspection */
if (!tracker_dbus_register_objects (disable_shutdown)) {
if (!tracker_dbus_register_objects (disable_shutdown,
force_internal_extractors)) {
g_object_unref (config);
return EXIT_FAILURE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment