Commit 477067ee authored by Emmanuele Bassi's avatar Emmanuele Bassi Committed by Emmanuele Bassi

Remove the MIME type calls and queries from the search engine

2007-06-22  Emmanuele Bassi  <ebassi@gnome.org>

	* gtk/gtksearchenginebeagle.c:
	* gtk/gtksearchenginesimple.c:
	* gtk/gtksearchenginetracker.c: Remove the MIME type calls and
	queries from the search engine implementations, since we use our
	own GtkFileSystem to filter out basing on MIME types and we cannot
	query MIME types anyway. The GtkQuery private object still has
	MIME type, as well as location, support for future expansion.

svn path=/trunk/; revision=18219
parent 76f9baba
2007-06-22 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtksearchenginebeagle.c:
* gtk/gtksearchenginesimple.c:
* gtk/gtksearchenginetracker.c: Remove the MIME type calls and
queries from the search engine implementations, since we use our
own GtkFileSystem to filter out basing on MIME types and we cannot
query MIME types anyway. The GtkQuery private object still has
MIME type, as well as location, support for future expansion.
Fri Jun 22 12:13:39 2007 Tim Janik <timj@imendio.com>
* gtk/gtkframe.c (gtk_frame_paint): applied patch from Xan Lopez
......
......@@ -23,6 +23,7 @@
#include <config.h>
#include <gmodule.h>
#include "gtksearchenginebeagle.h"
#if 0
#include <beagle/beagle.h>
#endif
......@@ -59,7 +60,7 @@ typedef enum
} BeaglePropertyType;
/* *static* wrapper function pointers */
static gboolean (*beagle_client_send_request_async) (BeagleClient *client,
static gboolean (*beagle_client_send_request_async) (BeagleClient *client,
BeagleRequest *request,
GError **err) = NULL;
static G_CONST_RETURN char *(*beagle_hit_get_uri) (BeagleHit *hit) = NULL;
......@@ -70,8 +71,6 @@ static void (*beagle_query_add_text) (BeagleQuery *query,
const char *str) = NULL;
static void (*beagle_query_add_hit_type) (BeagleQuery *query,
const char *hit_type) = NULL;
static void (*beagle_query_add_mime_type) (BeagleQuery *query,
const char *mime_type) = NULL;
static void (*beagle_query_set_max_hits) (BeagleQuery *query,
gint max_hits) = NULL;
static BeagleQueryPartProperty *(*beagle_query_part_property_new) (void) = NULL;
......@@ -104,7 +103,6 @@ static struct BeagleDlMapping
MAP (beagle_query_new),
MAP (beagle_query_add_text),
MAP (beagle_query_add_hit_type),
MAP (beagle_query_add_mime_type),
MAP (beagle_query_set_max_hits),
MAP (beagle_query_part_property_new),
MAP (beagle_query_part_set_logic),
......@@ -275,8 +273,7 @@ gtk_search_engine_beagle_start (GtkSearchEngine *engine)
{
GtkSearchEngineBeagle *beagle;
GError *error;
GList *mimetypes, *l;
gchar *text, *mimetype;
gchar *text;
error = NULL;
beagle = GTK_SEARCH_ENGINE_BEAGLE (engine);
......@@ -298,22 +295,12 @@ gtk_search_engine_beagle_start (GtkSearchEngine *engine)
"error", G_CALLBACK (beagle_error), engine);
/* We only want files */
beagle_query_add_hit_type (beagle->priv->current_query,
"File");
beagle_query_set_max_hits (beagle->priv->current_query,
1000);
beagle_query_add_hit_type (beagle->priv->current_query, "File");
beagle_query_set_max_hits (beagle->priv->current_query, 1000);
text = _gtk_query_get_text (beagle->priv->query);
beagle_query_add_text (beagle->priv->current_query,
text);
beagle_query_add_text (beagle->priv->current_query, text);
mimetypes = _gtk_query_get_mime_types (beagle->priv->query);
for (l = mimetypes; l != NULL; l = l->next)
{
mimetype = l->data;
beagle_query_add_mime_type (beagle->priv->current_query, mimetype);
}
beagle->priv->current_query_uri_prefix = _gtk_query_get_location (beagle->priv->query);
if (!beagle_client_send_request_async (beagle->priv->client,
......@@ -325,8 +312,6 @@ gtk_search_engine_beagle_start (GtkSearchEngine *engine)
/* These must live during the lifetime of the query */
g_free (text);
g_list_foreach (mimetypes, (GFunc)g_free, NULL);
g_list_free (mimetypes);
}
static void
......@@ -340,6 +325,7 @@ gtk_search_engine_beagle_stop (GtkSearchEngine *engine)
{
g_object_unref (beagle->priv->current_query);
beagle->priv->current_query = NULL;
g_free (beagle->priv->current_query_uri_prefix);
beagle->priv->current_query_uri_prefix = NULL;
}
......
......@@ -36,9 +36,6 @@
#include "gtksearchenginesimple.h"
#define XDG_PREFIX _gtk_xdg
#include "xdgmime/xdgmime.h"
#include <string.h>
#include <glib/gstrfuncs.h>
......@@ -50,7 +47,6 @@ typedef struct
GtkSearchEngineSimple *engine;
gchar *path;
GList *mime_types;
gchar **words;
GList *found_list;
......@@ -115,8 +111,6 @@ search_thread_data_new (GtkSearchEngineSimple *engine,
g_free (text);
g_free (lower);
data->mime_types = _gtk_query_get_mime_types (query);
return data;
}
......@@ -125,8 +119,6 @@ search_thread_data_free (SearchThreadData *data)
{
g_free (data->path);
g_strfreev (data->words);
g_list_foreach (data->mime_types, (GFunc)g_free, NULL);
g_list_free (data->mime_types);
g_free (data);
}
......@@ -204,7 +196,7 @@ search_visit_func (const char *fpath,
SearchThreadData *data;
gint i;
const gchar *name;
gchar *lower_name, *mime_type;
gchar *lower_name;
gchar *uri;
gboolean hit;
GList *l;
......@@ -245,22 +237,6 @@ search_visit_func (const char *fpath,
g_free (lower_name);
}
if (hit && data->mime_types != NULL)
{
hit = FALSE;
mime_type = xdg_mime_get_mime_type_for_file (fpath, (struct stat *)sb);
for (l = data->mime_types; l != NULL; l = l->next)
{
if (strcmp (mime_type, l->data) == 0)
{
hit = TRUE;
break;
}
}
g_free (mime_type);
}
if (hit)
{
uri = g_filename_to_uri (fpath, NULL, NULL);
......
......@@ -27,6 +27,8 @@
#include <tracker.h>
#endif
/* we dlopen() libtracker at runtime */
typedef struct _TrackerClient TrackerClient;
typedef void (*TrackerArrayReply) (char **result, GError *error, gpointer user_data);
......@@ -39,22 +41,11 @@ static void (*tracker_search_metadata_by_text_async) (TrackerClient *client,
const char *query,
TrackerArrayReply callback,
gpointer user_data) = NULL;
static void (*tracker_search_metadata_by_text_and_mime_async) (TrackerClient *client,
const char *query,
const char **mimes,
TrackerArrayReply callback,
gpointer user_data) = NULL;
static void (*tracker_search_metadata_by_text_and_location_async) (TrackerClient *client,
const char *query,
const char *location,
TrackerArrayReply callback,
gpointer user_data) = NULL;
static void (*tracker_search_metadata_by_text_and_mime_and_location_async) (TrackerClient *client,
const char *query,
const char **mimes,
const char *location,
TrackerArrayReply callback,
gpointer user_data) = NULL;
static struct TrackerDlMapping
{
......@@ -67,9 +58,7 @@ static struct TrackerDlMapping
MAP (tracker_disconnect),
MAP (tracker_cancel_last_call),
MAP (tracker_search_metadata_by_text_async),
MAP (tracker_search_metadata_by_text_and_mime_async),
MAP (tracker_search_metadata_by_text_and_location_async),
MAP (tracker_search_metadata_by_text_and_mime_and_location_async)
#undef MAP
};
......@@ -164,9 +153,9 @@ search_callback (gchar **results,
{
gchar *uri;
uri = g_filename_to_uri ((char *)*results_p, NULL, NULL);
uri = g_filename_to_uri (*results_p, NULL, NULL);
if (uri)
hit_uris = g_list_prepend (hit_uris, (char *)uri);
hit_uris = g_list_prepend (hit_uris, uri);
}
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hit_uris);
......@@ -182,10 +171,7 @@ static void
gtk_search_engine_tracker_start (GtkSearchEngine *engine)
{
GtkSearchEngineTracker *tracker;
GList *mimetypes, *l;
gchar *search_text, *location, *location_uri;
gchar **mimes;
gint i, mime_count;
gchar *search_text, *location, *location_uri;
tracker = GTK_SEARCH_ENGINE_TRACKER (engine);
......@@ -196,82 +182,34 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
return;
search_text = _gtk_query_get_text (tracker->priv->query);
mimetypes = _gtk_query_get_mime_types (tracker->priv->query);
location_uri = _gtk_query_get_location (tracker->priv->query);
location = NULL;
if (location_uri)
{
location = g_filename_from_uri (location_uri, NULL, NULL);
g_free (location_uri);
}
else
{
location = NULL;
}
mime_count = g_list_length (mimetypes);
i = 0;
/* convert list into array */
if (mime_count > 0)
if (location)
{
mimes = g_new (gchar *, (mime_count + 1));
for (l = mimetypes; l != NULL; l = l->next)
{
mimes[i] = g_strdup (l->data);
i++;
}
mimes[mime_count] = NULL;
if (location)
{
tracker_search_metadata_by_text_and_mime_and_location_async (tracker->priv->client,
search_text, (const char **)mimes, location,
search_callback,
tracker);
g_free (location);
}
else
{
tracker_search_metadata_by_text_and_mime_async (tracker->priv->client,
search_text, (const char**)mimes,
search_callback,
tracker);
}
g_strfreev (mimes);
tracker_search_metadata_by_text_and_location_async (tracker->priv->client,
search_text,
location,
search_callback,
tracker);
g_free (location);
}
else
{
if (location)
{
tracker_search_metadata_by_text_and_location_async (tracker->priv->client,
search_text,
location,
search_callback,
tracker);
g_free (location);
}
else
{
tracker_search_metadata_by_text_async (tracker->priv->client,
search_text,
search_callback,
tracker);
}
tracker_search_metadata_by_text_async (tracker->priv->client,
search_text,
search_callback,
tracker);
}
tracker->priv->query_pending = TRUE;
g_free (search_text);
g_list_foreach (mimetypes, (GFunc)g_free, NULL);
g_list_free (mimetypes);
}
static void
......@@ -355,7 +293,6 @@ _gtk_search_engine_tracker_new (void)
engine = g_object_new (GTK_TYPE_SEARCH_ENGINE_TRACKER, NULL);
engine->priv->client = tracker_client;
engine->priv->query_pending = FALSE;
return GTK_SEARCH_ENGINE (engine);
......
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