summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-09 15:19:39 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-09 15:19:39 +0000
commit9bcf58a830062a3283f325c5bcaa85b8bac9121e (patch)
tree774ea0f7c1a69879d67eb258105de7fcf773f960 /src
parent7e83bcfc78f002a10f47963172f502035bf8e807 (diff)
downloadtelepathy-logger-9bcf58a830062a3283f325c5bcaa85b8bac9121e.tar.gz
Moved dbus-service to telepathy-logger/
* moved the DBus related modules from src/ to telepathy-logger/ and data/ for dbus-bind-tools XML * adding doc for TplConf * TP-restyling for TplConf
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am28
-rw-r--r--src/dbus-service.c211
-rw-r--r--src/dbus-service.h77
-rw-r--r--src/dbus-service.xml15
-rw-r--r--src/log-manager.xsl148
-rw-r--r--src/telepathy-logger-dbus.c67
-rw-r--r--src/telepathy-logger.c33
-rw-r--r--src/test-api.c107
-rw-r--r--src/test_api.c93
9 files changed, 131 insertions, 648 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b485ffa..6414801 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,28 +10,24 @@ AM_CPPFLAGS = \
$(DISABLE_DEPRECATED) \
$(WARN_CFLAGS)
-LDADD = \
- $(top_builddir)/telepathy-logger/libtelepathy-logger.la \
- $(LIBTPL_LIBS)
# TODO removeme: kludge to let the compilation work, or it doesn't know how to buld the lib
#$(top_builddir)/telepathy-logger/libtelepathy-logger.la:
# $(MAKE) -C $(top_builddir)/libtelepathy-logger libtelepathy-logger.la
-BUILT_SOURCES = \
- dbus-service-server.h \
- dbus-service-client.h
bin_PROGRAMS = \
telepathy-logger \
test-api
-test_api_SOURCES = test_api.c
+telepathy_logger_LDADD = \
+ $(top_builddir)/telepathy-logger/libtelepathy-logger.la \
+ $(LIBTPL_LIBS)
-telepathy_logger_SOURCES = telepathy-logger.c \
- dbus-service.c
+test_api_LDADD = \
+ $(top_builddir)/telepathy-logger/libtelepathy-logger.la \
+ $(LIBTPL_LIBS)
-nodist_telepathy_logger_SOURCES = $(BUILT_SOURCES)
check_c_sources = \
$(test_api_SOURCES) \
@@ -40,17 +36,7 @@ check_c_sources = \
include $(top_srcdir)/tools/check-coding-style.mk
check-local: check-coding-style
-EXTRA_DIST = dbus-service.xml
-
-#Rule to generate the binding headers
-dbus-service-server.h: dbus-service.xml
- dbus-binding-tool --prefix=tpl_dbus_service --mode=glib-server $< > $@
-
-dbus-service-client.h: dbus-service.xml
- dbus-binding-tool --prefix=tpl_dbus_service --mode=glib-client $< > $@
-
-
-CLEANFILES = $(BUILT_SOURCES)
+CLEANFILES = $(BUILT_SOURCES) $(bin_PROGRAMS)
# Dbus service file
#servicedir = $(DBUS_SERVICES_DIR)
diff --git a/src/dbus-service.c b/src/dbus-service.c
deleted file mode 100644
index 7cfdf02..0000000
--- a/src/dbus-service.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
- */
-
-#include "dbus-service.h"
-
-#include <glib.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/account.h>
-
-#include <telepathy-logger/log-entry-text.h>
-#include <telepathy-logger/log-manager.h>
-
-#define DBUS_STRUCT_STRING_STRING_UINT \
- (dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
-
-
-static gboolean tpl_dbus_service_last_chats (TplDBusService *self,
- const gchar *account_path, const gchar *identifier, gboolean is_chatroom,
- guint lines, DBusGMethodInvocation *context);
-
-#define GET_PRIV(obj) TPL_GET_PRIV (obj, TplDBusService)
-struct _TplDBusServicePriv
-{
- TplLogManager *manager;
-};
-
-#include <dbus-service-server.h>
-
-G_DEFINE_TYPE (TplDBusService, tpl_dbus_service, G_TYPE_OBJECT)
-
-static void
-tpl_dbus_service_finalize (GObject *obj)
-{
- G_OBJECT_CLASS (tpl_dbus_service_parent_class)->dispose (obj);
-}
-
-static void
-tpl_dbus_service_dispose (GObject *obj)
-{
- G_OBJECT_CLASS (tpl_dbus_service_parent_class)->finalize (obj);
-}
-
-
-static void
-tpl_dbus_service_class_init (TplDBusServiceClass *klass)
-{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tpl_dbus_service_finalize;
- object_class->dispose = tpl_dbus_service_dispose;
-
- dbus_g_object_type_install_info (TPL_TYPE_DBUS_SERVICE,
- &dbus_glib_tpl_dbus_service_object_info);
-
- g_type_class_add_private (object_class, sizeof (TplDBusServicePriv));
-}
-
-
-static void
-tpl_dbus_service_init (TplDBusService *self)
-{
- TplDBusServicePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- TPL_TYPE_DBUS_SERVICE, TplDBusServicePriv);
-
- g_return_if_fail (TPL_IS_DBUS_SERVICE (self));
-
- self->priv = priv;
- GET_PRIV (self)->manager = tpl_log_manager_dup_singleton ();
-}
-
-
-TplDBusService *
-tpl_dbus_service_new (void)
-{
- return g_object_new(TPL_TYPE_DBUS_SERVICE, NULL);
-}
-
-
-static gboolean
-_pack_last_chats_answer (GList *data,
- GPtrArray **array)
-{
- guint data_idx;
- GPtrArray *retval;
-
- (*array) = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free);
- retval = *array;
-
- for(data_idx = 0; data_idx < g_list_length (data); ++data_idx)
- {
- TplLogEntry *log = g_list_nth_data (data, data_idx);
-
- GValue *value = g_new0 (GValue, 1);
-
- gchar *message = g_strdup (tpl_log_entry_text_get_message (
- TPL_LOG_ENTRY_TEXT (log)));
- gchar *sender = g_strdup (tpl_contact_get_identifier (
- tpl_log_entry_text_get_sender (TPL_LOG_ENTRY_TEXT (log))));
- guint timestamp = tpl_log_entry_get_timestamp (log);
-
- g_value_init (value, DBUS_STRUCT_STRING_STRING_UINT);
- g_value_take_boxed (value, dbus_g_type_specialized_construct (
- DBUS_STRUCT_STRING_STRING_UINT));
-
- dbus_g_type_struct_set (value, 0, sender, 1, message, 2, timestamp,
- G_MAXUINT);
- g_ptr_array_add (retval, g_value_get_boxed (value));
- g_free (value);
-
- g_debug ("retval[%d]=\"[%d] <%s>: %s\"\n", data_idx,
- timestamp, sender, message);
- }
- return TRUE;
-}
-
-static gboolean
-tpl_dbus_service_last_chats (TplDBusService *self,
- const gchar *account_path,
- const gchar *identifier,
- gboolean is_chatroom,
- guint lines,
- DBusGMethodInvocation *context)
-{
- guint dates_idx;
- gint msgs_idx;
- GError *error = NULL;
- TpAccount *account;
- DBusGConnection *dbus;
- TpDBusDaemon *tp_dbus;
- GList *ret = NULL;
- GPtrArray *answer;
- guint left_lines = lines;
- TplDBusServicePriv *priv = GET_PRIV (self);
-
- g_return_val_if_fail (TPL_IS_DBUS_SERVICE (self), FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- dbus = tp_get_bus ();
- tp_dbus = tp_dbus_daemon_new (dbus);
-
- account = tp_account_new (tp_dbus, account_path, &error);
- if (error != NULL)
- {
- g_error ("TpAccount creation: %s", error->message);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- g_object_unref (tp_dbus);
- g_object_unref (dbus);
- return FALSE;
- }
-
- GList *dates = tpl_log_manager_get_dates (priv->manager, account, identifier,
- is_chatroom);
- if (dates != NULL)
- {
- g_set_error_literal (&error, TPL_DBUS_SERVICE_ERROR,
- TPL_DBUS_SERVICE_ERROR_FAILED, "Error during date list retrieving");
- dbus_g_method_return_error (context, error);
- g_object_unref (tp_dbus);
- g_object_unref (dbus);
- return FALSE;
- }
- dates = g_list_reverse (dates);
-
- for(dates_idx = 0; dates_idx < g_list_length (dates) && left_lines > 0;
- ++dates_idx)
- {
- gchar *date = g_list_nth_data (dates, dates_idx);
- GList *messages = tpl_log_manager_get_messages_for_date (priv->manager,
- account, identifier, is_chatroom, date);
- guint msgs_len = g_list_length (messages);
- gint guard = (msgs_len>=left_lines ? left_lines : msgs_len);
-
- for (msgs_idx=msgs_len-1; guard>0 && left_lines>0; --guard, --msgs_idx)
- {
- TplLogEntry *log = g_list_nth_data (messages, msgs_idx);
- g_object_ref (log);
- ret = g_list_prepend (ret, log);
- left_lines-=1;
- }
- g_list_foreach (messages, (GFunc) g_object_unref, NULL);
- }
- g_list_foreach (dates, (GFunc) g_free, NULL);
-
- _pack_last_chats_answer (ret, &answer);
- g_list_foreach (ret, (GFunc) g_object_unref, NULL);
-
- dbus_g_method_return (context, answer);
-
- g_object_unref (tp_dbus);
-
- return TRUE;
-}
diff --git a/src/dbus-service.h b/src/dbus-service.h
deleted file mode 100644
index 7aefc7b..0000000
--- a/src/dbus-service.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
- */
-
-#ifndef __TPL_DBUS_SERVICE_H__
-#define __TPL_DBUS_SERVICE_H__
-
-#include <glib-object.h>
-
-#include <telepathy-logger/log-manager.h>
-
-#define TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME \
- "org.freedesktop.Telepathy.TelepathyLoggerService"
-#define TPL_DBUS_SRV_OBJECT_PATH \
- "/org/freedesktop/Telepathy/TelepathyLoggerService"
-
-G_BEGIN_DECLS
-
-#define TPL_TYPE_DBUS_SERVICE (tpl_dbus_service_get_type ())
-#define TPL_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_DBUS_SERVICE, TplDBusService))
-#define TPL_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPL_TYPE_DBUS_SERVICE, TplDBusServiceClass))
-#define TPL_IS_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_DBUS_SERVICE))
-#define TPL_IS_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_DBUS_SERVICE))
-#define TPL_DBUS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_DBUS_SERVICE, TplDBusServiceClass))
-
-#define TPL_DBUS_SERVICE_ERROR g_quark_from_static_string ("tpl-dbus-service-error-quark")
-typedef enum
-{
- TPL_DBUS_SERVICE_ERROR_FAILED
-} TplDBusServiceError;
-
-typedef struct _TplDBusServicePriv TplDBusServicePriv;
-typedef struct
-{
- GObject parent;
-
- /* Private */
- TplDBusServicePriv *priv;
-} TplDBusService;
-
-
-typedef struct
-{
- GObjectClass parent_class;
-} TplDBusServiceClass;
-
-typedef struct
-{
- long unsigned timestamp;
- gchar *sender;
- gchar *message;
-} TplDBusServiceChatMessage;
-
-GType tpl_dbus_service_get_type (void);
-
-TplDBusService *tpl_dbus_service_new (void);
-
-G_END_DECLS
-
-#endif
diff --git a/src/dbus-service.xml b/src/dbus-service.xml
deleted file mode 100644
index be4fe2c..0000000
--- a/src/dbus-service.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<node name="/org/freedesktop/Telepathy/TelepathyLoggerService">
- <interface name="org.freedesktop.Telepathy.TelepathyLoggerService">
- <method name="LastChats">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="o" name="account" direction="in" />
- <arg type="s" name="identifier" direction="in" />
- <arg type="b" name="is_chatroom" direction="in" />
- <arg type="u" name="lines" direction="in" />
- <!-- ARRAY of (TIMESTAMP SENDER MESSAGE) -->
- <arg type="a(ssu)" name="answer" direction="out" />
- </method>
- </interface>
-</node>
-
diff --git a/src/log-manager.xsl b/src/log-manager.xsl
deleted file mode 100644
index a934f3a..0000000
--- a/src/log-manager.xsl
+++ /dev/null
@@ -1,148 +0,0 @@
-<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
-
- <xsl:output method="html" encoding="utf-8" indent="yes"/>
-
- <xsl:template match="/">
- <html>
- <head>
- <style type="text/css">
- <xsl:text>
- body {
- background: #fff;
- font-family: Verdana, "Bitstream Vera Sans", Sans-Serif;
- font-size: 10pt;
- }
- .stamp {
- color: #999;
- }
- .top-day-stamp {
- color: #999;
- text-align: center;
- margin-bottom: 1em;
- }
- .new-day-stamp {
- color: #999;
- text-align: center;
- margin-bottom: 1em;
- margin-top: 1em;
- }
- .nick {
- color: rgb(54,100, 139);
- }
- .nick-self {
- color: rgb(46,139,87);
- }
- .nick-highlight {
- color: rgb(205,92,92);
- }
- </xsl:text>
- </style>
- <title><xsl:value-of select="$title"/></title>
- </head>
- <body>
- <xsl:apply-templates/>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="get-day">
- <xsl:param name="stamp"/>
- <xsl:value-of select="substring ($stamp, 1, 8)"/>
- </xsl:template>
-
- <xsl:template name="format-stamp">
- <xsl:param name="stamp"/>
- <xsl:variable name="hour" select="substring ($stamp, 10, 2)"/>
- <xsl:variable name="min" select="substring ($stamp, 13, 2)"/>
-
- <xsl:value-of select="$hour"/>:<xsl:value-of select="$min"/>
- </xsl:template>
-
- <xsl:template name="format-day-stamp">
- <xsl:param name="stamp"/>
- <xsl:variable name="year" select="substring ($stamp, 1, 4)"/>
- <xsl:variable name="month" select="substring ($stamp, 5, 2)"/>
- <xsl:variable name="day" select="substring ($stamp, 7, 2)"/>
-
- <xsl:value-of select="$year"/>-<xsl:value-of select="$month"/>-<xsl:value-of select="$day"/>
- </xsl:template>
-
- <xsl:template name="header">
- <xsl:param name="stamp"/>
- <div class="top-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </div>
- </xsl:template>
-
- <xsl:template match="a">
- <xsl:text disable-output-escaping="yes">&lt;a href="</xsl:text>
-
- <xsl:value-of disable-output-escaping="yes" select="@href"/>
-
- <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
-
- <xsl:value-of select="@href"/>
- <xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
- </xsl:template>
-
- <xsl:template match="log">
-
- <div class="top-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="//message[1]/@time"/>
- </xsl:call-template>
- </div>
-
- <xsl:for-each select="*">
-
- <xsl:variable name="prev-time">
- <xsl:call-template name="get-day">
- <xsl:with-param name="stamp" select="preceding-sibling::*[1]/@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="this-time">
- <xsl:call-template name="get-day">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:if test="$prev-time &lt; $this-time">
- <div class="new-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </div>
- </xsl:if>
-
- <xsl:variable name="stamp">
- <xsl:call-template name="format-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <span class="stamp">
- <xsl:value-of select="$stamp"/>
- </span>
-
- <xsl:variable name="nick-class">
- <xsl:choose>
- <xsl:when test="not(string(@id))">nick-self</xsl:when>
- <xsl:otherwise>nick</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <span class="{$nick-class}">
- &lt;<xsl:value-of select="@name"/>&gt;
- </span>
-
- <xsl:apply-templates/>
- <br/>
-
- </xsl:for-each>
-
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/src/telepathy-logger-dbus.c b/src/telepathy-logger-dbus.c
deleted file mode 100644
index 83c841c..0000000
--- a/src/telepathy-logger-dbus.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
- */
-
-#include <glib.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-logger-dbus.h>
-
-#include "dbus-service.h"
-
-static GMainLoop *loop = NULL;
-
-void telepathy_logger_dbus_init(void)
-{
- TplDBusService *dbus_srv;
- DBusGConnection *bus;
- TpDBusDaemon *tp_bus;
- GError *error = NULL;
-
- bus = tp_get_bus();
- tp_bus = tp_dbus_daemon_new(bus);
-
- if ( tp_dbus_daemon_request_name (tp_bus, TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME,
- TRUE, &error) ) {
- g_print("%s DBus well known name registered\n",
- TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME);
- } else {
- g_print("Well Known name request error: %s\n", error->message);
- g_clear_error(&error);
- g_error_free(error);
- }
-
- dbus_srv = tpl_dbus_service_new ();
- dbus_g_connection_register_g_object (bus,
- TPL_DBUS_SRV_OBJECT_PATH,
- G_OBJECT(dbus_srv));
-}
-
-int main(int argc, char *argv[])
-{
- g_type_init ();
-
- telepathy_logger_dbus_init ();
-
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
-
- return 0;
-}
diff --git a/src/telepathy-logger.c b/src/telepathy-logger.c
index 52eb574..84c485e 100644
--- a/src/telepathy-logger.c
+++ b/src/telepathy-logger.c
@@ -19,7 +19,6 @@
* Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
*/
-#include "dbus-service.h"
#include <glib.h>
#include <telepathy-glib/dbus.h>
@@ -27,6 +26,7 @@
#include <telepathy-logger/channel-factory.h>
#include <telepathy-logger/channel-text.h>
#include <telepathy-logger/observer.h>
+#include <telepathy-logger/dbus-service.h>
static GMainLoop *loop = NULL;
@@ -39,23 +39,24 @@ telepathy_logger_dbus_init (void)
TpDBusDaemon *tp_bus;
GError *error = NULL;
- bus = tp_get_bus();
- tp_bus = tp_dbus_daemon_new(bus);
+ bus = tp_get_bus ();
+ tp_bus = tp_dbus_daemon_new (bus);
- if ( tp_dbus_daemon_request_name (tp_bus, TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME,
- TRUE, &error) ) {
- g_print("%s DBus well known name registered\n",
- TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME);
- } else {
- g_print("Well Known name request error: %s\n", error->message);
- g_clear_error(&error);
- g_error_free(error);
- }
+ if (tp_dbus_daemon_request_name (tp_bus, TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME,
+ TRUE, &error))
+ {
+ g_debug ("%s DBus well known name registered",
+ TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME);
+ }
+ else
+ {
+ g_debug ("Well Known name request error: %s", error->message);
+ g_error_free (error);
+ }
dbus_srv = tpl_dbus_service_new ();
- dbus_g_connection_register_g_object (bus,
- TPL_DBUS_SRV_OBJECT_PATH,
- G_OBJECT(dbus_srv));
+ dbus_g_connection_register_g_object (bus, TPL_DBUS_SRV_OBJECT_PATH,
+ G_OBJECT (dbus_srv));
}
@@ -78,7 +79,7 @@ main(int argc,
g_debug ("Registering channel factory into TplObserver");
tpl_observer_set_channel_factory (observer, tpl_channel_factory_build);
- if (tpl_observer_register_dbus (observer, &error) == FALSE)
+ if (!tpl_observer_register_dbus (observer, &error))
{
g_debug ("Error during D-Bus registration: %s", error->message);
return 1;
diff --git a/src/test-api.c b/src/test-api.c
new file mode 100644
index 0000000..811ac98
--- /dev/null
+++ b/src/test-api.c
@@ -0,0 +1,107 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
+ */
+
+
+#include <glib.h>
+
+#include <telepathy-glib/dbus.h>
+
+#include <telepathy-logger/dbus-service.h>
+
+#define ACCOUNT_PATH "/org/freedesktop/Telepathy/Account/gabble/jabber/cosimo_2ealfarano_40collabora_2eco_2euk0"
+#define ID "echo@test.collabora.co.uk"
+
+//static GMainLoop *loop = NULL;
+
+static void
+last_chats_cb (DBusGProxy *proxy,
+ GPtrArray *result,
+ GError *error,
+ gpointer userdata)
+{
+ /* Just do demonstrate remote exceptions versus regular GError */
+ if (error != NULL) {
+ if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
+ g_printerr ("Caught remote method exception %s: %s",
+ dbus_g_error_get_name (error),
+ error->message);
+ else
+ g_printerr ("Error: %s\n", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ g_print ("Names on the message bus:\n");
+
+ for (guint i = 0; i < result->len; ++i)
+ {
+ GValueArray *message_struct;
+ const gchar *message_body;
+ const gchar *message_sender;
+ guint message_timestamp;
+
+ message_struct = g_ptr_array_index (result, i);
+
+ message_body = g_value_get_string (g_value_array_get_nth
+ (message_struct, 0));
+ message_sender = g_value_get_string (g_value_array_get_nth
+ (message_struct, 1));
+ message_timestamp = g_value_get_uint (g_value_array_get_nth
+ (message_struct, 2));
+
+ g_debug ("%d: [%d] from=%s - %s", i, message_timestamp, message_sender,
+ message_body);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ DBusGConnection *connection;
+ GError *error;
+ DBusGProxy *proxy;
+
+ g_type_init ();
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (connection == NULL)
+ {
+ g_printerr ("Failed to open connection to bus: %s\n",
+ error->message);
+ g_error_free (error);
+ return 1;
+ }
+
+ /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
+
+ proxy = dbus_g_proxy_new_for_name (connection,
+ TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME,
+ TPL_DBUS_SRV_OBJECT_PATH,
+ TPL_DBUS_SRV_WELL_KNOWN_BUS_NAME);
+
+ tpl_dbus_service_last_chats_async (proxy, ACCOUNT_PATH, ID, FALSE, 5,
+ last_chats_cb, NULL);
+
+ g_object_unref (proxy);
+
+ return 0;
+}
diff --git a/src/test_api.c b/src/test_api.c
deleted file mode 100644
index 4cbd1c2..0000000
--- a/src/test_api.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
- */
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/account.h>
-
-#include <telepathy-logger/log-manager.h>
-#include <telepathy-logger/log-entry-text.h>
-
-#define ACCOUNT_PATH "/org/freedesktop/Telepathy/Account/gabble/jabber/cosimo_2ealfarano_40collabora_2eco_2euk0"
-#define ID "echo@test.collabora.co.uk"
-
-static GMainLoop *loop = NULL;
-
-static
-void cb(GObject *obj,
- GAsyncResult *result,
- gpointer user_data)
-{
- GError *error = NULL;
- GList *lst;
-
- lst = tpl_log_manager_async_operation_finish (result, &error);
- if (error != NULL)
- g_debug ("%s", (gchar*)error->message);
-
- for(;lst;lst=g_list_next (lst)) {
- g_debug ("LST: %s", (gchar*) lst->data);
- }
-}
-
-static void foo(TplLogEntry *f)
-{
- g_return_if_fail (TPL_IS_LOG_ENTRY (f));
-
- if (TPL_IS_LOG_ENTRY_TEXT (f))
- g_debug ("FOO");
-}
-
-int
-main (int argc, char *argv[])
-{
- GError *error = NULL;
- TplLogManager *manager;
- TpDBusDaemon *dbus;
- TpAccount *acc;
-
- g_type_init ();
-
- TplLogEntryText *t = tpl_log_entry_text_new (0, ID,
- TPL_LOG_ENTRY_DIRECTION_IN);
-
- foo(TPL_LOG_ENTRY (t));
-
- g_debug ("FOOOO");
- dbus = tp_dbus_daemon_dup (&error);
- if (error != NULL) {
- g_debug ("%s", error->message);
- }
- g_debug ("FOOOO2");
- acc = tp_account_new (dbus, ACCOUNT_PATH, NULL);
- g_debug ("FOOOO3");
- manager = tpl_log_manager_dup_singleton ();
-
- g_debug ("FOOOO4");
- tpl_log_manager_get_dates_async (manager, acc, ID, FALSE, cb, NULL);
-
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
-
- return 0;
-}