summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2009-12-04 12:23:15 -0200
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2009-12-04 12:23:15 -0200
commit295573e92177b1c5077359e000c8dae3718e8e51 (patch)
treeb400f75e6932742956a565d5054f1fc95d5b9fab
parent23a56c112f55c59a7714cc63f2043b43ebbbc22f (diff)
downloadtelepathy-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
-rw-r--r--include/.tpl_contact.h.swpbin0 -> 12288 bytes
-rw-r--r--include/config.h0
-rw-r--r--include/tpl-log-manager.h (renamed from src/logstore/empathy-log-manager.h)4
-rw-r--r--include/tpl-log-store-empathy.h66
-rw-r--r--include/tpl-log-store.h103
-rw-r--r--include/tpl_channel_data.h (renamed from src/tpl_channel_data.h)0
-rw-r--r--include/tpl_contact.h (renamed from src/tpl_contact.h)13
-rw-r--r--include/tpl_log_entry_text.h (renamed from src/tpl_log_entry_text.h)46
-rw-r--r--include/tpl_observer.h (renamed from src/tpl_observer.h)4
-rw-r--r--include/tpl_text_channel_data.h (renamed from src/tpl_text_channel_data.h)0
-rw-r--r--include/tpl_utils.h (renamed from src/tpl_utils.h)0
-rwxr-xr-xsrc/compile.sh5
-rw-r--r--src/logstore/empathy-log-manager.c14
-rw-r--r--src/logstore/empathy-log-store-empathy.h66
-rw-r--r--src/logstore/empathy-log-store.h101
-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_contact.c4
-rw-r--r--src/tpl_headless_logger_init.c6
-rw-r--r--src/tpl_log_entry_text.c86
-rw-r--r--src/tpl_text_channel_data.c44
21 files changed, 419 insertions, 307 deletions
diff --git a/include/.tpl_contact.h.swp b/include/.tpl_contact.h.swp
new file mode 100644
index 0000000..02daa89
--- /dev/null
+++ b/include/.tpl_contact.h.swp
Binary files differ
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/config.h
diff --git a/src/logstore/empathy-log-manager.h b/include/tpl-log-manager.h
index 25f1b5f..8a89958 100644
--- a/src/logstore/empathy-log-manager.h
+++ b/include/tpl-log-manager.h
@@ -26,8 +26,8 @@
#include <glib-object.h>
-#include "empathy-message.h"
-#include "empathy-dispatcher.h"
+#include <empathy-message.h>
+#include <empathy-dispatcher.h>
G_BEGIN_DECLS
diff --git a/include/tpl-log-store-empathy.h b/include/tpl-log-store-empathy.h
new file mode 100644
index 0000000..86b5e77
--- /dev/null
+++ b/include/tpl-log-store-empathy.h
@@ -0,0 +1,66 @@
+/* -*- 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 __TPL_LOG_STORE_EMPATHY_H__
+#define __TPL_LOG_STORE_EMPATHY_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define TPL_TYPE_LOG_STORE_EMPATHY \
+ (tpl_log_store_empathy_get_type ())
+#define TPL_LOG_STORE_EMPATHY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_LOG_STORE_EMPATHY, \
+ TplLogStoreEmpathy))
+#define TPL_LOG_STORE_EMPATHY_CLASS(vtable) \
+ (G_TYPE_CHECK_CLASS_CAST ((vtable), TPL_TYPE_LOG_STORE_EMPATHY, \
+ TplLogStoreEmpathyClass))
+#define TPL_IS_LOG_STORE_EMPATHY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_LOG_STORE_EMPATHY))
+#define TPL_IS_LOG_STORE_EMPATHY_CLASS(vtable) \
+ (G_TYPE_CHECK_CLASS_TYPE ((vtable), TPL_TYPE_LOG_STORE_EMPATHY))
+#define TPL_LOG_STORE_EMPATHY_GET_CLASS(inst) \
+ (G_TYPE_INSTANCE_GET_CLASS ((inst), TPL_TYPE_LOG_STORE_EMPATHY, \
+ TplLogStoreEmpathyClass))
+
+typedef struct _TplLogStoreEmpathy TplLogStoreEmpathy;
+typedef struct _TplLogStoreEmpathyClass TplLogStoreEmpathyClass;
+
+struct _TplLogStoreEmpathy
+{
+ GObject parent;
+ gpointer priv;
+};
+
+struct _TplLogStoreEmpathyClass
+{
+ GObjectClass parent;
+};
+
+GType tpl_log_store_empathy_get_type (void);
+
+G_END_DECLS
+
+#endif /* __TPL_LOG_STORE_EMPATHY_H__ */
diff --git a/include/tpl-log-store.h b/include/tpl-log-store.h
new file mode 100644
index 0000000..8b8620d
--- /dev/null
+++ b/include/tpl-log-store.h
@@ -0,0 +1,103 @@
+/* -*- 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 __TPL_LOG_STORE_H__
+#define __TPL_LOG_STORE_H__
+
+#include <glib-object.h>
+
+#include <telepathy-glib/account.h>
+
+#include <empathy-message.h>
+#include <tpl-log-manager.h>
+
+#include <tpl_log_entry_text.h>
+
+G_BEGIN_DECLS
+
+#define TPL_TYPE_LOG_STORE (tpl_log_store_get_type ())
+#define TPL_LOG_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_LOG_STORE, \
+ TplLogStore))
+#define TPL_IS_LOG_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_LOG_STORE))
+#define TPL_LOG_STORE_GET_INTERFACE(inst) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((inst), TPL_TYPE_LOG_STORE, \
+ TplLogStoreInterface))
+
+typedef struct _TplLogStore TplLogStore; /* dummy object */
+typedef struct _TplLogStoreInterface TplLogStoreInterface;
+
+struct _TplLogStoreInterface
+{
+ GTypeInterface parent;
+
+ const gchar * (*get_name) (TplLogStore *self);
+ gboolean (*exists) (TplLogStore *self, TpAccount *account,
+ const gchar *chat_id, gboolean chatroom);
+ gboolean (*add_message) (TplLogStore *self, const gchar *chat_id,
+ gboolean chatroom, TplLogEntryText *message, GError **error);
+ GList * (*get_dates) (TplLogStore *self, TpAccount *account,
+ const gchar *chat_id, gboolean chatroom);
+ GList * (*get_messages_for_date) (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
+ const gchar *date);
+ GList * (*get_last_messages) (TplLogStore *self, TpAccount *account,
+ const gchar *chat_id, gboolean chatroom);
+ GList * (*get_chats) (TplLogStore *self,
+ TpAccount *account);
+ GList * (*search_new) (TplLogStore *self, const gchar *text);
+ void (*ack_message) (TplLogStore *self, const gchar *chat_id,
+ gboolean chatroom, TplLogEntryText *message);
+ GList * (*get_filtered_messages) (TplLogStore *self, TpAccount *account,
+ const gchar *chat_id, gboolean chatroom, guint num_messages,
+ EmpathyLogMessageFilter filter, gpointer user_data);
+};
+
+GType tpl_log_store_get_type (void) G_GNUC_CONST;
+
+const gchar *tpl_log_store_get_name (TplLogStore *self);
+gboolean tpl_log_store_exists (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
+gboolean tpl_log_store_add_message (TplLogStore *self,
+ const gchar *chat_id, gboolean chatroom, TplLogEntryText *message,
+ GError **error);
+GList *tpl_log_store_get_dates (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
+GList *tpl_log_store_get_messages_for_date (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
+ const gchar *date);
+GList *tpl_log_store_get_last_messages (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
+GList *tpl_log_store_get_chats (TplLogStore *self,
+ TpAccount *account);
+GList *tpl_log_store_search_new (TplLogStore *self,
+ const gchar *text);
+void tpl_log_store_ack_message (TplLogStore *self,
+ const gchar *chat_id, gboolean chatroom, TplLogEntryText *message);
+GList *tpl_log_store_get_filtered_messages (TplLogStore *self,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
+ guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data);
+
+G_END_DECLS
+
+#endif /* __TPL_LOG_STORE_H__ */
diff --git a/src/tpl_channel_data.h b/include/tpl_channel_data.h
index a3a44f3..a3a44f3 100644
--- a/src/tpl_channel_data.h
+++ b/include/tpl_channel_data.h
diff --git a/src/tpl_contact.h b/include/tpl_contact.h
index b291961..0fe756d 100644
--- a/src/tpl_contact.h
+++ b/include/tpl_contact.h
@@ -15,15 +15,24 @@ G_BEGIN_DECLS
#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 enum {
+ TPL_CONTACT_USER,
+ TPL_CONTACT_GROUP
+} TplContactType;
+
typedef struct {
GObject parent;
/* Private */
TpContact *contact; // maybe NULL
+ TplContactType contact_type;
const gchar *alias;
const gchar *identifier;
const gchar *presence_status;
const gchar *presence_message;
+
+ TpAccount *account;
} TplContact;
@@ -42,6 +51,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(x,y) void tpl_contact_set_##x(TplContact *self, y data)
@@ -50,6 +61,8 @@ TplContact *tpl_contact_new();
ADD_SET(identifier, const gchar *);
ADD_SET(presence_status, const gchar *);
ADD_SET(presence_message, const gchar *);
+ ADD_SET(contact_type, TplContactType);
+ ADD_SET(account, TpAccount *);
#undef ADD_SET
G_END_DECLS
diff --git a/src/tpl_log_entry_text.h b/include/tpl_log_entry_text.h
index de9e17f..92c61b5 100644
--- a/src/tpl_log_entry_text.h
+++ b/include/tpl_log_entry_text.h
@@ -1,16 +1,19 @@
-#ifndef __TPL_LOG_ENTRY_H__
-#define __TPL_LOG_ENTRY_H__
+#ifndef __TPL_LOG_ENTRY_TEXT_H__
+#define __TPL_LOG_ENTRY_TEXT_H__
+#include <telepathy-glib/enums.h>
#include <glib-object.h>
+#include <tpl_contact.h>
+#include <tpl_text_channel_data.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))
+#define TPL_TYPE_LOG_ENTRY_TEXT (tpl_log_entry_text_get_type ())
+#define TPL_LOG_ENTRY_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_LOG_ENTRY_TEXT, TplLogEntry))
+#define TPL_LOG_ENTRY_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_LOG_ENTRY_TEXT, TplLogEntryClass))
+#define TPL_IS_LOG_ENTRY_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_LOG_ENTRY_TEXT))
+#define TPL_IS_LOG_ENTRY_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_LOG_ENTRY_TEXT))
+#define TPL_LOG_ENTRY_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_LOG_ENTRY_TEXT, TplLogEntryClass))
/* Valid for org.freedesktop.Telepathy.Channel.Type.Text */
@@ -42,32 +45,41 @@ typedef struct {
TplContact *sender;
TplContact *receiver;
const gchar *message;
+ guint id;
+ time_t timestamp;
} TplLogEntryText;
typedef struct {
GObjectClass parent_class;
-} TplLogEntryClass;
+} TplLogEntryTextClass;
-GType tpl_log_entry_text_get_signal_type (void);
+GType tpl_log_entry_text_get_type (void);
TplLogEntryText *tpl_log_entry_text_new ();
-TplTextChannel *tpl_log_entry_text_get_tpl_channel(TplLogEntryText *self);
+const gchar *tpl_log_entry_text_message_type_to_str (TpChannelTextMessageType msg_type);
+
+
+TplChannel *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);
+TpChannelTextMessageType tpl_log_entry_text_get_message_type (TplLogEntryText *self);
+TplLogEntryTextSignalType tpl_log_entry_text_get_signal_type (TplLogEntryText *self);
+TplLogEntryTextDirection tpl_log_entry_text_get_direction (TplLogEntryText *self);
+time_t tpl_log_entry_text_get_timestamp (TplLogEntryText *self);
+guint tpl_log_entry_text_get_id (TplLogEntryText *self);
-void tpl_log_entry_text_set_tpl_channel(TplLogEntryText *self, TplChannel *data);
+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_message_type (TplLogEntryText *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);
+void tpl_log_entry_text_set_timestamp (TplLogEntryText *self, time_t data);
+void tpl_log_entry_text_set_id (TplLogEntryText *self, guint data);
G_END_DECLS
-#endif // __TPL_LOG_ENTRY_H__
+#endif // __TPL_LOG_ENTRY_TEXT_H__
diff --git a/src/tpl_observer.h b/include/tpl_observer.h
index 3938b4b..21433da 100644
--- a/src/tpl_observer.h
+++ b/include/tpl_observer.h
@@ -3,6 +3,7 @@
#include <glib-object.h>
#include <telepathy-glib/dbus-properties-mixin.h>
+#include <tpl-log-store-empathy.h>
#define TP_IFACE_CHAN_TEXT "org.freedesktop.Telepathy.Channel.Type.Text"
@@ -27,6 +28,9 @@ typedef struct _TplObserver TplObserver;
struct _TplObserver
{
GObject parent;
+
+ /* private */
+ TplLogStoreEmpathy *logstore;
};
typedef struct _TplObserverClass TplObserverClass;
diff --git a/src/tpl_text_channel_data.h b/include/tpl_text_channel_data.h
index b41200d..b41200d 100644
--- a/src/tpl_text_channel_data.h
+++ b/include/tpl_text_channel_data.h
diff --git a/src/tpl_utils.h b/include/tpl_utils.h
index b0ea03c..b0ea03c 100644
--- a/src/tpl_utils.h
+++ b/include/tpl_utils.h
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-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_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_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_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);
}