diff options
author | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2009-12-04 12:23:15 -0200 |
---|---|---|
committer | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2009-12-04 12:23:15 -0200 |
commit | 295573e92177b1c5077359e000c8dae3718e8e51 (patch) | |
tree | b400f75e6932742956a565d5054f1fc95d5b9fab /src | |
parent | 23a56c112f55c59a7714cc63f2043b43ebbbc22f (diff) | |
download | telepathy-logger-295573e92177b1c5077359e000c8dae3718e8e51.tar.gz |
Empathy's adapted log store can compile
* error free compilation of the empathy logstore
* changed the namspace for the empathy logstore from Empathy to Tpl
* added some function to TplLogEntryText and TplContact to be able
to recall EmpathyContact EmpathyMessage
* empathy's logstore is still not used
* moved headers file in ROOT/include
Diffstat (limited to 'src')
-rwxr-xr-x | src/compile.sh | 5 | ||||
-rw-r--r-- | src/logstore/empathy-log-manager.c | 14 | ||||
-rw-r--r-- | src/logstore/empathy-log-manager.h | 103 | ||||
-rw-r--r-- | src/logstore/empathy-log-store-empathy.h | 66 | ||||
-rw-r--r-- | src/logstore/empathy-log-store.h | 101 | ||||
-rw-r--r-- | src/logstore/tpl-log-store-empathy.c (renamed from src/logstore/empathy-log-store-empathy.c) | 92 | ||||
-rw-r--r-- | src/logstore/tpl-log-store.c (renamed from src/logstore/empathy-log-store.c) | 72 | ||||
-rw-r--r-- | src/tpl_channel_data.h | 75 | ||||
-rw-r--r-- | src/tpl_contact.c | 4 | ||||
-rw-r--r-- | src/tpl_contact.h | 57 | ||||
-rw-r--r-- | src/tpl_headless_logger_init.c | 6 | ||||
-rw-r--r-- | src/tpl_log_entry_text.c | 86 | ||||
-rw-r--r-- | src/tpl_log_entry_text.h | 73 | ||||
-rw-r--r-- | src/tpl_observer.h | 46 | ||||
-rw-r--r-- | src/tpl_text_channel_data.c | 44 | ||||
-rw-r--r-- | src/tpl_text_channel_data.h | 55 | ||||
-rw-r--r-- | src/tpl_utils.h | 9 |
17 files changed, 202 insertions, 706 deletions
diff --git a/src/compile.sh b/src/compile.sh index 70c770c..57d54fb 100755 --- a/src/compile.sh +++ b/src/compile.sh @@ -2,12 +2,15 @@ PACKAGE_NAME="TpHeadlessLogger" CC=${CC:-gcc} -CCOPTS="-DPACKAGE_NAME=${PACKAGE_NAME} --std=c99 -g -I. -I/usr/include/libempaty -Wall -Werror" # -pedantic" +CCOPTS="-DPACKAGE_NAME=\"${PACKAGE_NAME}\" --std=c99 -g -I/usr/include/libempathy -I../include -Wall -Werror" # -pedantic" PKGS="telepathy-glib libempathy" MODULES="tpl_observer.c tpl_headless_logger_init.c tpl_channel_data.c tpl_text_channel_data.c tpl_contact.c tpl_utils.c + logstore/tpl-log-store.c + logstore/tpl-log-store-empathy.c + tpl_log_entry_text.c test.c" EXECUTABLE="test" diff --git a/src/logstore/empathy-log-manager.c b/src/logstore/empathy-log-manager.c index 5a57f0c..07ea521 100644 --- a/src/logstore/empathy-log-manager.c +++ b/src/logstore/empathy-log-manager.c @@ -21,7 +21,7 @@ * Authors: Xavier Claessens <xclaesse@gmail.com> */ -#include <config.h> +//#include <config.h> #include <string.h> #include <stdio.h> @@ -31,14 +31,14 @@ #include <telepathy-glib/util.h> #include <telepathy-glib/interfaces.h> -#include "empathy-log-manager.h" -#include "empathy-log-store-empathy.h" -#include "empathy-log-store.h" -#include "empathy-tp-chat.h" -#include "empathy-utils.h" +#include <tpl-log-manager.h> +#include <tpl-log-store-empathy.h> +#include <tpl-log-store.h> +#include <empathy-tp-chat.h> +#include <empathy-utils.h> #define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include "empathy-debug.h" +#include <empathy-debug.h> #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLogManager) typedef struct diff --git a/src/logstore/empathy-log-manager.h b/src/logstore/empathy-log-manager.h deleted file mode 100644 index 25f1b5f..0000000 --- a/src/logstore/empathy-log-manager.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_LOG_MANAGER_H__ -#define __EMPATHY_LOG_MANAGER_H__ - -#include <glib-object.h> - -#include "empathy-message.h" -#include "empathy-dispatcher.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_LOG_MANAGER (empathy_log_manager_get_type ()) -#define EMPATHY_LOG_MANAGER(o) \ - (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_LOG_MANAGER, \ - EmpathyLogManager)) -#define EMPATHY_LOG_MANAGER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_LOG_MANAGER, \ - EmpathyLogManagerClass)) -#define EMPATHY_IS_LOG_MANAGER(o) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_LOG_MANAGER)) -#define EMPATHY_IS_LOG_MANAGER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_LOG_MANAGER)) -#define EMPATHY_LOG_MANAGER_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_LOG_MANAGER, \ - EmpathyLogManagerClass)) - -typedef struct _EmpathyLogManager EmpathyLogManager; -typedef struct _EmpathyLogManagerClass EmpathyLogManagerClass; -typedef struct _EmpathyLogSearchHit EmpathyLogSearchHit; - -struct _EmpathyLogManager -{ - GObject parent; - gpointer priv; -}; - -struct _EmpathyLogManagerClass -{ - GObjectClass parent_class; -}; - -struct _EmpathyLogSearchHit -{ - TpAccount *account; - gchar *chat_id; - gboolean is_chatroom; - gchar *filename; - gchar *date; -}; - -typedef gboolean (*EmpathyLogMessageFilter) (EmpathyMessage *message, - gpointer user_data); - -GType empathy_log_manager_get_type (void) G_GNUC_CONST; -EmpathyLogManager *empathy_log_manager_dup_singleton (void); -gboolean empathy_log_manager_add_message (EmpathyLogManager *manager, - const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, - GError **error); -gboolean empathy_log_manager_exists (EmpathyLogManager *manager, - TpAccount *account, const gchar *chat_id, gboolean chatroom); -GList *empathy_log_manager_get_dates (EmpathyLogManager *manager, - TpAccount *account, const gchar *chat_id, gboolean chatroom); -GList *empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager, - TpAccount *account, const gchar *chat_id, gboolean chatroom, - const gchar *date); -GList *empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager, - TpAccount *account, const gchar *chat_id, gboolean chatroom, - guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data); -GList *empathy_log_manager_get_chats (EmpathyLogManager *manager, - TpAccount *account); -GList *empathy_log_manager_search_new (EmpathyLogManager *manager, - const gchar *text); -void empathy_log_manager_search_free (GList *hits); -gchar *empathy_log_manager_get_date_readable (const gchar *date); -void empathy_log_manager_search_hit_free (EmpathyLogSearchHit *hit); -void empathy_log_manager_observe (EmpathyLogManager *log_manager, - EmpathyDispatcher *dispatcher); - -G_END_DECLS - -#endif /* __EMPATHY_LOG_MANAGER_H__ */ diff --git a/src/logstore/empathy-log-store-empathy.h b/src/logstore/empathy-log-store-empathy.h deleted file mode 100644 index e77076a..0000000 --- a/src/logstore/empathy-log-store-empathy.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#ifndef __EMPATHY_LOG_STORE_EMPATHY_H__ -#define __EMPATHY_LOG_STORE_EMPATHY_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_LOG_STORE_EMPATHY \ - (empathy_log_store_empathy_get_type ()) -#define EMPATHY_LOG_STORE_EMPATHY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_LOG_STORE_EMPATHY, \ - EmpathyLogStoreEmpathy)) -#define EMPATHY_LOG_STORE_EMPATHY_CLASS(vtable) \ - (G_TYPE_CHECK_CLASS_CAST ((vtable), EMPATHY_TYPE_LOG_STORE_EMPATHY, \ - EmpathyLogStoreEmpathyClass)) -#define EMPATHY_IS_LOG_STORE_EMPATHY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_LOG_STORE_EMPATHY)) -#define EMPATHY_IS_LOG_STORE_EMPATHY_CLASS(vtable) \ - (G_TYPE_CHECK_CLASS_TYPE ((vtable), EMPATHY_TYPE_LOG_STORE_EMPATHY)) -#define EMPATHY_LOG_STORE_EMPATHY_GET_CLASS(inst) \ - (G_TYPE_INSTANCE_GET_CLASS ((inst), EMPATHY_TYPE_LOG_STORE_EMPATHY, \ - EmpathyLogStoreEmpathyClass)) - -typedef struct _EmpathyLogStoreEmpathy EmpathyLogStoreEmpathy; -typedef struct _EmpathyLogStoreEmpathyClass EmpathyLogStoreEmpathyClass; - -struct _EmpathyLogStoreEmpathy -{ - GObject parent; - gpointer priv; -}; - -struct _EmpathyLogStoreEmpathyClass -{ - GObjectClass parent; -}; - -GType empathy_log_store_empathy_get_type (void); - -G_END_DECLS - -#endif /* __EMPATHY_LOG_STORE_EMPATHY_H__ */ diff --git a/src/logstore/empathy-log-store.h b/src/logstore/empathy-log-store.h deleted file mode 100644 index 94bc873..0000000 --- a/src/logstore/empathy-log-store.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2008 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#ifndef __EMPATHY_LOG_STORE_H__ -#define __EMPATHY_LOG_STORE_H__ - -#include <glib-object.h> - -#include <telepathy-glib/account.h> - -#include "empathy-message.h" -#include "empathy-log-manager.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_LOG_STORE (empathy_log_store_get_type ()) -#define EMPATHY_LOG_STORE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_LOG_STORE, \ - EmpathyLogStore)) -#define EMPATHY_IS_LOG_STORE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_LOG_STORE)) -#define EMPATHY_LOG_STORE_GET_INTERFACE(inst) \ - (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EMPATHY_TYPE_LOG_STORE, \ - EmpathyLogStoreInterface)) - -typedef struct _EmpathyLogStore EmpathyLogStore; /* dummy object */ -typedef struct _EmpathyLogStoreInterface EmpathyLogStoreInterface; - -struct _EmpathyLogStoreInterface -{ - GTypeInterface parent; - - const gchar * (*get_name) (EmpathyLogStore *self); - gboolean (*exists) (EmpathyLogStore *self, TpAccount *account, - const gchar *chat_id, gboolean chatroom); - gboolean (*add_message) (EmpathyLogStore *self, const gchar *chat_id, - gboolean chatroom, EmpathyMessage *message, GError **error); - GList * (*get_dates) (EmpathyLogStore *self, TpAccount *account, - const gchar *chat_id, gboolean chatroom); - GList * (*get_messages_for_date) (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom, - const gchar *date); - GList * (*get_last_messages) (EmpathyLogStore *self, TpAccount *account, - const gchar *chat_id, gboolean chatroom); - GList * (*get_chats) (EmpathyLogStore *self, - TpAccount *account); - GList * (*search_new) (EmpathyLogStore *self, const gchar *text); - void (*ack_message) (EmpathyLogStore *self, const gchar *chat_id, - gboolean chatroom, EmpathyMessage *message); - GList * (*get_filtered_messages) (EmpathyLogStore *self, TpAccount *account, - const gchar *chat_id, gboolean chatroom, guint num_messages, - EmpathyLogMessageFilter filter, gpointer user_data); -}; - -GType empathy_log_store_get_type (void) G_GNUC_CONST; - -const gchar *empathy_log_store_get_name (EmpathyLogStore *self); -gboolean empathy_log_store_exists (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom); -gboolean empathy_log_store_add_message (EmpathyLogStore *self, - const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, - GError **error); -GList *empathy_log_store_get_dates (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom); -GList *empathy_log_store_get_messages_for_date (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom, - const gchar *date); -GList *empathy_log_store_get_last_messages (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom); -GList *empathy_log_store_get_chats (EmpathyLogStore *self, - TpAccount *account); -GList *empathy_log_store_search_new (EmpathyLogStore *self, - const gchar *text); -void empathy_log_store_ack_message (EmpathyLogStore *self, - const gchar *chat_id, gboolean chatroom, EmpathyMessage *message); -GList *empathy_log_store_get_filtered_messages (EmpathyLogStore *self, - TpAccount *account, const gchar *chat_id, gboolean chatroom, - guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data); - -G_END_DECLS - -#endif /* __EMPATHY_LOG_STORE_H__ */ diff --git a/src/logstore/empathy-log-store-empathy.c b/src/logstore/tpl-log-store-empathy.c index ebf6c91..07f5a34 100644 --- a/src/logstore/empathy-log-store-empathy.c +++ b/src/logstore/tpl-log-store-empathy.c @@ -22,26 +22,32 @@ * Jonny Lamb <jonny.lamb@collabora.co.uk> */ -#include <config.h> +//#include <config.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <glib/gstdio.h> +#include <glib-object.h> + #include <telepathy-glib/account-manager.h> +#include <telepathy-glib/account.h> #include <telepathy-glib/util.h> #include <telepathy-glib/defs.h> -#include "empathy-log-store.h" -#include "empathy-log-store-empathy.h" -#include "empathy-log-manager.h" -#include "empathy-contact.h" -#include "empathy-time.h" -#include "empathy-utils.h" +#include <tpl-log-store.h> +#include <tpl-log-store-empathy.h> +#include <tpl-log-manager.h> +#include <empathy-contact.h> +#include <empathy-time.h> +#include <empathy-utils.h> + +#include <tpl_log_entry_text.h> +#include <tpl_contact.h> #define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include "empathy-debug.h" +#include <empathy-debug.h> #define LOG_DIR_CREATE_MODE (S_IRUSR | S_IWUSR | S_IXUSR) #define LOG_FILE_CREATE_MODE (S_IRUSR | S_IWUSR) @@ -69,7 +75,7 @@ typedef struct static void log_store_iface_init (gpointer g_iface,gpointer iface_data); G_DEFINE_TYPE_WITH_CODE (TplLogStoreEmpathy, tpl_log_store_empathy, - G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_LOG_STORE, + G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TPL_TYPE_LOG_STORE, log_store_iface_init)); static void @@ -97,7 +103,7 @@ static void tpl_log_store_empathy_init (TplLogStoreEmpathy *self) { TplLogStoreEmpathyPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - EMPATHY_TYPE_LOG_STORE_EMPATHY, TplLogStoreEmpathyPriv); + TPL_TYPE_LOG_STORE_EMPATHY, TplLogStoreEmpathyPriv); self->priv = priv; @@ -164,11 +170,11 @@ log_store_empathy_get_timestamp_filename (void) } static gchar * -log_store_empathy_get_timestamp_from_message (TplLogEntry *message) +log_store_empathy_get_timestamp_from_message (TplLogEntryText *message) { time_t t; - t = empathy_message_get_timestamp (message); + t = tpl_log_entry_text_get_timestamp (message); /* We keep the timestamps in the messages as UTC. */ return empathy_time_to_string_utc (t, LOG_TIME_FORMAT_FULL); @@ -198,12 +204,12 @@ static gboolean log_store_empathy_add_message (TplLogStore *self, const gchar *chat_id, gboolean chatroom, - TplLogEntry *message, + TplLogEntryText *message, GError **error) { FILE *file; TpAccount *account; - TpContact *sender; + TplContact *sender; const gchar *body_str; const gchar *str; //EmpathyAvatar *avatar; @@ -218,11 +224,11 @@ log_store_empathy_add_message (TplLogStore *self, g_return_val_if_fail (TPL_IS_LOG_STORE (self), FALSE); g_return_val_if_fail (chat_id != NULL, FALSE); - g_return_val_if_fail (TPL_IS_LOG_ENTRY (message), FALSE); + g_return_val_if_fail (TPL_IS_LOG_ENTRY_TEXT (message), FALSE); sender = tpl_log_entry_text_get_sender (message); account = tpl_channel_get_account ( - tpl_log_entry_text_get_channel (message) ); + tpl_log_entry_text_get_tpl_channel (message) ); body_str = tpl_log_entry_text_get_message (message); msg_type = tpl_log_entry_text_get_message_type (message); @@ -259,10 +265,10 @@ log_store_empathy_add_message (TplLogStore *self, body = g_markup_escape_text (body_str, -1); timestamp = log_store_empathy_get_timestamp_from_message (message); - str = tp_contact_get_alias (sender); + str = tpl_contact_get_alias (sender); contact_name = g_markup_escape_text (str, -1); - str = tp_contact_get_id (sender); + str = tpl_contact_get_identifier (sender); contact_id = g_markup_escape_text (str, -1); /* avatar = empathy_contact_get_avatar (sender); @@ -272,11 +278,13 @@ log_store_empathy_add_message (TplLogStore *self, g_fprintf (file, "<message time='%s' cm_id='%d' id='%s' name='%s' token='%s' isuser='%s' type='%s'>" "%s</message>\n" LOG_FOOTER, timestamp, - empathy_message_get_id (message), + tpl_log_entry_text_get_id (message), contact_id, contact_name, - avatar_token ? avatar_token : "", - empathy_contact_is_user (sender) ? "true" : "false", - empathy_message_type_to_str (msg_type), body); + //avatar_token ? avatar_token : "", // instead force to "" as + //follow + "", + tpl_contact_get_contact_type (sender) == TPL_CONTACT_USER ? "true" : "false", + tpl_log_entry_text_message_type_to_str (msg_type), body); fclose (file); g_free (filename); @@ -284,7 +292,7 @@ log_store_empathy_add_message (TplLogStore *self, g_free (contact_name); g_free (timestamp); g_free (body); - g_free (avatar_token); + //g_free (avatar_token); return TRUE; } @@ -446,7 +454,7 @@ log_store_empathy_get_messages_for_file (TplLogStore *self, xmlNodePtr log_node; xmlNodePtr node; - g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); + g_return_val_if_fail (TPL_IS_LOG_STORE (self), NULL); g_return_val_if_fail (filename != NULL, NULL); DEBUG ("Attempting to parse filename:'%s'...", filename); @@ -481,8 +489,8 @@ log_store_empathy_get_messages_for_file (TplLogStore *self, /* Now get the messages. */ for (node = log_node->children; node; node = node->next) { - TplLogEntry *message; - EmpathyContact *sender; + TplLogEntryText *message; + TplContact *sender; gchar *time_; time_t t; gchar *sender_id; @@ -519,22 +527,30 @@ log_store_empathy_get_messages_for_file (TplLogStore *self, cm_id = atoi (cm_id_str); t = empathy_time_parse (time_); - - sender = empathy_contact_new_for_log (account, sender_id, sender_name, - is_user); - +//TODO remove me + //sender = empathy_contact_new_for_log (account, sender_id, sender_name, + // is_user); + sender = tpl_contact_new(); + tpl_contact_set_account(sender, account); + tpl_contact_set_identifier(sender, sender_id); + tpl_contact_set_alias(sender, sender_name); + + /* TODO remove avatar code if (!EMP_STR_EMPTY (sender_avatar_token)) empathy_contact_load_avatar_cache (sender, sender_avatar_token); +*/ - message = empathy_message_new (body); - empathy_message_set_sender (message, sender); - empathy_message_set_timestamp (message, t); - empathy_message_set_tptype (message, msg_type); - empathy_message_set_is_backlog (message, TRUE); + message = tpl_log_entry_text_new(); + tpl_log_entry_text_set_message(message, body); + tpl_log_entry_text_set_sender (message, sender); + tpl_log_entry_text_set_timestamp (message, t); + tpl_log_entry_text_set_message_type (message, msg_type); + //TODO uderstand if useful + //tpl_log_entry_text_set_is_backlog (message, TRUE); if (cm_id_str) - empathy_message_set_id (message, cm_id); + tpl_log_entry_text_set_id (message, cm_id); messages = g_list_append (messages, message); @@ -609,7 +625,7 @@ log_store_empathy_search_new (TplLogStore *self, GList *hits = NULL; gchar *text_casefold; - g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); + g_return_val_if_fail (TPL_IS_LOG_STORE (self), NULL); g_return_val_if_fail (!EMP_STR_EMPTY (text), NULL); text_casefold = g_utf8_casefold (text, -1); @@ -714,7 +730,7 @@ log_store_empathy_get_messages_for_date (TplLogStore *self, gchar *filename; GList *messages; - g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); + g_return_val_if_fail (TPL_IS_LOG_STORE (self), NULL); g_return_val_if_fail (chat_id != NULL, NULL); g_return_val_if_fail (account != NULL, NULL); diff --git a/src/logstore/empathy-log-store.c b/src/logstore/tpl-log-store.c index 512c4c0..0e439d4 100644 --- a/src/logstore/empathy-log-store.c +++ b/src/logstore/tpl-log-store.c @@ -20,15 +20,15 @@ * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk> */ -#include "empathy-log-store.h" +#include <tpl-log-store.h> GType -empathy_log_store_get_type (void) +tpl_log_store_get_type (void) { static GType type = 0; if (type == 0) { static const GTypeInfo info = { - sizeof (EmpathyLogStoreInterface), + sizeof (TplLogStoreInterface), NULL, /* base_init */ NULL, /* base_finalize */ NULL, /* class_init */ @@ -38,125 +38,125 @@ empathy_log_store_get_type (void) 0, /* n_preallocs */ NULL /* instance_init */ }; - type = g_type_register_static (G_TYPE_INTERFACE, "EmpathyLogStore", + type = g_type_register_static (G_TYPE_INTERFACE, "TplLogStore", &info, 0); } return type; } const gchar * -empathy_log_store_get_name (EmpathyLogStore *self) +tpl_log_store_get_name (TplLogStore *self) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_name) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_name) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_name (self); + return TPL_LOG_STORE_GET_INTERFACE (self)->get_name (self); } gboolean -empathy_log_store_exists (EmpathyLogStore *self, +tpl_log_store_exists (TplLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->exists) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->exists) return FALSE; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->exists ( + return TPL_LOG_STORE_GET_INTERFACE (self)->exists ( self, account, chat_id, chatroom); } gboolean -empathy_log_store_add_message (EmpathyLogStore *self, +tpl_log_store_add_message (TplLogStore *self, const gchar *chat_id, gboolean chatroom, - EmpathyMessage *message, + TplLogEntryText *message, GError **error) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->add_message) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->add_message) return FALSE; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->add_message ( + return TPL_LOG_STORE_GET_INTERFACE (self)->add_message ( self, chat_id, chatroom, message, error); } GList * -empathy_log_store_get_dates (EmpathyLogStore *self, +tpl_log_store_get_dates (TplLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_dates) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_dates) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_dates ( + return TPL_LOG_STORE_GET_INTERFACE (self)->get_dates ( self, account, chat_id, chatroom); } GList * -empathy_log_store_get_messages_for_date (EmpathyLogStore *self, +tpl_log_store_get_messages_for_date (TplLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date ( + return TPL_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date ( self, account, chat_id, chatroom, date); } GList * -empathy_log_store_get_last_messages (EmpathyLogStore *self, +tpl_log_store_get_last_messages (TplLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_last_messages) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_last_messages) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_last_messages ( + return TPL_LOG_STORE_GET_INTERFACE (self)->get_last_messages ( self, account, chat_id, chatroom); } GList * -empathy_log_store_get_chats (EmpathyLogStore *self, +tpl_log_store_get_chats (TplLogStore *self, TpAccount *account) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_chats) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats (self, account); + return TPL_LOG_STORE_GET_INTERFACE (self)->get_chats (self, account); } GList * -empathy_log_store_search_new (EmpathyLogStore *self, +tpl_log_store_search_new (TplLogStore *self, const gchar *text) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->search_new) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->search_new) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->search_new (self, text); + return TPL_LOG_STORE_GET_INTERFACE (self)->search_new (self, text); } void -empathy_log_store_ack_message (EmpathyLogStore *self, +tpl_log_store_ack_message (TplLogStore *self, const gchar *chat_id, gboolean chatroom, - EmpathyMessage *message) + TplLogEntryText *message) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->ack_message) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->ack_message) return; - EMPATHY_LOG_STORE_GET_INTERFACE (self)->ack_message ( + TPL_LOG_STORE_GET_INTERFACE (self)->ack_message ( self, chat_id, chatroom, message); } GList * -empathy_log_store_get_filtered_messages (EmpathyLogStore *self, +tpl_log_store_get_filtered_messages (TplLogStore *self, TpAccount *account, const gchar *chat_id, gboolean chatroom, @@ -165,9 +165,9 @@ empathy_log_store_get_filtered_messages (EmpathyLogStore *self, gpointer user_data) { - if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages) + if (!TPL_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages) return NULL; - return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages ( + return TPL_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages ( self, account, chat_id, chatroom, num_messages, filter, user_data); } diff --git a/src/tpl_channel_data.h b/src/tpl_channel_data.h deleted file mode 100644 index a3a44f3..0000000 --- a/src/tpl_channel_data.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __TPL_DATA_H__ -#define __TPL_DATA_H__ - -#include <glib-object.h> -#include <telepathy-glib/channel.h> -#include <telepathy-glib/account.h> -#include <telepathy-glib/connection.h> -#include <telepathy-glib/svc-client.h> - -#include <tpl_observer.h> -#include <tpl_utils.h> - -G_BEGIN_DECLS - -#define TPL_TYPE_CHANNEL (tpl_channel_get_type ()) -#define TPL_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_CHANNEL, TplChannel)) -#define TPL_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_CHANNEL, TplChannelClass)) -#define TPL_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_CHANNEL)) -#define TPL_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_CHANNEL)) -#define TPL_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_CHANNEL, TplChannelClass)) - - -typedef struct { - GObject parent; - - /* private */ - TpChannel *channel; - const gchar *channel_path; - const gchar *channel_type; - GHashTable *channel_properties; - - TpAccount *account; - const gchar *account_path; - TpConnection *connection; - const gchar *connection_path; - - TpSvcClientObserver *observer; -} TplChannel; - -typedef struct { - GObjectClass parent_class; -} TplChannelClass; - - -GType tpl_channel_get_type (void); - -TplChannel* tpl_channel_new (TpSvcClientObserver *observer); -void tpl_channel_free(TplChannel* tpl_chan); - - -TpSvcClientObserver*tpl_channel_get_observer(TplChannel *self); -TpAccount *tpl_channel_get_account(TplChannel *self); -const gchar *tpl_channel_get_account_path(TplChannel *self); -TpConnection *tpl_channel_get_connection(TplChannel *self); -const gchar *tpl_channel_get_connection_path(TplChannel *self); -TpChannel *tpl_channel_get_channel(TplChannel *self); -const gchar *tpl_channel_get_channel_path(TplChannel *self); -const gchar *tpl_channel_get_channel_type(TplChannel *self); -GHashTable *tpl_channel_get_channel_properties(TplChannel *self); - - -void tpl_channel_set_observer(TplChannel *self, - TpSvcClientObserver *data); -void tpl_channel_set_account(TplChannel *self, TpAccount *data); -void tpl_channel_set_account_path(TplChannel *self, const gchar *data); -void tpl_channel_set_connection(TplChannel *self, TpConnection *data); -void tpl_channel_set_connection_path(TplChannel *self, const gchar *data); -void tpl_channel_set_channel(TplChannel *self, TpChannel *data); -void tpl_channel_set_channel_path(TplChannel *self, const gchar *data); -void tpl_channel_set_channel_type(TplChannel *self, const gchar *data); -void tpl_channel_set_channel_properties(TplChannel *self, GHashTable *data); - -G_END_DECLS - -#endif // __TPL_DATA_H__ diff --git a/src/tpl_contact.c b/src/tpl_contact.c index 00477a3..ec1ebea 100644 --- a/src/tpl_contact.c +++ b/src/tpl_contact.c @@ -23,6 +23,8 @@ TplContact *tpl_contact_new() { ADD_GET(identifier, const gchar *); ADD_GET(presence_status, const gchar *); ADD_GET(presence_message, const gchar *); + ADD_GET(contact_type, TplContactType); + ADD_GET(account, TpAccount *); #undef ADD_GET #define ADD_SET(member,y) void tpl_contact_set_##member(TplContact *self, y data) { \ @@ -30,6 +32,7 @@ TplContact *tpl_contact_new() { self->member = data; \ _ref_object_if_not_null(data); } ADD_SET(contact, TpContact *); + ADD_SET(account, TpAccount *); #undef ADD_SET #define ADD_SET_SIMPLE(member,y) void tpl_contact_set_##member(TplContact *self, y data) { \ self->member = data;} @@ -37,4 +40,5 @@ TplContact *tpl_contact_new() { ADD_SET_SIMPLE(identifier, const gchar *); ADD_SET_SIMPLE(presence_status, const gchar *); ADD_SET_SIMPLE(presence_message, const gchar *); + ADD_SET_SIMPLE(contact_type, TplContactType); #undef ADD_SET_SIMPLE diff --git a/src/tpl_contact.h b/src/tpl_contact.h deleted file mode 100644 index b291961..0000000 --- a/src/tpl_contact.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __TPL_CONTACT_H__ -#define __TPL_CONTACT_H__ - -#include <glib-object.h> -#include <telepathy-glib/contact.h> - -#include <tpl_channel_data.h> - -G_BEGIN_DECLS - -#define TPL_TYPE_CONTACT (tpl_contact_get_type ()) -#define TPL_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_CONTACT, TplContact)) -#define TPL_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_CONTACT, TplContactClass)) -#define TPL_IS_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_CONTACT)) -#define TPL_IS_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_CONTACT)) -#define TPL_CONTACT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_CONTACT, TplContactClass)) - -typedef struct { - GObject parent; - - /* Private */ - TpContact *contact; // maybe NULL - const gchar *alias; - const gchar *identifier; - const gchar *presence_status; - const gchar *presence_message; -} TplContact; - - -typedef struct { - GObjectClass parent_class; -} TplContactClass; - - -GType tpl_contact_get_type (void); - -TplContact *tpl_contact_new(); - -#define ADD_GET(x,y) y tpl_contact_get_##x(TplContact *self) - ADD_GET(contact, TpContact *); - ADD_GET(alias, const gchar *); - ADD_GET(identifier, const gchar *); - ADD_GET(presence_status, const gchar *); - ADD_GET(presence_message, const gchar *); -#undef ADD_GET - -#define ADD_SET(x,y) void tpl_contact_set_##x(TplContact *self, y data) - ADD_SET(contact, TpContact *); - ADD_SET(alias, const gchar *); - ADD_SET(identifier, const gchar *); - ADD_SET(presence_status, const gchar *); - ADD_SET(presence_message, const gchar *); -#undef ADD_SET - -G_END_DECLS - -#endif // __TPL_CONTACT_H__ diff --git a/src/tpl_headless_logger_init.c b/src/tpl_headless_logger_init.c index 744cb18..a54b94b 100644 --- a/src/tpl_headless_logger_init.c +++ b/src/tpl_headless_logger_init.c @@ -5,6 +5,8 @@ #include <tpl_observer.h> +#include <empathy-log-store-empathy.h> + /* * Initialization of TPL (TelePathy Logger), it futurely set all the * inernal structs. tpl_headless_logger_deinit will free/unref them @@ -15,6 +17,7 @@ void tpl_headless_logger_init(void) DBusGConnection *bus; TpDBusDaemon *tp_bus; GError *error = NULL; + TplLogStoreEmpathy *logstore; bus = tp_get_bus(); tp_bus = tp_dbus_daemon_new(bus); @@ -28,8 +31,11 @@ void tpl_headless_logger_init(void) g_error_free(error); } + logstore = g_object_new(TPL_TYPE_LOG_STORE_EMPATHY, NULL); + observer = tpl_observer_new (); dbus_g_connection_register_g_object (bus, TPL_OBSERVER_OBJECT_PATH, G_OBJECT(observer)); + observer->logstore = logstore; } diff --git a/src/tpl_log_entry_text.c b/src/tpl_log_entry_text.c index ce885f6..d94324a 100644 --- a/src/tpl_log_entry_text.c +++ b/src/tpl_log_entry_text.c @@ -1,45 +1,71 @@ -#include <tpl_log_entry.h> +#include <tpl_channel_data.h> +#include <tpl_contact.h> +#include <tpl_log_entry_text.h> #include <tpl_utils.h> -G_DEFINE_TYPE (TplLogEntry, tpl_log_entry, G_TYPE_OBJECT) +G_DEFINE_TYPE (TplLogEntryText, tpl_log_entry_text, G_TYPE_OBJECT) -static void tpl_log_entry_class_init(TplLogEntryClass* klass) { +static void tpl_log_entry_text_class_init(TplLogEntryTextClass* klass) { //GObjectClass* gobject_class = G_OBJECT_CLASS (klass); } -static void tpl_log_entry_init(TplLogEntry* self) { - /* Init TplTextChannel's members to zero/NULL */ -#define TPL_SET_NULL(x) tpl_log_entry_set_##x(self, NULL) +static void tpl_log_entry_text_init(TplLogEntryText* self) { +#define TPL_SET_NULL(x) tpl_log_entry_text_set_##x(self, NULL) + TPL_SET_NULL(tpl_channel); #undef TPL_SET_NULL } -TplLogEntry *tpl_log_entry_new(void) { - TplLogEntry *ret = g_object_new(TPL_TYPE_LOG_ENTRY, NULL); +TplLogEntryText *tpl_log_entry_text_new(void) { + TplLogEntryText *ret = g_object_new(TPL_TYPE_LOG_ENTRY_TEXT, NULL); return ret; } -TplTextChannel *tpl_log_entry_text_get_tpl_channel(TplLogEntryText *self) { + +const gchar *tpl_log_entry_text_message_type_to_str (TpChannelTextMessageType msg_type) +{ + switch (msg_type) { + case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: + return "action"; + case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: + return "notice"; + case TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY: + return "auto-reply"; + default: + return "normal"; + } +} + + +TplChannel *tpl_log_entry_text_get_tpl_channel(TplLogEntryText *self) { return self->tpl_channel; } -TpContact *tpl_log_entry_text_get_sender (TplLogEntry *self) { +TplContact *tpl_log_entry_text_get_sender (TplLogEntryText *self) { return self->sender; } -TpContact *tpl_log_entry_text_get_receiver (TplLogEntry *self) { +TplContact *tpl_log_entry_text_get_receiver (TplLogEntryText *self) { return self->receiver; } -const gchar *tpl_log_entry_text_get_message (TplLogEntry *self) { +const gchar *tpl_log_entry_text_get_message (TplLogEntryText *self) { return self->message; } -TpChannelTextMessageType tpl_log_entry_text_get_message_type (TplLogEntry *self) { - return self->message_type;; +TpChannelTextMessageType tpl_log_entry_text_get_message_type (TplLogEntryText *self) { + return self->message_type; } -TplLogEntryTextSignalType tpl_log_entry_text_get_signal_type (TplLogEntry *self) { - return self->signal_type;; +TplLogEntryTextSignalType tpl_log_entry_text_get_signal_type (TplLogEntryText *self) { + return self->signal_type; } -TplLogEntryTextDirection tpl_log_entry_text_get_direction (TplLogEntry *self) { +TplLogEntryTextDirection tpl_log_entry_text_get_direction (TplLogEntryText *self) { return self->direction; } +time_t tpl_log_entry_text_get_timestamp (TplLogEntryText *self) +{ + return self->timestamp; +} +guint tpl_log_entry_text_get_id (TplLogEntryText *self) +{ + return self->id; +} void tpl_log_entry_text_set_tpl_channel(TplLogEntryText *self, TplChannel *data) { @@ -48,21 +74,31 @@ void tpl_log_entry_text_set_tpl_channel(TplLogEntryText *self, TplChannel *data) _ref_object_if_not_null(data); } -void tpl_log_entry_text_set_sender (TplLogEntry *self, TpContact *data) { +void tpl_log_entry_text_set_sender (TplLogEntryText *self, TplContact *data) { self->sender = data; } -void tpl_log_entry_text_set_receiver (TplLogEntry *self, TpContact *data) { +void tpl_log_entry_text_set_receiver (TplLogEntryText *self, TplContact *data) { self->receiver = data; } -void tpl_log_entry_text_set_message (TplLogEntry *self, const gchar *data) { +void tpl_log_entry_text_set_message (TplLogEntryText *self, const gchar *data) { self->message = data; } -void tpl_log_entry_text_set_message_type (TplLogEntry *self, TpChannelTextMessageType data) { - self->message_type; = data; +void tpl_log_entry_text_set_message_type (TplLogEntryText *self, TpChannelTextMessageType data) { + self->message_type = data; } -void tpl_log_entry_text_set_signal_type (TplLogEntry *self, TplLogEntryTextSignalType data) { - self->signal_type; = data; +void tpl_log_entry_text_set_signal_type (TplLogEntryText *self, TplLogEntryTextSignalType data) { + self->signal_type = data; } -void tpl_log_entry_text_set_direction (TplLogEntry *self, TplLogEntryTextDirection data) { +void tpl_log_entry_text_set_direction (TplLogEntryText *self, TplLogEntryTextDirection data) { self->direction = data; } + +void tpl_log_entry_text_set_timestamp (TplLogEntryText *self, time_t data) +{ + self->timestamp = data; +} + +void tpl_log_entry_text_set_id (TplLogEntryText *self, guint data) +{ + self->id = data; +} diff --git a/src/tpl_log_entry_text.h b/src/tpl_log_entry_text.h deleted file mode 100644 index de9e17f..0000000 --- a/src/tpl_log_entry_text.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __TPL_LOG_ENTRY_H__ -#define __TPL_LOG_ENTRY_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define TPL_TYPE_LOG_ENTRY (tpl_log_entry_text_get_signal_type ()) -#define TPL_LOG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_LOG_ENTRY, TplLogEntry)) -#define TPL_LOG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_LOG_ENTRY, TplLogEntryClass)) -#define TPL_IS_LOG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_LOG_ENTRY)) -#define TPL_IS_LOG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_LOG_ENTRY)) -#define TPL_LOG_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_LOG_ENTRY, TplLogEntryClass)) - - -/* Valid for org.freedesktop.Telepathy.Channel.Type.Text */ - -typedef enum { - TPL_LOG_ENTRY_TEXT_CHANNEL_MESSAGE, - TPL_LOG_ENTRY_TEXT_CHANNEL_ERROR, - TPL_LOG_ENTRY_TEXT_CHANNEL_LOSTMESSAGE -} TplLogEntryTextSignalType; - -/* wether the log entry is referring to something outgoing on incoming */ -typedef enum { - TPL_LOG_ENTRY_TEXT_CHANNEL_IN, - TPL_LOG_ENTRY_TEXT_CHANNEL_OUT -} TplLogEntryTextDirection; - -typedef struct { - GObject parent; - - /* Private */ - // tpl_channel has informations about channel/account/connection - TplChannel *tpl_channel; - // what kind of signal caused this log entry - TplLogEntryTextSignalType signal_type; - TpChannelTextMessageType message_type; - // is the this entry cause by something incoming or outgoing - TplLogEntryTextDirection direction; - - TplContact *sender; - TplContact *receiver; - const gchar *message; -} TplLogEntryText; - -typedef struct { - GObjectClass parent_class; -} TplLogEntryClass; - -GType tpl_log_entry_text_get_signal_type (void); - -TplLogEntryText *tpl_log_entry_text_new (); - -TplTextChannel *tpl_log_entry_text_get_tpl_channel(TplLogEntryText *self); -TplContact *tpl_log_entry_text_get_sender (TplLogEntryText *self); -TplContact *tpl_log_entry_text_get_receiver (TplLogEntryText *self); -const gchar *tpl_log_entry_text_get_message (TplLogEntryText *self); -TpChannelTextMessageType tpl_log_entry_text_get_message_type (TplLogEntry *self); -TplLogEntryTextSignalType tpl_log_entry_text_get_signal_type (TplLogEntryTextSignalType *self); -TplLogEntryTextDirection tpl_log_entry_text_get_direction (TplLogEntryTextDirection *self); - -void tpl_log_entry_text_set_tpl_channel(TplLogEntryText *self, TplChannel *data); -void tpl_log_entry_text_set_sender (TplLogEntryText *self, TplContact *data); -void tpl_log_entry_text_set_receiver (TplLogEntryText *self, TplContact *data); -void tpl_log_entry_text_set_message (TplLogEntryText *self, const gchar *data); -void tpl_log_entry_text_set_message_type (TplLogEntry *self, TpChannelTextMessageType data); -void tpl_log_entry_text_set_signal_type (TplLogEntryText *self, TplLogEntryTextSignalType data); -void tpl_log_entry_text_set_direction (TplLogEntryText *self, TplLogEntryTextDirection data); - -G_END_DECLS - -#endif // __TPL_LOG_ENTRY_H__ diff --git a/src/tpl_observer.h b/src/tpl_observer.h deleted file mode 100644 index 3938b4b..0000000 --- a/src/tpl_observer.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __TPL_OBSERVER_H__ -#define __TPL_OBSERVER_H__ - -#include <glib-object.h> -#include <telepathy-glib/dbus-properties-mixin.h> - -#define TP_IFACE_CHAN_TEXT "org.freedesktop.Telepathy.Channel.Type.Text" - -G_BEGIN_DECLS - -#define TYPE_TPL_OBSERVER (tpl_observer_get_type ()) -#define TPL_OBSERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TPL_OBSERVER, TplObserver)) -#define TPL_OBSERVER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TYPE_TPL_OBSERVER, TplObserverClass)) -#define IS_TPL_OBSERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TPL_OBSERVER)) -#define IS_TPL_OBSERVER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), TYPE_TPL_OBSERVER)) -#define TPL_OBSERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TPL_OBSERVER, TplObserverClass)) - - -#define TPL_OBSERVER_WELL_KNOWN_BUS_NAME \ - "org.freedesktop.Telepathy.Client.HeadlessLogger" -#define TPL_OBSERVER_OBJECT_PATH \ - "/org/freedesktop/Telepathy/Client/HeadlessLogger" - - -typedef struct _TplObserver TplObserver; - -struct _TplObserver -{ - GObject parent; -}; - -typedef struct _TplObserverClass TplObserverClass; -struct _TplObserverClass -{ - GObjectClass parent_class; - TpDBusPropertiesMixinClass dbus_props_class; -}; - -GType tpl_observer_get_type (void); -TplObserver *tpl_observer_new (void); - -void tpl_headless_logger_init(void); - -G_END_DECLS - -#endif diff --git a/src/tpl_text_channel_data.c b/src/tpl_text_channel_data.c index e4f4cc6..5c3bee3 100644 --- a/src/tpl_text_channel_data.c +++ b/src/tpl_text_channel_data.c @@ -3,7 +3,7 @@ #include <tpl_observer.h> #include <tpl_channel_data.h> #include <tpl_text_channel_data.h> -//#include <tpl_log_entry_text.h> +#include <tpl_log_entry_text.h> #include <tpl_contact.h> #define TP_CONTACT_FEATURES_LEN 2 @@ -52,6 +52,7 @@ void _channel_on_sent_signal_cb (TpChannel *proxy, const gchar *remote_pres_msg, *remote_pres_status; TplContact *tpl_contact_sender; TplContact *tpl_contact_receiver; + TplLogEntryText *log; me = tpl_text_channel_get_my_contact(tpl_text); @@ -69,8 +70,6 @@ void _channel_on_sent_signal_cb (TpChannel *proxy, my_pres_msg = tp_contact_get_presence_message (me); remote_pres_msg = tp_contact_get_presence_message (remote); - g_message("%s (%s): %s\n", my_id, my_alias, arg_Text); - tpl_contact_sender = tpl_contact_new(); tpl_contact_receiver = tpl_contact_new(); #define CONTACT_ENTRY_SET(x,y) tpl_contact_set_##x(tpl_contact_sender,y) @@ -88,11 +87,20 @@ void _channel_on_sent_signal_cb (TpChannel *proxy, CONTACT_ENTRY_SET(presence_message, remote_pres_msg); #undef CONTACT_ENTRY_SET - g_message("BIS: %s (%s): %s\n", - tpl_contact_get_identifier(tpl_contact_sender), - tpl_contact_get_alias(tpl_contact_sender), - arg_Text); + g_message("%s (%s): %s\n", + tpl_contact_get_identifier(tpl_contact_sender), + tpl_contact_get_alias(tpl_contact_sender), + arg_Text); + + log = tpl_log_entry_text_new(); + tpl_log_entry_text_set_tpl_channel(log, + tpl_text_channel_get_tpl_channel(tpl_text)); + tpl_log_entry_text_set_sender(log, tpl_contact_sender); + tpl_log_entry_text_set_receiver(log, tpl_contact_receiver); + tpl_log_entry_text_set_message(log, arg_Text); + tpl_log_entry_text_set_message_type(log, arg_Type); + tpl_log_entry_text_set_signal_type(log, TPL_LOG_ENTRY_TEXT_CHANNEL_MESSAGE); } @@ -113,6 +121,7 @@ void _channel_on_received_signal_cb (TpChannel *proxy, const gchar *remote_pres_msg, *remote_pres_status; TplContact *tpl_contact_sender; TplContact *tpl_contact_receiver; + TplLogEntryText *log; me = tpl_text_channel_get_my_contact(tpl_text); remote = tpl_text_channel_get_remote_contact(tpl_text); @@ -129,8 +138,6 @@ void _channel_on_received_signal_cb (TpChannel *proxy, my_pres_msg = tp_contact_get_presence_message (me); remote_pres_msg = tp_contact_get_presence_message (remote); - g_message("FOO%s (%s): %s\n", remote_id, remote_alias, arg_Text); - tpl_contact_sender = tpl_contact_new(); tpl_contact_receiver = tpl_contact_new(); #define CONTACT_ENTRY_SET(x,y) tpl_contact_set_##x(tpl_contact_sender,y) @@ -148,11 +155,20 @@ void _channel_on_received_signal_cb (TpChannel *proxy, CONTACT_ENTRY_SET(presence_message, my_pres_msg); #undef CONTACT_ENTRY_SET - g_message("BIS: %s (%s): %s\n", - tpl_contact_get_identifier(tpl_contact_sender), - tpl_contact_get_alias(tpl_contact_sender), - arg_Text); + g_message("%s (%s): %s\n", + tpl_contact_get_identifier(tpl_contact_sender), + tpl_contact_get_alias(tpl_contact_sender), + arg_Text); + + log = tpl_log_entry_text_new(); + tpl_log_entry_text_set_tpl_channel(log, + tpl_text_channel_get_tpl_channel(tpl_text)); + tpl_log_entry_text_set_sender(log, tpl_contact_sender); + tpl_log_entry_text_set_receiver(log, tpl_contact_receiver); + tpl_log_entry_text_set_message(log, arg_Text); + tpl_log_entry_text_set_message_type(log, arg_Type); + tpl_log_entry_text_set_signal_type(log, TPL_LOG_ENTRY_TEXT_CHANNEL_MESSAGE); } /* connect signals to TplTextChannel instance */ @@ -170,7 +186,7 @@ void _tpl_text_channel_connect_signals(TplTextChannel* self) { tp_cli_channel_type_text_connect_to_received(self->tpl_channel->channel, _channel_on_received_signal_cb, self, NULL, NULL, &error); if (error!=NULL) { - g_error("receaived signal connect: %s\n", error->message); + g_error("received signal connect: %s\n", error->message); g_clear_error(&error); g_error_free(error); } diff --git a/src/tpl_text_channel_data.h b/src/tpl_text_channel_data.h deleted file mode 100644 index b41200d..0000000 --- a/src/tpl_text_channel_data.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __TPL_TEXT_CHANNEL_H__ -#define __TPL_TEXT_CHANNEL_H__ - -/* - * http://telepathy.freedesktop.org/doc/telepathy-glib/telepathy-glib-channel-text.html#tp-cli-channel-type-text-connect-to-received - */ - -#include <glib-object.h> -#include <telepathy-glib/channel.h> -#include <telepathy-glib/account.h> -#include <telepathy-glib/connection.h> -#include <telepathy-glib/contact.h> -#include <telepathy-glib/svc-client.h> - -#include <tpl_observer.h> -#include <tpl_utils.h> - -G_BEGIN_DECLS - -#define TPL_TYPE_TEXT_CHANNEL (tpl_text_channel_get_type ()) -#define TPL_TEXT_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_TEXT_CHANNEL, TplTextChannel)) -#define TPL_TEXT_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_TEXT_CHANNEL, TplTextChannelClass)) -#define TPL_IS_TEXT_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_TEXT_CHANNEL)) -#define TPL_IS_TEXT_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_TEXT_CHANNEL)) -#define TPL_TEXT_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_TEXT_CHANNEL, TplTextChannelClass)) - - -typedef struct { - GObject parent; - - /* private */ - TplChannel *tpl_channel; - TpContact *remote_contact, *my_contact; -} TplTextChannel; - -typedef struct { - GObjectClass parent_class; -} TplTextChannelClass; - -GType tpl_text_channel_get_type (void); - -TplTextChannel* tpl_text_channel_new(TplChannel* tpl_channel); -void tpl_text_channel_free(TplTextChannel* tpl_chan); - -TplChannel *tpl_text_channel_get_tpl_channel(TplTextChannel *self); -TpContact *tpl_text_channel_get_remote_contact(TplTextChannel *self); -TpContact *tpl_text_channel_get_my_contact(TplTextChannel *self); - -void tpl_text_channel_set_tpl_channel(TplTextChannel *self, TplChannel *tpl_chan); -void tpl_text_channel_set_remote_contact(TplTextChannel *self, TpContact *data); -void tpl_text_channel_set_my_contact(TplTextChannel *self, TpContact *data); - -G_END_DECLS - -#endif // __TPL_TEXT_CHANNEL_H__ diff --git a/src/tpl_utils.h b/src/tpl_utils.h deleted file mode 100644 index b0ea03c..0000000 --- a/src/tpl_utils.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __TPL_UTILS_H__ -#define __TPL_UTILS_H__ - -#include <glib-object.h> - -void _unref_object_if_not_null(void* data); -void _ref_object_if_not_null(void* data); - -#endif // __TPL_UTILS_H__ |