tracker r2829 - in trunk: . data/modules data/services src/tracker-indexer/modules
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2829 - in trunk: . data/modules data/services src/tracker-indexer/modules
- Date: Fri, 23 Jan 2009 13:43:42 +0000 (UTC)
Author: carlosg
Date: Fri Jan 23 13:43:41 2009
New Revision: 2829
URL: http://svn.gnome.org/viewvc/tracker?rev=2829&view=rev
Log:
2009-01-23 Carlos Garnacho <carlos imendio com>
Actually implement Gaim/Pidgin logs indexing.
* data/services/conversation.metadata: Add basic metadata definitions
for IM conversations.
* data/services/Makefile.am: Install that file.
* data/modules/gaim-conversation.module: Specify service type, and set
10 min timeout so the log isn't reindexed after each sent/received
phrase.
* src/tracker-indexer/modules/gaim-conversations.c: Extract
metadata/text from Gaim/Pidgin logs.
Added:
trunk/data/services/conversation.metadata
Modified:
trunk/ChangeLog
trunk/data/modules/gaim-conversations.module
trunk/data/services/Makefile.am
trunk/src/tracker-indexer/modules/gaim-conversations.c
Modified: trunk/data/modules/gaim-conversations.module
==============================================================================
--- trunk/data/modules/gaim-conversations.module (original)
+++ trunk/data/modules/gaim-conversations.module Fri Jan 23 13:43:41 2009
@@ -11,10 +11,10 @@
Files=
[Index]
-Service=Files
+Service=GaimConversations
MimeTypes=
Files=
-ScanTimeout=0
+ScanTimeout=6000
[Specific]
# Options specific to this module
Modified: trunk/data/services/Makefile.am
==============================================================================
--- trunk/data/services/Makefile.am (original)
+++ trunk/data/services/Makefile.am Fri Jan 23 13:43:41 2009
@@ -5,6 +5,7 @@
config_DATA = \
application.metadata \
audio.metadata \
+ conversation.metadata \
default.metadata \
default.service \
document.metadata \
Added: trunk/data/services/conversation.metadata
==============================================================================
--- (empty file)
+++ trunk/data/services/conversation.metadata Fri Jan 23 13:43:41 2009
@@ -0,0 +1,48 @@
+[Conversation:Account]
+Abstract=true
+DisplayName=Account
+Description=IM account
+DataType=index
+
+[Conversation:UserAccount]
+DisplayName=User account
+Description=User account
+DataType=index
+FieldName=UserAccount
+Parent=Conversation:Account
+Weight=10
+
+[Conversation:PeerAccount]
+DisplayName=Peer account
+Description=Peer account
+DataType=index
+FieldName=PeerAccount
+Parent=Conversation:Account
+Weight=20
+
+[Conversation:ChatRoom]
+DisplayName=Chat room
+Description=Chat room
+DataType=index
+FieldName=ChatRoom
+Weight=20
+
+[Conversation:Protocol]
+DisplayName=Protocol
+Description=Protocol used in the conversation
+DataType=index
+FieldName=Protocol
+Weight=1
+
+[Conversation:Date]
+DisplayName=Date
+Description=Date conversation was held
+DataType=date
+Parent=DC:Date
+Weight=1
+
+[Conversation:Text]
+DisplayName=Text
+Description=Conversation
+DataType=fulltext
+Weight=1
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 Jan 23 13:43:41 2009
@@ -22,6 +22,14 @@
#include "config.h"
#include <tracker-indexer/tracker-module.h>
+#include <time.h>
+
+#define METADATA_CONVERSATION_USER_ACCOUNT "Conversation:UserAccount"
+#define METADATA_CONVERSATION_PEER_ACCOUNT "Conversation:PeerAccount"
+#define METADATA_CONVERSATION_CHAT_ROOM "Conversation:ChatRoom"
+#define METADATA_CONVERSATION_PROTOCOL "Conversation:Protocol"
+#define METADATA_CONVERSATION_DATE "Conversation:Date"
+#define METADATA_CONVERSATION_TEXT "Conversation:Text"
#define GAIM_TYPE_FILE (gaim_file_get_type ())
#define GAIM_FILE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), GAIM_TYPE_FILE, GaimFile))
@@ -52,36 +60,18 @@
static GType gaim_file_get_type (void) G_GNUC_CONST;
-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 TrackerModuleMetadata *
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))
+G_DEFINE_DYNAMIC_TYPE (GaimFile, gaim_file, TRACKER_TYPE_MODULE_FILE)
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;
}
@@ -96,98 +86,49 @@
{
}
-static void
-gaim_file_iteratable_init (TrackerModuleIteratableIface *iface)
+static gchar *
+gaim_file_get_text (TrackerModuleFile *file)
{
- iface->iter_contents = gaim_file_iter_contents;
- iface->get_count = gaim_file_get_count;
+ return tracker_module_metadata_utils_get_text (tracker_module_file_get_file (file));
}
-static void
-gaim_file_finalize (GObject *object)
+static TrackerModuleMetadata *
+gaim_file_get_metadata (TrackerModuleFile *file)
{
- /* Free here all resources allocated by the object, if any */
+ TrackerModuleMetadata *metadata;
+ GFile *f;
+ gchar *path;
+ gchar **path_decomposed;
+ guint len;
+ struct tm tm;
+
+ f = tracker_module_file_get_file (file);
+ path = g_file_get_path (f);
+
+ if (!g_str_has_suffix (path, ".txt") &&
+ !g_str_has_suffix (path, ".html")) {
+ /* Not a log file */
+ g_free (path);
+ return NULL;
+ }
- /* Chain up to parent implementation */
- G_OBJECT_CLASS (gaim_file_parent_class)->finalize (object);
-}
+ path_decomposed = g_strsplit (path, G_DIR_SEPARATOR_S, -1);
+ len = g_strv_length (path_decomposed);
-static void
-gaim_file_initialize (TrackerModuleFile *file)
-{
- /* Allocate here all resources for the file, if any */
-}
+ metadata = tracker_module_metadata_new ();
-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;
-}
+ tracker_module_metadata_add_string (metadata, METADATA_CONVERSATION_USER_ACCOUNT, path_decomposed [len - 3]);
+ tracker_module_metadata_add_string (metadata, METADATA_CONVERSATION_PEER_ACCOUNT, path_decomposed [len - 2]);
+ tracker_module_metadata_add_string (metadata, METADATA_CONVERSATION_PROTOCOL, path_decomposed [len - 4]);
-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;
-}
+ if (strptime (path_decomposed [len - 1], "%Y-%m-%d.%H%M%S%z", &tm) != NULL) {
+ tracker_module_metadata_add_date (metadata, METADATA_CONVERSATION_DATE, mktime (&tm));
+ }
-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;
-}
+ g_strfreev (path_decomposed);
+ g_free (path);
-static TrackerModuleMetadata *
-gaim_file_get_metadata (TrackerModuleFile *file)
-{
- /* Return a TrackerModuleMetadata 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;
+ return metadata;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]