tracker r2617 - in trunk: . src/tracker-indexer/modules tests/libtracker-common
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2617 - in trunk: . src/tracker-indexer/modules tests/libtracker-common
- Date: Mon, 1 Dec 2008 10:24:37 +0000 (UTC)
Author: mr
Date: Mon Dec 1 10:24:37 2008
New Revision: 2617
URL: http://svn.gnome.org/viewvc/tracker?rev=2617&view=rev
Log:
* src/tracker-indexer/modules/dummy.c: Small code clean up.
* src/tracker-indexer/modules/gaim-conversations.c: Used the
dummy.c for this module. The indexer logging was complaining about
some modular functions not existing.
* tests/libtracker-common/tracker-dbus-test.c:
* tests/libtracker-common/tracker-type-utils-test.c: Small code
clean ups.
Modified:
trunk/ChangeLog
trunk/src/tracker-indexer/modules/dummy.c
trunk/src/tracker-indexer/modules/gaim-conversations.c
trunk/tests/libtracker-common/tracker-dbus-test.c
trunk/tests/libtracker-common/tracker-type-utils-test.c
Modified: trunk/src/tracker-indexer/modules/dummy.c
==============================================================================
--- trunk/src/tracker-indexer/modules/dummy.c (original)
+++ trunk/src/tracker-indexer/modules/dummy.c Mon Dec 1 10:24:37 2008
@@ -29,13 +29,17 @@
#define DUMMY_TYPE_FILE (dummy_file_get_type ())
#define DUMMY_FILE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), DUMMY_TYPE_FILE, DummyFile))
-#define MODULE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
-{ \
- const GInterfaceInfo g_implement_interface_info = { \
- (GInterfaceInitFunc) iface_init, NULL, NULL \
- }; \
- g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
-}
+#define MODULE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
+ { \
+ const GInterfaceInfo g_implement_interface_info = { \
+ (GInterfaceInitFunc) iface_init, NULL, NULL \
+ }; \
+ \
+ g_type_module_add_interface (type_module, \
+ g_define_type_id, \
+ TYPE_IFACE, \
+ &g_implement_interface_info); \
+ }
typedef struct DummyFile DummyFile;
typedef struct DummyFileClass DummyFileClass;
@@ -48,7 +52,6 @@
TrackerModuleFileClass parent_class;
};
-
static void dummy_file_iteratable_init (TrackerModuleIteratableIface *iface);
static void dummy_file_finalize (GObject *object);
@@ -84,9 +87,13 @@
}
static void
-dummy_file_init (DummyFile *file)
+dummy_file_class_finalize (DummyFileClass *klass)
{
+}
+static void
+dummy_file_init (DummyFile *file)
+{
}
static void
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 Mon Dec 1 10:24:37 2008
@@ -21,11 +21,191 @@
#include "config.h"
-#include <glib.h>
+#include <libtracker-data/tracker-data-metadata.h>
-G_CONST_RETURN gchar *
-tracker_module_get_name (void)
+#include <tracker-indexer/tracker-module-file.h>
+#include <tracker-indexer/tracker-module-iteratable.h>
+
+#define GAIM_TYPE_FILE (gaim_file_get_type ())
+#define GAIM_FILE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), GAIM_TYPE_FILE, GaimFile))
+
+#define MODULE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
+ { \
+ const GInterfaceInfo g_implement_interface_info = { \
+ (GInterfaceInitFunc) iface_init, NULL, NULL \
+ }; \
+ \
+ g_type_module_add_interface (type_module, \
+ g_define_type_id, \
+ TYPE_IFACE, \
+ &g_implement_interface_info); \
+ }
+
+typedef struct GaimFile GaimFile;
+typedef struct GaimFileClass GaimFileClass;
+
+struct GaimFile {
+ TrackerModuleFile parent_instance;
+};
+
+struct GaimFileClass {
+ TrackerModuleFileClass parent_class;
+};
+
+
+static void gaim_file_iteratable_init (TrackerModuleIteratableIface *iface);
+
+static void gaim_file_finalize (GObject *object);
+
+static void gaim_file_initialize (TrackerModuleFile *file);
+static const gchar * gaim_file_get_service_type (TrackerModuleFile *file);
+static gchar * gaim_file_get_uri (TrackerModuleFile *file);
+static gchar * gaim_file_get_text (TrackerModuleFile *file);
+static TrackerDataMetadata *
+ gaim_file_get_metadata (TrackerModuleFile *file);
+
+static gboolean gaim_file_iter_contents (TrackerModuleIteratable *iteratable);
+static guint gaim_file_get_count (TrackerModuleIteratable *iteratable);
+
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GaimFile, gaim_file, TRACKER_TYPE_MODULE_FILE, 0,
+ MODULE_IMPLEMENT_INTERFACE (TRACKER_TYPE_MODULE_ITERATABLE,
+ gaim_file_iteratable_init))
+
+static void
+gaim_file_class_init (GaimFileClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ TrackerModuleFileClass *file_class = TRACKER_MODULE_FILE_CLASS (klass);
+
+ object_class->finalize = gaim_file_finalize;
+
+ file_class->initialize = gaim_file_initialize;
+ file_class->get_service_type = gaim_file_get_service_type;
+ file_class->get_uri = gaim_file_get_uri;
+ file_class->get_text = gaim_file_get_text;
+ file_class->get_metadata = gaim_file_get_metadata;
+}
+
+static void
+gaim_file_class_finalize (GaimFileClass *klass)
+{
+}
+
+static void
+gaim_file_init (GaimFile *file)
+{
+}
+
+static void
+gaim_file_iteratable_init (TrackerModuleIteratableIface *iface)
+{
+ iface->iter_contents = gaim_file_iter_contents;
+ iface->get_count = gaim_file_get_count;
+}
+
+static void
+gaim_file_finalize (GObject *object)
+{
+ /* Free here all resources allocated by the object, if any */
+
+ /* Chain up to parent implementation */
+ G_OBJECT_CLASS (gaim_file_parent_class)->finalize (object);
+}
+
+static void
+gaim_file_initialize (TrackerModuleFile *file)
+{
+ /* Allocate here all resources for the file, if any */
+}
+
+static const gchar *
+gaim_file_get_service_type (TrackerModuleFile *file)
+{
+ /* Implementing this function is optional.
+ *
+ * Return the service type for the given file.
+ *
+ * If this function is not implemented, the indexer will use
+ * whatever service name is specified in the module configuration
+ * file.
+ */
+ return NULL;
+}
+
+static gchar *
+gaim_file_get_uri (TrackerModuleFile *file)
+{
+ /* Implementing this function is optional
+ *
+ * Return URI for the current item, with this method
+ * modules can specify different URIs for different
+ * elements contained in the file. See also
+ * TrackerModuleIteratable.
+ */
+ return NULL;
+}
+
+static gchar *
+gaim_file_get_text (TrackerModuleFile *file)
+{
+ /* Implementing this function is optional
+ *
+ * Return here full text for file, given the current state,
+ * see also TrackerModuleIteratable.
+ */
+ return NULL;
+}
+
+static TrackerDataMetadata *
+gaim_file_get_metadata (TrackerModuleFile *file)
+{
+ /* Return a TrackerDataMetadata filled with metadata for file,
+ * given the current state. Also see TrackerModuleIteratable.
+ */
+ return NULL;
+}
+
+static gboolean
+gaim_file_iter_contents (TrackerModuleIteratable *iteratable)
+{
+ /* This function is meant to iterate the internal state,
+ * so it points to the next entity inside the file.
+ * In case there is such next entity, this function must
+ * return TRUE, else, returning FALSE will make the indexer
+ * think it is done with this file and move on to the next one.
+ *
+ * What an "entity" is considered is left to the module
+ * implementation.
+ */
+ return FALSE;
+}
+
+static guint
+gaim_file_get_count (TrackerModuleIteratable *iteratable)
+{
+ /* This function is meant to return the number of entities
+ * contained in the file, what an "entity" is considered is
+ * left to the module implementation.
+ */
+ return 0;
+}
+
+void
+indexer_module_initialize (GTypeModule *module)
+{
+ gaim_file_register_type (module);
+}
+
+void
+indexer_module_shutdown (void)
+{
+}
+
+TrackerModuleFile *
+indexer_module_create_file (GFile *file)
{
- /* Return module name here */
- return "GaimConversations";
+ return g_object_new (GAIM_TYPE_FILE,
+ "file", file,
+ NULL);
}
Modified: trunk/tests/libtracker-common/tracker-dbus-test.c
==============================================================================
--- trunk/tests/libtracker-common/tracker-dbus-test.c (original)
+++ trunk/tests/libtracker-common/tracker-dbus-test.c Mon Dec 1 10:24:37 2008
@@ -19,9 +19,10 @@
*/
#include <glib.h>
#include <glib/gtestutils.h>
+
#include <libtracker-common/tracker-dbus.h>
-#include <tracker-test-helpers.h>
+#include <tracker-test-helpers.h>
static void
slist_to_strv (gboolean utf8)
@@ -44,7 +45,7 @@
g_assert_cmpint (g_strv_length (input_as_strv), ==, (utf8 ? strings : 0));
- g_slist_foreach (input, (GFunc)g_free, NULL);
+ g_slist_foreach (input, (GFunc) g_free, NULL);
g_slist_free (input);
g_strfreev (input_as_strv);
@@ -85,13 +86,11 @@
g_assert_cmpint (g_strv_length (queue_as_strv), ==, (utf8 ? strings : 0));
- // Queue empty by tracker_dbus_async_queue_to_strv
+ /* Queue empty by tracker_dbus_async_queue_to_strv */
g_queue_free (queue);
g_strfreev (queue_as_strv);
-
}
-
static void
test_async_queue_to_strv (void)
{
@@ -160,13 +159,14 @@
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
tracker_dbus_request_failed (1, &error, NULL);
}
+
g_test_trap_assert_stderr ("*Unset error and no error message*");
}
int
main (int argc, char **argv) {
- int result;
+ gint result;
g_type_init ();
g_thread_init (NULL);
Modified: trunk/tests/libtracker-common/tracker-type-utils-test.c
==============================================================================
--- trunk/tests/libtracker-common/tracker-type-utils-test.c (original)
+++ trunk/tests/libtracker-common/tracker-type-utils-test.c Mon Dec 1 10:24:37 2008
@@ -30,14 +30,13 @@
#include <tracker-test-helpers.h>
static void
-test_date_format ()
+test_date_format (void)
{
gchar *result;
result = tracker_date_format ("");
g_assert (result == NULL);
-
/* Fails
result = tracker_date_format ("1978"); //Audio.ReleaseDate
g_assert (tracker_test_helpers_cmpstr_equal (result, "1978-01-01T00:00:00"));
@@ -55,23 +54,23 @@
g_assert (tracker_test_helpers_cmpstr_equal (result, "2008-06-14T00:00:00Z"));
g_free (result);
- result = tracker_date_format ("Mon Jun 14 04:20:20 2008"); //MS Office
+ result = tracker_date_format ("Mon Jun 14 04:20:20 2008"); /* MS Office */
g_assert (tracker_test_helpers_cmpstr_equal (result, "2008-06-14T04:20:20"));
g_free (result);
- result = tracker_date_format ("2008:06:14 04:20:20"); //Exif style
+ result = tracker_date_format ("2008:06:14 04:20:20"); /* Exif style */
g_assert (tracker_test_helpers_cmpstr_equal (result, "2008-06-14T04:20:20"));
g_free (result);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
result = tracker_date_format (NULL);
}
- g_test_trap_assert_failed ();
+ g_test_trap_assert_failed ();
}
static void
-test_string_to_date ()
+test_string_to_date (void)
{
GDate *expected;
GDate *result;
@@ -107,7 +106,7 @@
}
static void
-test_date_to_string ()
+test_date_to_string (void)
{
struct tm *original;
time_t input;
@@ -129,9 +128,8 @@
g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10", 19) == 0);
}
-
static void
-test_long_to_string ()
+test_long_to_string (void)
{
glong n;
gchar *result;
@@ -148,7 +146,7 @@
}
static void
-test_int_to_string ()
+test_int_to_string (void)
{
gint n;
gchar *result;
@@ -165,9 +163,8 @@
}
-
static void
-test_uint_to_string ()
+test_uint_to_string (void)
{
guint n;
gchar *result;
@@ -179,7 +176,7 @@
}
static void
-test_gint32_to_string ()
+test_gint32_to_string (void)
{
gint32 n;
gchar *result;
@@ -196,9 +193,8 @@
}
-
static void
-test_guint32_to_string ()
+test_guint32_to_string (void)
{
guint32 n;
gchar *result;
@@ -210,9 +206,8 @@
}
-
static void
-test_string_to_uint ()
+test_string_to_uint (void)
{
guint num_result, rc;
@@ -227,9 +222,8 @@
}
g_test_trap_assert_failed ();
- // ???? FIXME
+ /* ???? FIXME */
rc = tracker_string_to_uint ("-20", &num_result);
- // ????
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
tracker_string_to_uint (NULL, &num_result);
@@ -246,9 +240,8 @@
g_assert_cmpint (rc, ==, 0);
}
-
static void
-test_string_in_string_list ()
+test_string_in_string_list (void)
{
gchar *complete = "This is an extract of text with different terms an props like Audio:Title ...";
gchar **pieces;
@@ -270,7 +263,7 @@
}
static void
-test_gslist_to_string_list ()
+test_gslist_to_string_list (void)
{
GSList *input = NULL;
gchar **result;
@@ -282,22 +275,22 @@
result = tracker_gslist_to_string_list (input);
- g_assert (tracker_test_helpers_cmpstr_equal (result[0], "one")
- && tracker_test_helpers_cmpstr_equal (result[1], "two")
- && tracker_test_helpers_cmpstr_equal (result[2], "three")
- && tracker_test_helpers_cmpstr_equal (result[3], "four"));
+ g_assert (tracker_test_helpers_cmpstr_equal (result[0], "one") &&
+ tracker_test_helpers_cmpstr_equal (result[1], "two") &&
+ tracker_test_helpers_cmpstr_equal (result[2], "three") &&
+ tracker_test_helpers_cmpstr_equal (result[3], "four"));
g_strfreev (result);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
result = tracker_gslist_to_string_list (NULL);
}
+
g_test_trap_assert_failed ();
}
-
static void
-test_string_list_to_string ()
+test_string_list_to_string (void)
{
gchar *input = "one two three four";
gchar **pieces;
@@ -330,9 +323,8 @@
g_strfreev (pieces);
}
-
static void
-test_boolean_as_text_to_number ()
+test_boolean_as_text_to_number (void)
{
gchar *result;
@@ -383,11 +375,10 @@
g_test_trap_assert_failed ();
}
-
int
-main (int argc, char **argv) {
-
- int result;
+main (int argc, char **argv)
+{
+ 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]