tracker r2540 - in trunk: . po src/libtracker-common src/tracker-applet src/tracker-indexer/modules tests/libtracker-common
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2540 - in trunk: . po src/libtracker-common src/tracker-applet src/tracker-indexer/modules tests/libtracker-common
- Date: Fri, 21 Nov 2008 11:02:04 +0000 (UTC)
Author: mr
Date: Fri Nov 21 11:02:04 2008
New Revision: 2540
URL: http://svn.gnome.org/viewvc/tracker?rev=2540&view=rev
Log:
* POTFILES.in: Updated files we skip/include.
* src/libtracker-common/tracker-ontology.c: Code clean ups, don't
unnecessarily cast and coding style.
* src/tracker-indexer/modules/Makefile.am: Included new evolution
module header files so make distcheck works.
* src/tracker-indexer/modules/applications.c:
* src/tracker-indexer/modules/dummy.c:
* src/tracker-indexer/modules/evolution-common.[ch]:
* src/tracker-indexer/modules/evolution-imap.[ch]:
* src/tracker-indexer/modules/evolution-pop.[ch]:
* src/tracker-indexer/modules/evolution.c:
* src/tracker-indexer/modules/files.c:
* src/tracker-indexer/modules/gaim-conversations.c: Added common.h
include and formatting line at the top of these files.
* tests/libtracker-common/tracker-ontology-test.c: Fixed several
leaks and updated the calls which now return static data so we
don't free the result. Also don't free the return from
tracker_ontology_get_subcategory_ids() since it is a const array.
This was crashing the test cases.
Modified:
trunk/ChangeLog
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/libtracker-common/tracker-ontology.c
trunk/src/tracker-applet/tracker-applet.c
trunk/src/tracker-indexer/modules/Makefile.am
trunk/src/tracker-indexer/modules/applications.c
trunk/src/tracker-indexer/modules/dummy.c
trunk/src/tracker-indexer/modules/evolution-common.c
trunk/src/tracker-indexer/modules/evolution-common.h
trunk/src/tracker-indexer/modules/evolution-imap.c
trunk/src/tracker-indexer/modules/evolution-imap.h
trunk/src/tracker-indexer/modules/evolution-pop.c
trunk/src/tracker-indexer/modules/evolution-pop.h
trunk/src/tracker-indexer/modules/evolution.c
trunk/src/tracker-indexer/modules/files.c
trunk/src/tracker-indexer/modules/gaim-conversations.c
trunk/tests/libtracker-common/tracker-ontology-test.c
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Fri Nov 21 11:02:04 2008
@@ -3,26 +3,25 @@
[encoding: UTF-8]
data/trackerd.desktop.in.in
-python/deskbar-handler/tracker-handler.py
python/deskbar-handler/tracker-handler-static.py
+python/deskbar-handler/tracker-handler.py
python/deskbar-handler/tracker-module.py
src/libtracker-common/tracker-dbus.c
src/libtracker-common/tracker-utils.c
src/libtracker-gtk/tracker-metadata-tile.c
src/libtracker-gtk/tracker-tag-bar.c
+src/tracker-applet/tracker-applet-prefs.glade
src/tracker-applet/tracker-applet.c
src/tracker-applet/tracker-applet.desktop.in.in
-src/tracker-applet/tracker-applet-prefs.glade
src/tracker-extract/tracker-extract.c
-src/tracker-indexer/tracker-indexer.c
src/tracker-indexer/tracker-main.c
src/tracker-preferences/tracker-preferences.c
src/tracker-preferences/tracker-preferences.desktop.in.in
src/tracker-preferences/tracker-preferences.glade
-src/tracker-search-tool/tracker-search-tool.c
src/tracker-search-tool/tracker-search-tool-callbacks.c
-src/tracker-search-tool/tracker-search-tool.desktop.in.in
src/tracker-search-tool/tracker-search-tool-support.c
+src/tracker-search-tool/tracker-search-tool.c
+src/tracker-search-tool/tracker-search-tool.desktop.in.in
src/tracker-utils/tracker-files.c
src/tracker-utils/tracker-info.c
src/tracker-utils/tracker-meta-folder.c
Modified: trunk/src/libtracker-common/tracker-ontology.c
==============================================================================
--- trunk/src/libtracker-common/tracker-ontology.c (original)
+++ trunk/src/libtracker-common/tracker-ontology.c Fri Nov 21 11:02:04 2008
@@ -19,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <string.h>
#include <stdlib.h>
@@ -31,6 +33,11 @@
gint service;
} ServiceMimePrefixes;
+typedef struct {
+ gchar *name;
+ GArray *subcategories;
+} CalculateSubcategoriesForEach;
+
static gboolean initialized;
/* Hash (gint service_type_id, TrackerService *service) */
@@ -60,7 +67,7 @@
{
ServiceMimePrefixes *mime_prefix;
- mime_prefix = (ServiceMimePrefixes*) data;
+ mime_prefix = data;
g_free (mime_prefix->prefix);
g_free (mime_prefix);
@@ -407,11 +414,11 @@
GSList *
tracker_ontology_get_field_names_registered (const gchar *service_str)
{
- GList *fields;
- GList *l;
- GSList *names;
- const gchar *prefix = NULL;
- const gchar *parent_prefix;
+ GList *fields;
+ GList *l;
+ GSList *names;
+ const gchar *prefix = NULL;
+ const gchar *parent_prefix;
parent_prefix = NULL;
@@ -470,24 +477,21 @@
return names;
}
-typedef struct {
- gchar *name;
- GArray *subcategories;
-} CalculateSubcategoriesForEach;
-
static void
-calculate_subcategories_foreach (gpointer key, gpointer value, gpointer user_data)
+calculate_subcategories_foreach (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
- TrackerService *service_def;
+ TrackerService *service;
CalculateSubcategoriesForEach *data;
- service_def = (TrackerService *)value;
- data = (CalculateSubcategoriesForEach *)user_data;
+ service = value;
+ data = user_data;
- if (!g_strcmp0 (tracker_service_get_name (service_def), data->name)
- || !g_strcmp0 (tracker_service_get_parent (service_def), data->name)
- || !g_strcmp0 ("*", data->name)) {
- gint id = tracker_service_get_id (service_def);
+ if (!g_strcmp0 (tracker_service_get_name (service), data->name) ||
+ !g_strcmp0 (tracker_service_get_parent (service), data->name) ||
+ !g_strcmp0 ("*", data->name)) {
+ gint id = tracker_service_get_id (service);
g_array_append_val (data->subcategories, id);
}
}
@@ -506,7 +510,6 @@
data.subcategories = g_array_new (TRUE, TRUE, sizeof (int));
g_hash_table_foreach (service_names, calculate_subcategories_foreach, &data);
-
g_hash_table_insert (subcategories_cache, data.name, data.subcategories);
subcategories = data.subcategories;
Modified: trunk/src/tracker-applet/tracker-applet.c
==============================================================================
--- trunk/src/tracker-applet/tracker-applet.c (original)
+++ trunk/src/tracker-applet/tracker-applet.c Fri Nov 21 11:02:04 2008
@@ -121,6 +121,7 @@
IndexStateEnum index_state;
PauseStateEnum pause_state;
IndexIcon index_icon;
+ gboolean initial_index;
gboolean animated;
gboolean animated_timer_active;
gboolean is_watching_events;
@@ -136,7 +137,8 @@
/* Main window */
GtkMenu *menu;
- gboolean initial_index_msg_shown;
+ gboolean shown_starting_msg;
+ gboolean shown_finished_msg;
/* Tracker connection */
TrackerClient *tracker;
@@ -160,9 +162,6 @@
static TrayIcon *main_icon;
-static gchar *initial_index_1;
-static gchar *initial_index_2;
-
static gchar *index_icons[4] = {
"tracker-applet-default.png",
"tracker-applet-paused.png",
@@ -1489,17 +1488,41 @@
gdouble seconds_elapsed,
TrayIcon *icon)
{
- gchar *str;
+ TrayIconPrivate *priv;
+
+ priv = TRAY_ICON_GET_PRIVATE (icon);
+
+ g_print ("Indexing finished in %f seconds\n",
+ seconds_elapsed);
+
+ priv->indexer_stopped = FALSE;
- str = tracker_seconds_to_string (seconds_elapsed, FALSE);
- tray_icon_show_message (icon,
- "%s in %s.\n"
- "\n"
- "%s",
- _("Tracker has finished indexing your system"),
- str,
- _("You can now perform searches by clicking here"));
- g_free (str);
+ priv->index_state = INDEX_IDLE;
+ priv->pause_state = PAUSE_NONE;
+
+ priv->user_pause = FALSE;
+ priv->auto_pause = FALSE;
+
+ if (!priv->shown_finished_msg && priv->initial_index) {
+ gchar *str;
+
+ priv->shown_finished_msg = TRUE;
+
+ str = tracker_seconds_to_string (seconds_elapsed, FALSE);
+ tray_icon_show_message (icon,
+ "%s in %s.\n"
+ "\n"
+ "%s",
+ _("Tracker has finished indexing your system"),
+ str,
+ _("You can now perform searches by clicking here"));
+ g_free (str);
+ }
+
+ set_icon (priv);
+ set_status_hint (icon);
+
+ refresh_stats (icon);
stop_watching_events (icon);
}
@@ -1523,7 +1546,9 @@
}
priv = TRAY_ICON_GET_PRIVATE (icon);
+
priv->indexer_stopped = FALSE;
+ priv->initial_index = initial_index;
paused = FALSE;
@@ -1538,9 +1563,20 @@
}
}
- if (!priv->initial_index_msg_shown && initial_index) {
- priv->initial_index_msg_shown = TRUE;
+ if (!priv->shown_starting_msg && priv->initial_index) {
+ static gchar *initial_index_1;
+ static gchar *initial_index_2;
+
+ priv->shown_starting_msg = TRUE;
+
g_usleep (G_USEC_PER_SEC / 10);
+
+ initial_index_1 =
+ _("Your computer is about to be indexed so "
+ "you can perform fast searches of your files and emails");
+ initial_index_2 =
+ _("You can pause indexing at any time and "
+ "configure index settings by right clicking here");
tray_icon_show_message (icon,
"%s\n"
"\n"
@@ -1643,19 +1679,7 @@
priv->pause_state = PAUSE_NONE;
priv->auto_pause_setting = AUTO_PAUSE_MERGING;
priv->index_icon = ICON_DEFAULT;
- priv->animated = FALSE;
- priv->animated_timer_active = FALSE;
- priv->user_pause = FALSE;
- priv->auto_pause = FALSE;
- priv->auto_hide = FALSE;
- priv->disabled = FALSE;
priv->show_animation = TRUE;
- priv->auto_pause_timer_active = FALSE;
- priv->is_watching_events = FALSE;
- priv->initial_index_msg_shown = FALSE;
- priv->stat_window_active = FALSE;
- priv->stat_request_pending = FALSE;
- priv->indexer_stopped = FALSE;
set_tracker_icon (priv);
}
@@ -2116,13 +2140,6 @@
gtk_window_set_default_icon_name ("tracker");
g_set_application_name (_("Tracker"));
- initial_index_1 =
- _("Your computer is about to be indexed so "
- "you can perform fast searches of your files and emails");
- initial_index_2 =
- _("You can pause indexing at any time and "
- "configure index settings by right clicking here");
-
stat_info[0].label = _("Files:");
stat_info[1].label = _(" Folders:");
stat_info[2].label = _(" Documents:");
Modified: trunk/src/tracker-indexer/modules/Makefile.am
==============================================================================
--- trunk/src/tracker-indexer/modules/Makefile.am (original)
+++ trunk/src/tracker-indexer/modules/Makefile.am Fri Nov 21 11:02:04 2008
@@ -56,8 +56,11 @@
# Evolution
libtracker_indexer_evolution_la_SOURCES = \
evolution-common.c \
+ evolution-common.h \
evolution-imap.c \
+ evolution-imap.h \
evolution-pop.c \
+ evolution-pop.h \
evolution.c
libtracker_indexer_evolution_la_LDFLAGS = $(module_flags)
Modified: trunk/src/tracker-indexer/modules/applications.c
==============================================================================
--- trunk/src/tracker-indexer/modules/applications.c (original)
+++ trunk/src/tracker-indexer/modules/applications.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,9 +19,14 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <stdlib.h>
+
#include <glib.h>
+
#include <tracker-indexer/tracker-module-file.h>
+
#include <libtracker-data/tracker-data-metadata.h>
#define GROUP_DESKTOP_ENTRY "Desktop Entry"
Modified: trunk/src/tracker-indexer/modules/dummy.c
==============================================================================
--- trunk/src/tracker-indexer/modules/dummy.c (original)
+++ trunk/src/tracker-indexer/modules/dummy.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,7 +19,10 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <libtracker-data/tracker-data-metadata.h>
+
#include <tracker-indexer/tracker-module-file.h>
#include <tracker-indexer/tracker-module-iteratable.h>
Modified: trunk/src/tracker-indexer/modules/evolution-common.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-common.c (original)
+++ trunk/src/tracker-indexer/modules/evolution-common.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,10 +19,14 @@
* Boston, MA 02110-1301, USA.
*/
-#include <sys/types.h>
-#include <fcntl.h>
+#include "config.h"
+
#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
#include <tracker-indexer/tracker-metadata-utils.h>
+
#include "evolution-common.h"
GMimeStream *
Modified: trunk/src/tracker-indexer/modules/evolution-common.h
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-common.h (original)
+++ trunk/src/tracker-indexer/modules/evolution-common.h Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -21,7 +23,9 @@
#define __EVOLUTION_COMMON_H__
#include <glib.h>
+
#include <gmime/gmime.h>
+
#include <libtracker-data/tracker-data-metadata.h>
G_BEGIN_DECLS
@@ -35,7 +39,6 @@
#define METADATA_EMAIL_SENT_TO "Email:SentTo"
#define METADATA_EMAIL_CC "Email:CC"
-
enum EvolutionFlags {
EVOLUTION_MESSAGE_ANSWERED = 1 << 0,
EVOLUTION_MESSAGE_DELETED = 1 << 1,
@@ -51,11 +54,9 @@
GMimeStream * evolution_common_get_stream (const gchar *path,
gint flags,
off_t start);
-
TrackerDataMetadata * evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper);
gchar * evolution_common_get_object_encoding (GMimeObject *object);
-
G_END_DECLS
#endif /* __EVOLUTION_COMMON_H__ */
Modified: trunk/src/tracker-indexer/modules/evolution-imap.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-imap.c (original)
+++ trunk/src/tracker-indexer/modules/evolution-imap.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,11 +19,17 @@
* Boston, MA 02110-1301, USA.
*/
-#include <libtracker-data/tracker-data-metadata.h>
+#include "config.h"
+
+#include <string.h>
+
+#include <gconf/gconf-client.h>
+
+#include <libtracker-data/tracker-data-metadata.h>o
+
#include <tracker-indexer/tracker-module-file.h>
#include <tracker-indexer/tracker-module-iteratable.h>
-#include <gconf/gconf-client.h>
-#include <string.h>
+
#include "evolution-imap.h"
#include "evolution-common.h"
Modified: trunk/src/tracker-indexer/modules/evolution-imap.h
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-imap.h (original)
+++ trunk/src/tracker-indexer/modules/evolution-imap.h Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -20,11 +22,13 @@
#ifndef __TRACKER_EVOLUTION_IMAP_H__
#define __TRACKER_EVOLUTION_IMAP_H__
+#include <stdlib.h>
+#include <fcntl.h>
+
#include <glib.h>
#include <glib/gstdio.h>
+
#include <tracker-indexer/tracker-module-file.h>
-#include <fcntl.h>
-#include <stdlib.h>
G_BEGIN_DECLS
Modified: trunk/src/tracker-indexer/modules/evolution-pop.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-pop.c (original)
+++ trunk/src/tracker-indexer/modules/evolution-pop.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,11 +19,16 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
+#include <string.h>
+#include <fcntl.h>
+
#include <libtracker-data/tracker-data-metadata.h>
+
#include <tracker-indexer/tracker-module-file.h>
#include <tracker-indexer/tracker-module-iteratable.h>
-#include <string.h>
-#include <fcntl.h>
+
#include "evolution-pop.h"
#include "evolution-common.h"
Modified: trunk/src/tracker-indexer/modules/evolution-pop.h
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-pop.h (original)
+++ trunk/src/tracker-indexer/modules/evolution-pop.h Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -21,9 +23,11 @@
#define __TRACKER_EVOLUTION_POP_H__
#include <glib.h>
-#include <tracker-indexer/tracker-module-file.h>
+
#include <gmime/gmime.h>
+#include <tracker-indexer/tracker-module-file.h>
+
G_BEGIN_DECLS
#define TRACKER_TYPE_EVOLUTION_POP_FILE (tracker_evolution_pop_file_get_type())
Modified: trunk/src/tracker-indexer/modules/evolution.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution.c (original)
+++ trunk/src/tracker-indexer/modules/evolution.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,7 +19,10 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <string.h>
+
#include "evolution-pop.h"
#include "evolution-imap.h"
Modified: trunk/src/tracker-indexer/modules/files.c
==============================================================================
--- trunk/src/tracker-indexer/modules/files.c (original)
+++ trunk/src/tracker-indexer/modules/files.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
@@ -27,6 +31,7 @@
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-ontology.h>
+
#include <tracker-indexer/tracker-metadata-utils.h>
#include <tracker-indexer/tracker-module-file.h>
Modified: trunk/src/tracker-indexer/modules/gaim-conversations.c
==============================================================================
--- trunk/src/tracker-indexer/modules/gaim-conversations.c (original)
+++ trunk/src/tracker-indexer/modules/gaim-conversations.c Fri Nov 21 11:02:04 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2008, Nokia
* This library is free software; you can redistribute it and/or
@@ -17,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <glib.h>
G_CONST_RETURN gchar *
Modified: trunk/tests/libtracker-common/tracker-ontology-test.c
==============================================================================
--- trunk/tests/libtracker-common/tracker-ontology-test.c (original)
+++ trunk/tests/libtracker-common/tracker-ontology-test.c Fri Nov 21 11:02:04 2008
@@ -18,6 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
#include <string.h>
#include <glib.h>
@@ -29,9 +31,16 @@
#include <tracker-test-helpers.h>
+typedef struct {
+ TrackerService *service;
+ TrackerService *parent_service;
+} ExpectedResults;
+
+static ExpectedResults *expected_results = NULL;
+
static gboolean
-test_cmp_servicedef_equals (TrackerService *one,
- TrackerService *two)
+test_cmp_service_equals (TrackerService *one,
+ TrackerService *two)
{
if (one && !two) {
return FALSE;
@@ -45,19 +54,20 @@
return TRUE;
}
- return (tracker_service_get_id (one) == tracker_service_get_id (two) &&
+ return
+ tracker_service_get_id (one) == tracker_service_get_id (two) &&
tracker_test_helpers_cmpstr_equal (tracker_service_get_name (one),
tracker_service_get_name (two)) &&
tracker_test_helpers_cmpstr_equal (tracker_service_get_parent (one),
tracker_service_get_parent (two)) &&
tracker_service_get_db_type (one) == tracker_service_get_db_type (two) &&
- tracker_service_get_embedded (one) == tracker_service_get_embedded (two));
+ tracker_service_get_embedded (one) == tracker_service_get_embedded (two);
}
static gboolean
element_in_list (GSList *list, gchar *element)
{
- return (g_slist_find_custom (list, element, (GCompareFunc) strcmp) != NULL);
+ return g_slist_find_custom (list, element, (GCompareFunc) strcmp) != NULL;
}
static GSList *
@@ -102,7 +112,8 @@
const gchar *prefix,
gboolean embedded)
{
- TrackerService *def;
+ TrackerService *service;
+
/* array_to_list use prepend, so use reverse order here */
gchar *key_metadata [] = {
"Key:Metadata2",
@@ -110,45 +121,39 @@
NULL
};
- def = tracker_service_new ();
- tracker_service_set_id (def, id);
- tracker_service_set_name (def, name);
- tracker_service_set_parent (def, parent);
- tracker_service_set_property_prefix (def, prefix);
- tracker_service_set_db_type (def, TRACKER_DB_TYPE_CONTENT);
- tracker_service_set_enabled (def, FALSE);
- tracker_service_set_embedded (def, embedded);
- tracker_service_set_has_thumbs (def, TRUE);
- tracker_service_set_has_full_text (def, TRUE);
- tracker_service_set_has_metadata (def, FALSE);
- tracker_service_set_key_metadata (def, array_to_list (key_metadata));
+ service = tracker_service_new ();
+ tracker_service_set_id (service, id);
+ tracker_service_set_name (service, name);
+ tracker_service_set_parent (service, parent);
+ tracker_service_set_property_prefix (service, prefix);
+ tracker_service_set_db_type (service, TRACKER_DB_TYPE_CONTENT);
+ tracker_service_set_enabled (service, FALSE);
+ tracker_service_set_embedded (service, embedded);
+ tracker_service_set_has_thumbs (service, TRUE);
+ tracker_service_set_has_full_text (service, TRUE);
+ tracker_service_set_has_metadata (service, FALSE);
+ tracker_service_set_key_metadata (service, array_to_list (key_metadata));
- return def;
+ return service;
}
-typedef struct {
- TrackerService *def;
- TrackerService *parent_def;
-} ExpectedResults;
-
-static ExpectedResults *expected_results = NULL;
-
static void
-tracker_services_general_setup ()
+tracker_services_general_setup (void)
{
- TrackerService *def, *parent_def, *other_def;
- TrackerService *conv_def, *gaim_def, *gossip_def, *new_gaim_def;
+ TrackerService *service, *parent_service, *other_service;
+ TrackerService *conv_service, *gaim_service, *gossip_service, *new_gaim_service;
TrackerField *field_title;
-
GSList *mimes, *mime_prefixes;
+ gchar *m[] = {"application/rtf", "text/joke", "test/1", NULL};
+ gchar *mp[] = {"images/", "video/", "other.mimes.", NULL};
- def = create_service_definition (0, "Test service", "Parent service", NULL, TRUE);
- parent_def = create_service_definition (1, "Parent service", NULL, NULL, FALSE);
- other_def = create_service_definition (2, "Applications", NULL, "App", FALSE);
- conv_def = create_service_definition (3, "Conversations", NULL, NULL, FALSE);
- gaim_def = create_service_definition (4, "GaimConversations", "Conversations", NULL, FALSE);
- gossip_def = create_service_definition (5, "GossipConversations", "Conversations", NULL, FALSE);
- new_gaim_def = create_service_definition (6, "NewGaimConversations", "GaimConversations", NULL, FALSE);
+ service = create_service_definition (0, "Test service", "Parent service", NULL, TRUE);
+ parent_service = create_service_definition (1, "Parent service", NULL, NULL, FALSE);
+ other_service = create_service_definition (2, "Applications", NULL, "App", FALSE);
+ conv_service = create_service_definition (3, "Conversations", NULL, NULL, FALSE);
+ gaim_service = create_service_definition (4, "GaimConversations", "Conversations", NULL, FALSE);
+ gossip_service = create_service_definition (5, "GossipConversations", "Conversations", NULL, FALSE);
+ new_gaim_service = create_service_definition (6, "NewGaimConversations", "GaimConversations", NULL, FALSE);
field_title = create_field_definition ("0",
"App.Title",
@@ -157,30 +162,27 @@
TRUE,
NULL);
- char * m[] = {"application/rtf", "text/joke", "test/1", NULL};
mimes = array_to_list (m);
- char *mp[] = {"images/", "video/", "other.mimes.", NULL};
mime_prefixes = array_to_list (mp);
tracker_ontology_init ();
expected_results = g_new0 (ExpectedResults, 1);
- expected_results->def = def;
- expected_results->parent_def = parent_def;
+ expected_results->service = service;
+ expected_results->parent_service = parent_service;
- tracker_ontology_service_add (def, NULL, NULL);
- tracker_ontology_service_add (parent_def, mimes, mime_prefixes);
- tracker_ontology_service_add (other_def, NULL, NULL);
- tracker_ontology_service_add (conv_def, NULL, NULL);
- tracker_ontology_service_add (gaim_def, NULL, NULL);
- tracker_ontology_service_add (gossip_def, NULL, NULL);
- tracker_ontology_service_add (new_gaim_def, NULL, NULL);
+ tracker_ontology_service_add (service, NULL, NULL);
+ tracker_ontology_service_add (parent_service, mimes, mime_prefixes);
+ tracker_ontology_service_add (other_service, NULL, NULL);
+ tracker_ontology_service_add (conv_service, NULL, NULL);
+ tracker_ontology_service_add (gaim_service, NULL, NULL);
+ tracker_ontology_service_add (gossip_service, NULL, NULL);
+ tracker_ontology_service_add (new_gaim_service, NULL, NULL);
tracker_ontology_field_add (field_title);
g_slist_free (mimes);
g_slist_free (mime_prefixes);
-
}
static void
@@ -190,34 +192,35 @@
result_int = tracker_ontology_get_service_id_by_name ("Test service");
g_assert_cmpint (result_int, ==, 0);
+
result_int = tracker_ontology_get_service_id_by_name ("trash");
g_assert_cmpint (result_int, ==, -1);
}
-
static void
test_get_service_by_id (void)
{
- gchar *result_string;
+ const gchar *result_string;
result_string = tracker_ontology_get_service_by_id (0);
- g_assert ( g_str_equal (result_string, "Test service"));
- g_free (result_string);
+ g_assert (g_str_equal (result_string, "Test service"));
+
result_string = tracker_ontology_get_service_by_id (20);
g_assert (!result_string);
}
-
static void
test_get_parent_service_by_id (void)
{
gchar *result_string;
result_string = tracker_ontology_get_service_parent_by_id (0);
- g_assert ( g_str_equal (result_string, "Parent service"));
+ g_assert (g_str_equal (result_string, "Parent service"));
g_free (result_string);
+
result_string = tracker_ontology_get_service_parent_by_id (1);
g_assert (!result_string);
+ g_free (result_string);
}
static void
@@ -227,6 +230,7 @@
result_int = tracker_ontology_get_service_parent_id_by_id (0);
g_assert_cmpint (result_int, ==, 1);
+
result_int = tracker_ontology_get_service_parent_id_by_id (1);
g_assert_cmpint (result_int, ==, -1);
}
@@ -239,39 +243,40 @@
result_string = tracker_ontology_get_service_parent ("Test service");
g_assert (g_str_equal (result_string, "Parent service"));
g_free (result_string);
+
result_string = tracker_ontology_get_service_parent ("Parent service");
g_assert (!result_string);
+ g_free (result_string);
}
static void
test_get_service_type_for_mime (void)
{
- gchar *value;
+ const gchar *value;
value = tracker_ontology_get_service_by_mime ("application/rtf");
- g_assert ( g_str_equal ("Parent service", value));
- g_free (value);
+ g_assert (g_str_equal ("Parent service", value));
value = tracker_ontology_get_service_by_mime ("images/jpeg");
- g_assert ( g_str_equal ("Parent service", value));
- g_free (value);
+ g_assert (g_str_equal ("Parent service", value));
value = tracker_ontology_get_service_by_mime ("noexists/bla");
- g_assert ( g_str_equal ("Other", value));
- g_free (value);
+ g_assert (g_str_equal ("Other", value));
}
static void
test_get_service (void)
{
- TrackerService *result_def;
+ TrackerService *service;
+
+ service = tracker_ontology_get_service_by_name ("Test service");
+ g_assert (test_cmp_service_equals (service, expected_results->service));
- result_def = tracker_ontology_get_service_by_name ("Test service");
- g_assert (test_cmp_servicedef_equals (result_def, expected_results->def));
- result_def = tracker_ontology_get_service_by_name ("No no no");
- g_assert (!test_cmp_servicedef_equals (result_def, expected_results->def));
- result_def = tracker_ontology_get_service_by_name ("Parent service");
- g_assert (test_cmp_servicedef_equals (result_def, expected_results->parent_def));
+ service = tracker_ontology_get_service_by_name ("No no no");
+ g_assert (!test_cmp_service_equals (service, expected_results->service));
+
+ service = tracker_ontology_get_service_by_name ("Parent service");
+ g_assert (test_cmp_service_equals (service, expected_results->parent_service));
}
static void
@@ -281,6 +286,7 @@
result_db = tracker_ontology_get_service_db_by_name ("Test service");
g_assert (result_db == TRACKER_DB_TYPE_FILES); // ????? HARDCODED IN tracker-ontology!!!!!
+
result_db = tracker_ontology_get_service_db_by_name ("trash");
g_assert (result_db == TRACKER_DB_TYPE_FILES);
}
@@ -327,12 +333,10 @@
static void
test_get_registered_service_types (void)
{
- GSList *service_types = NULL;
+ GSList *service_types;
service_types = tracker_ontology_get_service_names_registered ();
-
g_assert_cmpint (7, ==, g_slist_length (service_types));
-
g_assert (element_in_list (service_types, "Applications"));
g_slist_foreach (service_types, (GFunc)g_free, NULL);
@@ -342,7 +346,7 @@
static void
test_get_registered_field_types (void)
{
- GSList *field_types = NULL;
+ GSList *field_types;
/* All registered field types */
field_types = tracker_ontology_get_field_names_registered (NULL);
@@ -356,14 +360,11 @@
/* Music field types */
field_types = tracker_ontology_get_field_names_registered ("Music");
-
g_assert (!field_types);
/* App field types */
field_types = tracker_ontology_get_field_names_registered ("Applications");
-
g_assert_cmpint (1 ,==, g_slist_length (field_types));
-
g_assert (element_in_list (field_types, "App.Title"));
g_slist_foreach (field_types, (GFunc)g_free, NULL);
@@ -390,28 +391,22 @@
GArray *result;
result = tracker_ontology_get_subcategory_ids ("Applications");
-
+ g_assert (result != NULL);
g_assert_cmpint (result->len, ==, 1);
result = tracker_ontology_get_subcategory_ids ("Conversations");
-/*
- Conversations, GaimConversations, GossipConversations
- FIXME implement more than one level of hierarchy!
-*/
+ g_assert (result != NULL);
g_assert_cmpint (result->len, ==, 3);
-
result = tracker_ontology_get_subcategory_ids ("*");
-
+ g_assert (result != NULL);
g_assert_cmpint (result->len, ==, 7);
-
- g_array_free (result, TRUE);
}
int
main (int argc, char **argv)
{
- int result;
+ gint result;
g_type_init ();
g_test_init (&argc, &argv, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]