diff options
92 files changed, 1603 insertions, 11568 deletions
diff --git a/Makefile.am b/Makefile.am index b07c050a..e040519a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = lib src data m4 generate tests +SUBDIRS = lib src data m4 tests dist-hook: chmod u+w ${distdir}/ChangeLog diff --git a/configure.ac b/configure.ac index 71398dcd..4e8484b3 100644 --- a/configure.ac +++ b/configure.ac @@ -88,6 +88,12 @@ PKG_CHECK_MODULES(LIBXML2, [libxml-2.0]) AC_SUBST(LIBXML2_CFLAGS) AC_SUBST(LIBXML2_LIBS) +dnl Check for telepathy-glib +PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib]) + +AC_SUBST(TELEPATHY_GLIB_CFLAGS) +AC_SUBST(TELEPATHY_GLIB_LIBS) + dnl Check for OpenSSL PKG_CHECK_MODULES(LIBSSL, [openssl], [ HAVE_LIBSSL="yes" ], @@ -137,7 +143,6 @@ AC_OUTPUT( Makefile \ src/Makefile \ m4/Makefile \ data/Makefile \ - generate/Makefile \ tests/Makefile \ tests/inputs/Makefile ) diff --git a/generate/.git-darcs-dir b/generate/.git-darcs-dir deleted file mode 100644 index e69de29b..00000000 --- a/generate/.git-darcs-dir +++ /dev/null diff --git a/generate/Makefile.am b/generate/Makefile.am deleted file mode 100644 index 0a393e54..00000000 --- a/generate/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST = \ - do_src.sh \ - do_xml.sh \ - salut.def \ - src \ - xml-pristine \ - xml-modified - diff --git a/generate/README b/generate/README deleted file mode 100644 index 1e86148c..00000000 --- a/generate/README +++ /dev/null @@ -1,21 +0,0 @@ -Source code in this tree was originally generated from a magical gobject -generation tool called gengobject.py. It takes D-Bus XML introspection data and -outputs source, header and other files like signal marshallers. To read the XML -from generate/xml-modified/ directory, and output new source in the -generate/src/ directory, where changes can be reveiwed and applied to the src/ -directory by hand, run generate/do_src.sh. - -The XML is generated from the Python classes which are the current canonical -definition of the Telepathy interfaces, according to the definitions in -xml.def, and the list of methods which are to be implemented as asynchronous -in async_implementations. To generate the XML run generate/do_xml.sh. This is -a two-stage process: firstly, the "pristine" XML in generate/xml-pristine/ -is generated from the Python classes and xml.def, and secondly, the "modified" -XML in generate/xml-modified/ is generated by patching xml-pristine/ according -to async_implementations. - -Applying the changes to the C source can be as easy as: - darcs diff -u generate/src | patch -d src -Patch does a much better job of applying generated changes to the modified code -than darcs did when pulling patches from seperate trees (xml -> generate -> -live). diff --git a/generate/async_annotate.py b/generate/async_annotate.py deleted file mode 100644 index f05c0674..00000000 --- a/generate/async_annotate.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python2.4 - -import sys - -try: - from elementtree.ElementTree import fromstring, tostring, ElementTree, Element -except ImportError: - print "You need to install ElementTree (http://effbot.org/zone/element-index.htm)" - sys.exit(1) - -from xml.dom.minidom import parseString -from telepathy.server import * - -import sys - -def strip (element): - if element.text: - element.text = element.text.strip() - if element.tail: - element.tail = element.tail.strip() - for child in element: - strip (child) - -class AsyncAnnotation: - def __init__(self, line): - self.cls, self.interface, self.method = line.strip().split() - -def annotate(root, annotations): - assert root.tag == 'node' - annotations = [a for a in annotations if root.get('name') == '/' + a.cls] - - for interface_elt in root: - if interface_elt.tag != 'interface': - continue - for method_elt in interface_elt: - if method_elt.tag != 'method': - continue - for a in annotations: - if (interface_elt.get('name') == a.interface - and method_elt.get('name') == a.method): - a_elt = Element('annotation', - name='org.freedesktop.DBus.GLib.Async', - value='') - method_elt.insert(0, a_elt) - -if __name__ == '__main__': - annotations = [AsyncAnnotation(line) for line in file(sys.argv[1])] - - root = ElementTree(file=sys.argv[2]).getroot() - annotate(root, annotations) - - # pretty print - strip(root) - xml = tostring(root) - dom = parseString(xml) - - output = file(sys.argv[3], 'w') - output.write(dom.toprettyxml(' ', '\n')) - output.close() diff --git a/generate/async_implementations b/generate/async_implementations deleted file mode 100644 index e3cf353a..00000000 --- a/generate/async_implementations +++ /dev/null @@ -1,5 +0,0 @@ -SalutConnection org.freedesktop.Telepathy.Connection HoldHandles -SalutConnection org.freedesktop.Telepathy.Connection InspectHandles -SalutConnection org.freedesktop.Telepathy.Connection ReleaseHandles -SalutConnection org.freedesktop.Telepathy.Connection RequestChannel -SalutConnection org.freedesktop.Telepathy.Connection RequestHandles diff --git a/generate/do_src.sh b/generate/do_src.sh deleted file mode 100644 index f9abef89..00000000 --- a/generate/do_src.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -set -e - -PYVER=2.4 -PYTHON=python$PYVER - -if [ `basename $PWD` == "generate" ]; then - TP=${TELEPATHY_SPEC:=$PWD/../../telepathy-spec} -else - TP=${TELEPATHY_SPEC:=$PWD/../telepathy-spec} -fi - -export PYTHONPATH=$TP:$PYTHONPATH - -if test -d generate; then cd generate; fi -cd src - -echo Generating SalutConnectionManager files ... -$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-connection-manager.xml SalutConnectionManager - -echo Generating SalutConnection files ... -$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-connection.xml SalutConnection - -#echo Generating SalutContactChannel files ... -$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-contact-channel.xml SalutContactChannel - -echo Generating SalutIMChannel files ... -$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-im-channel.xml SalutIMChannel - -echo Generating SalutMucChannel files ... -$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-muc-channel.xml SalutMucChannel - -#echo Generating SalutMediaChannel files ... -#$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-media-channel.xml SalutMediaChannel - -#echo Generating SalutMediaSession files ... -#$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-media-session.xml SalutMediaSession - -#echo Generating SalutMediaStream files ... -#$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-media-stream.xml SalutMediaStream - -#echo Generating SalutRoomlistChannel files ... -#$PYTHON $TP/tools/gengobject.py ../xml-modified/salut-roomlist-channel.xml SalutRoomlistChannel - -echo Generating error enums ... -$PYTHON $TP/tools/generrors.py diff --git a/generate/do_xml.sh b/generate/do_xml.sh deleted file mode 100644 index 144cc9d8..00000000 --- a/generate/do_xml.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -set -e - -PYVER=2.4 -PYTHON=python$PYVER - -if [ `basename $PWD` == "generate" ]; then - TP=${TELEPATHY_SPEC:=$PWD/../../telepathy-spec} -else - TP=${TELEPATHY_SPEC:=$PWD/../telepathy-spec} -fi - -export PYTHONPATH=$TP:$PYTHONPATH - -if test -d generate; then cd generate; fi -cd xml-pristine - -echo "Generating pristine XML in generate/xml-pristine..." -$PYTHON $TP/tools/genxml.py ../salut.def -echo "Patching XML to incorporate async annotations..." -for x in *.xml; do - $PYTHON ../async_annotate.py ../async_implementations $x ../xml-modified/$x -done diff --git a/generate/salut.def b/generate/salut.def deleted file mode 100644 index ae97c9df..00000000 --- a/generate/salut.def +++ /dev/null @@ -1,10 +0,0 @@ -salut-connection-manager.xml SalutConnectionManager ConnectionManager -salut-connection.xml SalutConnection Connection, ConnectionInterfaceAliasing, ConnectionInterfacePresence -salut-contact-channel.xml SalutContactChannel ChannelTypeContactList, ChannelInterfaceGroup -salut-im-channel.xml SalutIMChannel ChannelTypeText -salut-muc-channel.xml SalutMucChannel ChannelTypeText, ChannelInterfaceGroup - -#salut-media-channel.xml SalutMediaChannel ChannelTypeStreamedMedia, ChannelInterfaceGroup, ChannelInterfaceMediaSignalling -#salut-media-session.xml SalutMediaSession MediaSessionHandler -#salut-media-stream.xml SalutMediaStream MediaStreamHandler -#salut-roomlist-channel.xml SalutRoomlistChannel ChannelTypeRoomList diff --git a/generate/src/.git-darcs-dir b/generate/src/.git-darcs-dir deleted file mode 100644 index e69de29b..00000000 --- a/generate/src/.git-darcs-dir +++ /dev/null diff --git a/generate/src/salut-connection-manager-signals-marshal.list b/generate/src/salut-connection-manager-signals-marshal.list deleted file mode 100644 index 41e40276..00000000 --- a/generate/src/salut-connection-manager-signals-marshal.list +++ /dev/null @@ -1 +0,0 @@ -VOID:STRING,STRING,STRING diff --git a/generate/src/salut-connection-manager.c b/generate/src/salut-connection-manager.c deleted file mode 100644 index 4fdc2914..00000000 --- a/generate/src/salut-connection-manager.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * salut-connection-manager.c - Source for SalutConnectionManager - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "salut-connection-manager.h" -#include "salut-connection-manager-signals-marshal.h" - -#include "salut-connection-manager-glue.h" - -G_DEFINE_TYPE(SalutConnectionManager, salut_connection_manager, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - NEW_CONNECTION, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutConnectionManagerPrivate SalutConnectionManagerPrivate; - -struct _SalutConnectionManagerPrivate -{ - gboolean dispose_has_run; -}; - -#define SALUT_CONNECTION_MANAGER_GET_PRIVATE(obj) \ - ((SalutConnectionManagerPrivate *)obj->priv) - -static void -salut_connection_manager_init (SalutConnectionManager *self) -{ - SalutConnectionManagerPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManagerPrivate); - - self->priv = priv; - - /* allocate any data required by the object here */ -} - -static void salut_connection_manager_dispose (GObject *object); -static void salut_connection_manager_finalize (GObject *object); - -static void -salut_connection_manager_class_init (SalutConnectionManagerClass *salut_connection_manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_connection_manager_class); - - g_type_class_add_private (salut_connection_manager_class, sizeof (SalutConnectionManagerPrivate)); - - object_class->dispose = salut_connection_manager_dispose; - object_class->finalize = salut_connection_manager_finalize; - - signals[NEW_CONNECTION] = - g_signal_new ("new-connection", - G_OBJECT_CLASS_TYPE (salut_connection_manager_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_manager_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, 3, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_connection_manager_class), &dbus_glib_salut_connection_manager_object_info); -} - -void -salut_connection_manager_dispose (GObject *object) -{ - SalutConnectionManager *self = SALUT_CONNECTION_MANAGER (object); - SalutConnectionManagerPrivate *priv = SALUT_CONNECTION_MANAGER_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (salut_connection_manager_parent_class)->dispose) - G_OBJECT_CLASS (salut_connection_manager_parent_class)->dispose (object); -} - -void -salut_connection_manager_finalize (GObject *object) -{ - SalutConnectionManager *self = SALUT_CONNECTION_MANAGER (object); - SalutConnectionManagerPrivate *priv = SALUT_CONNECTION_MANAGER_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_connection_manager_parent_class)->finalize (object); -} - - - -/** - * salut_connection_manager_get_parameters - * - * Implements D-Bus method GetParameters - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_get_parameters (SalutConnectionManager *self, - const gchar *proto, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_manager_list_protocols - * - * Implements D-Bus method ListProtocols - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_list_protocols (SalutConnectionManager *self, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_manager_request_connection - * - * Implements D-Bus method RequestConnection - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_request_connection (SalutConnectionManager *self, - const gchar *proto, - GHashTable *parameters, - gchar **ret, - gchar **ret1, - GError **error) -{ - return TRUE; -} - diff --git a/generate/src/salut-connection-manager.h b/generate/src/salut-connection-manager.h deleted file mode 100644 index 329ce948..00000000 --- a/generate/src/salut-connection-manager.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * salut-connection-manager.h - Header for SalutConnectionManager - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __SALUT_CONNECTION_MANAGER_H__ -#define __SALUT_CONNECTION_MANAGER_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SalutConnectionManager SalutConnectionManager; -typedef struct _SalutConnectionManagerClass SalutConnectionManagerClass; - -struct _SalutConnectionManagerClass { - GObjectClass parent_class; -}; - -struct _SalutConnectionManager { - GObject parent; - - gpointer priv; -}; - -GType salut_connection_manager_get_type(void); - -/* TYPE MACROS */ -#define SALUT_TYPE_CONNECTION_MANAGER \ - (salut_connection_manager_get_type()) -#define SALUT_CONNECTION_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManager)) -#define SALUT_CONNECTION_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManagerClass)) -#define SALUT_IS_CONNECTION_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_CONNECTION_MANAGER)) -#define SALUT_IS_CONNECTION_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_CONNECTION_MANAGER)) -#define SALUT_CONNECTION_MANAGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManagerClass)) - - -gboolean -salut_connection_manager_get_parameters (SalutConnectionManager *self, - const gchar *proto, - GPtrArray **ret, - GError **error); - -gboolean -salut_connection_manager_list_protocols (SalutConnectionManager *self, - gchar ***ret, - GError **error); - -gboolean -salut_connection_manager_request_connection (SalutConnectionManager *self, - const gchar *proto, - GHashTable *parameters, - gchar **ret, - gchar **ret1, - GError **error); - - - -G_END_DECLS - -#endif /* #ifndef __SALUT_CONNECTION_MANAGER_H__*/ diff --git a/generate/src/salut-connection-signals-marshal.list b/generate/src/salut-connection-signals-marshal.list deleted file mode 100644 index 454f5679..00000000 --- a/generate/src/salut-connection-signals-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:STRING,STRING,UINT,UINT,BOOLEAN -VOID:UINT,UINT diff --git a/generate/src/salut-connection.c b/generate/src/salut-connection.c deleted file mode 100644 index 77f931e4..00000000 --- a/generate/src/salut-connection.c +++ /dev/null @@ -1,621 +0,0 @@ -/* - * salut-connection.c - Source for SalutConnection - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "salut-connection.h" -#include "salut-connection-signals-marshal.h" - -#include "salut-connection-glue.h" - -G_DEFINE_TYPE(SalutConnection, salut_connection, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - ALIASES_CHANGED, - NEW_CHANNEL, - PRESENCE_UPDATE, - STATUS_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutConnectionPrivate SalutConnectionPrivate; - -struct _SalutConnectionPrivate -{ - gboolean dispose_has_run; -}; - -#define SALUT_CONNECTION_GET_PRIVATE(obj) \ - ((SalutConnectionPrivate *)obj->priv) - -static void -salut_connection_init (SalutConnection *self) -{ - SalutConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SALUT_TYPE_CONNECTION, SalutConnectionPrivate); - - self->priv = priv; - - /* allocate any data required by the object here */ -} - -static void salut_connection_dispose (GObject *object); -static void salut_connection_finalize (GObject *object); - -static void -salut_connection_class_init (SalutConnectionClass *salut_connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_connection_class); - - g_type_class_add_private (salut_connection_class, sizeof (SalutConnectionPrivate)); - - object_class->dispose = salut_connection_dispose; - object_class->finalize = salut_connection_finalize; - - signals[ALIASES_CHANGED] = - g_signal_new ("aliases-changed", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))))); - - signals[NEW_CHANNEL] = - g_signal_new ("new-channel", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_marshal_VOID__STRING_STRING_UINT_UINT_BOOLEAN, - G_TYPE_NONE, 5, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN); - - signals[PRESENCE_UPDATE] = - g_signal_new ("presence-update", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, (dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)))), G_TYPE_INVALID))))); - - signals[STATUS_CHANGED] = - g_signal_new ("status-changed", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_connection_class), &dbus_glib_salut_connection_object_info); -} - -void -salut_connection_dispose (GObject *object) -{ - SalutConnection *self = SALUT_CONNECTION (object); - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (salut_connection_parent_class)->dispose) - G_OBJECT_CLASS (salut_connection_parent_class)->dispose (object); -} - -void -salut_connection_finalize (GObject *object) -{ - SalutConnection *self = SALUT_CONNECTION (object); - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_connection_parent_class)->finalize (object); -} - - - -/** - * salut_connection_add_status - * - * Implements D-Bus method AddStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_add_status (SalutConnection *self, - const gchar *status, - GHashTable *parms, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_clear_status - * - * Implements D-Bus method ClearStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_clear_status (SalutConnection *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_connect - * - * Implements D-Bus method Connect - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_connect (SalutConnection *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_disconnect - * - * Implements D-Bus method Disconnect - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_disconnect (SalutConnection *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_alias_flags - * - * Implements D-Bus method GetAliasFlags - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_alias_flags (SalutConnection *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_interfaces - * - * Implements D-Bus method GetInterfaces - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_interfaces (SalutConnection *self, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_presence - * - * Implements D-Bus method GetPresence - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_presence (SalutConnection *self, - const GArray *contacts, - GHashTable **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_protocol - * - * Implements D-Bus method GetProtocol - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_protocol (SalutConnection *self, - gchar **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_self_handle - * - * Implements D-Bus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_self_handle (SalutConnection *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_status - * - * Implements D-Bus method GetStatus - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_status (SalutConnection *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_get_statuses - * - * Implements D-Bus method GetStatuses - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_statuses (SalutConnection *self, - GHashTable **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_hold_handles - * - * Implements D-Bus method HoldHandles - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -void -salut_connection_hold_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context) -{ - return; -} - - -/** - * salut_connection_inspect_handles - * - * Implements D-Bus method InspectHandles - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -void -salut_connection_inspect_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context) -{ - return; -} - - -/** - * salut_connection_list_channels - * - * Implements D-Bus method ListChannels - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_list_channels (SalutConnection *self, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_release_handles - * - * Implements D-Bus method ReleaseHandles - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -void -salut_connection_release_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context) -{ - return; -} - - -/** - * salut_connection_remove_status - * - * Implements D-Bus method RemoveStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_remove_status (SalutConnection *self, - const gchar *status, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_request_aliases - * - * Implements D-Bus method RequestAliases - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_request_aliases (SalutConnection *self, - const GArray *contacts, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_request_channel - * - * Implements D-Bus method RequestChannel - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -void -salut_connection_request_channel (SalutConnection *self, - const gchar *type, - guint handle_type, - guint handle, - gboolean suppress_handler, - DBusGMethodInvocation *context) -{ - return; -} - - -/** - * salut_connection_request_handles - * - * Implements D-Bus method RequestHandles - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -void -salut_connection_request_handles (SalutConnection *self, - guint handle_type, - const gchar **names, - DBusGMethodInvocation *context) -{ - return; -} - - -/** - * salut_connection_request_presence - * - * Implements D-Bus method RequestPresence - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_request_presence (SalutConnection *self, - const GArray *contacts, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_set_aliases - * - * Implements D-Bus method SetAliases - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_set_aliases (SalutConnection *self, - GHashTable *aliases, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_set_last_activity_time - * - * Implements D-Bus method SetLastActivityTime - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_set_last_activity_time (SalutConnection *self, - guint time, - GError **error) -{ - return TRUE; -} - - -/** - * salut_connection_set_status - * - * Implements D-Bus method SetStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_set_status (SalutConnection *self, - GHashTable *statuses, - GError **error) -{ - return TRUE; -} - diff --git a/generate/src/salut-connection.h b/generate/src/salut-connection.h deleted file mode 100644 index aebd99eb..00000000 --- a/generate/src/salut-connection.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * salut-connection.h - Header for SalutConnection - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __SALUT_CONNECTION_H__ -#define __SALUT_CONNECTION_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SalutConnection SalutConnection; -typedef struct _SalutConnectionClass SalutConnectionClass; - -struct _SalutConnectionClass { - GObjectClass parent_class; -}; - -struct _SalutConnection { - GObject parent; - - gpointer priv; -}; - -GType salut_connection_get_type(void); - -/* TYPE MACROS */ -#define SALUT_TYPE_CONNECTION \ - (salut_connection_get_type()) -#define SALUT_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_CONNECTION, SalutConnection)) -#define SALUT_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_CONNECTION, SalutConnectionClass)) -#define SALUT_IS_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_CONNECTION)) -#define SALUT_IS_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_CONNECTION)) -#define SALUT_CONNECTION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONNECTION, SalutConnectionClass)) - - -gboolean -salut_connection_add_status (SalutConnection *self, - const gchar *status, - GHashTable *parms, - GError **error); - -gboolean -salut_connection_clear_status (SalutConnection *self, - GError **error); - -gboolean -salut_connection_connect (SalutConnection *self, - GError **error); - -gboolean -salut_connection_disconnect (SalutConnection *self, - GError **error); - -gboolean -salut_connection_get_alias_flags (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_interfaces (SalutConnection *self, - gchar ***ret, - GError **error); - -gboolean -salut_connection_get_presence (SalutConnection *self, - const GArray *contacts, - GHashTable **ret, - GError **error); - -gboolean -salut_connection_get_protocol (SalutConnection *self, - gchar **ret, - GError **error); - -gboolean -salut_connection_get_self_handle (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_status (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_statuses (SalutConnection *self, - GHashTable **ret, - GError **error); - -void -salut_connection_hold_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -void -salut_connection_inspect_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -gboolean -salut_connection_list_channels (SalutConnection *self, - GPtrArray **ret, - GError **error); - -void -salut_connection_release_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -gboolean -salut_connection_remove_status (SalutConnection *self, - const gchar *status, - GError **error); - -gboolean -salut_connection_request_aliases (SalutConnection *self, - const GArray *contacts, - gchar ***ret, - GError **error); - -void -salut_connection_request_channel (SalutConnection *self, - const gchar *type, - guint handle_type, - guint handle, - gboolean suppress_handler, - DBusGMethodInvocation *context); - -void -salut_connection_request_handles (SalutConnection *self, - guint handle_type, - const gchar **names, - DBusGMethodInvocation *context); - -gboolean -salut_connection_request_presence (SalutConnection *self, - const GArray *contacts, - GError **error); - -gboolean -salut_connection_set_aliases (SalutConnection *self, - GHashTable *aliases, - GError **error); - -gboolean -salut_connection_set_last_activity_time (SalutConnection *self, - guint time, - GError **error); - -gboolean -salut_connection_set_status (SalutConnection *self, - GHashTable *statuses, - GError **error); - - - -G_END_DECLS - -#endif /* #ifndef __SALUT_CONNECTION_H__*/ diff --git a/generate/src/salut-contact-channel-signals-marshal.list b/generate/src/salut-contact-channel-signals-marshal.list deleted file mode 100644 index c1333dfa..00000000 --- a/generate/src/salut-contact-channel-signals-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:UINT,UINT -VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT diff --git a/generate/src/salut-contact-channel.c b/generate/src/salut-contact-channel.c deleted file mode 100644 index 90caab47..00000000 --- a/generate/src/salut-contact-channel.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - * salut-contact-channel.c - Source for SalutContactChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "salut-contact-channel.h" -#include "salut-contact-channel-signals-marshal.h" - -#include "salut-contact-channel-glue.h" - -G_DEFINE_TYPE(SalutContactChannel, salut_contact_channel, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - CLOSED, - GROUP_FLAGS_CHANGED, - MEMBERS_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutContactChannelPrivate SalutContactChannelPrivate; - -struct _SalutContactChannelPrivate -{ - gboolean dispose_has_run; -}; - -#define SALUT_CONTACT_CHANNEL_GET_PRIVATE(obj) \ - ((SalutContactChannelPrivate *)obj->priv) - -static void -salut_contact_channel_init (SalutContactChannel *self) -{ - SalutContactChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SALUT_TYPE_CONTACT_CHANNEL, SalutContactChannelPrivate); - - self->priv = priv; - - /* allocate any data required by the object here */ -} - -static void salut_contact_channel_dispose (GObject *object); -static void salut_contact_channel_finalize (GObject *object); - -static void -salut_contact_channel_class_init (SalutContactChannelClass *salut_contact_channel_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_contact_channel_class); - - g_type_class_add_private (salut_contact_channel_class, sizeof (SalutContactChannelPrivate)); - - object_class->dispose = salut_contact_channel_dispose; - object_class->finalize = salut_contact_channel_finalize; - - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_contact_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[GROUP_FLAGS_CHANGED] = - g_signal_new ("group-flags-changed", - G_OBJECT_CLASS_TYPE (salut_contact_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_contact_channel_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - signals[MEMBERS_CHANGED] = - g_signal_new ("members-changed", - G_OBJECT_CLASS_TYPE (salut_contact_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_contact_channel_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT, - G_TYPE_NONE, 7, G_TYPE_STRING, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, G_TYPE_UINT, G_TYPE_UINT); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_contact_channel_class), &dbus_glib_salut_contact_channel_object_info); -} - -void -salut_contact_channel_dispose (GObject *object) -{ - SalutContactChannel *self = SALUT_CONTACT_CHANNEL (object); - SalutContactChannelPrivate *priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (salut_contact_channel_parent_class)->dispose) - G_OBJECT_CLASS (salut_contact_channel_parent_class)->dispose (object); -} - -void -salut_contact_channel_finalize (GObject *object) -{ - SalutContactChannel *self = SALUT_CONTACT_CHANNEL (object); - SalutContactChannelPrivate *priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_contact_channel_parent_class)->finalize (object); -} - - - -/** - * salut_contact_channel_add_members - * - * Implements D-Bus method AddMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_add_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_close - * - * Implements D-Bus method Close - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_close (SalutContactChannel *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_all_members - * - * Implements D-Bus method GetAllMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_all_members (SalutContactChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_channel_type - * - * Implements D-Bus method GetChannelType - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_channel_type (SalutContactChannel *self, - gchar **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_group_flags - * - * Implements D-Bus method GetGroupFlags - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_group_flags (SalutContactChannel *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_handle - * - * Implements D-Bus method GetHandle - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_handle (SalutContactChannel *self, - guint *ret, - guint *ret1, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_handle_owners - * - * Implements D-Bus method GetHandleOwners - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_handle_owners (SalutContactChannel *self, - const GArray *handles, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_interfaces - * - * Implements D-Bus method GetInterfaces - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_interfaces (SalutContactChannel *self, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_local_pending_members - * - * Implements D-Bus method GetLocalPendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_local_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_local_pending_members_with_info - * - * Implements D-Bus method GetLocalPendingMembersWithInfo - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_local_pending_members_with_info (SalutContactChannel *self, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_members - * - * Implements D-Bus method GetMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_members (SalutContactChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_remote_pending_members - * - * Implements D-Bus method GetRemotePendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_remote_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_get_self_handle - * - * Implements D-Bus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_self_handle (SalutContactChannel *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_contact_channel_remove_members - * - * Implements D-Bus method RemoveMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_remove_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error) -{ - return TRUE; -} - diff --git a/generate/src/salut-contact-channel.h b/generate/src/salut-contact-channel.h deleted file mode 100644 index dc45adb2..00000000 --- a/generate/src/salut-contact-channel.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * salut-contact-channel.h - Header for SalutContactChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __SALUT_CONTACT_CHANNEL_H__ -#define __SALUT_CONTACT_CHANNEL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SalutContactChannel SalutContactChannel; -typedef struct _SalutContactChannelClass SalutContactChannelClass; - -struct _SalutContactChannelClass { - GObjectClass parent_class; -}; - -struct _SalutContactChannel { - GObject parent; - - gpointer priv; -}; - -GType salut_contact_channel_get_type(void); - -/* TYPE MACROS */ -#define SALUT_TYPE_CONTACT_CHANNEL \ - (salut_contact_channel_get_type()) -#define SALUT_CONTACT_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_CONTACT_CHANNEL, SalutContactChannel)) -#define SALUT_CONTACT_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_CONTACT_CHANNEL, SalutContactChannelClass)) -#define SALUT_IS_CONTACT_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_CONTACT_CHANNEL)) -#define SALUT_IS_CONTACT_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_CONTACT_CHANNEL)) -#define SALUT_CONTACT_CHANNEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONTACT_CHANNEL, SalutContactChannelClass)) - - -gboolean -salut_contact_channel_add_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_contact_channel_close (SalutContactChannel *self, - GError **error); - -gboolean -salut_contact_channel_get_all_members (SalutContactChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error); - -gboolean -salut_contact_channel_get_channel_type (SalutContactChannel *self, - gchar **ret, - GError **error); - -gboolean -salut_contact_channel_get_group_flags (SalutContactChannel *self, - guint *ret, - GError **error); - -gboolean -salut_contact_channel_get_handle (SalutContactChannel *self, - guint *ret, - guint *ret1, - GError **error); - -gboolean -salut_contact_channel_get_handle_owners (SalutContactChannel *self, - const GArray *handles, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_interfaces (SalutContactChannel *self, - gchar ***ret, - GError **error); - -gboolean -salut_contact_channel_get_local_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_local_pending_members_with_info (SalutContactChannel *self, - GPtrArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_remote_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_self_handle (SalutContactChannel *self, - guint *ret, - GError **error); - -gboolean -salut_contact_channel_remove_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - - - -G_END_DECLS - -#endif /* #ifndef __SALUT_CONTACT_CHANNEL_H__*/ diff --git a/generate/src/salut-im-channel-signals-marshal.list b/generate/src/salut-im-channel-signals-marshal.list deleted file mode 100644 index da94b09b..00000000 --- a/generate/src/salut-im-channel-signals-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -VOID:UINT,UINT,UINT,UINT,UINT,STRING -VOID:UINT,UINT,UINT,STRING -VOID:UINT,UINT,STRING diff --git a/generate/src/salut-im-channel.c b/generate/src/salut-im-channel.c deleted file mode 100644 index be484b38..00000000 --- a/generate/src/salut-im-channel.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * salut-im-channel.c - Source for SalutIMChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "salut-im-channel.h" -#include "salut-im-channel-signals-marshal.h" - -#include "salut-im-channel-glue.h" - -G_DEFINE_TYPE(SalutIMChannel, salut_im_channel, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - CLOSED, - LOST_MESSAGE, - RECEIVED, - SEND_ERROR, - SENT, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutIMChannelPrivate SalutIMChannelPrivate; - -struct _SalutIMChannelPrivate -{ - gboolean dispose_has_run; -}; - -#define SALUT_IM_CHANNEL_GET_PRIVATE(obj) \ - ((SalutIMChannelPrivate *)obj->priv) - -static void -salut_im_channel_init (SalutIMChannel *self) -{ - SalutIMChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SALUT_TYPE_IM_CHANNEL, SalutIMChannelPrivate); - - self->priv = priv; - - /* allocate any data required by the object here */ -} - -static void salut_im_channel_dispose (GObject *object); -static void salut_im_channel_finalize (GObject *object); - -static void -salut_im_channel_class_init (SalutIMChannelClass *salut_im_channel_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_im_channel_class); - - g_type_class_add_private (salut_im_channel_class, sizeof (SalutIMChannelPrivate)); - - object_class->dispose = salut_im_channel_dispose; - object_class->finalize = salut_im_channel_finalize; - - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[LOST_MESSAGE] = - g_signal_new ("lost-message", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[RECEIVED] = - g_signal_new ("received", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_im_channel_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING, - G_TYPE_NONE, 6, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - signals[SEND_ERROR] = - g_signal_new ("send-error", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_im_channel_marshal_VOID__UINT_UINT_UINT_STRING, - G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - signals[SENT] = - g_signal_new ("sent", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_im_channel_marshal_VOID__UINT_UINT_STRING, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_im_channel_class), &dbus_glib_salut_im_channel_object_info); -} - -void -salut_im_channel_dispose (GObject *object) -{ - SalutIMChannel *self = SALUT_IM_CHANNEL (object); - SalutIMChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (salut_im_channel_parent_class)->dispose) - G_OBJECT_CLASS (salut_im_channel_parent_class)->dispose (object); -} - -void -salut_im_channel_finalize (GObject *object) -{ - SalutIMChannel *self = SALUT_IM_CHANNEL (object); - SalutIMChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_im_channel_parent_class)->finalize (object); -} - - - -/** - * salut_im_channel_acknowledge_pending_messages - * - * Implements D-Bus method AcknowledgePendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_acknowledge_pending_messages (SalutIMChannel *self, - const GArray *ids, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_close - * - * Implements D-Bus method Close - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_close (SalutIMChannel *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_get_channel_type - * - * Implements D-Bus method GetChannelType - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_get_channel_type (SalutIMChannel *self, - gchar **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_get_handle - * - * Implements D-Bus method GetHandle - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_get_handle (SalutIMChannel *self, - guint *ret, - guint *ret1, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_get_interfaces - * - * Implements D-Bus method GetInterfaces - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_get_interfaces (SalutIMChannel *self, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_get_message_types - * - * Implements D-Bus method GetMessageTypes - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_get_message_types (SalutIMChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_list_pending_messages - * - * Implements D-Bus method ListPendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_list_pending_messages (SalutIMChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_im_channel_send - * - * Implements D-Bus method Send - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_send (SalutIMChannel *self, - guint type, - const gchar *text, - GError **error) -{ - return TRUE; -} - diff --git a/generate/src/salut-im-channel.h b/generate/src/salut-im-channel.h deleted file mode 100644 index 4a69fe15..00000000 --- a/generate/src/salut-im-channel.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * salut-im-channel.h - Header for SalutIMChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __SALUT_IM_CHANNEL_H__ -#define __SALUT_IM_CHANNEL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SalutIMChannel SalutIMChannel; -typedef struct _SalutIMChannelClass SalutIMChannelClass; - -struct _SalutIMChannelClass { - GObjectClass parent_class; -}; - -struct _SalutIMChannel { - GObject parent; - - gpointer priv; -}; - -GType salut_im_channel_get_type(void); - -/* TYPE MACROS */ -#define SALUT_TYPE_IM_CHANNEL \ - (salut_im_channel_get_type()) -#define SALUT_IM_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_IM_CHANNEL, SalutIMChannel)) -#define SALUT_IM_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_IM_CHANNEL, SalutIMChannelClass)) -#define SALUT_IS_IM_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_IM_CHANNEL)) -#define SALUT_IS_IM_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_IM_CHANNEL)) -#define SALUT_IM_CHANNEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_IM_CHANNEL, SalutIMChannelClass)) - - -gboolean -salut_im_channel_acknowledge_pending_messages (SalutIMChannel *self, - const GArray *ids, - GError **error); - -gboolean -salut_im_channel_close (SalutIMChannel *self, - GError **error); - -gboolean -salut_im_channel_get_channel_type (SalutIMChannel *self, - gchar **ret, - GError **error); - -gboolean -salut_im_channel_get_handle (SalutIMChannel *self, - guint *ret, - guint *ret1, - GError **error); - -gboolean -salut_im_channel_get_interfaces (SalutIMChannel *self, - gchar ***ret, - GError **error); - -gboolean -salut_im_channel_get_message_types (SalutIMChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_im_channel_list_pending_messages (SalutIMChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error); - -gboolean -salut_im_channel_send (SalutIMChannel *self, - guint type, - const gchar *text, - GError **error); - - - -G_END_DECLS - -#endif /* #ifndef __SALUT_IM_CHANNEL_H__*/ diff --git a/generate/src/salut-muc-channel-signals-marshal.list b/generate/src/salut-muc-channel-signals-marshal.list deleted file mode 100644 index 8fd20bec..00000000 --- a/generate/src/salut-muc-channel-signals-marshal.list +++ /dev/null @@ -1,5 +0,0 @@ -VOID:UINT,UINT,UINT,UINT,UINT,STRING -VOID:UINT,UINT,UINT,STRING -VOID:UINT,UINT,STRING -VOID:UINT,UINT -VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT diff --git a/generate/src/salut-muc-channel.c b/generate/src/salut-muc-channel.c deleted file mode 100644 index 7801aae5..00000000 --- a/generate/src/salut-muc-channel.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * salut-muc-channel.c - Source for SalutMucChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "salut-muc-channel.h" -#include "salut-muc-channel-signals-marshal.h" - -#include "salut-muc-channel-glue.h" - -G_DEFINE_TYPE(SalutMucChannel, salut_muc_channel, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - CLOSED, - GROUP_FLAGS_CHANGED, - LOST_MESSAGE, - MEMBERS_CHANGED, - RECEIVED, - SEND_ERROR, - SENT, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutMucChannelPrivate SalutMucChannelPrivate; - -struct _SalutMucChannelPrivate -{ - gboolean dispose_has_run; -}; - -#define SALUT_MUC_CHANNEL_GET_PRIVATE(obj) \ - ((SalutMucChannelPrivate *)obj->priv) - -static void -salut_muc_channel_init (SalutMucChannel *self) -{ - SalutMucChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SALUT_TYPE_MUC_CHANNEL, SalutMucChannelPrivate); - - self->priv = priv; - - /* allocate any data required by the object here */ -} - -static void salut_muc_channel_dispose (GObject *object); -static void salut_muc_channel_finalize (GObject *object); - -static void -salut_muc_channel_class_init (SalutMucChannelClass *salut_muc_channel_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_muc_channel_class); - - g_type_class_add_private (salut_muc_channel_class, sizeof (SalutMucChannelPrivate)); - - object_class->dispose = salut_muc_channel_dispose; - object_class->finalize = salut_muc_channel_finalize; - - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[GROUP_FLAGS_CHANGED] = - g_signal_new ("group-flags-changed", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_muc_channel_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - signals[LOST_MESSAGE] = - g_signal_new ("lost-message", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[MEMBERS_CHANGED] = - g_signal_new ("members-changed", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_muc_channel_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT, - G_TYPE_NONE, 7, G_TYPE_STRING, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, G_TYPE_UINT, G_TYPE_UINT); - - signals[RECEIVED] = - g_signal_new ("received", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_muc_channel_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING, - G_TYPE_NONE, 6, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - signals[SEND_ERROR] = - g_signal_new ("send-error", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_muc_channel_marshal_VOID__UINT_UINT_UINT_STRING, - G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - signals[SENT] = - g_signal_new ("sent", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_muc_channel_marshal_VOID__UINT_UINT_STRING, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_muc_channel_class), &dbus_glib_salut_muc_channel_object_info); -} - -void -salut_muc_channel_dispose (GObject *object) -{ - SalutMucChannel *self = SALUT_MUC_CHANNEL (object); - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (salut_muc_channel_parent_class)->dispose) - G_OBJECT_CLASS (salut_muc_channel_parent_class)->dispose (object); -} - -void -salut_muc_channel_finalize (GObject *object) -{ - SalutMucChannel *self = SALUT_MUC_CHANNEL (object); - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_muc_channel_parent_class)->finalize (object); -} - - - -/** - * salut_muc_channel_acknowledge_pending_messages - * - * Implements D-Bus method AcknowledgePendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_acknowledge_pending_messages (SalutMucChannel *self, - const GArray *ids, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_add_members - * - * Implements D-Bus method AddMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_add_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_close - * - * Implements D-Bus method Close - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_close (SalutMucChannel *self, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_all_members - * - * Implements D-Bus method GetAllMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_all_members (SalutMucChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_channel_type - * - * Implements D-Bus method GetChannelType - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_channel_type (SalutMucChannel *self, - gchar **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_group_flags - * - * Implements D-Bus method GetGroupFlags - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_group_flags (SalutMucChannel *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_handle - * - * Implements D-Bus method GetHandle - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_handle (SalutMucChannel *self, - guint *ret, - guint *ret1, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_handle_owners - * - * Implements D-Bus method GetHandleOwners - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_handle_owners (SalutMucChannel *self, - const GArray *handles, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_interfaces - * - * Implements D-Bus method GetInterfaces - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_interfaces (SalutMucChannel *self, - gchar ***ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_local_pending_members - * - * Implements D-Bus method GetLocalPendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_local_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_local_pending_members_with_info - * - * Implements D-Bus method GetLocalPendingMembersWithInfo - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_local_pending_members_with_info (SalutMucChannel *self, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_members - * - * Implements D-Bus method GetMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_members (SalutMucChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_message_types - * - * Implements D-Bus method GetMessageTypes - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_message_types (SalutMucChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_remote_pending_members - * - * Implements D-Bus method GetRemotePendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_remote_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_get_self_handle - * - * Implements D-Bus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_self_handle (SalutMucChannel *self, - guint *ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_list_pending_messages - * - * Implements D-Bus method ListPendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_list_pending_messages (SalutMucChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_remove_members - * - * Implements D-Bus method RemoveMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_remove_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error) -{ - return TRUE; -} - - -/** - * salut_muc_channel_send - * - * Implements D-Bus method Send - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_send (SalutMucChannel *self, - guint type, - const gchar *text, - GError **error) -{ - return TRUE; -} - diff --git a/generate/src/salut-muc-channel.h b/generate/src/salut-muc-channel.h deleted file mode 100644 index ce8fc539..00000000 --- a/generate/src/salut-muc-channel.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * salut-muc-channel.h - Header for SalutMucChannel - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __SALUT_MUC_CHANNEL_H__ -#define __SALUT_MUC_CHANNEL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SalutMucChannel SalutMucChannel; -typedef struct _SalutMucChannelClass SalutMucChannelClass; - -struct _SalutMucChannelClass { - GObjectClass parent_class; -}; - -struct _SalutMucChannel { - GObject parent; - - gpointer priv; -}; - -GType salut_muc_channel_get_type(void); - -/* TYPE MACROS */ -#define SALUT_TYPE_MUC_CHANNEL \ - (salut_muc_channel_get_type()) -#define SALUT_MUC_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_MUC_CHANNEL, SalutMucChannel)) -#define SALUT_MUC_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_MUC_CHANNEL, SalutMucChannelClass)) -#define SALUT_IS_MUC_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_MUC_CHANNEL)) -#define SALUT_IS_MUC_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_MUC_CHANNEL)) -#define SALUT_MUC_CHANNEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_MUC_CHANNEL, SalutMucChannelClass)) - - -gboolean -salut_muc_channel_acknowledge_pending_messages (SalutMucChannel *self, - const GArray *ids, - GError **error); - -gboolean -salut_muc_channel_add_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_muc_channel_close (SalutMucChannel *self, - GError **error); - -gboolean -salut_muc_channel_get_all_members (SalutMucChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error); - -gboolean -salut_muc_channel_get_channel_type (SalutMucChannel *self, - gchar **ret, - GError **error); - -gboolean -salut_muc_channel_get_group_flags (SalutMucChannel *self, - guint *ret, - GError **error); - -gboolean -salut_muc_channel_get_handle (SalutMucChannel *self, - guint *ret, - guint *ret1, - GError **error); - -gboolean -salut_muc_channel_get_handle_owners (SalutMucChannel *self, - const GArray *handles, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_interfaces (SalutMucChannel *self, - gchar ***ret, - GError **error); - -gboolean -salut_muc_channel_get_local_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_local_pending_members_with_info (SalutMucChannel *self, - GPtrArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_message_types (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_remote_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_self_handle (SalutMucChannel *self, - guint *ret, - GError **error); - -gboolean -salut_muc_channel_list_pending_messages (SalutMucChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error); - -gboolean -salut_muc_channel_remove_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_muc_channel_send (SalutMucChannel *self, - guint type, - const gchar *text, - GError **error); - - - -G_END_DECLS - -#endif /* #ifndef __SALUT_MUC_CHANNEL_H__*/ diff --git a/generate/src/telepathy-errors.h b/generate/src/telepathy-errors.h deleted file mode 100644 index 18c00cca..00000000 --- a/generate/src/telepathy-errors.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * telepathy-errors.h - Header for Telepathy error types - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __TELEPATHY_ERRORS_H__ -#define __TELEPATHY_ERRORS_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef enum -{ - ChannelBanned, /** You are banned from the channel. - */ - ChannelFull, /** The channel is full. - */ - ChannelInviteOnly, /** The requested channel is invite-only. - */ - Disconnected, /** The connection is not currently connected and cannot - * be used. - */ - InvalidArgument, /** Raised when one of the provided arguments is invalid. - */ - InvalidHandle, /** The contact name specified is unknown on this channel - * or connection. - */ - NetworkError, /** Raised when there is an error reading from or writing - * to the network. - */ - NotAvailable, /** Raised when the requested functionality is temporarily - * unavailable. - */ - NotImplemented, /** Raised when the requested method, channel, etc is not - * available on this connection. - */ - PermissionDenied, /** The user is not permitted to perform the requested - * operation. - */ -} TelepathyErrors; - - -G_END_DECLS - -#endif /* #ifndef __TELEPATHY_ERRORS_H__*/ diff --git a/generate/xml-modified/.git-darcs-dir b/generate/xml-modified/.git-darcs-dir deleted file mode 100644 index e69de29b..00000000 --- a/generate/xml-modified/.git-darcs-dir +++ /dev/null diff --git a/generate/xml-modified/salut-connection-manager.xml b/generate/xml-modified/salut-connection-manager.xml deleted file mode 100644 index 282f1f19..00000000 --- a/generate/xml-modified/salut-connection-manager.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutConnectionManager"> - <interface name="org.freedesktop.Telepathy.ConnectionManager"> - <method name="GetParameters"> - <arg direction="in" name="proto" type="s"/> - <arg direction="out" type="a(susv)"/> - </method> - <method name="ListProtocols"> - <arg direction="out" type="as"/> - </method> - <signal name="NewConnection"> - <arg name="bus_name" type="s"/> - <arg name="object_path" type="o"/> - <arg name="proto" type="s"/> - </signal> - <method name="RequestConnection"> - <arg direction="in" name="proto" type="s"/> - <arg direction="in" name="parameters" type="a{sv}"/> - <arg direction="out" type="s"/> - <arg direction="out" type="o"/> - </method> - </interface> -</node> diff --git a/generate/xml-modified/salut-connection.xml b/generate/xml-modified/salut-connection.xml deleted file mode 100644 index 14a3c244..00000000 --- a/generate/xml-modified/salut-connection.xml +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutConnection"> - <interface name="org.freedesktop.Telepathy.Connection"> - <method name="Connect"/> - <method name="Disconnect"/> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - <method name="GetProtocol"> - <arg direction="out" type="s"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <method name="GetStatus"> - <arg direction="out" type="u"/> - </method> - <method name="HoldHandles"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - </method> - <method name="InspectHandles"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="as"/> - </method> - <method name="ListChannels"> - <arg direction="out" type="a(osuu)"/> - </method> - <signal name="NewChannel"> - <arg name="object_path" type="o"/> - <arg name="channel_type" type="s"/> - <arg name="handle_type" type="u"/> - <arg name="handle" type="u"/> - <arg name="suppress_handler" type="b"/> - </signal> - <method name="ReleaseHandles"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - </method> - <method name="RequestChannel"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - <arg direction="in" name="type" type="s"/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handle" type="u"/> - <arg direction="in" name="suppress_handler" type="b"/> - <arg direction="out" type="o"/> - </method> - <method name="RequestHandles"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="names" type="as"/> - <arg direction="out" type="au"/> - </method> - <signal name="StatusChanged"> - <arg name="status" type="u"/> - <arg name="reason" type="u"/> - </signal> - </interface> - <interface name="org.freedesktop.Telepathy.Connection.Interface.Aliasing"> - <signal name="AliasesChanged"> - <arg name="aliases" type="a(us)"/> - </signal> - <method name="GetAliasFlags"> - <arg direction="out" type="u"/> - </method> - <method name="RequestAliases"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="out" type="as"/> - </method> - <method name="SetAliases"> - <arg direction="in" name="aliases" type="a{us}"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Connection.Interface.Presence"> - <method name="AddStatus"> - <arg direction="in" name="status" type="s"/> - <arg direction="in" name="parms" type="a{sv}"/> - </method> - <method name="ClearStatus"/> - <method name="GetPresence"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="out" type="a{u(ua{sa{sv}})}"/> - </method> - <method name="GetStatuses"> - <arg direction="out" type="a{s(ubba{ss})}"/> - </method> - <signal name="PresenceUpdate"> - <arg name="presence" type="a{u(ua{sa{sv}})}"/> - </signal> - <method name="RemoveStatus"> - <arg direction="in" name="status" type="s"/> - </method> - <method name="RequestPresence"> - <arg direction="in" name="contacts" type="au"/> - </method> - <method name="SetLastActivityTime"> - <arg direction="in" name="time" type="u"/> - </method> - <method name="SetStatus"> - <arg direction="in" name="statuses" type="a{sa{sv}}"/> - </method> - </interface> -</node> diff --git a/generate/xml-modified/salut-contact-channel.xml b/generate/xml-modified/salut-contact-channel.xml deleted file mode 100644 index 7aaf95aa..00000000 --- a/generate/xml-modified/salut-contact-channel.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutContactChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Interface.Group"> - <method name="AddMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - <method name="GetAllMembers"> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetGroupFlags"> - <arg direction="out" type="u"/> - </method> - <method name="GetHandleOwners"> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembersWithInfo"> - <arg direction="out" type="a(uuus)"/> - </method> - <method name="GetMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetRemotePendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <signal name="GroupFlagsChanged"> - <arg name="added" type="u"/> - <arg name="removed" type="u"/> - </signal> - <signal name="MembersChanged"> - <arg name="message" type="s"/> - <arg name="added" type="au"/> - <arg name="removed" type="au"/> - <arg name="local_pending" type="au"/> - <arg name="remote_pending" type="au"/> - <arg name="actor" type="u"/> - <arg name="reason" type="u"/> - </signal> - <method name="RemoveMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - </interface> -</node> diff --git a/generate/xml-modified/salut-im-channel.xml b/generate/xml-modified/salut-im-channel.xml deleted file mode 100644 index 3a3f40d3..00000000 --- a/generate/xml-modified/salut-im-channel.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutIMChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Type.Text"> - <method name="AcknowledgePendingMessages"> - <arg direction="in" name="ids" type="au"/> - </method> - <method name="GetMessageTypes"> - <arg direction="out" type="au"/> - </method> - <method name="ListPendingMessages"> - <arg direction="in" name="clear" type="b"/> - <arg direction="out" type="a(uuuuus)"/> - </method> - <signal name="LostMessage"/> - <signal name="Received"> - <arg name="id" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="sender" type="u"/> - <arg name="type" type="u"/> - <arg name="flags" type="u"/> - <arg name="text" type="s"/> - </signal> - <method name="Send"> - <arg direction="in" name="type" type="u"/> - <arg direction="in" name="text" type="s"/> - </method> - <signal name="SendError"> - <arg name="error" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - <signal name="Sent"> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - </interface> -</node> diff --git a/generate/xml-modified/salut-muc-channel.xml b/generate/xml-modified/salut-muc-channel.xml deleted file mode 100644 index 3c8c2927..00000000 --- a/generate/xml-modified/salut-muc-channel.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutMucChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Interface.Group"> - <method name="AddMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - <method name="GetAllMembers"> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetGroupFlags"> - <arg direction="out" type="u"/> - </method> - <method name="GetHandleOwners"> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembersWithInfo"> - <arg direction="out" type="a(uuus)"/> - </method> - <method name="GetMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetRemotePendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <signal name="GroupFlagsChanged"> - <arg name="added" type="u"/> - <arg name="removed" type="u"/> - </signal> - <signal name="MembersChanged"> - <arg name="message" type="s"/> - <arg name="added" type="au"/> - <arg name="removed" type="au"/> - <arg name="local_pending" type="au"/> - <arg name="remote_pending" type="au"/> - <arg name="actor" type="u"/> - <arg name="reason" type="u"/> - </signal> - <method name="RemoveMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Type.Text"> - <method name="AcknowledgePendingMessages"> - <arg direction="in" name="ids" type="au"/> - </method> - <method name="GetMessageTypes"> - <arg direction="out" type="au"/> - </method> - <method name="ListPendingMessages"> - <arg direction="in" name="clear" type="b"/> - <arg direction="out" type="a(uuuuus)"/> - </method> - <signal name="LostMessage"/> - <signal name="Received"> - <arg name="id" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="sender" type="u"/> - <arg name="type" type="u"/> - <arg name="flags" type="u"/> - <arg name="text" type="s"/> - </signal> - <method name="Send"> - <arg direction="in" name="type" type="u"/> - <arg direction="in" name="text" type="s"/> - </method> - <signal name="SendError"> - <arg name="error" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - <signal name="Sent"> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - </interface> -</node> diff --git a/generate/xml-pristine/.git-darcs-dir b/generate/xml-pristine/.git-darcs-dir deleted file mode 100644 index e69de29b..00000000 --- a/generate/xml-pristine/.git-darcs-dir +++ /dev/null diff --git a/generate/xml-pristine/salut-connection-manager.xml b/generate/xml-pristine/salut-connection-manager.xml deleted file mode 100644 index 282f1f19..00000000 --- a/generate/xml-pristine/salut-connection-manager.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutConnectionManager"> - <interface name="org.freedesktop.Telepathy.ConnectionManager"> - <method name="GetParameters"> - <arg direction="in" name="proto" type="s"/> - <arg direction="out" type="a(susv)"/> - </method> - <method name="ListProtocols"> - <arg direction="out" type="as"/> - </method> - <signal name="NewConnection"> - <arg name="bus_name" type="s"/> - <arg name="object_path" type="o"/> - <arg name="proto" type="s"/> - </signal> - <method name="RequestConnection"> - <arg direction="in" name="proto" type="s"/> - <arg direction="in" name="parameters" type="a{sv}"/> - <arg direction="out" type="s"/> - <arg direction="out" type="o"/> - </method> - </interface> -</node> diff --git a/generate/xml-pristine/salut-connection.xml b/generate/xml-pristine/salut-connection.xml deleted file mode 100644 index e0406504..00000000 --- a/generate/xml-pristine/salut-connection.xml +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutConnection"> - <interface name="org.freedesktop.Telepathy.Connection"> - <method name="Connect"/> - <method name="Disconnect"/> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - <method name="GetProtocol"> - <arg direction="out" type="s"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <method name="GetStatus"> - <arg direction="out" type="u"/> - </method> - <method name="HoldHandles"> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - </method> - <method name="InspectHandles"> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="as"/> - </method> - <method name="ListChannels"> - <arg direction="out" type="a(osuu)"/> - </method> - <signal name="NewChannel"> - <arg name="object_path" type="o"/> - <arg name="channel_type" type="s"/> - <arg name="handle_type" type="u"/> - <arg name="handle" type="u"/> - <arg name="suppress_handler" type="b"/> - </signal> - <method name="ReleaseHandles"> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handles" type="au"/> - </method> - <method name="RequestChannel"> - <arg direction="in" name="type" type="s"/> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="handle" type="u"/> - <arg direction="in" name="suppress_handler" type="b"/> - <arg direction="out" type="o"/> - </method> - <method name="RequestHandles"> - <arg direction="in" name="handle_type" type="u"/> - <arg direction="in" name="names" type="as"/> - <arg direction="out" type="au"/> - </method> - <signal name="StatusChanged"> - <arg name="status" type="u"/> - <arg name="reason" type="u"/> - </signal> - </interface> - <interface name="org.freedesktop.Telepathy.Connection.Interface.Aliasing"> - <signal name="AliasesChanged"> - <arg name="aliases" type="a(us)"/> - </signal> - <method name="GetAliasFlags"> - <arg direction="out" type="u"/> - </method> - <method name="RequestAliases"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="out" type="as"/> - </method> - <method name="SetAliases"> - <arg direction="in" name="aliases" type="a{us}"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Connection.Interface.Presence"> - <method name="AddStatus"> - <arg direction="in" name="status" type="s"/> - <arg direction="in" name="parms" type="a{sv}"/> - </method> - <method name="ClearStatus"/> - <method name="GetPresence"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="out" type="a{u(ua{sa{sv}})}"/> - </method> - <method name="GetStatuses"> - <arg direction="out" type="a{s(ubba{ss})}"/> - </method> - <signal name="PresenceUpdate"> - <arg name="presence" type="a{u(ua{sa{sv}})}"/> - </signal> - <method name="RemoveStatus"> - <arg direction="in" name="status" type="s"/> - </method> - <method name="RequestPresence"> - <arg direction="in" name="contacts" type="au"/> - </method> - <method name="SetLastActivityTime"> - <arg direction="in" name="time" type="u"/> - </method> - <method name="SetStatus"> - <arg direction="in" name="statuses" type="a{sa{sv}}"/> - </method> - </interface> -</node> diff --git a/generate/xml-pristine/salut-contact-channel.xml b/generate/xml-pristine/salut-contact-channel.xml deleted file mode 100644 index 7aaf95aa..00000000 --- a/generate/xml-pristine/salut-contact-channel.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutContactChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Interface.Group"> - <method name="AddMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - <method name="GetAllMembers"> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetGroupFlags"> - <arg direction="out" type="u"/> - </method> - <method name="GetHandleOwners"> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembersWithInfo"> - <arg direction="out" type="a(uuus)"/> - </method> - <method name="GetMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetRemotePendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <signal name="GroupFlagsChanged"> - <arg name="added" type="u"/> - <arg name="removed" type="u"/> - </signal> - <signal name="MembersChanged"> - <arg name="message" type="s"/> - <arg name="added" type="au"/> - <arg name="removed" type="au"/> - <arg name="local_pending" type="au"/> - <arg name="remote_pending" type="au"/> - <arg name="actor" type="u"/> - <arg name="reason" type="u"/> - </signal> - <method name="RemoveMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - </interface> -</node> diff --git a/generate/xml-pristine/salut-im-channel.xml b/generate/xml-pristine/salut-im-channel.xml deleted file mode 100644 index 3a3f40d3..00000000 --- a/generate/xml-pristine/salut-im-channel.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutIMChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Type.Text"> - <method name="AcknowledgePendingMessages"> - <arg direction="in" name="ids" type="au"/> - </method> - <method name="GetMessageTypes"> - <arg direction="out" type="au"/> - </method> - <method name="ListPendingMessages"> - <arg direction="in" name="clear" type="b"/> - <arg direction="out" type="a(uuuuus)"/> - </method> - <signal name="LostMessage"/> - <signal name="Received"> - <arg name="id" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="sender" type="u"/> - <arg name="type" type="u"/> - <arg name="flags" type="u"/> - <arg name="text" type="s"/> - </signal> - <method name="Send"> - <arg direction="in" name="type" type="u"/> - <arg direction="in" name="text" type="s"/> - </method> - <signal name="SendError"> - <arg name="error" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - <signal name="Sent"> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - </interface> -</node> diff --git a/generate/xml-pristine/salut-muc-channel.xml b/generate/xml-pristine/salut-muc-channel.xml deleted file mode 100644 index 3c8c2927..00000000 --- a/generate/xml-pristine/salut-muc-channel.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" ?> -<node name="/SalutMucChannel"> - <interface name="org.freedesktop.Telepathy.Channel"> - <method name="Close"/> - <signal name="Closed"/> - <method name="GetChannelType"> - <arg direction="out" type="s"/> - </method> - <method name="GetHandle"> - <arg direction="out" type="u"/> - <arg direction="out" type="u"/> - </method> - <method name="GetInterfaces"> - <arg direction="out" type="as"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Interface.Group"> - <method name="AddMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - <method name="GetAllMembers"> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetGroupFlags"> - <arg direction="out" type="u"/> - </method> - <method name="GetHandleOwners"> - <arg direction="in" name="handles" type="au"/> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetLocalPendingMembersWithInfo"> - <arg direction="out" type="a(uuus)"/> - </method> - <method name="GetMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetRemotePendingMembers"> - <arg direction="out" type="au"/> - </method> - <method name="GetSelfHandle"> - <arg direction="out" type="u"/> - </method> - <signal name="GroupFlagsChanged"> - <arg name="added" type="u"/> - <arg name="removed" type="u"/> - </signal> - <signal name="MembersChanged"> - <arg name="message" type="s"/> - <arg name="added" type="au"/> - <arg name="removed" type="au"/> - <arg name="local_pending" type="au"/> - <arg name="remote_pending" type="au"/> - <arg name="actor" type="u"/> - <arg name="reason" type="u"/> - </signal> - <method name="RemoveMembers"> - <arg direction="in" name="contacts" type="au"/> - <arg direction="in" name="message" type="s"/> - </method> - </interface> - <interface name="org.freedesktop.Telepathy.Channel.Type.Text"> - <method name="AcknowledgePendingMessages"> - <arg direction="in" name="ids" type="au"/> - </method> - <method name="GetMessageTypes"> - <arg direction="out" type="au"/> - </method> - <method name="ListPendingMessages"> - <arg direction="in" name="clear" type="b"/> - <arg direction="out" type="a(uuuuus)"/> - </method> - <signal name="LostMessage"/> - <signal name="Received"> - <arg name="id" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="sender" type="u"/> - <arg name="type" type="u"/> - <arg name="flags" type="u"/> - <arg name="text" type="s"/> - </signal> - <method name="Send"> - <arg direction="in" name="type" type="u"/> - <arg direction="in" name="text" type="s"/> - </method> - <signal name="SendError"> - <arg name="error" type="u"/> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - <signal name="Sent"> - <arg name="timestamp" type="u"/> - <arg name="type" type="u"/> - <arg name="text" type="s"/> - </signal> - </interface> -</node> diff --git a/src/Makefile.am b/src/Makefile.am index 73fefbcc..d3289b7b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,39 +1,22 @@ BUILT_SOURCES = \ - salut-connection-manager-glue.h \ - salut-connection-manager-signals-marshal.h \ - salut-connection-manager-signals-marshal.c \ - salut-contact-manager-signals-marshal.h \ - salut-contact-manager-signals-marshal.c \ salut-im-manager-signals-marshal.h \ salut-im-manager-signals-marshal.c \ salut-muc-manager-signals-marshal.h \ salut-muc-manager-signals-marshal.c \ - salut-im-channel-glue.h \ salut-im-channel-signals-marshal.h \ salut-im-channel-signals-marshal.c \ - salut-muc-channel-glue.h \ salut-muc-channel-signals-marshal.h \ salut-muc-channel-signals-marshal.c \ salut-self-signals-marshal.h \ salut-self-signals-marshal.c \ salut-contact-signals-marshal.h \ salut-contact-signals-marshal.c \ - salut-connection-glue.h \ - salut-connection-signals-marshal.h \ - salut-connection-signals-marshal.c \ + salut-contact-manager-signals-marshal.h \ + salut-contact-manager-signals-marshal.c \ salut-muc-connection-signals-marshal.h \ salut-muc-connection-signals-marshal.c \ salut-presence-enumtypes.h \ salut-presence-enumtypes.c \ - telepathy-errors-enumtypes.h \ - telepathy-errors-enumtypes.c \ - tp-channel-factory-iface-signals-marshal.h \ - tp-channel-factory-iface-signals-marshal.c \ - group-mixin-signals-marshal.h \ - group-mixin-signals-marshal.c \ - text-mixin-signals-marshal.h \ - text-mixin-signals-marshal.c \ - salut-contact-channel-glue.h \ salut-contact-channel-signals-marshal.h \ salut-contact-channel-signals-marshal.c \ salut-avahi-client-signals-marshal.h \ @@ -59,13 +42,10 @@ dist-hook: $(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done) EXTRA_DIST = \ - group-mixin-signals-marshal.list \ salut-avahi-client-signals-marshal.list \ salut-avahi-entry-group-signals-marshal.list \ salut-avahi-service-browser-signals-marshal.list \ salut-avahi-service-resolver-signals-marshal.list \ - salut-connection-manager-signals-marshal.list \ - salut-connection-signals-marshal.list \ salut-contact-channel-signals-marshal.list \ salut-contact-manager-signals-marshal.list \ salut-contact-signals-marshal.list \ @@ -74,9 +54,7 @@ EXTRA_DIST = \ salut-muc-channel-signals-marshal.list \ salut-muc-manager-signals-marshal.list \ salut-self-signals-marshal.list \ - salut-muc-connection-signals-marshal.list \ - text-mixin-signals-marshal.list \ - tp-channel-factory-iface-signals-marshal.list + salut-muc-connection-signals-marshal.list bin_PROGRAMS=telepathy-salut noinst_PROGRAMS = write-mgr-file @@ -118,33 +96,10 @@ CORE_SOURCES = \ salut-presence.h \ salut-muc-connection.c \ salut-muc-connection.h \ - telepathy-errors.c \ - telepathy-errors.h \ - telepathy-constants.h \ - telepathy-helpers.c \ - telepathy-helpers.h \ - telepathy-interfaces.h \ - gintset.c \ - gintset.h \ - gheap.c \ - gheap.h \ - util.c \ - util.h \ - handle-set.c \ - handle-set.h \ - handle-types.h \ - handle-repository.c \ - handle-repository.h \ - tp-channel-iface.h \ - tp-channel-iface.c \ - tp-channel-factory-iface.h \ - tp-channel-factory-iface.c \ salut-contact-channel.h \ salut-contact-channel.c \ - group-mixin.c \ - group-mixin.h \ - text-mixin.c \ - text-mixin.h \ + text-helper.c \ + text-helper.h \ debug.c \ debug.h \ ansi.h \ @@ -156,23 +111,29 @@ libsalut_convenience_la_SOURCES = $(CORE_SOURCES) write_mgr_file_SOURCES = write-mgr-file.c write_mgr_file_LDADD = libsalut-convenience.la \ - $(top_builddir)/lib/gibber/libgibber.la + $(top_builddir)/lib/gibber/libgibber.la \ + -ltelepathy-glib telepathy_salut_SOURCES = \ salut.c +# TELEPATHY_GLIB_LIBS is only here so compiling against a static lib succeeds telepathy_salut_LDADD = libsalut-convenience.la \ - $(top_builddir)/lib/gibber/libgibber.la + $(top_builddir)/lib/gibber/libgibber.la \ + -ltelepathy-glib noinst_LTLIBRARIES = libsalut-convenience.la AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ \ @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ \ @HANDLE_LEAK_DEBUG_CFLAGS@ \ + @TELEPATHY_GLIB_CFLAGS@ \ @AVAHI_CFLAGS@ \ -I $(top_srcdir)/lib -I $(top_builddir)/lib -AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @LIBXML2_LIBS@ @AVAHI_LIBS@ +AM_LDFLAGS = @DBUS_LIBS@ \ + @TELEPATHY_GLIB_LIBS@ \ + @GLIB_LIBS@ @LIBXML2_LIBS@ @AVAHI_LIBS@ # Teach it how to make libgibber.la $(top_builddir)/lib/gibber/libgibber.la: @@ -180,10 +141,6 @@ $(top_builddir)/lib/gibber/libgibber.la: .PHONY: $(top_builddir)/lib/gibber/libgibber.la -# rule to generate the binding headers -%-glue.h: ../generate/xml-modified/%.xml - dbus-binding-tool --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $< - %-signals-marshal.h: %-signals-marshal.list glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-signals-marshal.h diff --git a/src/debug.c b/src/debug.c index f51dd611..43f4bfa2 100644 --- a/src/debug.c +++ b/src/debug.c @@ -3,6 +3,8 @@ #include <glib.h> +#include <telepathy-glib/debug.h> + #include "debug.h" #ifdef ENABLE_DEBUG @@ -36,8 +38,10 @@ void debug_set_flags_from_env () flags_string = g_getenv ("SALUT_DEBUG"); - if (flags_string) + if (flags_string) { + tp_debug_set_flags_from_env("SALUT_DEBUG"); debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); + } } void debug_set_flags (DebugFlags new_flags) diff --git a/src/gheap.c b/src/gheap.c deleted file mode 100644 index 4362dd6b..00000000 --- a/src/gheap.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Header file for GHeap - * - * Copyright (C) 2006 Nokia Corporation. All rights reserved. - * - * Contact: Olli Salli (Nokia-M/Helsinki) <olli.salli@nokia.com> - * - * 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 - */ - -#include <glib.h> -#include "gheap.h" - -#define DEFAULT_SIZE 64 - -struct _GHeap -{ - GPtrArray *data; - GCompareFunc comparator; -}; - -GHeap * -g_heap_new (GCompareFunc comparator) -{ - GHeap *ret = g_slice_new (GHeap); - g_assert (comparator != NULL); - - ret->data = g_ptr_array_sized_new (DEFAULT_SIZE); - ret->comparator = comparator; - - return ret; -} - -void -g_heap_destroy (GHeap * heap) -{ - g_return_if_fail (heap != NULL); - - g_ptr_array_free (heap->data, TRUE); - g_slice_free (GHeap, heap); -} - -void -g_heap_clear (GHeap *heap) -{ - g_return_if_fail (heap != NULL); - - g_ptr_array_free (heap->data, TRUE); - heap->data = g_ptr_array_sized_new (DEFAULT_SIZE); -} - -#define HEAP_INDEX(heap, index) (g_ptr_array_index ((heap)->data, (index)-1)) - -void -g_heap_add (GHeap *heap, gpointer element) -{ - guint m; - - g_return_if_fail (heap != NULL); - - g_ptr_array_add (heap->data, element); - m = heap->data->len; - while (m != 1) - { - gpointer parent = HEAP_INDEX (heap, m / 2); - - if (heap->comparator (element, parent) == -1) - { - HEAP_INDEX (heap, m / 2) = element; - HEAP_INDEX (heap, m) = parent; - m /= 2; - } - else - break; - } -} - -gpointer -g_heap_peek_first (GHeap *heap) -{ - g_return_val_if_fail (heap != NULL, NULL); - - if (heap->data->len > 0) - return HEAP_INDEX (heap, 1); - else - return NULL; -} - -gpointer -g_heap_extract_first (GHeap * heap) -{ - gpointer ret; - - g_return_val_if_fail (heap != NULL, NULL); - - if (heap->data->len > 0) - { - guint m = heap->data->len; - guint i = 1, j; - ret = HEAP_INDEX (heap, 1); - - HEAP_INDEX (heap, 1) = HEAP_INDEX (heap, m); - - while (i * 2 <= m) - { - /* select the child which is supposed to come FIRST */ - if ((i * 2 + 1 <= m) - && (heap-> - comparator (HEAP_INDEX (heap, i * 2), - HEAP_INDEX (heap, i * 2 + 1)) == 1)) - j = i * 2 + 1; - else - j = i * 2; - - if (heap->comparator (HEAP_INDEX (heap, i), HEAP_INDEX (heap, j)) == - 1) - { - gpointer tmp = HEAP_INDEX (heap, i); - HEAP_INDEX (heap, i) = HEAP_INDEX (heap, j); - HEAP_INDEX (heap, j) = tmp; - i = j; - } - else - break; - } - - g_ptr_array_remove_index (heap->data, m - 1); - } - else - ret = NULL; - - return ret; -} - -guint -g_heap_size (GHeap *heap) -{ - g_return_val_if_fail (heap != NULL, 0); - - return heap->data->len; -} diff --git a/src/gheap.h b/src/gheap.h deleted file mode 100644 index b199ef69..00000000 --- a/src/gheap.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Header file for GHeap - * - * Copyright (C) 2006 Nokia Corporation. All rights reserved. - * - * Contact: Olli Salli (Nokia-M/Helsinki) <olli.salli@nokia.com> - * - * 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 - */ - -#ifndef __G_HEAP_H__ -#define __G_HEAP_H__ - -#include <glib.h> - -typedef struct _GHeap GHeap; - -GHeap *g_heap_new (GCompareFunc comparator); -void g_heap_destroy (GHeap *); -void g_heap_clear (GHeap *); - -void g_heap_add (GHeap *heap, gpointer element); -gpointer g_heap_peek_first (GHeap *heap); -gpointer g_heap_extract_first (GHeap *heap); - -guint g_heap_size (GHeap *heap); - -#endif diff --git a/src/gintset.c b/src/gintset.c deleted file mode 100644 index a8d8f4f1..00000000 --- a/src/gintset.c +++ /dev/null @@ -1,415 +0,0 @@ -/* gintset.c - Source for a Glib-link set of integers - * - * 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 - * - */ - -#include <string.h> -#include <glib.h> -#include "gintset.h" - -#define DEFAULT_SIZE 16 -#define DEFAULT_INCREMENT 8 -#define DEFAULT_INCREMENT_LOG2 3 - -struct _GIntSet -{ - guint32 *bits; - guint size; -}; - -static GIntSet * -_g_intset_new_with_size (guint size) -{ - GIntSet *set = g_new (GIntSet, 1); - set->size = MAX (size, DEFAULT_SIZE); - set->bits = g_new0 (guint32, set->size); - return set; -} - -GIntSet * -g_intset_new () -{ - return _g_intset_new_with_size (DEFAULT_SIZE); -} - -/** - * g_intset_destroy: - * @set: set - * - * delete the set - */ -void -g_intset_destroy (GIntSet *set) -{ - g_return_if_fail (set != NULL); - - g_free (set->bits); - g_free (set); -} - -/** - * g_intset_clear: - * @set : set - * - * Unset every integer in the set. - */ -void -g_intset_clear (GIntSet *set) -{ - g_return_if_fail (set != NULL); - - memset (set->bits, 0, set->size * sizeof (guint32)); -} - -/** - * g_intset_add: - * @set: set - * @element: integer to add - * - * Add an integer into a GIntSet - */ -void -g_intset_add (GIntSet *set, guint element) -{ - guint offset; - guint newsize; - - g_return_if_fail (set != NULL); - - offset = element >> 5; - - if (offset >= set->size) - { - newsize = ((offset>>DEFAULT_INCREMENT_LOG2) +1 ) << DEFAULT_INCREMENT_LOG2; - set->bits = g_renew(guint32, set->bits, newsize); - memset (set->bits + set->size, 0, sizeof(guint32) * (newsize - set->size)); - set->size = newsize; - g_assert(offset<newsize); - } - set->bits[offset] = set->bits[offset] | (1<<(element & 0x1f)); -} - -/** - * g_intset_remove: - * @set: set - * @element: integer to add - * - * Remove an integer from a GIntSet - * Returns: TRUE if element was in set - */ -gboolean -g_intset_remove (GIntSet *set, guint element) -{ - guint offset; - guint mask; - - g_return_val_if_fail (set != NULL, FALSE); - - offset = element >> 5; - mask = 1 << (element & 0x1f); - if (offset >= set->size) - return FALSE; - else if (!(set->bits[offset] & mask)) - return FALSE; - else - { - set->bits[offset] &= ~mask; - return TRUE; - } -} - -/** - * g_intset_is_member: - * @set: set - * @element: integer to test - * - * Tests if @element is a member of @set - * Returns: TRUE if element was in set - */ -gboolean -g_intset_is_member (const GIntSet *set, guint element) -{ - guint offset; - - g_return_val_if_fail (set != NULL, FALSE); - - offset = element >> 5; - if (offset >= set->size) - return FALSE; - else - return (set->bits[offset] & (1 << (element & 0x1f))); -} - -/** - * g_intset_foreach: - * @set: set - * @func: @GIntFunc to use to iterate the set - * @userdata: user data to pass to each call of @func - * - * Iterates every member of the set calling @func - */ - -void -g_intset_foreach (GIntSet *set, GIntFunc func, gpointer userdata) -{ - guint i, j; - - g_return_if_fail (set != NULL); - g_return_if_fail (func != NULL); - - for (i = 0; i < set->size; i++) - { - if (set->bits[i]) - for (j = 0; j < 32; j++) - { - if (set->bits[i] & 1 << j) - func (i * 32 + j, userdata); - } - } -} - - -static void -addint (guint32 i, gpointer data) -{ - GArray *array = (GArray *) data; - g_array_append_val (array, i); -} - -/** - * g_intset_to_array: - * @set: set to convert - * Convert a gintset to an array, allocates the array for you, hence you - * must free it after use. - */ -GArray * -g_intset_to_array (GIntSet *set) -{ - GArray *array; - - g_return_val_if_fail (set != NULL, NULL); - - array = g_array_new (FALSE, TRUE, sizeof (guint32)); - - g_intset_foreach (set, addint, array); - - return array; -} - -GIntSet * -g_intset_from_array (GArray *array) -{ - GIntSet *set; - guint32 max, i; - - g_return_val_if_fail (array != NULL, NULL); - - /* look at the 1st, last and middle values in the array to get an - * approximation of the largest */ - max = 0; - if (array->len > 0) - max = g_array_index (array, guint32, 0); - if (array->len > 1) - max = MAX (max, g_array_index (array, guint32, array->len - 1)); - if (array->len > 2) - max = MAX (max, g_array_index (array, guint32, (array->len - 1) >> 1)); - set = _g_intset_new_with_size (1 + (max >> 5)); - - for (i = 0; i < array->len; i++) - { - g_intset_add (set, g_array_index (array, guint32, i)); - } - - return set; -} - -int -g_intset_size(const GIntSet *set) -{ - int i, count = 0; - guint32 n; - - g_return_val_if_fail (set != NULL, 0); - - for (i = 0; i < set->size; i++) - { - n = set->bits[i]; - n = n - ((n >> 1) & 033333333333) - ((n >> 2) & 011111111111); - count += ((n + (n >> 3)) & 030707070707) % 63; - } - return count; -} - -gboolean -g_intset_is_equal (const GIntSet *left, const GIntSet *right) -{ - const GIntSet *large, *small; - int i; - - g_return_val_if_fail (left != NULL, FALSE); - g_return_val_if_fail (right != NULL, FALSE); - - if (left->size > right->size) - { - large = left; - small = right; - } - else - { - large = right; - small = left; - } - - for (i = 0; i < small->size; i++) - { - if (large->bits[i] != small->bits[i]) - return FALSE; - } - - for (i = small->size; i < large->size; i++) - { - if (large->bits[i] != 0) - return FALSE; - } - - return TRUE; -} - -GIntSet * -g_intset_copy (const GIntSet *orig) -{ - GIntSet *ret; - - g_return_val_if_fail (orig != NULL, NULL); - - ret = _g_intset_new_with_size (orig->size); - memcpy (ret->bits, orig->bits, (ret->size * sizeof (guint32))); - - return ret; -} - -GIntSet * -g_intset_intersection (const GIntSet *left, const GIntSet *right) -{ - const GIntSet *large, *small; - GIntSet *ret; - int i; - - g_return_val_if_fail (left != NULL, NULL); - g_return_val_if_fail (right != NULL, NULL); - - if (left->size > right->size) - { - large = left; - small = right; - } - else - { - large = right; - small = left; - } - - ret = g_intset_copy (small); - - for (i = 0; i < ret->size; i++) - { - ret->bits[i] &= large->bits[i]; - } - - return ret; -} - -GIntSet * -g_intset_union (const GIntSet *left, const GIntSet *right) -{ - const GIntSet *large, *small; - GIntSet *ret; - int i; - - g_return_val_if_fail (left != NULL, NULL); - g_return_val_if_fail (right != NULL, NULL); - - if (left->size > right->size) - { - large = left; - small = right; - } - else - { - large = right; - small = left; - } - - ret = g_intset_copy (large); - - for (i = 0; i < small->size; i++) - { - ret->bits[i] |= small->bits[i]; - } - - return ret; -} - -GIntSet * -g_intset_difference (const GIntSet *left, const GIntSet *right) -{ - GIntSet *ret; - int i; - - g_return_val_if_fail (left != NULL, NULL); - g_return_val_if_fail (right != NULL, NULL); - - ret = g_intset_copy (left); - - for (i = 0; i < MIN (right->size, left->size); i++) - { - ret->bits[i] &= ~right->bits[i]; - } - - return ret; -} - -GIntSet * -g_intset_symmetric_difference (const GIntSet *left, const GIntSet *right) -{ - const GIntSet *large, *small; - GIntSet *ret; - int i; - - g_return_val_if_fail (left != NULL, NULL); - g_return_val_if_fail (right != NULL, NULL); - - if (left->size > right->size) - { - large = left; - small = right; - } - else - { - large = right; - small = left; - } - - ret = g_intset_copy (large); - - for (i = 0; i < small->size; i++) - { - ret->bits[i] ^= small->bits[i]; - } - - return ret; -} diff --git a/src/gintset.h b/src/gintset.h deleted file mode 100644 index ab8e09b7..00000000 --- a/src/gintset.h +++ /dev/null @@ -1,50 +0,0 @@ -/* gintset.h - Headers for a Glib-link set of integers - * - * 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 - * - */ - -#ifndef __G_INTSET_H__ -#define __G_INTSET_H__ - -#include <glib-object.h> - -typedef struct _GIntSet GIntSet; -typedef void (*GIntFunc) (guint i, gpointer userdata); - -GIntSet *g_intset_new (); -void g_intset_destroy (GIntSet *); -void g_intset_clear (GIntSet *); - -void g_intset_add (GIntSet *set, guint element); -gboolean g_intset_remove (GIntSet *set, guint element); -gboolean g_intset_is_member (const GIntSet *set, guint element); - -void g_intset_foreach (GIntSet *set, GIntFunc func, gpointer userdata); -GArray *g_intset_to_array (GIntSet *set); -GIntSet *g_intset_from_array (GArray *array); - -int g_intset_size(const GIntSet *set); - -gboolean g_intset_is_equal (const GIntSet *left, const GIntSet *right); - -GIntSet *g_intset_copy (const GIntSet *orig); -GIntSet *g_intset_intersection (const GIntSet *left, const GIntSet *right); -GIntSet *g_intset_union (const GIntSet *left, const GIntSet *right); -GIntSet *g_intset_difference (const GIntSet *left, const GIntSet *right); -GIntSet *g_intset_symmetric_difference (const GIntSet *left, const GIntSet *right); - -#endif /*__G_INTSET_H__*/ diff --git a/src/group-mixin-signals-marshal.list b/src/group-mixin-signals-marshal.list deleted file mode 100644 index c1333dfa..00000000 --- a/src/group-mixin-signals-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:UINT,UINT -VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT diff --git a/src/group-mixin.c b/src/group-mixin.c deleted file mode 100644 index 5e9ca25b..00000000 --- a/src/group-mixin.c +++ /dev/null @@ -1,877 +0,0 @@ -/* - * group-mixin.c - Source for GroupMixin - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> - -#include "ansi.h" - -#include "telepathy-errors.h" - -#define DEBUG_FLAG DEBUG_GROUPS - -#include "debug.h" -#include "group-mixin.h" -#include "group-mixin-signals-marshal.h" - -static const char *group_change_reason_str(guint reason) -{ - switch (reason) - { - case TP_CHANNEL_GROUP_CHANGE_REASON_NONE: - return "unspecified reason"; - case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE: - return "offline"; - case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED: - return "kicked"; - case TP_CHANNEL_GROUP_CHANGE_REASON_BUSY: - return "busy"; - case TP_CHANNEL_GROUP_CHANGE_REASON_INVITED: - return "invited"; - case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED: - return "banned"; - default: - return "(unknown reason code)"; - } -} - -typedef struct { - Handle actor; - guint reason; - const gchar *message; - HandleRepo *repo; -} LocalPendingInfo; - -LocalPendingInfo * -new_local_pending_info(HandleRepo *repo, Handle actor, - guint reason, const gchar *message) { - LocalPendingInfo *info = g_slice_new0(LocalPendingInfo); - info->actor = actor; - info->reason = reason; - info->message = g_strdup(message); - info->repo = repo; - handle_ref(repo, TP_HANDLE_TYPE_CONTACT, actor); - - return info; -} - -void -free_local_pending_info(LocalPendingInfo *info) { - g_free((gchar *)info->message); - handle_unref(info->repo, TP_HANDLE_TYPE_CONTACT, info->actor); - g_slice_free(LocalPendingInfo, info); -} - - -struct _GroupMixinPrivate { - HandleSet *actors; - GHashTable *handle_owners; - GHashTable *local_pending_info; -}; - -/** - * group_mixin_class_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObjectClass - */ -GQuark -group_mixin_class_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string("GroupMixinClassOffsetQuark"); - return offset_quark; -} - -/** - * group_mixin_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObject - */ -GQuark -group_mixin_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string("GroupMixinOffsetQuark"); - return offset_quark; -} - -void group_mixin_class_init (GObjectClass *obj_cls, - glong offset, - GroupMixinAddMemberFunc add_func, - GroupMixinRemMemberFunc rem_func) -{ - GroupMixinClass *mixin_cls; - - g_assert (G_IS_OBJECT_CLASS (obj_cls)); - - g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls), - GROUP_MIXIN_CLASS_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin_cls = GROUP_MIXIN_CLASS (obj_cls); - - mixin_cls->add_member = add_func; - mixin_cls->remove_member = rem_func; - - mixin_cls->group_flags_changed_signal_id = - g_signal_new ("group-flags-changed", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - group_mixin_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - mixin_cls->members_changed_signal_id = - g_signal_new ("members-changed", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - group_mixin_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT, - G_TYPE_NONE, 7, G_TYPE_STRING, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, G_TYPE_UINT, G_TYPE_UINT); -} - -void group_mixin_init (GObject *obj, - glong offset, - HandleRepo *handle_repo, - Handle self_handle) -{ - GroupMixin *mixin; - - g_assert (G_IS_OBJECT (obj)); - - g_type_set_qdata (G_OBJECT_TYPE (obj), - GROUP_MIXIN_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin = GROUP_MIXIN (obj); - - mixin->handle_repo = handle_repo; - mixin->self_handle = self_handle; - - mixin->group_flags = 0; - - mixin->members = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT); - mixin->local_pending = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT); - mixin->remote_pending = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT); - - mixin->priv = g_new0 (GroupMixinPrivate, 1); - mixin->priv->handle_owners = g_hash_table_new (g_direct_hash, g_direct_equal); - mixin->priv->local_pending_info = g_hash_table_new_full ( - g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify) - free_local_pending_info); - mixin->priv->actors = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT); -} - -static void -handle_owners_foreach_unref (gpointer key, - gpointer value, - gpointer user_data) -{ - GroupMixin *mixin = user_data; - - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - GPOINTER_TO_UINT (key)); - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - GPOINTER_TO_UINT (value)); -} - -void group_mixin_finalize (GObject *obj) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - handle_set_destroy (mixin->priv->actors); - - g_hash_table_foreach (mixin->priv->handle_owners, - handle_owners_foreach_unref, - mixin); - - g_hash_table_destroy (mixin->priv->handle_owners); - g_hash_table_destroy (mixin->priv->local_pending_info); - - g_free (mixin->priv); - - handle_set_destroy (mixin->members); - handle_set_destroy (mixin->local_pending); - handle_set_destroy (mixin->remote_pending); -} - -gboolean -group_mixin_get_self_handle (GObject *obj, guint *ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - if (handle_set_is_member (mixin->members, mixin->self_handle) || - handle_set_is_member (mixin->local_pending, mixin->self_handle) || - handle_set_is_member (mixin->remote_pending, mixin->self_handle)) - { - *ret = mixin->self_handle; - } - else - { - *ret = 0; - } - - return TRUE; -} - -gboolean -group_mixin_get_group_flags (GObject *obj, guint *ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - *ret = mixin->group_flags; - - return TRUE; -} - -gboolean -group_mixin_add_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error) -{ - GroupMixinClass *mixin_cls = GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - GroupMixin *mixin = GROUP_MIXIN (obj); - guint i; - Handle handle; - - /* reject invalid handles */ - if (!handles_are_valid (mixin->handle_repo, - TP_HANDLE_TYPE_CONTACT, - contacts, - FALSE, - error)) - return FALSE; - - /* check that adding is allowed by flags */ - for (i = 0; i < contacts->len; i++) - { - handle = g_array_index (contacts, Handle, i); - - if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) == 0 && - !handle_set_is_member (mixin->local_pending, handle)) - { - DEBUG ("handle %u cannot be added to members without GROUP_FLAG_CAN_ADD", - handle); - - *error = g_error_new (TELEPATHY_ERRORS, PermissionDenied, - "handle %u cannot be added to members without GROUP_FLAG_CAN_ADD", - handle); - - return FALSE; - } - } - - /* add handle by handle */ - for (i = 0; i < contacts->len; i++) - { - handle = g_array_index (contacts, Handle, i); - - if (handle_set_is_member (mixin->members, handle)) - { - DEBUG ("handle %u is already a member, skipping", handle); - - continue; - } - - g_assert(mixin_cls->add_member); - if (!mixin_cls->add_member (obj, handle, message, error)) - { - return FALSE; - } - } - - return TRUE; -} - -gboolean -group_mixin_remove_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error) -{ - GroupMixinClass *mixin_cls = GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - GroupMixin *mixin = GROUP_MIXIN (obj); - guint i; - Handle handle; - - /* reject invalid handles */ - if (!handles_are_valid (mixin->handle_repo, - TP_HANDLE_TYPE_CONTACT, - contacts, - FALSE, - error)) - return FALSE; - - /* check removing is allowed by flags */ - for (i = 0; i < contacts->len; i++) - { - handle = g_array_index (contacts, Handle, i); - - if (handle_set_is_member (mixin->members, handle)) - { - if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) == 0) - { - DEBUG ("handle %u cannot be removed from members without GROUP_FLAG_CAN_REMOVE", - handle); - - *error = g_error_new (TELEPATHY_ERRORS, PermissionDenied, - "handle %u cannot be removed from members without GROUP_FLAG_CAN_REMOVE", - handle); - - return FALSE; - } - } - else if (handle_set_is_member (mixin->remote_pending, handle)) - { - if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_RESCIND) == 0) - { - DEBUG ("handle %u cannot be removed from remote pending without GROUP_FLAG_CAN_RESCIND", - handle); - - *error = g_error_new (TELEPATHY_ERRORS, PermissionDenied, - "handle %u cannot be removed from remote pending without GROUP_FLAG_CAN_RESCIND", - handle); - - return FALSE; - } - } - else if (!handle_set_is_member (mixin->local_pending, handle)) - { - DEBUG ("handle %u is not a current or pending member", - handle); - - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, - "handle %u is not a current or pending member", handle); - - return FALSE; - } - } - - /* remove handle by handle */ - for (i = 0; i < contacts->len; i++) - { - handle = g_array_index (contacts, Handle, i); - - if (!mixin_cls->remove_member (obj, handle, message, error)) - { - return FALSE; - } - } - - return TRUE; -} - -gboolean -group_mixin_get_members (GObject *obj, GArray **ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - *ret = handle_set_to_array (mixin->members); - - return TRUE; -} - -gboolean -group_mixin_get_local_pending_members (GObject *obj, GArray **ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - *ret = handle_set_to_array (mixin->local_pending); - - return TRUE; -} - -static void -local_pending_members_with_info_foreach(HandleSet *set, - Handle i, gpointer userdata) { - gpointer *data = (gpointer *)userdata; - GroupMixin *mixin = (GroupMixin *) data[0]; - GroupMixinPrivate *priv = mixin->priv; - GPtrArray *array = (GPtrArray *)data[1]; - GValueArray *varray = g_value_array_new(4); - LocalPendingInfo *info = g_hash_table_lookup(priv->local_pending_info, - GUINT_TO_POINTER(i)); - g_assert(info != NULL); - - g_value_array_append(varray, NULL); - g_value_init(g_value_array_get_nth(varray, 0), G_TYPE_UINT); - g_value_set_uint(g_value_array_get_nth(varray, 0), i); - - g_value_array_append(varray, NULL); - g_value_init(g_value_array_get_nth(varray, 1), G_TYPE_UINT); - g_value_set_uint(g_value_array_get_nth(varray, 1), info->actor); - - g_value_array_append(varray, NULL); - g_value_init(g_value_array_get_nth(varray, 2), G_TYPE_UINT); - g_value_set_uint(g_value_array_get_nth(varray, 2), info->reason); - - g_value_array_append(varray, NULL); - g_value_init(g_value_array_get_nth(varray, 3), G_TYPE_STRING); - g_value_set_string(g_value_array_get_nth(varray, 3), info->message); - - g_ptr_array_add(array, varray); -} - -gboolean -group_mixin_get_local_pending_members_with_info (GObject *obj, GPtrArray **ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - gpointer data[2] = { mixin, NULL }; - - *ret = g_ptr_array_new(); - data[1] = *ret; - - handle_set_foreach(mixin->local_pending, - local_pending_members_with_info_foreach , data); - - return TRUE; -} - -gboolean -group_mixin_get_remote_pending_members (GObject *obj, GArray **ret, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - *ret = handle_set_to_array (mixin->remote_pending); - - return TRUE; -} - -gboolean -group_mixin_get_all_members (GObject *obj, GArray **ret, GArray **ret1, GArray **ret2, GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - - *ret = handle_set_to_array (mixin->members); - *ret1 = handle_set_to_array (mixin->local_pending); - *ret2 = handle_set_to_array (mixin->remote_pending); - - return TRUE; -} - -gboolean -group_mixin_get_handle_owners (GObject *obj, - const GArray *handles, - GArray **ret, - GError **error) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - GroupMixinPrivate *priv = mixin->priv; - guint i; - - if ((mixin->group_flags & - TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES) == 0) - { - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, - "channel doesn't have channel specific handles"); - - return FALSE; - } - - if (!handles_are_valid (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - handles, FALSE, error)) - { - return FALSE; - } - - *ret = g_array_sized_new (FALSE, FALSE, sizeof (Handle), handles->len); - - for (i = 0; i < handles->len; i++) - { - Handle local_handle = g_array_index (handles, Handle, i); - Handle owner_handle; - - if (!handle_set_is_member (mixin->members, local_handle)) - { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "handle %u is not a member", local_handle); - - g_array_free (*ret, TRUE); - *ret = NULL; - - return FALSE; - } - - owner_handle = GPOINTER_TO_UINT ( - g_hash_table_lookup (priv->handle_owners, - GUINT_TO_POINTER (local_handle))); - - g_array_append_val (*ret, owner_handle); - } - - return TRUE; -} - -#define GFTS_APPEND_FLAG_IF_SET(flag) \ - if (flags & flag) \ - { \ - if (i++ > 0) \ - g_string_append (str, "|"); \ - g_string_append (str, #flag + 22); \ - } - -static gchar * -group_flags_to_string (TpChannelGroupFlags flags) -{ - gint i = 0; - GString *str; - - str = g_string_new ("[" ANSI_BOLD_OFF); - - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_ADD); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_REMOVE); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_RESCIND); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_REJECT); - GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND); - - g_string_append (str, ANSI_BOLD_ON "]"); - - return g_string_free (str, FALSE); -} - -/** - * group_mixin_change_flags: - * - * Request a change to be made to the flags. Emits the - * signal with the changes which were made. - */ -void -group_mixin_change_flags (GObject *obj, - TpChannelGroupFlags add, - TpChannelGroupFlags remove) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - GroupMixinClass *mixin_cls = GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - TpChannelGroupFlags added, removed; - - added = add & ~mixin->group_flags; - mixin->group_flags |= added; - - removed = remove & mixin->group_flags; - mixin->group_flags &= ~removed; - - if (add != 0 || remove != 0) - { - gchar *str_added, *str_removed, *str_flags; - - if (DEBUGGING) - { - str_added = group_flags_to_string (added); - str_removed = group_flags_to_string (removed); - str_flags = group_flags_to_string (mixin->group_flags); - - printf (ANSI_BOLD_ON ANSI_FG_WHITE - "%s: emitting group flags changed\n" - " added : %s\n" - " removed : %s\n" - " flags now: %s\n" ANSI_RESET, - G_STRFUNC, str_added, str_removed, str_flags); - - fflush (stdout); - - g_free (str_added); - g_free (str_removed); - g_free (str_flags); - } - - g_signal_emit(obj, mixin_cls->group_flags_changed_signal_id, 0, added, removed); - } -} - -static gchar * -member_array_to_string (HandleRepo *repo, const GArray *array) -{ - GString *str; - guint i; - - str = g_string_new ("[" ANSI_BOLD_OFF); - - for (i = 0; i < array->len; i++) - { - Handle handle; - const gchar *handle_str; - - handle = g_array_index (array, guint32, i); - handle_str = handle_inspect (repo, TP_HANDLE_TYPE_CONTACT, handle); - - g_string_append_printf (str, "%s%u (%s)", - (i > 0) ? "\n " : "", - handle, handle_str); - } - - g_string_append (str, ANSI_BOLD_ON "]"); - - return g_string_free (str, FALSE); -} - -static void remove_handle_owners_if_exist (GObject *obj, GArray *array); - -void -local_pending_added_foreach(guint i, gpointer userdata) { - gpointer *data = (gpointer *)userdata; - GroupMixin *mixin = (GroupMixin *) data[0]; - GroupMixinPrivate *priv = mixin->priv; - LocalPendingInfo *info = (LocalPendingInfo *)data[1]; - - g_hash_table_insert(priv->local_pending_info, - GUINT_TO_POINTER(i), - new_local_pending_info(mixin->handle_repo, - info->actor, info->reason, info->message)); -} - -static void -local_pending_added(GroupMixin *mixin, GIntSet *added, - Handle actor, guint reason, const gchar *message) { - LocalPendingInfo info; - gpointer data[2] = { mixin, &info }; - info.actor = actor; - info.reason = reason; - info.message = message; - - g_intset_foreach(added, local_pending_added_foreach, data); -} - -void -local_pending_remove_foreach(guint i, gpointer userdata) { - GroupMixin *mixin = (GroupMixin *) userdata; - GroupMixinPrivate *priv = mixin->priv; - - g_hash_table_remove(priv->local_pending_info, GUINT_TO_POINTER(i)); -} - -static void -local_pending_remove(GroupMixin *mixin, GIntSet *removed) { - g_intset_foreach(removed, local_pending_remove_foreach, mixin); -} - -/** - * group_mixin_change_members: - * - * Request members to be added, removed or marked as local or remote pending. - * Changes member sets, references, and emits the MembersChanged signal. - */ -gboolean -group_mixin_change_members (GObject *obj, - const gchar *message, - GIntSet *add, - GIntSet *remove, - GIntSet *local_pending, - GIntSet *remote_pending, - Handle actor, - guint reason) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - GroupMixinClass *mixin_cls = GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - GIntSet *new_add, *new_remove, *new_local_pending, - *new_remote_pending, *tmp, *tmp2; - gboolean ret; - - g_assert (add != NULL); - g_assert (remove != NULL); - g_assert (local_pending != NULL); - g_assert (remote_pending != NULL); - - /* members + add */ - new_add = handle_set_update (mixin->members, add); - - /* members - remove */ - new_remove = handle_set_difference_update (mixin->members, remove); - - /* members - local_pending */ - tmp = handle_set_difference_update (mixin->members, local_pending); - g_intset_destroy (tmp); - - /* members - remote_pending */ - tmp = handle_set_difference_update (mixin->members, remote_pending); - g_intset_destroy (tmp); - - - /* local pending + local_pending */ - new_local_pending = handle_set_update (mixin->local_pending, local_pending); - local_pending_added(mixin, local_pending, actor, reason, message); - - /* local pending - add */ - tmp = handle_set_difference_update (mixin->local_pending, add); - local_pending_remove(mixin, tmp); - g_intset_destroy (tmp); - - /* local pending - remove */ - tmp = handle_set_difference_update (mixin->local_pending, remove); - local_pending_remove(mixin, tmp); - - tmp2 = g_intset_union (new_remove, tmp); - g_intset_destroy (new_remove); - g_intset_destroy (tmp); - new_remove = tmp2; - - /* local pending - remote_pending */ - tmp = handle_set_difference_update (mixin->local_pending, remote_pending); - local_pending_remove(mixin, tmp); - g_intset_destroy (tmp); - - - /* remote pending + remote_pending */ - new_remote_pending = handle_set_update (mixin->remote_pending, remote_pending); - - /* remote pending - add */ - tmp = handle_set_difference_update (mixin->remote_pending, add); - g_intset_destroy (tmp); - - /* remote pending - remove */ - tmp = handle_set_difference_update (mixin->remote_pending, remove); - tmp2 = g_intset_union (new_remove, tmp); - g_intset_destroy (new_remove); - g_intset_destroy (tmp); - new_remove = tmp2; - - /* remote pending - local_pending */ - tmp = handle_set_difference_update (mixin->remote_pending, local_pending); - g_intset_destroy (tmp); - - if (g_intset_size (new_add) > 0 || - g_intset_size (new_remove) > 0 || - g_intset_size (new_local_pending) > 0 || - g_intset_size (new_remote_pending) > 0) - { - GArray *arr_add, *arr_remove, *arr_local, *arr_remote; - gchar *add_str, *rem_str, *local_str, *remote_str; - - /* translate intsets to arrays */ - arr_add = g_intset_to_array (new_add); - arr_remove = g_intset_to_array (new_remove); - arr_local = g_intset_to_array (new_local_pending); - arr_remote = g_intset_to_array (new_remote_pending); - - /* remove any handle owner mappings */ - remove_handle_owners_if_exist (obj, arr_remove); - - if (DEBUGGING) - { - add_str = member_array_to_string (mixin->handle_repo, arr_add); - rem_str = member_array_to_string (mixin->handle_repo, arr_remove); - local_str = member_array_to_string (mixin->handle_repo, arr_local); - remote_str = member_array_to_string (mixin->handle_repo, arr_remote); - - printf (ANSI_BOLD_ON ANSI_FG_CYAN - "%s: emitting members changed\n" - " message : \"%s\"\n" - " added : %s\n" - " removed : %s\n" - " local_pending : %s\n" - " remote_pending: %s\n" - " actor : %u\n" - " reason : %u: %s\n" ANSI_RESET, - G_STRFUNC, message, add_str, rem_str, local_str, remote_str, - actor, reason, group_change_reason_str(reason)); - - fflush (stdout); - - g_free (add_str); - g_free (rem_str); - g_free (local_str); - g_free (remote_str); - } - - if (actor) - { - handle_set_add (mixin->priv->actors, actor); - } - /* emit signal */ - g_signal_emit(obj, mixin_cls->members_changed_signal_id, 0, - message, - arr_add, arr_remove, - arr_local, arr_remote, - actor, reason); - - /* free arrays */ - g_array_free (arr_add, TRUE); - g_array_free (arr_remove, TRUE); - g_array_free (arr_local, TRUE); - g_array_free (arr_remote, TRUE); - - ret = TRUE; - } - else - { - DEBUG ("not emitting signal, nothing changed"); - - ret = FALSE; - } - - /* free intsets */ - g_intset_destroy (new_add); - g_intset_destroy (new_remove); - g_intset_destroy (new_local_pending); - g_intset_destroy (new_remote_pending); - - return ret; -} - -void -group_mixin_add_handle_owner (GObject *obj, - Handle local_handle, - Handle owner_handle) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - GroupMixinPrivate *priv = mixin->priv; - - g_hash_table_insert (priv->handle_owners, GUINT_TO_POINTER (local_handle), - GUINT_TO_POINTER (owner_handle)); - - handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - local_handle); - handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - owner_handle); -} - -static void -remove_handle_owners_if_exist (GObject *obj, GArray *array) -{ - GroupMixin *mixin = GROUP_MIXIN (obj); - GroupMixinPrivate *priv = mixin->priv; - guint i; - - for (i = 0; i < array->len; i++) - { - Handle handle = g_array_index (array, guint32, i); - gpointer local_handle, owner_handle; - - if (g_hash_table_lookup_extended (priv->handle_owners, - GUINT_TO_POINTER (handle), - &local_handle, - &owner_handle)) - { - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - GPOINTER_TO_UINT (local_handle)); - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, - GPOINTER_TO_UINT (owner_handle)); - - g_hash_table_remove (priv->handle_owners, GUINT_TO_POINTER (handle)); - } - } -} - diff --git a/src/group-mixin.h b/src/group-mixin.h deleted file mode 100644 index d074bca3..00000000 --- a/src/group-mixin.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * group-mixin.h - Header for GroupMixin - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * - * 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 - */ - -#ifndef __GROUP_MIXIN_H__ -#define __GROUP_MIXIN_H__ - -#include "handle-repository.h" -#include "handle-set.h" - -G_BEGIN_DECLS - -typedef struct _GroupMixinClass GroupMixinClass; -typedef struct _GroupMixin GroupMixin; -typedef struct _GroupMixinPrivate GroupMixinPrivate; - -typedef gboolean (*GroupMixinAddMemberFunc) (GObject *obj, Handle handle, const gchar *message, GError **error); -typedef gboolean (*GroupMixinRemMemberFunc) (GObject *obj, Handle handle, const gchar *message, GError **error); - -struct _GroupMixinClass { - GroupMixinAddMemberFunc add_member; - GroupMixinRemMemberFunc remove_member; - - guint group_flags_changed_signal_id; - guint members_changed_signal_id; -}; - -struct _GroupMixin { - HandleRepo *handle_repo; - Handle self_handle; - - TpChannelGroupFlags group_flags; - - HandleSet *members; - HandleSet *local_pending; - HandleSet *remote_pending; - - GroupMixinPrivate *priv; -}; - -/* TYPE MACROS */ -#define GROUP_MIXIN_CLASS_OFFSET_QUARK (group_mixin_class_get_offset_quark()) -#define GROUP_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GROUP_MIXIN_CLASS_OFFSET_QUARK))) -#define GROUP_MIXIN_CLASS(o) ((GroupMixinClass *)((guchar *) o + GROUP_MIXIN_CLASS_OFFSET (o))) - -#define GROUP_MIXIN_OFFSET_QUARK (group_mixin_get_offset_quark()) -#define GROUP_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GROUP_MIXIN_OFFSET_QUARK))) -#define GROUP_MIXIN(o) ((GroupMixin *)((guchar *) o + GROUP_MIXIN_OFFSET (o))) - -GQuark group_mixin_class_get_offset_quark (void); -GQuark group_mixin_get_offset_quark (void); - -void group_mixin_class_init (GObjectClass *obj_cls, glong offset, GroupMixinAddMemberFunc add_func, GroupMixinRemMemberFunc rem_func); - -void group_mixin_init (GObject *obj, glong offset, HandleRepo *handle_repo, Handle self_handle); -void group_mixin_finalize (GObject *obj); - -gboolean group_mixin_get_self_handle (GObject *obj, guint *ret, GError **error); -gboolean group_mixin_get_group_flags (GObject *obj, guint *ret, GError **error); - -gboolean group_mixin_add_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error); -gboolean group_mixin_remove_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error); - -gboolean group_mixin_get_members (GObject *obj, GArray **ret, GError **error); -gboolean group_mixin_get_local_pending_members (GObject *obj, GArray **ret, GError **error); -gboolean group_mixin_get_local_pending_members_with_info (GObject *obj, GPtrArray **ret, GError **error); -gboolean group_mixin_get_remote_pending_members (GObject *obj, GArray **ret, GError **error); -gboolean group_mixin_get_all_members (GObject *obj, GArray **ret, GArray **ret1, GArray **ret2, GError **error); - -gboolean group_mixin_get_handle_owners (GObject *obj, const GArray *handles, GArray **ret, GError **error); - -void group_mixin_change_flags (GObject *obj, TpChannelGroupFlags add, TpChannelGroupFlags remove); -gboolean group_mixin_change_members (GObject *obj, const gchar *message, GIntSet *add, GIntSet *remove, GIntSet *local_pending, GIntSet *remote_pending, Handle actor, guint reason); - -void group_mixin_add_handle_owner (GObject *obj, Handle local_handle, Handle owner_handle); - -G_END_DECLS - -#endif /* #ifndef __GROUP_MIXIN_H__ */ diff --git a/src/handle-repository.c b/src/handle-repository.c deleted file mode 100644 index 2d3b9c65..00000000 --- a/src/handle-repository.c +++ /dev/null @@ -1,871 +0,0 @@ -/* - * handles.c - mechanism to store and retrieve handles on a connection - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <glib.h> -#include <dbus/dbus-glib.h> -#include <string.h> - -#include "gheap.h" -#include "handle-repository.h" -#include "handle-set.h" -#include "telepathy-errors.h" -#include "telepathy-helpers.h" - -#include "config.h" - -#ifdef ENABLE_HANDLE_LEAK_DEBUG -#include <stdlib.h> -#include <stdio.h> -#include <execinfo.h> - -typedef struct _HandleLeakTrace HandleLeakTrace; - -struct _HandleLeakTrace -{ - char **trace; - int len; -}; - -static void -handle_leak_trace_free (HandleLeakTrace *hltrace) -{ - free (hltrace->trace); - g_free (hltrace); -} - -static void -handle_leak_trace_free_gfunc (gpointer data, gpointer user_data) -{ - return handle_leak_trace_free ((HandleLeakTrace *) data); -} - -#endif /* ENABLE_HANDLE_LEAK_DEBUG */ - -typedef struct _HandlePriv HandlePriv; - -struct _HandlePriv -{ - guint refcount; - gchar *string; -#ifdef ENABLE_HANDLE_LEAK_DEBUG - GSList *traces; -#endif /* ENABLE_HANDLE_LEAK_DEBUG */ - GData *datalist; -}; - -struct _HandleRepo -{ - GHashTable *contact_handles; - GHashTable *room_handles; - GData *list_handles; - GHashTable *contact_strings; - GHashTable *room_strings; - GHeap *free_contact_handles; - GHeap *free_room_handles; - guint contact_serial; - guint room_serial; - GData *client_contact_handle_sets; - GData *client_room_handle_sets; - DBusGProxy *bus_service_proxy; -}; - -static const char *list_handle_strings[LIST_HANDLE_LAST] = -{ - "publish", /* LIST_HANDLE_PUBLISH */ - "subscribe", /* LIST_HANDLE_SUBSCRIBE */ - "known", /* LIST_HANDLE_KNOWN */ -}; - -/* private functions */ - -static HandlePriv * -handle_priv_new () -{ - HandlePriv *priv; - - priv = g_new0 (HandlePriv, 1); - - g_datalist_init (&(priv->datalist)); - return priv; -} - -static void -handle_priv_free (HandlePriv *priv) -{ - g_assert (priv != NULL); - - g_free(priv->string); - g_datalist_clear (&(priv->datalist)); -#ifdef ENABLE_HANDLE_LEAK_DEBUG - g_slist_foreach (priv->traces, handle_leak_trace_free_gfunc, NULL); - g_slist_free (priv->traces); -#endif /* ENABLE_HANDLE_LEAK_DEBUG */ - g_free (priv); -} - -HandlePriv * -handle_priv_lookup (HandleRepo *repo, - TpHandleType type, - Handle handle) -{ - HandlePriv *priv = NULL; - - g_assert (repo != NULL); - g_assert (handle_type_is_valid (type, NULL)); - g_assert (handle != 0); - - switch (type) { - case TP_HANDLE_TYPE_CONTACT: - priv = g_hash_table_lookup (repo->contact_handles, GINT_TO_POINTER (handle)); - break; - case TP_HANDLE_TYPE_ROOM: - priv = g_hash_table_lookup (repo->room_handles, GINT_TO_POINTER (handle)); - break; - case TP_HANDLE_TYPE_LIST: - priv = g_datalist_id_get_data (&repo->list_handles, handle); - break; - default: - g_assert_not_reached(); - } - - return priv; -} - -static Handle -handle_alloc (HandleRepo *repo, TpHandleType type) -{ - Handle ret = 0; - - g_assert (repo != NULL); - g_assert (handle_type_is_valid (type, NULL)); - - switch (type) { - case TP_HANDLE_TYPE_CONTACT: - if (g_heap_size (repo->free_contact_handles)) - ret = GPOINTER_TO_UINT (g_heap_extract_first (repo->free_contact_handles)); - else - ret = repo->contact_serial++; - break; - case TP_HANDLE_TYPE_ROOM: - if (g_heap_size (repo->free_room_handles)) - ret = GPOINTER_TO_UINT (g_heap_extract_first (repo->free_room_handles)); - else - ret = repo->room_serial++; - break; - default: - g_assert_not_reached(); - } - - return ret; -} - -static gint -handle_compare_func (gconstpointer a, gconstpointer b) -{ - Handle first = GPOINTER_TO_UINT (a); - Handle second = GPOINTER_TO_UINT (b); - - return (first == second) ? 0 : ((first < second) ? -1 : 1); -} - -void -handle_priv_remove (HandleRepo *repo, - TpHandleType type, - Handle handle) -{ - HandlePriv *priv; - const gchar *string; - - g_assert (handle_type_is_valid (type, NULL)); - g_assert (handle != 0); - g_assert (repo != NULL); - - priv = handle_priv_lookup (repo, type, handle); - - g_assert (priv != NULL); - - string = priv->string; - - switch (type) { - case TP_HANDLE_TYPE_CONTACT: - g_hash_table_remove (repo->contact_strings, string); - g_hash_table_remove (repo->contact_handles, GINT_TO_POINTER (handle)); - if (handle == repo->contact_serial-1) - repo->contact_serial--; - else - g_heap_add (repo->free_contact_handles, GUINT_TO_POINTER (handle)); - break; - case TP_HANDLE_TYPE_ROOM: - g_hash_table_remove (repo->room_strings, string); - g_hash_table_remove (repo->room_handles, GINT_TO_POINTER (handle)); - if (handle == repo->room_serial-1) - repo->room_serial--; - else - g_heap_add (repo->free_room_handles, GUINT_TO_POINTER (handle)); - break; - case TP_HANDLE_TYPE_LIST: - g_dataset_id_remove_data (&repo->list_handles, handle); - break; - default: - g_assert_not_reached (); - } -} - -void -handles_name_owner_changed_cb (DBusGProxy *proxy, - const gchar *name, - const gchar *old_owner, - const gchar *new_owner, - gpointer data) -{ - HandleRepo *repo = (HandleRepo *) data; - - if (old_owner && strlen (old_owner)) - { - if (!new_owner || !strlen (new_owner)) - { - g_datalist_remove_data (&repo->client_contact_handle_sets, old_owner); - g_datalist_remove_data (&repo->client_room_handle_sets, old_owner); - } - } -} - -/* public API */ - -/** - * handle_name_is_valid - * - * Validates a name for given handle type and returns TRUE/FALSE - * on success/failure. In the latter case further information is - * provided through error if set. - */ -gboolean -handle_name_is_valid (TpHandleType type, const gchar *name, GError **error) -{ - switch (type) { - case TP_HANDLE_TYPE_CONTACT: - case TP_HANDLE_TYPE_ROOM: - case TP_HANDLE_TYPE_LIST: - /* FIXME actually do some checking */ - return TRUE; - default: - g_assert_not_reached(); - } - return TRUE; -} - -gboolean -handle_type_is_valid (TpHandleType type, GError **error) -{ - gboolean ret; - - if (type > TP_HANDLE_TYPE_NONE && type <= TP_HANDLE_TYPE_LIST) - { - ret = TRUE; - } - else - { - if (error != NULL) - { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "invalid handle type %u", type); - } - - ret = FALSE; - } - - return ret; -} - -HandleRepo * -handle_repo_new () -{ - HandleRepo *repo; - Handle h; - - g_assert(sizeof(list_handle_strings)/sizeof(char *) == LIST_HANDLE_LAST); - - repo = g_new0 (HandleRepo, 1); - - repo->contact_handles = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) handle_priv_free); - - repo->room_handles = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) handle_priv_free); - - repo->contact_strings = g_hash_table_new (g_str_hash, g_str_equal); - repo->room_strings = g_hash_table_new (g_str_hash, g_str_equal); - - repo->free_contact_handles = g_heap_new (handle_compare_func); - repo->free_room_handles = g_heap_new (handle_compare_func); - - repo->contact_serial = 1; - repo->room_serial = 1; - - g_datalist_init (&repo->list_handles); - - for (h = LIST_HANDLE_FIRST; h <= LIST_HANDLE_LAST; h++) { - g_datalist_id_set_data_full (&repo->list_handles, (GQuark) h, - handle_priv_new(), (GDestroyNotify) handle_priv_free); - } - - repo->bus_service_proxy = dbus_g_proxy_new_for_name (tp_get_bus(), - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - dbus_g_proxy_add_signal (repo->bus_service_proxy, - "NameOwnerChanged", - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (repo->bus_service_proxy, - "NameOwnerChanged", - G_CALLBACK (handles_name_owner_changed_cb), - repo, - NULL); - - return repo; -} - -#ifdef ENABLE_HANDLE_LEAK_DEBUG - -static void -handle_leak_debug_printbt_foreach (gpointer data, gpointer user_data) -{ - HandleLeakTrace *hltrace = (HandleLeakTrace *) data; - int i; - - for (i = 1; i < hltrace->len; i++) - { - printf ("\t\t%s\n", hltrace->trace[i]); - } - - printf ("\n"); -} - -static void -handle_leak_debug_printhandles_foreach (gpointer key, gpointer value, gpointer ignore) -{ - Handle handle = GPOINTER_TO_UINT (key); - HandlePriv *priv = (HandlePriv *) value; - - printf ("\t%5u: %s (%u refs), traces:\n", handle, priv->string, priv->refcount); - - g_slist_foreach (priv->traces, handle_leak_debug_printbt_foreach, NULL); -} - -static void -handle_leak_debug_print_report (HandleRepo *repo) -{ - g_assert (repo != NULL); - - printf ("The following contact handles were not freed:\n"); - g_hash_table_foreach (repo->contact_handles, handle_leak_debug_printhandles_foreach, NULL); - printf ("The following room handles were not freed:\n"); - g_hash_table_foreach (repo->room_handles, handle_leak_debug_printhandles_foreach, NULL); -} - -static HandleLeakTrace * -handle_leak_debug_bt () -{ - void *bt_addresses[16]; - HandleLeakTrace *ret = g_new0 (HandleLeakTrace, 1); - - ret->len = backtrace (bt_addresses, 16); - ret->trace = backtrace_symbols (bt_addresses, ret->len); - - return ret; -} - -#define HANDLE_LEAK_DEBUG_DO(traces_slist) \ - { (traces_slist) = g_slist_append ((traces_slist), handle_leak_debug_bt ()); } - -#else /* !ENABLE_HANDLE_LEAK_DEBUG */ - -#define HANDLE_LEAK_DEBUG_DO(traces_slist) {} - -#endif /* ENABLE_HANDLE_LEAK_DEBUG */ - -void -handle_repo_destroy (HandleRepo *repo) -{ - g_assert (repo != NULL); - g_assert (repo->contact_handles); - g_assert (repo->room_handles); - g_assert (repo->contact_strings); - g_assert (repo->room_strings); - - g_datalist_clear (&repo->client_contact_handle_sets); - g_datalist_clear (&repo->client_room_handle_sets); - -#ifdef ENABLE_HANDLE_LEAK_DEBUG - handle_leak_debug_print_report (repo); -#endif /* ENABLE_HANDLE_LEAK_DEBUG */ - - g_hash_table_destroy (repo->contact_handles); - g_hash_table_destroy (repo->room_handles); - g_hash_table_destroy (repo->contact_strings); - g_hash_table_destroy (repo->room_strings); - g_heap_destroy (repo->free_contact_handles); - g_heap_destroy (repo->free_room_handles); - g_datalist_clear (&repo->list_handles); - - dbus_g_proxy_disconnect_signal (repo->bus_service_proxy, - "NameOwnerChanged", - G_CALLBACK (handles_name_owner_changed_cb), - repo); - g_object_unref (G_OBJECT (repo->bus_service_proxy)); - - g_free (repo); -} - -gboolean -handle_is_valid (HandleRepo *repo, TpHandleType type, Handle handle, GError **error) -{ - GArray *arr; - gboolean ret; - - arr = g_array_new (FALSE, FALSE, sizeof (Handle)); - g_array_insert_val (arr, 0, handle); - - ret = handles_are_valid (repo, type, arr, FALSE, error); - - g_array_free (arr, TRUE); - - return ret; -} - -gboolean -handles_are_valid (HandleRepo *repo, - TpHandleType type, - const GArray *array, - gboolean allow_zero, - GError **error) -{ - int i; - - g_return_val_if_fail (repo != NULL, FALSE); - g_return_val_if_fail (array != NULL, FALSE); - - if (!handle_type_is_valid (type, error)) - return FALSE; - - for (i = 0; i < array->len; i++) - { - Handle handle = g_array_index (array, Handle, i); - - if ((handle == 0 && !allow_zero) || - (handle_priv_lookup (repo, type, handle) == NULL)) - { - if (error != NULL) - { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "invalid handle %u", handle); - } - - return FALSE; - } - } - - return TRUE; -} - -gboolean -handle_ref (HandleRepo *repo, - TpHandleType type, - Handle handle) -{ - HandlePriv *priv; - - if (type == TP_HANDLE_TYPE_LIST) - { - if (handle >= LIST_HANDLE_FIRST && handle <= LIST_HANDLE_LAST) - return TRUE; - else - return FALSE; - } - - priv = handle_priv_lookup (repo, type, handle); - - if (priv == NULL) - return FALSE; - - priv->refcount++; - - HANDLE_LEAK_DEBUG_DO (priv->traces); - - return TRUE; -} - -gboolean -handle_unref (HandleRepo *repo, - TpHandleType type, - Handle handle) -{ - HandlePriv *priv; - - if (type == TP_HANDLE_TYPE_LIST) - { - if (handle >= LIST_HANDLE_FIRST && handle <= LIST_HANDLE_LAST) - return TRUE; - else - return FALSE; - } - - priv = handle_priv_lookup (repo, type, handle); - - if (priv == NULL) - return FALSE; - - HANDLE_LEAK_DEBUG_DO (priv->traces); - - g_assert (priv->refcount > 0); - - priv->refcount--; - - if (priv->refcount == 0) - handle_priv_remove (repo, type, handle); - - return TRUE; -} - -const char * -handle_inspect (HandleRepo *repo, - TpHandleType type, - Handle handle) -{ - HandlePriv *priv; - - if (type == TP_HANDLE_TYPE_LIST) - { - g_assert (handle >= LIST_HANDLE_FIRST - && handle <= LIST_HANDLE_LAST); - return list_handle_strings[handle-1]; - } - - priv = handle_priv_lookup (repo, type, handle); - - if (priv == NULL) - return NULL; - else - return priv->string; -} - -static Handle -_handle_lookup_by_name (HandleRepo *repo, - const gchar *name) -{ - Handle handle; - - handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->contact_strings, name)); - - if (0 == handle) - return 0; - - return handle; -} - -Handle -handle_for_contact (HandleRepo *repo, const char *name) -{ - Handle handle = 0; - HandlePriv *priv; - - g_assert (name != NULL); - g_assert (*name != '\0'); - - handle = _handle_lookup_by_name (repo, name); - - if (0 != handle) { - goto OUT; - } - - handle = handle_alloc (repo, TP_HANDLE_TYPE_CONTACT); - priv = handle_priv_new (); - priv->string = g_strdup(name); - g_hash_table_insert (repo->contact_handles, GINT_TO_POINTER (handle), priv); - g_hash_table_insert (repo->contact_strings, priv->string, GUINT_TO_POINTER (handle)); - - HANDLE_LEAK_DEBUG_DO (priv->traces); - -OUT: - return handle; -} - -gboolean -handle_for_room_exists (HandleRepo *repo, const gchar *name) -{ - Handle handle; - handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->room_strings, - name)); - - if (handle == 0) - return FALSE; - - return (handle_priv_lookup (repo, TP_HANDLE_TYPE_ROOM, handle) != NULL); -} - -Handle -handle_for_room (HandleRepo *repo, const gchar *name) -{ - Handle handle; - - g_assert (name != NULL); - g_assert (*name != '\0'); - - handle = 0; - - handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->room_strings, name)); - - if (handle == 0) { - HandlePriv *priv; - handle = handle_alloc (repo, TP_HANDLE_TYPE_ROOM); - priv = handle_priv_new (); - priv->string = g_strdup(name); - g_hash_table_insert (repo->room_handles, GUINT_TO_POINTER (handle), priv); - g_hash_table_insert (repo->room_strings, priv->string, GUINT_TO_POINTER (handle)); - HANDLE_LEAK_DEBUG_DO (priv->traces); - } - - return handle; -} - -Handle -handle_for_list (HandleRepo *repo, - const gchar *list) -{ - Handle handle = 0; - int i; - - g_assert (repo != NULL); - g_assert (list != NULL); - - for (i = 0; i < LIST_HANDLE_LAST; i++) - { - if (0 == strcmp (list_handle_strings[i], list)) - handle = (Handle) i + 1; - } - - return handle; -} - -Handle -handle_for_type(HandleRepo *repo, TpHandleType type, const gchar *name) { - switch (type) { - case TP_HANDLE_TYPE_CONTACT: - return handle_for_contact(repo, name); - case TP_HANDLE_TYPE_ROOM: - return handle_for_room(repo, name); - case TP_HANDLE_TYPE_LIST: - return handle_for_list(repo, name); - default: - g_assert_not_reached(); - } -} - - -/** - * handle_set_qdata: - * @repo: A #HandleRepo - * @type: The handle type - * @handle: A handle to set data on - * @key_id: Key id to associate data with - * @data: data to associate with handle - * @destroy: A #GDestroyNotify to call to detroy the data, - * or NULL if not needed. - * - * Associates a blob of data with a given handle and a given key - * - * If @destroy is set, then the data is freed when the handle is freed. - */ - -gboolean -handle_set_qdata (HandleRepo *repo, - TpHandleType type, Handle handle, - GQuark key_id, gpointer data, GDestroyNotify destroy) -{ - HandlePriv *priv; - priv = handle_priv_lookup (repo, type, handle); - - if (!priv) - return FALSE; - - g_datalist_id_set_data_full (&priv->datalist, key_id, data, destroy); - return TRUE; -} - -/** - * handle_get_qdata: - * @repo: A #HandleRepo - * @type: The handle type - * @handle: A handle to get data from - * @key_id: Key id of data to fetch - * - * Gets the data associated with a given key on a given handle - */ -gpointer -handle_get_qdata (HandleRepo *repo, - TpHandleType type, Handle handle, - GQuark key_id) -{ - HandlePriv *priv; - priv = handle_priv_lookup (repo, type, handle); - - if (!priv) - return NULL; - - return g_datalist_id_get_data(&priv->datalist, key_id); -} - -/** - * handle_client_hold: - * @repo: a #HandleRepo - * @client_name: D-Bus bus name of client to hold the handle for - * @handle: the handle to hold - * @type: type of handle to hold - * @error: used to return a pointer to a GError detailing any error that occurred - * - * Marks a handle as held by a given client. - * - * Returns: Whether the handle was succesfully marked as held or an error occurred. - */ -gboolean -handle_client_hold (HandleRepo *repo, - const gchar *client_name, - Handle handle, - TpHandleType type, - GError **error) -{ - GData **handle_set_list; - HandleSet *handle_set; - - g_assert (repo != NULL); - - switch (type) - { - case TP_HANDLE_TYPE_CONTACT: - handle_set_list = &repo->client_contact_handle_sets; - break; - case TP_HANDLE_TYPE_ROOM: - handle_set_list = &repo->client_room_handle_sets; - break; - case TP_HANDLE_TYPE_LIST: - /* no-op */ - return TRUE; - default: - g_critical ("%s: called with invalid handle type %u", G_STRFUNC, type); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, "invalid handle type %u", type); - return FALSE; - } - - if (!client_name || *client_name == '\0') - { - g_critical ("%s: called with invalid client name", G_STRFUNC); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, "invalid client name"); - return FALSE; - } - - handle_set = (HandleSet*) g_datalist_get_data (handle_set_list, client_name); - - if (!handle_set) - { - handle_set = handle_set_new (repo, type); - g_datalist_set_data_full (handle_set_list, - client_name, - handle_set, - (GDestroyNotify) handle_set_destroy); - } - - handle_set_add (handle_set, handle); - - return TRUE; -} - -/** - * handle_client_release: - * @repo: a #HandleRepo - * @client_name: D-Bus bus name of client to release the handle for - * @handle: the handle to release - * @type: type of handle to release - * @error: used to return a pointer to a GError detailing any error that occurred - * - * Unmarks a handle as held by a given client. - * - * Returns: Whether the handle had been marked as held by the given client and now unmarked or not. - */ -gboolean -handle_client_release (HandleRepo *repo, - const gchar *client_name, - Handle handle, - TpHandleType type, - GError **error) -{ - GData **handle_set_list; - HandleSet *handle_set; - - g_assert (repo != NULL); - - switch (type) - { - case TP_HANDLE_TYPE_CONTACT: - handle_set_list = &repo->client_contact_handle_sets; - break; - case TP_HANDLE_TYPE_ROOM: - handle_set_list = &repo->client_room_handle_sets; - break; - case TP_HANDLE_TYPE_LIST: - /* no-op */ - return TRUE; - default: - g_critical ("%s: called with invalid handle type %u", G_STRFUNC, type); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, "invalid handle type %u", type); - return FALSE; - } - - if (!client_name || *client_name == '\0') - { - g_critical ("%s: called with invalid client name", G_STRFUNC); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, "invalid client name"); - return FALSE; - } - - handle_set = (HandleSet*) g_datalist_get_data (handle_set_list, client_name); - - if (!handle_set) - { - g_critical ("%s: no handle set found for the given client %s", G_STRFUNC, client_name); - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, - "the given client %s wasn't holding any handles", - client_name); - return FALSE; - } - - if (!handle_set_remove (handle_set, handle)) - { - g_critical ("%s: the client %s wasn't holding the handle %u", G_STRFUNC, client_name, handle); - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, - "the given client %s wasn't holding the handle %u", - client_name, handle); - return FALSE; - } - - return TRUE; -} - diff --git a/src/handle-repository.h b/src/handle-repository.h deleted file mode 100644 index ad20058a..00000000 --- a/src/handle-repository.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * handles.h - mechanism to store and retrieve handles on a connection - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __HANDLE_REPOSITORY_H__ -#define __HANDLE_REPOSITORY_H__ - -#include <glib.h> - -#include "telepathy-constants.h" -#include "handle-types.h" - -G_BEGIN_DECLS - -typedef enum -{ - LIST_HANDLE_PUBLISH = 1, - LIST_HANDLE_SUBSCRIBE, - LIST_HANDLE_KNOWN, - - LIST_HANDLE_LAST = LIST_HANDLE_KNOWN, - LIST_HANDLE_FIRST = LIST_HANDLE_PUBLISH -} ListHandle; - -gboolean handle_name_is_valid (TpHandleType type, const gchar *name, - GError **error); - -gboolean handle_type_is_valid (TpHandleType type, GError **error); - -HandleRepo *handle_repo_new (); -void handle_repo_destroy (HandleRepo *repo); - -gboolean handle_is_valid (HandleRepo *repo, TpHandleType type, - Handle handle, GError **error); -gboolean handles_are_valid (HandleRepo *repo, TpHandleType type, const GArray *array, gboolean allow_zero, GError **error); - -gboolean handle_ref (HandleRepo *repo, TpHandleType type, Handle handle); -gboolean handle_unref (HandleRepo *repo, TpHandleType type, Handle handle); -const char *handle_inspect (HandleRepo *repo, TpHandleType type, Handle handle); - -Handle handle_for_contact (HandleRepo *repo, const char *name); -gboolean handle_for_room_exists (HandleRepo *repo, const gchar *name); -Handle handle_for_room (HandleRepo *repo, const gchar *name); -Handle handle_for_list (HandleRepo *repo, const gchar *list); - -Handle handle_for_type (HandleRepo *repo, TpHandleType type, const gchar *name); - -gboolean handle_set_qdata (HandleRepo *repo, TpHandleType type, - Handle handle, GQuark key_id, gpointer data, GDestroyNotify destroy); - -gpointer handle_get_qdata (HandleRepo *repo, TpHandleType type, - Handle handle, GQuark key_id); - -gboolean handle_client_hold (HandleRepo *repo, const gchar *client_name, Handle handle, TpHandleType type, GError **error); - -gboolean handle_client_release (HandleRepo *repo, const gchar *client_name, Handle handle, TpHandleType type, GError **error); - -G_END_DECLS - -#endif /* #ifndef __HANDLES_H__ */ diff --git a/src/handle-set.c b/src/handle-set.c deleted file mode 100644 index 249f8994..00000000 --- a/src/handle-set.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * handle-set.c - a set which refs a handle when inserted - * - * Copyright (C) 2005,2006 Collabora Ltd. - * Copyright (C) 2005,2006 Nokia Corporation - * - * 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 - * - */ -#include <glib.h> -#include "gintset.h" -#include "handle-repository.h" - -#include "handle-set.h" - -struct _HandleSet -{ - HandleRepo *repo; - GIntSet *intset; - TpHandleType type; -}; - -/** - * handle_set_new: - * @repo: #HandleRepo that holds the handles to be reffed by this set - * - * Creates a new #HandleSet - * - * Returns: A new #HandleSet - */ -HandleSet * -handle_set_new (HandleRepo *repo, TpHandleType type) -{ - HandleSet *set = g_new(HandleSet, 1); - set->intset = g_intset_new(); - set->repo = repo; - set->type = type; - - return set; -} - -static void -freer (HandleSet *set, Handle handle, gpointer userdata) -{ - handle_set_remove (set, handle); -} - -/** - * handle_set_destroy: - * @set:#HandleSet to destroy - * - * Delete a #HandleSet and unreference any handles that it holds - */ -void -handle_set_destroy (HandleSet *set) -{ - handle_set_foreach (set, freer, NULL); - g_intset_destroy (set->intset); - g_free (set); -} - -/** - * handle_set_peek: - * @set:#HandleSet to peek at - * - * Get the underlying GIntSet used by this HandleSet - */ -GIntSet * -handle_set_peek (HandleSet *set) -{ - return set->intset; -} - -/** - * handle_set_add: - * @set: #HandleSet to add this handle to - * @handle: handle to add - * - * Add a handle to a #HandleSet,and reference it in the attched - * #HandleRepo - * - */ -void -handle_set_add (HandleSet *set, Handle handle) -{ - g_return_if_fail (set != NULL); - g_return_if_fail (handle != 0); - - if (!g_intset_is_member(set->intset, handle)) - { - g_return_if_fail (handle_ref (set->repo, set->type, handle)); - - g_intset_add (set->intset, handle); - } -} - -/** - * handle_set_remove: - * @set: #HandleSet to remove this handle from - * @handle: handle to remove - * @type: type of handle - * - * Remove a handle to a #HandleSet,and unreference it in the attched - * #HandleRepo - * - * Returns: FALSE if the (handle,type) pair was invalid, or was not in this set - */ - -gboolean -handle_set_remove (HandleSet *set, Handle handle) -{ - g_return_val_if_fail (set != NULL, FALSE); - g_return_val_if_fail (handle != 0, FALSE); - - if (g_intset_is_member(set->intset, handle)) - { - g_return_val_if_fail (handle_unref (set->repo, set->type, handle), FALSE); - - g_intset_remove (set->intset, handle); - return TRUE; - } - - return FALSE; -} - -/** - * handle_set_is_member: - * @set: A #HandleSet - * @handle: handle to check - * @type: type of handle - * - * Check if the (handle,type) pair is in this set - * - * Returns: TRUE if the (handle,type) pair is in this repo - * - */ -gboolean -handle_set_is_member (HandleSet *set, Handle handle) -{ - return g_intset_is_member(set->intset, handle); -} - -typedef struct __foreach_data -{ - HandleSet *set; - HandleFunc func; - gpointer userdata; -} _foreach_data; - -static void -foreach_helper(guint i, gpointer userdata) -{ - _foreach_data *data = (_foreach_data*) userdata; - - data->func(data->set, i, data->userdata); -} - -void -handle_set_foreach (HandleSet *set, HandleFunc func, gpointer userdata) -{ - _foreach_data data = {set, func, userdata}; - data.set = set; - data.func = func; - data.userdata = userdata; - g_intset_foreach (set->intset, foreach_helper, &data); -} - -int -handle_set_size (HandleSet *set) -{ - return g_intset_size (set->intset); -} - -GArray *handle_set_to_array (HandleSet *set) -{ - g_return_val_if_fail (set != NULL, NULL); - - return g_intset_to_array (set->intset); -} - -static void -ref_one (guint handle, gpointer data) -{ - HandleSet *set = (HandleSet *) data; - handle_ref (set->repo, set->type, handle); -} - -/** - * handle_set_update: - * @set: a #HandleSet to update - * @add: a #GIntSet of handles to add - * - * Add a set of handles to a handle set, referencing those which are not - * already members. The GIntSet returned must be freed with g_intset_destroy. - * - * Returns: the handles which were added - */ -GIntSet * -handle_set_update (HandleSet *set, const GIntSet *add) -{ - GIntSet *ret, *tmp; - - g_return_val_if_fail (set != NULL, NULL); - g_return_val_if_fail (add != NULL, NULL); - - /* reference each of ADD - CURRENT */ - ret = g_intset_difference (add, set->intset); - g_intset_foreach (ret, ref_one, set); - - /* update CURRENT to be the union of CURRENT and ADD */ - tmp = g_intset_union (add, set->intset); - g_intset_destroy (set->intset); - set->intset = tmp; - - return ret; -} - -static void -unref_one (guint handle, gpointer data) -{ - HandleSet *set = (HandleSet *) data; - handle_unref (set->repo, set->type, handle); -} - -/** - * handle_set_difference_update: - * @set: a #HandleSet to update - * @remove: a #GIntSet of handles to remove - * - * Remove a set of handles from a handle set, dereferencing those which are - * members. The GIntSet returned must be freed with g_intset_destroy. - * - * Returns: the handles which were removed - */ -GIntSet * -handle_set_difference_update (HandleSet *set, const GIntSet *remove) -{ - GIntSet *ret, *tmp; - - g_return_val_if_fail (set != NULL, NULL); - g_return_val_if_fail (remove != NULL, NULL); - - /* dereference each of REMOVE n CURRENT */ - ret = g_intset_intersection (remove, set->intset); - g_intset_foreach (ret, unref_one, set); - - /* update CURRENT to be CURRENT - REMOVE */ - tmp = g_intset_difference (set->intset, remove); - g_intset_destroy (set->intset); - set->intset = tmp; - - return ret; -} diff --git a/src/handle-set.h b/src/handle-set.h deleted file mode 100644 index 2a1f327f..00000000 --- a/src/handle-set.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * tp-handle-set.h - a set which refs a handle when inserted - * - * Copyright (C) 2005,2006 Collabora Ltd. - * Copyright (C) 2005,2006 Nokia Corporation - * - * 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 - * - */ - -#ifndef __HANDLE_SET_H__ -#define __HANDLE_SET_H__ - -#include "gintset.h" - -G_BEGIN_DECLS - -typedef struct _HandleSet HandleSet; -typedef void (*HandleFunc)(HandleSet *set, Handle handle, gpointer userdata); - -HandleSet * handle_set_new (HandleRepo *, TpHandleType type); -void handle_set_destroy (HandleSet *); - -GIntSet *handle_set_peek (HandleSet *set); - -void handle_set_add (HandleSet *set, Handle handle); -gboolean handle_set_remove (HandleSet *set, Handle handle); -gboolean handle_set_is_member (HandleSet *set, Handle handle); - -void handle_set_foreach (HandleSet *set, HandleFunc func, gpointer userdata); - -int handle_set_size (HandleSet *set); -GArray *handle_set_to_array (HandleSet *set); - -GIntSet *handle_set_update (HandleSet *set, const GIntSet *add); -GIntSet *handle_set_difference_update (HandleSet *set, const GIntSet *remove); - -G_END_DECLS - -#endif /*__HANDLE_SET_H__*/ diff --git a/src/handle-types.h b/src/handle-types.h deleted file mode 100644 index 64dae23f..00000000 --- a/src/handle-types.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2006 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 - */ - -#ifndef __HANDLE_TYPES_H__ -#define __HANDLE_TYPES_H__ - -G_BEGIN_DECLS - -typedef struct _HandleRepo HandleRepo; -typedef guint32 Handle; - -G_END_DECLS - -#endif diff --git a/src/salut-connection-manager-signals-marshal.list b/src/salut-connection-manager-signals-marshal.list deleted file mode 100644 index 41e40276..00000000 --- a/src/salut-connection-manager-signals-marshal.list +++ /dev/null @@ -1 +0,0 @@ -VOID:STRING,STRING,STRING diff --git a/src/salut-connection-manager.c b/src/salut-connection-manager.c index 0cea018e..6fdbb7f6 100644 --- a/src/salut-connection-manager.c +++ b/src/salut-connection-manager.c @@ -19,138 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <dbus/dbus-protocol.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-bindings.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> - -#include "salut-connection-manager.h" -#include "salut-connection-manager-signals-marshal.h" -#include "salut-connection-manager-glue.h" +#include <dbus/dbus-protocol.h> +#include <telepathy-glib/util.h> +#include "salut-connection-manager.h" #include "salut-connection.h" -#include "salut-contact-manager.h" - -#include "telepathy-helpers.h" -#include "telepathy-constants.h" -#include "telepathy-errors.h" - -#define TP_TYPE_PARAM (dbus_g_type_get_struct ("GValueArray", \ - G_TYPE_STRING, \ - G_TYPE_UINT, \ - G_TYPE_STRING, \ - G_TYPE_VALUE, \ - G_TYPE_INVALID)) - -G_DEFINE_TYPE(SalutConnectionManager, salut_connection_manager, G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - NEW_CONNECTION, - NO_MORE_CONNECTIONS, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* private structure */ -typedef struct _SalutConnectionManagerPrivate SalutConnectionManagerPrivate; - -struct _SalutConnectionManagerPrivate -{ - gboolean dispose_has_run; - GHashTable *connections; -}; - -#define SALUT_CONNECTION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManagerPrivate)) - -static void -salut_connection_manager_init (SalutConnectionManager *obj) -{ - SalutConnectionManagerPrivate *priv = SALUT_CONNECTION_MANAGER_GET_PRIVATE (obj); - - /* allocate any data required by the object here */ - priv->connections = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, g_object_unref); -} - -static void salut_connection_manager_dispose (GObject *object); -static void salut_connection_manager_finalize (GObject *object); - -static void -salut_connection_manager_class_init (SalutConnectionManagerClass *salut_connection_manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (salut_connection_manager_class); - - g_type_class_add_private (salut_connection_manager_class, sizeof (SalutConnectionManagerPrivate)); - - object_class->dispose = salut_connection_manager_dispose; - object_class->finalize = salut_connection_manager_finalize; - - signals[NEW_CONNECTION] = - g_signal_new ("new-connection", - G_OBJECT_CLASS_TYPE (salut_connection_manager_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_manager_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, 3, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING); - signals[NO_MORE_CONNECTIONS] = - g_signal_new ("no-more-connections", - G_OBJECT_CLASS_TYPE (salut_connection_manager_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_connection_manager_class), &dbus_glib_salut_connection_manager_object_info); -} - -void -salut_connection_manager_dispose (GObject *object) -{ - SalutConnectionManager *self = SALUT_CONNECTION_MANAGER (object); - SalutConnectionManagerPrivate *priv = SALUT_CONNECTION_MANAGER_GET_PRIVATE (self); - DBusGProxy *bus_proxy; - bus_proxy = tp_get_bus_proxy();; - - if (priv->dispose_has_run) - return; - priv->dispose_has_run = TRUE; - - if (priv->connections != NULL) { - g_hash_table_destroy(priv->connections); - priv->connections = NULL; - } - - - /* release any references held by the object here */ - org_freedesktop_DBus_request_name(bus_proxy, - SALUT_CONN_MGR_BUS_NAME, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - NULL, NULL); - if (G_OBJECT_CLASS (salut_connection_manager_parent_class)->dispose) - G_OBJECT_CLASS (salut_connection_manager_parent_class)->dispose (object); -} - -void -salut_connection_manager_finalize (GObject *object) -{ - //SalutConnectionManager *self = SALUT_CONNECTION_MANAGER (object); - //SalutConnectionManagerPrivate *priv = SALUT_CONNECTION_MANAGER_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (salut_connection_manager_parent_class)->finalize (object); -} - -/* private data */ typedef struct { guint set_mask; @@ -162,15 +39,15 @@ typedef struct { } SalutParams; enum { - LOCAL_JABBER_PARAM_NICKNAME = 0, - LOCAL_JABBER_PARAM_FIRST_NAME, - LOCAL_JABBER_PARAM_LAST_NAME, - LOCAL_JABBER_PARAM_JID, - LOCAL_JABBER_PARAM_EMAIL, - LOCAL_JABBER_NR_PARAMS + SALUT_PARAM_NICKNAME = 0, + SALUT_PARAM_FIRST_NAME, + SALUT_PARAM_LAST_NAME, + SALUT_PARAM_JID, + SALUT_PARAM_EMAIL, + SALUT_NR_PARAMS }; -static const SalutParamSpec local_jabber_params[] = { +static const TpCMParamSpec salut_params[] = { { "nickname", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(SalutParams, nickname)}, @@ -187,342 +64,88 @@ static const SalutParamSpec local_jabber_params[] = { {NULL, NULL, 0, 0, NULL, 0} }; -static const SalutProtocolSpec _salut_protocols[] = { - {"salut", local_jabber_params}, +static void *salut_params_new(void); +static void salut_params_free(void *params); + +const TpCMProtocolSpec salut_protocols[] = { + {"salut", salut_params, salut_params_new, salut_params_free }, { NULL, NULL} }; -const SalutProtocolSpec *salut_protocols = _salut_protocols; - -/* public functions */ -void -_salut_connection_manager_register(SalutConnectionManager *self) { - DBusGConnection *bus; - DBusGProxy *bus_proxy; - GError *error = NULL; - guint request_name_result; - - g_assert(SALUT_IS_CONNECTION_MANAGER (self)); +static TpBaseConnection * +salut_connection_manager_new_connection(TpBaseConnectionManager *self, + const gchar *proto, + TpIntSet *params_present, + void *parsed_params, + GError **error); - bus = tp_get_bus(); - bus_proxy = tp_get_bus_proxy(); - if (!org_freedesktop_DBus_request_name(bus_proxy, - SALUT_CONN_MGR_BUS_NAME, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &request_name_result, - &error)) { - g_error("Failed to request bus name: %s", error->message); - } +G_DEFINE_TYPE(SalutConnectionManager, salut_connection_manager, + TP_TYPE_BASE_CONNECTION_MANAGER) - if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) - g_error("Failed to acquire bus name, connection manager already running?"); - - dbus_g_connection_register_g_object(bus, SALUT_CONN_MGR_OBJECT_PATH, - G_OBJECT(self)); -} - -/* private */ static void -connection_disconnected_cb(SalutConnection *conn, gpointer data) { - SalutConnectionManager *mgr = SALUT_CONNECTION_MANAGER(data); - SalutConnectionManagerPrivate *priv = - SALUT_CONNECTION_MANAGER_GET_PRIVATE(mgr); - g_assert(g_hash_table_remove(priv->connections, conn)); - - if (g_hash_table_size(priv->connections) == 0) { - g_signal_emit(mgr, signals[NO_MORE_CONNECTIONS], 0); - } -} - -static gboolean -get_parameters (const char *proto, const SalutParamSpec **params, GError **error) -{ - if (!strcmp (proto, "salut")) - { - *params = local_jabber_params; - } - else - { - g_debug ("%s: unknown protocol %s", G_STRFUNC, proto); - - *error = g_error_new (TELEPATHY_ERRORS, NotImplemented, - "unknown protocol %s", proto); - - return FALSE; - } - - return TRUE; -} - -static gboolean -set_param_from_value (const SalutParamSpec *paramspec, - GValue *value, - SalutParams *params, - GError **error) +salut_connection_manager_init (SalutConnectionManager *obj) { - if (G_VALUE_TYPE (value) != paramspec->gtype) - { - g_debug ("%s: expected type %s for parameter %s, got %s", - G_STRFUNC, - g_type_name (paramspec->gtype), paramspec->name, - G_VALUE_TYPE_NAME (value)); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "expected type %s for account parameter %s, got %s", - g_type_name (paramspec->gtype), paramspec->name, - G_VALUE_TYPE_NAME (value)); - return FALSE; - } - - switch (paramspec->dtype[0]) - { - case DBUS_TYPE_STRING: - { - const char *str = g_value_get_string (value); - if (!str || *str == '\0') { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "empty string for for account parameter %s", - paramspec->name); - return FALSE; - } else { - *((char **) ((void *)params + paramspec->offset)) = g_value_dup_string (value); - } - } - break; - case DBUS_TYPE_INT16: - *((gint *) ((void *)params + paramspec->offset)) = g_value_get_int (value); - break; - case DBUS_TYPE_UINT16: - *((guint *) ((void *)params + paramspec->offset)) = g_value_get_uint (value); - break; - case DBUS_TYPE_BOOLEAN: - *((gboolean *) ((void *)params + paramspec->offset)) = g_value_get_boolean (value); - break; - default: - g_error ("set_param_from_value: encountered unknown type %s on argument %s", - paramspec->dtype, paramspec->name); - return FALSE; - } - - return TRUE; } - -static gboolean -parse_parameters (const SalutParamSpec *paramspec, - GHashTable *provided, - SalutParams *params, - GError **error) +static void +salut_connection_manager_class_init (SalutConnectionManagerClass *salut_connection_manager_class) { - int unhandled; - int i; - guint mandatory_flag = TP_CONN_MGR_PARAM_FLAG_REQUIRED; - GValue *value; - - unhandled = g_hash_table_size (provided); - - for (i = 0; paramspec[i].name; i++) { - value = g_hash_table_lookup (provided, paramspec[i].name); + TpBaseConnectionManagerClass *base_cm_class = + TP_BASE_CONNECTION_MANAGER_CLASS(salut_connection_manager_class); - if (value == NULL) - { - if (paramspec[i].flags & mandatory_flag) - { - g_debug ("%s: missing mandatory param %s", - G_STRFUNC, paramspec[i].name); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "missing mandatory account parameter %s", - paramspec[i].name); - return FALSE; - } - else - { - g_debug ("%s: using default value for param %s", - G_STRFUNC, paramspec[i].name); - } - } - else - { - if (!set_param_from_value (¶mspec[i], value, params, error)) - return FALSE; + base_cm_class->cm_dbus_name = "salut"; + base_cm_class->protocol_params = salut_protocols; + base_cm_class->new_connection = salut_connection_manager_new_connection; - params->set_mask |= 1 << i; - unhandled--; - if (paramspec[i].gtype == G_TYPE_STRING) { - g_debug ("%s: accepted value %s for param %s", - G_STRFUNC, - *((char **) ((void *)params + paramspec[i].offset)), - paramspec[i].name); - } - else - { - g_debug ("%s: accepted value %u for param %s", G_STRFUNC, - *((guint *) ((void *)params + paramspec[i].offset)), paramspec[i].name); - } - } - } - - if (unhandled) - { - g_debug ("%s: unknown argument name provided", G_STRFUNC); - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "unknown argument name provided"); - return FALSE; - } - - return TRUE; -} - -static void -free_params(SalutParams *params) { - g_free(params->first_name); - g_free(params->last_name); - g_free(params->jid); - g_free(params->email); - params->set_mask = 0; } +static void *salut_params_new(void) { + return g_slice_new0(SalutParams); +}; +static void salut_params_free(void *params) { + SalutParams *p = (SalutParams *)params; -/* dbus-exported methods */ - -/** - * salut_connection_manager_get_parameters - * - * Implements DBus method GetParameters - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_get_parameters (SalutConnectionManager *obj, - const gchar * proto, - GPtrArray ** ret, - GError **error) -{ - const SalutParamSpec *params = NULL; - int i; - - if (!get_parameters(proto, ¶ms, error)) { - return FALSE; - } - - *ret = g_ptr_array_new(); - for (i = 0; params[i].name != NULL ; i++) { - GValue *def_value; - GValue param = { 0, }; - g_value_init(¶m, TP_TYPE_PARAM); - g_value_set_static_boxed(¶m, - dbus_g_type_specialized_construct (TP_TYPE_PARAM)); - /* There are no default values for salut */ - def_value = g_new0(GValue, 1); - g_value_init(def_value, params[i].gtype); - dbus_g_type_struct_set(¶m, - 0, params[i].name, - 1, params[i].flags, - 2, params[i].dtype, - 3, def_value, - G_MAXUINT); - g_value_unset(def_value); - g_free(def_value); - g_ptr_array_add(*ret, g_value_get_boxed(¶m)); - } - return TRUE; -} - + g_free(p->nickname); + g_free(p->first_name); + g_free(p->last_name); + g_free(p->email); + g_free(p->jid); -/** - * salut_connection_manager_list_protocols - * - * Implements DBus method ListProtocols - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_list_protocols (SalutConnectionManager *obj, - gchar *** ret, - GError **error) -{ - const char *protocols[] = { "salut", NULL }; - *ret = g_strdupv((gchar **) protocols); - return TRUE; -} + g_slice_free(SalutParams, params); +}; #define SET_PROPERTY_IF_PARAM_SET(prop, param, member) \ - if ((params.set_mask & (1 << param)) != 0) \ + if (tp_intset_is_member(params_present, param)) \ { \ g_object_set (conn, prop, member, NULL); \ } -/** - * salut_connection_manager_request_connection - * - * Implements DBus method RequestConnection - * on interface org.freedesktop.Telepathy.ConnectionManager - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_manager_request_connection (SalutConnectionManager *self, - const gchar * proto, - GHashTable * parameters, - gchar ** bus_name, - gchar ** object_path, - GError **error) -{ - SalutConnection *conn = NULL; - SalutConnectionManagerPrivate *priv = - SALUT_CONNECTION_MANAGER_GET_PRIVATE(self); - const SalutParamSpec *paramspec; - SalutParams params = { 0, }; - - - if (!get_parameters(proto, ¶mspec, error)) { - return FALSE; - } - if (!parse_parameters (paramspec, parameters, ¶ms, error)) { - free_params(¶ms); - return FALSE; - } - conn = g_object_new(SALUT_TYPE_CONNECTION, NULL); - SET_PROPERTY_IF_PARAM_SET("nickname", LOCAL_JABBER_PARAM_NICKNAME, - params.nickname); - SET_PROPERTY_IF_PARAM_SET("first-name", LOCAL_JABBER_PARAM_FIRST_NAME, - params.first_name); - SET_PROPERTY_IF_PARAM_SET("last-name", LOCAL_JABBER_PARAM_LAST_NAME, - params.last_name); - SET_PROPERTY_IF_PARAM_SET("jid", LOCAL_JABBER_PARAM_EMAIL, params.jid); - SET_PROPERTY_IF_PARAM_SET("email", LOCAL_JABBER_PARAM_JID, params.email); - free_params(¶ms); - - if (!_salut_connection_register(conn, bus_name, object_path, error)) { - goto ERROR; - } - g_hash_table_insert(priv->connections, conn, conn); - g_signal_connect(conn, "disconnected", - G_CALLBACK(connection_disconnected_cb), self); - - g_signal_emit(self, signals[NEW_CONNECTION], 0, - *bus_name, *object_path, proto); - - return TRUE; -ERROR: - if (conn) - g_object_unref(G_OBJECT(conn)); - - return FALSE; +static TpBaseConnection * +salut_connection_manager_new_connection(TpBaseConnectionManager *self, + const gchar *proto, + TpIntSet *params_present, + void *parsed_params, + GError **error) { + SalutConnection *conn; + SalutParams *params = (SalutParams *)parsed_params; + + g_assert(!tp_strdiff(proto, "salut")); + + conn = g_object_new(SALUT_TYPE_CONNECTION, + "protocol", proto, + NULL); + + SET_PROPERTY_IF_PARAM_SET("nickname", SALUT_PARAM_NICKNAME, + params->nickname); + SET_PROPERTY_IF_PARAM_SET("first-name", SALUT_PARAM_FIRST_NAME, + params->first_name); + SET_PROPERTY_IF_PARAM_SET("last-name", SALUT_PARAM_LAST_NAME, + params->last_name); + SET_PROPERTY_IF_PARAM_SET("jid", SALUT_PARAM_EMAIL, params->jid); + SET_PROPERTY_IF_PARAM_SET("email", SALUT_PARAM_JID, params->email); + + return TP_BASE_CONNECTION(conn); } diff --git a/src/salut-connection-manager.h b/src/salut-connection-manager.h index 6a242d10..bd9a803a 100644 --- a/src/salut-connection-manager.h +++ b/src/salut-connection-manager.h @@ -22,10 +22,7 @@ #define __SALUT_CONNECTION_MANAGER_H__ #include <glib-object.h> - -#define SALUT_CONN_MGR_BUS_NAME "org.freedesktop.Telepathy.ConnectionManager.salut" -#define SALUT_CONN_MGR_OBJECT_PATH "/org/freedesktop/Telepathy/ConnectionManager/salut" - +#include <telepathy-glib/base-connection-manager.h> G_BEGIN_DECLS @@ -33,29 +30,14 @@ typedef struct _SalutConnectionManager SalutConnectionManager; typedef struct _SalutConnectionManagerClass SalutConnectionManagerClass; struct _SalutConnectionManagerClass { - GObjectClass parent_class; + TpBaseConnectionManagerClass parent_class; }; struct _SalutConnectionManager { - GObject parent; + TpBaseConnectionManager parent; }; - -typedef struct { - const gchar *name; /* name as passed over dbus */ - const gchar *dtype; /* D-Bus type string */ - const GType gtype; /* glib type string */ - guint flags; /* combination of TP_CONN_MGR_PARAM_FLAG_foo */ - const gpointer def; /* default - gchar * or GINT_TO_POINTER */ - const gsize offset; /* internal use only */ -} SalutParamSpec; - -typedef struct { - const gchar *name; - const SalutParamSpec *parameters; /* terminated by a NULL name */ -} SalutProtocolSpec; - -const SalutProtocolSpec *salut_protocols; /* terminated by a NULL name */ +extern const TpCMProtocolSpec salut_protocols[]; GType salut_connection_manager_get_type(void); @@ -73,26 +55,6 @@ GType salut_connection_manager_get_type(void); #define SALUT_CONNECTION_MANAGER_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONNECTION_MANAGER, SalutConnectionManagerClass)) -void _salut_connection_manager_register(SalutConnectionManager *self); - -gboolean -salut_connection_manager_get_parameters (SalutConnectionManager *self, - const gchar * proto, - GPtrArray ** ret, - GError **error); -gboolean -salut_connection_manager_list_protocols (SalutConnectionManager *self, - gchar *** ret, - GError **error); -gboolean -salut_connection_manager_request_connection (SalutConnectionManager *self, - const gchar * proto, - GHashTable * parameters, - gchar ** ret, - gchar ** ret1, - GError **error); - - G_END_DECLS #endif /* #ifndef __SALUT_CONNECTION_MANAGER_H__*/ diff --git a/src/salut-connection-signals-marshal.list b/src/salut-connection-signals-marshal.list deleted file mode 100644 index 454f5679..00000000 --- a/src/salut-connection-signals-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:STRING,STRING,UINT,UINT,BOOLEAN -VOID:UINT,UINT diff --git a/src/salut-connection.c b/src/salut-connection.c index 9435b5c4..94966fca 100644 --- a/src/salut-connection.c +++ b/src/salut-connection.c @@ -30,9 +30,6 @@ #include "salut-connection.h" -#include "salut-connection-signals-marshal.h" - -#include "salut-connection-glue.h" #include "salut-avahi-client.h" #include "salut-avahi-entry-group.h" @@ -45,24 +42,21 @@ #include "salut-presence.h" -#include "handle-repository.h" - -#include "telepathy-helpers.h" -#include "telepathy-errors.h" -#include "telepathy-interfaces.h" -#include "tp-channel-factory-iface.h" - #include <avahi-client/client.h> #include <avahi-client/lookup.h> #include <avahi-common/error.h> #include <avahi-glib/glib-watch.h> +#include <telepathy-glib/util.h> +#include <telepathy-glib/dbus.h> +#include <telepathy-glib/handle-repo-dynamic.h> +#include <telepathy-glib/handle-repo-static.h> +#include <telepathy-glib/handle-repo.h> +#include <telepathy-glib/interfaces.h> + #define DEBUG_FLAG DEBUG_CONNECTION #include "debug.h" -#define BUS_NAME "org.freedesktop.Telepathy.Connection.salut" -#define OBJECT_PATH "/org/freedesktop/Telepathy/Connection/salut" - #define TP_CHANNEL_LIST_ENTRY_TYPE (dbus_g_type_get_struct ("GValueArray", \ DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, \ G_TYPE_INVALID)) @@ -70,43 +64,40 @@ #define TP_ALIAS_PAIR_TYPE (dbus_g_type_get_struct ("GValueArray", \ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID)) -/* Protocol as know to telepathy */ -#define PROTOCOL "salut" - -#define ERROR_IF_NOT_CONNECTED(CONN, ERROR) \ - if ((CONN)->status != TP_CONN_STATUS_CONNECTED) \ - { \ - DEBUG ("rejected request as disconnected"); \ - (ERROR) = g_error_new(TELEPATHY_ERRORS, NotAvailable, \ - "Connection is disconnected"); \ - return FALSE; \ - } - -#define ERROR_IF_NOT_CONNECTED_ASYNC(CONN, ERROR, CONTEXT) \ - if ((CONN)->status != TP_CONN_STATUS_CONNECTED) \ +#define ERROR_IF_NOT_CONNECTED_ASYNC(BASE, ERROR, CONTEXT) \ + if ((BASE)->status != TP_CONNECTION_STATUS_CONNECTED) \ { \ DEBUG ("rejected request as disconnected"); \ - (ERROR) = g_error_new(TELEPATHY_ERRORS, NotAvailable, \ + (ERROR) = g_error_new(TP_ERRORS, TP_ERROR_NOT_AVAILABLE, \ "Connection is disconnected"); \ dbus_g_method_return_error ((CONTEXT), (ERROR)); \ g_error_free ((ERROR)); \ return; \ } -G_DEFINE_TYPE(SalutConnection, salut_connection, G_TYPE_OBJECT) -/* signal enum */ -enum -{ - ALIASES_CHANGED, - NEW_CHANNEL, - PRESENCE_UPDATE, - STATUS_CHANGED, - DISCONNECTED, - LAST_SIGNAL -}; +static void +salut_connection_connection_service_iface_init(gpointer g_iface, + gpointer iface_data); -static guint signals[LAST_SIGNAL] = {0}; +static void +salut_connection_aliasing_service_iface_init(gpointer g_iface, + gpointer iface_data); + +static void +salut_connection_presence_service_iface_init(gpointer g_iface, + gpointer iface_data); + +G_DEFINE_TYPE_WITH_CODE(SalutConnection, + salut_connection, + TP_TYPE_BASE_CONNECTION, + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION, + salut_connection_connection_service_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING, + salut_connection_aliasing_service_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE, + salut_connection_presence_service_iface_init); + ) /* properties */ enum { @@ -135,7 +126,7 @@ struct _SalutConnectionPrivate /* Avahi client for browsing and resolving */ SalutAvahiClient *avahi_client; - /* Handler for our presence on the lan */ + /* TpHandler for our presence on the lan */ SalutSelf *self; /* Contact manager */ @@ -147,16 +138,10 @@ struct _SalutConnectionPrivate /* MUC channel manager */ SalutMucManager *muc_manager; - /* Channel requests */ - GPtrArray *channel_requests; - /* Whether the channel was created during a request met supress handler is - * true */ - gboolean suppress_current; }; #define SALUT_CONNECTION_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), SALUT_TYPE_CONNECTION, \ - SalutConnectionPrivate)) + ((SalutConnectionPrivate *)((SalutConnection *)o)->priv); typedef struct _ChannelRequest ChannelRequest; @@ -169,17 +154,33 @@ struct _ChannelRequest gboolean suppress_handler; }; -static gboolean _salut_connection_disconnect(SalutConnection *self); -static void emit_one_presence_update (SalutConnection *self, Handle handle); +static void _salut_connection_disconnect(SalutConnection *self); +static void emit_one_presence_update (SalutConnection *self, TpHandle handle); + +static void +salut_connection_create_handle_repos(TpBaseConnection *self, + TpHandleRepoIface *repos[NUM_TP_HANDLE_TYPES]); + +static GPtrArray* +salut_connection_create_channel_factories(TpBaseConnection *self); + +static gchar * +salut_connection_get_unique_connection_name(TpBaseConnection *self); + +static void +salut_connection_shut_down(TpBaseConnection *self); + +static gboolean +salut_connection_start_connecting(TpBaseConnection *self, GError **error); static void salut_connection_init (SalutConnection *obj) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (obj); + SalutConnectionPrivate *priv = + G_TYPE_INSTANCE_GET_PRIVATE(obj, SALUT_TYPE_CONNECTION, + SalutConnectionPrivate); - obj->status = TP_CONN_STATUS_DISCONNECTED; - obj->self_handle = 0; - obj->handle_repo = NULL; + obj->priv = priv; obj->name = NULL; /* allocate any data required by the object here */ @@ -194,7 +195,6 @@ salut_connection_init (SalutConnection *obj) priv->self = NULL; priv->contact_manager = NULL; - priv->channel_requests = g_ptr_array_new(); } static void @@ -269,16 +269,30 @@ static void salut_connection_class_init (SalutConnectionClass *salut_connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (salut_connection_class); + TpBaseConnectionClass *tp_connection_class = + TP_BASE_CONNECTION_CLASS(salut_connection_class); GParamSpec *param_spec; object_class->get_property = salut_connection_get_property; object_class->set_property = salut_connection_set_property; - g_type_class_add_private (salut_connection_class, sizeof (SalutConnectionPrivate)); + g_type_class_add_private (salut_connection_class, + sizeof (SalutConnectionPrivate)); object_class->dispose = salut_connection_dispose; object_class->finalize = salut_connection_finalize; + tp_connection_class->create_handle_repos = + salut_connection_create_handle_repos; + tp_connection_class->create_channel_factories = + salut_connection_create_channel_factories; + tp_connection_class->get_unique_connection_name = + salut_connection_get_unique_connection_name; + tp_connection_class->shut_down = + salut_connection_shut_down; + tp_connection_class->start_connecting = + salut_connection_start_connecting; + param_spec = g_param_spec_string("nickname", "nickname", "Nickname used in the published data", NULL, @@ -312,59 +326,13 @@ salut_connection_class_init (SalutConnectionClass *salut_connection_class) g_object_class_install_property(object_class, PROP_EMAIL, param_spec); param_spec = g_param_spec_string("jid", "Jabber id", - "Jabber idused in the published data", + "Jabber id used in the published data", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB); g_object_class_install_property(object_class, PROP_JID, param_spec); - signals[ALIASES_CHANGED] = - g_signal_new ("aliases-changed", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))))); - - signals[NEW_CHANNEL] = - g_signal_new ("new-channel", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_marshal_VOID__STRING_STRING_UINT_UINT_BOOLEAN, - G_TYPE_NONE, 5, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN); - - signals[PRESENCE_UPDATE] = - g_signal_new ("presence-update", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, (dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)))), G_TYPE_INVALID))))); - - signals[STATUS_CHANGED] = - g_signal_new ("status-changed", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_connection_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - signals[DISCONNECTED] = - g_signal_new ("disconnected", - G_OBJECT_CLASS_TYPE (salut_connection_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_connection_class), &dbus_glib_salut_connection_object_info); } void @@ -377,22 +345,10 @@ salut_connection_dispose (GObject *object) if (priv->dispose_has_run) return; - DEBUG("Disposing connection"); bus_proxy = tp_get_bus_proxy();; priv->dispose_has_run = TRUE; - if (priv->contact_manager) { - g_object_unref(priv->contact_manager); - priv->contact_manager = NULL; - } - - if (priv->channel_requests) { - g_assert(priv->channel_requests->len == 0); - g_ptr_array_free(priv->channel_requests, TRUE); - priv->channel_requests = NULL; - } - if (priv->self) { g_object_unref(priv->self); priv->self = NULL; @@ -403,102 +359,11 @@ salut_connection_dispose (GObject *object) priv->avahi_client = NULL; } - if (NULL != self->bus_name) { - dbus_g_proxy_call_no_reply (bus_proxy, "ReleaseName", - G_TYPE_STRING, self->bus_name, - G_TYPE_INVALID); - } - /* release any references held by the object here */ if (G_OBJECT_CLASS (salut_connection_parent_class)->dispose) G_OBJECT_CLASS (salut_connection_parent_class)->dispose (object); } -static ChannelRequest * -channel_request_new (DBusGMethodInvocation *context, - const char *channel_type, - guint handle_type, - guint handle, - gboolean suppress_handler) -{ - ChannelRequest *ret; - - g_assert (NULL != context); - g_assert (NULL != channel_type); - - ret = g_new0 (ChannelRequest, 1); - ret->context = context; - ret->channel_type = g_strdup (channel_type); - ret->handle_type = handle_type; - ret->handle = handle; - ret->suppress_handler = suppress_handler; - - return ret; -} - -static void -channel_request_free (ChannelRequest *request) -{ - g_assert (NULL == request->context); - g_free (request->channel_type); - g_free (request); -} - -static void -channel_request_cancel (gpointer data, gpointer user_data) -{ - ChannelRequest *request = (ChannelRequest *) data; - GError *error; - - DEBUG ("cancelling request for %s/%d/%d", request->channel_type, request->handle_type, request->handle); - - error = g_error_new (TELEPATHY_ERRORS, Disconnected, "unable to " - "service this channel request, we're disconnecting!"); - - dbus_g_method_return_error (request->context, error); - request->context = NULL; - - g_error_free (error); - channel_request_free (request); -} - -static GPtrArray * -find_matching_channel_requests (SalutConnection *conn, - const gchar *channel_type, - guint handle_type, - guint handle, - gboolean *suppress_handler) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (conn); - GPtrArray *requests; - guint i; - - requests = g_ptr_array_sized_new (1); - - for (i = 0; i < priv->channel_requests->len; i++) - { - ChannelRequest *request = g_ptr_array_index (priv->channel_requests, i); - - if (0 != strcmp (request->channel_type, channel_type)) - continue; - - if (handle_type != request->handle_type) - continue; - - if (handle != request->handle) - continue; - - /* As soon as one requests wants to suppress, send out a signal - * with suppress_handler TRUE */ - if (request->suppress_handler && suppress_handler) - *suppress_handler = TRUE; - - g_ptr_array_add (requests, request); - } - - return requests; -} - - void salut_connection_finalize (GObject *object) { @@ -515,11 +380,6 @@ salut_connection_finalize (GObject *object) DEBUG("Finalizing connection"); - if (self->handle_repo) { - handle_repo_destroy(self->handle_repo); - self->handle_repo = NULL; - } - G_OBJECT_CLASS (salut_connection_parent_class)->finalize (object); } @@ -535,67 +395,6 @@ get_statuses_arguments(void) { return arguments; } -static void -connection_status_change(SalutConnection *self, - TpConnectionStatus status, - TpConnectionStatusReason reason) { - if (self->status == status) - return; - self->status = status; - g_signal_emit (self, signals[STATUS_CHANGED], 0, status, reason); - DEBUG("State changed to %d", status); - if (status == TP_CONN_STATUS_DISCONNECTED) { - g_signal_emit(self, signals[DISCONNECTED], 0); - } -} - -void -_channel_iface_new_channel_cb(TpChannelFactoryIface *channel_iface, - TpChannelIface *channel, - gpointer data) { - SalutConnection *self = SALUT_CONNECTION(data); - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); - gchar *object_path = NULL; - gchar *channel_type = NULL; - guint handle_type = 0; - Handle handle = 0; - gboolean surpress_handler = priv->suppress_current; - GPtrArray *requests; - int i; - - g_object_get(channel, - "object-path", &object_path, - "channel-type", &channel_type, - "handle-type", &handle_type, - "handle", &handle, - NULL); - requests = find_matching_channel_requests(self, channel_type, handle_type, - handle, &surpress_handler); - - g_signal_emit(self, signals[NEW_CHANNEL], 0, - object_path, channel_type, - handle_type, handle, surpress_handler); - - for (i = 0; i < requests->len; i++) { - ChannelRequest *request = g_ptr_array_index(requests, i); - - DEBUG ("completing queued request, channel_type=%s, handle_type=%u, " - "handle=%u, suppress_handler=%u", request->channel_type, - request->handle_type, request->handle, request->suppress_handler); - - dbus_g_method_return (request->context, object_path); - request->context = NULL; - - g_ptr_array_remove (priv->channel_requests, request); - - channel_request_free (request); - } - - g_ptr_array_free(requests, TRUE); - g_free(object_path); - g_free(channel_type); -} - void _contact_manager_contact_status_cb(SalutContactManager *mgr, SalutContact *contact, @@ -603,83 +402,53 @@ _contact_manager_contact_status_cb(SalutContactManager *mgr, gchar *message, gpointer data) { SalutConnection *self = SALUT_CONNECTION(data); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(self), TP_HANDLE_TYPE_CONTACT); /* TODO, this can be shortcutted as we have all info needed right here */ - emit_one_presence_update(self, - handle_for_contact(self->handle_repo, contact->name)); -} - -void -_contact_manager_contact_alias_cb(SalutContactManager *mgr, - SalutContact *contact, - gchar *alias, - gpointer data) { - SalutConnection *self = SALUT_CONNECTION(data); - GPtrArray *aliases; - GValue entry = {0, }; - guint handle = handle_for_contact(self->handle_repo, contact->name); - g_value_init(&entry, TP_ALIAS_PAIR_TYPE); - g_value_take_boxed(&entry, - dbus_g_type_specialized_construct(TP_ALIAS_PAIR_TYPE)); - - dbus_g_type_struct_set(&entry, - 0, handle, - 1, alias, - G_MAXUINT); - aliases = g_ptr_array_sized_new(1); - g_ptr_array_add(aliases, g_value_get_boxed(&entry)); - - DEBUG("Emitting AliasesChanged"); - - g_signal_emit(self, signals[ALIASES_CHANGED], 0, aliases); + emit_one_presence_update(self, + tp_handle_lookup(handle_repo, contact->name, NULL, NULL)); } static void _self_established_cb(SalutSelf *s, gpointer data) { SalutConnection *self = SALUT_CONNECTION(data); SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(self), TP_HANDLE_TYPE_CONTACT); + - self->self_handle = handle_for_contact(self->handle_repo, s->name); - handle_ref(self->handle_repo, TP_HANDLE_TYPE_CONTACT, self->self_handle); g_free(self->name); self->name = g_strdup(s->name); - priv->contact_manager = salut_contact_manager_new(self, priv->avahi_client); - g_signal_connect(priv->contact_manager, "new-channel", - G_CALLBACK(_channel_iface_new_channel_cb), self); - g_signal_connect(priv->contact_manager, "contact-status-changed", - G_CALLBACK(_contact_manager_contact_status_cb), self); - g_signal_connect(priv->contact_manager, "contact-alias-changed", - G_CALLBACK(_contact_manager_contact_alias_cb), self); - - priv->im_manager = salut_im_manager_new(self, priv->contact_manager); - g_signal_connect(priv->im_manager, "new-channel", - G_CALLBACK(_channel_iface_new_channel_cb), self); - - priv->muc_manager = salut_muc_manager_new(self, priv->im_manager); - g_signal_connect(priv->muc_manager, "new-channel", - G_CALLBACK(_channel_iface_new_channel_cb), self); + base->self_handle = tp_handle_ensure(handle_repo, self->name, NULL, NULL); - - if (!salut_contact_manager_start(priv->contact_manager, NULL)) { + if (!salut_contact_manager_start(priv->contact_manager, + priv->avahi_client, NULL)) { /* FIXME handle error */ - _salut_connection_disconnect(self); + tp_base_connection_change_status( + TP_BASE_CONNECTION(base), + TP_CONNECTION_STATUS_CONNECTING, + TP_CONNECTION_STATUS_REASON_REQUESTED); return; } - connection_status_change(self, - TP_CONN_STATUS_CONNECTED, - TP_CONN_STATUS_REASON_NONE_SPECIFIED); + tp_base_connection_change_status(base, + TP_CONNECTION_STATUS_CONNECTED, + TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED); } static void _self_failed_cb(SalutSelf *s, GError *error, gpointer data) { SalutConnection *self = SALUT_CONNECTION(data); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + /* FIXME better error handling */ - connection_status_change(self, - TP_CONN_STATUS_DISCONNECTED, - TP_CONN_STATUS_REASON_NONE_SPECIFIED); + tp_base_connection_change_status(base, + TP_CONNECTION_STATUS_DISCONNECTED, + TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED); } static void @@ -703,10 +472,12 @@ static void _salut_avahi_client_failure_cb(SalutAvahiClient *c, SalutAvahiClientState state, gpointer data) { - SalutConnection *self = SALUT_CONNECTION(data); /* FIXME better error messages */ /* FIXME instead of full disconnect we could handle the avahi restart */ - _salut_connection_disconnect(self); + tp_base_connection_change_status( + TP_BASE_CONNECTION(data), + TP_CONNECTION_STATUS_DISCONNECTED, + TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); } static void @@ -715,6 +486,9 @@ _salut_avahi_client_running_cb(SalutAvahiClient *c, gpointer data) { SalutConnection *self = SALUT_CONNECTION(data); SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); + + g_assert(c == priv->avahi_client); + priv->self = salut_self_new(priv->avahi_client, priv->nickname, priv->first_name, @@ -728,154 +502,44 @@ _salut_avahi_client_running_cb(SalutAvahiClient *c, g_signal_connect(priv->self, "new-connection", G_CALLBACK(_self_new_connection_cb), self); if (!salut_self_announce(priv->self, NULL)) { - _salut_connection_disconnect(self); + tp_base_connection_change_status( + TP_BASE_CONNECTION(self), + TP_CONNECTION_STATUS_DISCONNECTED, + TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); } } /* public functions */ -gboolean _salut_connection_register(SalutConnection *conn, char **bus_name, - char **object_path, GError **error) { - SalutConnectionPrivate *priv; - GError *request_error; - guint request_name_result; - DBusGConnection *bus; - DBusGProxy *bus_proxy; - - bus = tp_get_bus (); - bus_proxy = tp_get_bus_proxy (); - priv = SALUT_CONNECTION_GET_PRIVATE (conn); - - - conn->bus_name = - g_strdup_printf(BUS_NAME ".%s.%s", PROTOCOL, priv->published_name); - conn->object_path = - g_strdup_printf(OBJECT_PATH "/%s/%s", PROTOCOL, priv->published_name); - - if (!org_freedesktop_DBus_request_name(bus_proxy, - conn->bus_name, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &request_name_result, - &request_error)) { - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, "Error acquiring " - "bus name %s: %s", conn->bus_name, request_error->message); - g_error_free (request_error); - } - if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - gchar *msg; - switch (request_name_result) { - case DBUS_REQUEST_NAME_REPLY_IN_QUEUE: - msg = "Request has been queued, though we request non-queueing."; - break; - case DBUS_REQUEST_NAME_REPLY_EXISTS: - msg = "A connection manger already has this busname."; - break; - case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: - msg = "Connection manager already has a connection."; - break; - default: - msg = "Unknown error return from RequestName"; - } - DEBUG("Registering connection failed: %s", msg); - *error = g_error_new (TELEPATHY_ERRORS, NotAvailable, "Error acquiring " - "bus name %s: %s", conn->bus_name, msg); - - g_free (conn->bus_name); - conn->bus_name = NULL; - g_free (conn->object_path); - conn->object_path = NULL; - return FALSE; - } - - dbus_g_connection_register_g_object(bus, conn->object_path, G_OBJECT(conn)); - *bus_name = g_strdup(conn->bus_name); - *object_path = g_strdup(conn->object_path); - return TRUE; -} - - -gboolean +static void _salut_connection_disconnect(SalutConnection *self) { SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - if (priv->contact_manager) { - g_object_unref(priv->contact_manager); - priv->contact_manager = NULL; - } - if (priv->im_manager) { - g_object_unref(priv->im_manager); - priv->im_manager = NULL; - } - - if (priv->muc_manager) { - g_object_unref(priv->muc_manager); - priv->muc_manager = NULL; - } - - if (self->handle_repo) { - handle_repo_destroy(self->handle_repo); - self->handle_repo = NULL; - } if (priv->self) { g_object_unref(priv->self); priv->self = NULL; } + if (priv->avahi_client) { g_object_unref(priv->avahi_client); priv->avahi_client = NULL; } - self->self_handle = 0; - - g_ptr_array_foreach(priv->channel_requests, - (GFunc) channel_request_cancel, NULL); - - connection_status_change(self, TP_CONN_STATUS_DISCONNECTED, - TP_CONN_STATUS_REASON_REQUESTED); - return TRUE; } -gboolean -_salut_connection_connect(SalutConnection *self, GError **error) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - GError *client_error = NULL; - - connection_status_change(self, TP_CONN_STATUS_CONNECTING, - TP_CONN_STATUS_REASON_REQUESTED); - - self->handle_repo = handle_repo_new(); - - priv->avahi_client = salut_avahi_client_new(SALUT_AVAHI_CLIENT_FLAG_NO_FAIL); - - g_signal_connect(priv->avahi_client, "state-changed::running", - G_CALLBACK(_salut_avahi_client_running_cb), self); - g_signal_connect(priv->avahi_client, "state-changed::failure", - G_CALLBACK(_salut_avahi_client_failure_cb), self); - - if (!salut_avahi_client_start(priv->avahi_client, &client_error)) { - *error = g_error_new(TELEPATHY_ERRORS, NotAvailable, - "Unstable to initialize the avahi client: %s", - client_error->message); - g_error_free(client_error); - goto error; - } - return TRUE; -error: - _salut_connection_disconnect(self); - return FALSE; -} +/* Presence interface */ static void destroy_value(GValue *value) { g_value_unset(value); g_free(value); } - static void get_presence_info(SalutConnection *self, const GArray *contact_handles, GHashTable **info) { SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); GHashTable *presence_hash; GValueArray *vals; GHashTable *contact_status, *parameters; @@ -886,16 +550,13 @@ get_presence_info(SalutConnection *self, const GArray *contact_handles, (GDestroyNotify) g_value_array_free); for (i = 0; i < contact_handles->len; i++) { - Handle handle = g_array_index (contact_handles, Handle, i); + TpHandle handle = g_array_index (contact_handles, TpHandle, i); GValue *message; SalutPresenceId status; gchar *status_message = NULL; SalutContact *contact = NULL; - g_assert(handle_is_valid(self->handle_repo, - TP_HANDLE_TYPE_CONTACT, handle, NULL)); - - if (handle == self->self_handle) { + if (handle == base->self_handle) { status = priv->self->status; status_message = priv->self->status_message; } else { @@ -966,7 +627,9 @@ emit_presence_update (SalutConnection *self, get_presence_info(self, contact_handles, &presence_hash); - g_signal_emit (self, signals[PRESENCE_UPDATE], 0, presence_hash); + tp_svc_connection_interface_presence_emit_presence_update (self, + presence_hash); + g_hash_table_destroy (presence_hash); } @@ -975,36 +638,15 @@ emit_presence_update (SalutConnection *self, * Convenience function for calling emit_presence_update with one handle. */ static void -emit_one_presence_update (SalutConnection *self, Handle handle) +emit_one_presence_update (SalutConnection *self, TpHandle handle) { - GArray *handles = g_array_sized_new (FALSE, FALSE, sizeof (Handle), 1); + GArray *handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); g_array_insert_val (handles, 0, handle); emit_presence_update (self, handles); g_array_free (handles, TRUE); } -/* Dbus functions */ -/** - * salut_connection_add_status - * - * Implements DBus method AddStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_add_status (SalutConnection *obj, const gchar * status, GHashTable * parms, GError **error) -{ - *error = g_error_new (TELEPATHY_ERRORS, NotImplemented, - "Only one status is possible at a time with this protocol"); - return FALSE; -} - - /** * salut_connection_clear_status * @@ -1017,86 +659,25 @@ gboolean salut_connection_add_status (SalutConnection *obj, const gchar * status * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean salut_connection_clear_status (SalutConnection *self, GError **error) -{ +static void +salut_connection_clear_status (TpSvcConnectionInterfacePresence *iface, + DBusGMethodInvocation *context) { + SalutConnection *self = SALUT_CONNECTION(iface); SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); gboolean ret; + GError *error = NULL; - ERROR_IF_NOT_CONNECTED(self, *error); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); ret = salut_self_set_presence(priv->self, SALUT_PRESENCE_AVAILABLE, - NULL, error); + NULL, NULL); /* FIXME turn into a TP ERROR */ if (ret) { - emit_one_presence_update(self, self->self_handle); + emit_one_presence_update(self, base->self_handle); } - return TRUE; -} - - -/** - * salut_connection_connect - * - * Implements DBus method Connect - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_connect (SalutConnection *self, GError **error) -{ - if (self->status == TP_CONN_STATUS_DISCONNECTED) - return _salut_connection_connect(self, error); - return TRUE; -} - - -/** - * salut_connection_disconnect - * - * Implements DBus method Disconnect - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_disconnect (SalutConnection *self, GError **error) -{ - DEBUG("Disconnect request"); - if (self->status != TP_CONN_STATUS_DISCONNECTED) - return _salut_connection_disconnect(self); - return TRUE; -} - - -/** - * salut_connection_get_interfaces - * - * Implements DBus method GetInterfaces - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_get_interfaces (SalutConnection *obj, gchar *** ret, GError **error) -{ - const gchar *interfaces [] = { - TP_IFACE_CONN_INTERFACE_ALIASING, - TP_IFACE_CONN_INTERFACE_PRESENCE, - NULL }; - - *ret = g_strdupv((gchar **)interfaces); - return TRUE; + tp_svc_connection_interface_presence_return_from_clear_status(context); } /** @@ -1111,80 +692,28 @@ gboolean salut_connection_get_interfaces (SalutConnection *obj, gchar *** ret, G * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_connection_get_presence (SalutConnection *self, - const GArray *contacts, - GHashTable **ret, - GError **error) { - - get_presence_info(self, contacts, ret); - return TRUE; -} - - - - -/** - * salut_connection_get_protocol - * - * Implements DBus method GetProtocol - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_get_protocol (SalutConnection *obj, gchar ** ret, GError **error) +static void +salut_connection_get_presence (TpSvcConnectionInterfacePresence *iface, + const GArray *contacts, + DBusGMethodInvocation *context) { - g_assert(SALUT_IS_CONNECTION(obj)); - - *ret = g_strdup(PROTOCOL); - - return TRUE; -} - - -/** - * salut_connection_get_self_handle - * - * Implements DBus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_self_handle (SalutConnection *self, guint* ret, - GError **error) { - ERROR_IF_NOT_CONNECTED(self, *error); - *ret = self->self_handle; - return TRUE; -} + SalutConnection *self = SALUT_CONNECTION(iface); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + base,TP_HANDLE_TYPE_CONTACT); + GError *error = NULL; + GHashTable *ret; + if (!tp_handles_are_valid(handle_repo, contacts, FALSE, &error)) { + dbus_g_method_return_error(context, error); + g_error_free(error); + return; + } -/** - * salut_connection_get_status - * - * Implements DBus method GetStatus - * on interface org.freedesktop.Telepathy.Connection - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_status (SalutConnection *obj, guint* ret, GError **error) -{ - *ret = obj->status; - return TRUE; + get_presence_info(self, contacts, &ret); + tp_svc_connection_interface_presence_return_from_get_presence(context, ret); + g_hash_table_destroy(ret); } @@ -1200,11 +729,14 @@ salut_connection_get_status (SalutConnection *obj, guint* ret, GError **error) * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean salut_connection_get_statuses (SalutConnection *obj, GHashTable ** ret, GError **error) -{ +static void +salut_connection_get_statuses (TpSvcConnectionInterfacePresence *iface, + DBusGMethodInvocation *context) { GValueArray *status; int i; - *ret = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + GHashTable *ret; + + ret = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_value_array_free); for (i = 0; salut_presence_statuses[i].name ; i++) { status = g_value_array_new(5); @@ -1228,135 +760,99 @@ gboolean salut_connection_get_statuses (SalutConnection *obj, GHashTable ** ret, g_value_set_static_boxed(g_value_array_get_nth(status, 3), get_statuses_arguments()); - g_hash_table_insert(*ret, (gchar*)salut_presence_statuses[i].name, status); + g_hash_table_insert(ret, (gchar*)salut_presence_statuses[i].name, status); } - return TRUE; + tp_svc_connection_interface_presence_return_from_get_statuses(context, + ret); + g_hash_table_destroy(ret); } - /** - * salut_connection_hold_handles + * salut_connection_remove_status * - * Implements DBus method HoldHandles - * on interface org.freedesktop.Telepathy.Connection + * Implements DBus method RemoveStatus + * on interface org.freedesktop.Telepathy.Connection.Interface.Presence * - * @context: The DBUS invocation context to use to return values - * or throw an error. + * @error: Used to return a pointer to a GError detailing any error + * that occured, DBus will throw the error only if this + * function returns false. + * + * Returns: TRUE if successful, FALSE if an error was thrown. */ -void salut_connection_hold_handles (SalutConnection *self, - guint handle_type, - const GArray * handles, - DBusGMethodInvocation *context) -{ +static void +salut_connection_remove_status (TpSvcConnectionInterfacePresence *iface, + const gchar *status, + DBusGMethodInvocation *context) { + SalutConnection *self = SALUT_CONNECTION(iface); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + gboolean ret = TRUE; GError *error = NULL; - gchar *sender; - int i; - ERROR_IF_NOT_CONNECTED_ASYNC(self, error, context); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); - if (!handles_are_valid(self->handle_repo, handle_type, - handles, FALSE, &error)) { - dbus_g_method_return_error (context, error); + if (!tp_strdiff(status, salut_presence_statuses[priv->self->status].name)) { + ret = salut_self_set_presence(priv->self, SALUT_PRESENCE_AVAILABLE, + "Available", NULL); + /* FIXME turn into a TP ERROR */ + if (ret) { + emit_one_presence_update(self, base->self_handle); + } + } else { + error = g_error_new (TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Attempting to remove non-existing presence."); + dbus_g_method_return_error(context, error); g_error_free(error); return; } - sender = dbus_g_method_get_sender(context); - for (i = 0; i < handles->len; i++) { - Handle handle = g_array_index(handles, Handle, i); - if (!handle_client_hold(self->handle_repo, sender, handle, - handle_type, &error)) { - dbus_g_method_return_error(context, error); - g_error_free(error); - return; - } - } - - dbus_g_method_return(context); + + tp_svc_connection_interface_presence_return_from_remove_status(context); } - /** - * salut_connection_inspect_handles + * salut_connection_request_presence * - * Implements DBus method InspectHandles - * on interface org.freedesktop.Telepathy.Connection + * Implements DBus method RequestPresence + * on interface org.freedesktop.Telepathy.Connection.Interface.Presence * - * @context: The DBUS invocation context to use to return values - * or throw an error. + * @error: Used to return a pointer to a GError detailing any error + * that occured, DBus will throw the error only if this + * function returns false. + * + * Returns: TRUE if successful, FALSE if an error was thrown. */ -void -salut_connection_inspect_handles (SalutConnection *self, guint handle_type, - const GArray * handles, - DBusGMethodInvocation *context) -{ +static void +salut_connection_request_presence (TpSvcConnectionInterfacePresence *iface, + const GArray * contacts, + DBusGMethodInvocation *context) { + SalutConnection *self = SALUT_CONNECTION (iface); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(self), TP_HANDLE_TYPE_CONTACT); GError *error = NULL; - const gchar **ret; - int i; - ERROR_IF_NOT_CONNECTED_ASYNC(self, error, context); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); - if (!handles_are_valid(self->handle_repo, - handle_type, - handles, - FALSE, - &error)) { + if (!tp_handles_are_valid(handle_repo, contacts, FALSE, &error)) { dbus_g_method_return_error(context, error); g_error_free(error); return; } - ret = g_new(const gchar *, handles->len + 1); - for (i = 0 ; i < handles->len ; i++ ) { - Handle handle; - const gchar *n; - handle = g_array_index(handles, Handle, i); - n = handle_inspect(self->handle_repo, handle_type, handle); - g_assert(n != NULL); - - ret[i] = n; - } - - ret[i] = NULL; + if (contacts->len) + emit_presence_update(self, contacts); - dbus_g_method_return(context, ret); - g_free(ret); + tp_svc_connection_interface_presence_return_from_request_presence(context); + return; } -static void -list_channel_factory_foreach_one(TpChannelIface *chan, gpointer data) { - GObject *channel = G_OBJECT(chan); - GPtrArray *channels = (GPtrArray *)data; - gchar *path, *type; - guint handle_type, handle; - - GValue entry = {0, }; - g_value_init(&entry, TP_CHANNEL_LIST_ENTRY_TYPE); - g_value_take_boxed(&entry, - dbus_g_type_specialized_construct((TP_CHANNEL_LIST_ENTRY_TYPE))); - - g_object_get(channel, - "object-path", &path, - "channel-type", &type, - "handle-type", &handle_type, - "handle", &handle, - NULL); - dbus_g_type_struct_set(&entry, - 0, path, - 1, type, - 2, handle_type, - 3, handle, G_MAXUINT); - g_ptr_array_add(channels, g_value_get_boxed(&entry)); - - g_free(path); - g_free(type); -} /** - * salut_connection_list_channels + * salut_connection_set_status * - * Implements DBus method ListChannels - * on interface org.freedesktop.Telepathy.Connection + * Implements DBus method SetStatus + * on interface org.freedesktop.Telepathy.Connection.Interface.Presence * * @error: Used to return a pointer to a GError detailing any error * that occured, DBus will throw the error only if this @@ -1364,234 +860,361 @@ list_channel_factory_foreach_one(TpChannelIface *chan, gpointer data) { * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_connection_list_channels (SalutConnection *self, - GPtrArray ** ret, - GError **error) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); - GPtrArray *channels = NULL; - int i; - TpChannelFactoryIface *factories[] = - { TP_CHANNEL_FACTORY_IFACE(priv->contact_manager), - TP_CHANNEL_FACTORY_IFACE(priv->im_manager), - TP_CHANNEL_FACTORY_IFACE(priv->muc_manager), - NULL - }; - - - ERROR_IF_NOT_CONNECTED(self, *error); +static void +salut_connection_set_status (TpSvcConnectionInterfacePresence *iface, + GHashTable * statuses, + DBusGMethodInvocation *context) +{ + SalutConnection *self = SALUT_CONNECTION(iface); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); + SalutPresenceId id = 0; + GHashTable *parameters = NULL; + const gchar *status_message = NULL; + GValue *message; + gboolean ret = TRUE; + GError *error = NULL; - channels = g_ptr_array_sized_new(3); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); - for (i = 0; factories[i] != NULL; i++) { - tp_channel_factory_iface_foreach(factories[i], - list_channel_factory_foreach_one, channels); + if (g_hash_table_size(statuses) != 1) { + DEBUG("Got more then one status"); + error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Only one status may be set at a time in this protocol"); + dbus_g_method_return_error(context, error); + g_error_free(error); + return; } - *ret = channels; - return TRUE; -} - - -/** - * salut_connection_release_handles - * - * Implements DBus method ReleaseHandles - * on interface org.freedesktop.Telepathy.Connection - * - * @context: The DBUS invocation context to use to return values - * or throw an error. - */ -void -salut_connection_release_handles (SalutConnection *self, - guint handle_type, - const GArray * handles, - DBusGMethodInvocation *context) { - gchar *sender; - GError *error = NULL; - int i; + /* Don't feel like jumping through hoops with a foreach */ + for ( ; id < SALUT_PRESENCE_NR_PRESENCES; id++) { + parameters = g_hash_table_lookup(statuses, + salut_presence_statuses[id].name); + if (parameters) { + break; + } + } - ERROR_IF_NOT_CONNECTED_ASYNC(self, error, context); - if (!handles_are_valid(self->handle_repo, - handle_type, - handles, - FALSE, - &error)) { + if (id == SALUT_PRESENCE_NR_PRESENCES) { + error = g_error_new (TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Unknown status"); dbus_g_method_return_error(context, error); g_error_free(error); return; } - sender = dbus_g_method_get_sender(context); - for (i = 0; i < handles->len; i++) { - Handle handle = g_array_index(handles, Handle, i); - if (!handle_client_release (self->handle_repo, sender, handle, - handle_type, &error)) { + + message = g_hash_table_lookup(parameters, "message"); + if (message) { + if (!G_VALUE_HOLDS_STRING(message)) { + error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Status argument 'message' requeires a string"); dbus_g_method_return_error(context, error); g_error_free(error); return; } + status_message = g_value_get_string(message); } - dbus_g_method_return (context); - return; + ret = salut_self_set_presence(priv->self, id, status_message, NULL); + /* FIXME turn into a TP ERROR */ + if (ret) { + emit_one_presence_update(self, base->self_handle); + } + + tp_svc_connection_interface_presence_return_from_set_status(context); } +static void +salut_connection_presence_service_iface_init(gpointer g_iface, + gpointer iface_data) +{ + TpSvcConnectionInterfacePresenceClass *klass = + (TpSvcConnectionInterfacePresenceClass *) g_iface; +#define IMPLEMENT(x) tp_svc_connection_interface_presence_implement_##x (klass, \ + salut_connection_##x) + IMPLEMENT(set_status); + IMPLEMENT(remove_status); + IMPLEMENT(request_presence); + IMPLEMENT(get_presence); + IMPLEMENT(get_statuses); + IMPLEMENT(clear_status); + +#undef IMPLEMENT +} + +/* Aliasing interface */ /** - * salut_connection_remove_status - * - * Implements DBus method RemoveStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence + * salut_connection_get_alias_flags * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. + * Implements D-Bus method GetAliasFlags + * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing * - * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_connection_remove_status (SalutConnection *self, - const gchar * status, GError **error) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); - gboolean ret = TRUE; - - ERROR_IF_NOT_CONNECTED(self, *error); - - if (strcmp(status, salut_presence_statuses[priv->self->status].name) == 0) { - ret = salut_self_set_presence(priv->self, SALUT_PRESENCE_AVAILABLE, - "Available", error); - /* FIXME turn into a TP ERROR */ - if (ret) { - emit_one_presence_update(self, self->self_handle); - } - } else { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "Attempting to remove non-existing presence."); - ret = FALSE; - } +void +salut_connection_get_alias_flags (TpSvcConnectionInterfaceAliasing *self, + DBusGMethodInvocation *context) +{ + /* Aliases are set by the contacts + * Actually we concat the first and lastname property */ - return ret; + tp_svc_connection_interface_aliasing_return_from_get_alias_flags (context, 0); } - /** - * salut_connection_request_channel + * salut_connection_request_aliases * - * Implements DBus method RequestChannel - * on interface org.freedesktop.Telepathy.Connection + * Implements D-Bus method RequestAliases + * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing * - * @context: The DBUS invocation context to use to return values - * or throw an error. */ -void -salut_connection_request_channel (SalutConnection *self, const gchar * type, - guint handle_type, guint handle, - gboolean suppress_handler, - DBusGMethodInvocation *context) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); - TpChannelFactoryRequestStatus status = - TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED ; - TpChannelIface *chan = NULL; - gchar *object_path = NULL; - GError *error = NULL; - TpChannelFactoryIface *factories[] = - { TP_CHANNEL_FACTORY_IFACE(priv->contact_manager), - TP_CHANNEL_FACTORY_IFACE(priv->im_manager), - TP_CHANNEL_FACTORY_IFACE(priv->muc_manager), - NULL - }; +void +salut_connection_request_aliases (TpSvcConnectionInterfaceAliasing *iface, + const GArray *contacts, + DBusGMethodInvocation *context) +{ + SalutConnection *self = SALUT_CONNECTION(iface); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); + TpBaseConnection *base = TP_BASE_CONNECTION(self); int i; + const gchar **aliases; + GError *error = NULL; + TpHandleRepoIface *contact_handles = + tp_base_connection_get_handles(base, TP_HANDLE_TYPE_CONTACT); - ERROR_IF_NOT_CONNECTED_ASYNC(self, error, context); + DEBUG("Alias requested"); - DEBUG("Requested channel of type %s for handle %d of type %d", - type, handle, handle_type); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); - priv->suppress_current = suppress_handler; - for (i = 0; factories[i] != NULL; i++) { - TpChannelFactoryRequestStatus prev_status = status; - status = tp_channel_factory_iface_request ( - factories[i], type, (TpHandleType) handle_type, handle, &chan); - if (status == TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE || - status == TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED) { - break; - } - status = MAX(prev_status, status); + if (!tp_handles_are_valid(contact_handles, contacts, FALSE, &error)) { + dbus_g_method_return_error(context, error); + g_error_free(error); + return; } - priv->suppress_current = FALSE; - - - switch (status) { - case TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE: - g_object_get (chan, "object-path", &object_path, NULL); - goto got_channel; - case TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED: { - ChannelRequest *request; - DEBUG ("queueing request, channel_type=%s, handle_type=%u, " - "handle=%u, suppress_handler=%u", type, handle_type, - handle, suppress_handler); - request = channel_request_new (context, type, handle_type, handle, - suppress_handler); - g_ptr_array_add (priv->channel_requests, request); - goto out; + aliases = g_new0(const gchar *, contacts->len + 1); + for (i = 0; i < contacts->len; i++) { + TpHandle handle = g_array_index (contacts, TpHandle, i); + SalutContact *contact; + if (handle == TP_BASE_CONNECTION(self)->self_handle) { + aliases[i] = salut_self_get_alias(priv->self); + } else { + contact = salut_contact_manager_get_contact(priv->contact_manager, handle); + aliases[i] = salut_contact_get_alias(contact); + g_object_unref(contact); } - case TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE: - error = g_error_new (TELEPATHY_ERRORS, InvalidHandle, - "invalid handle %u", handle); - break; - case TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE: - error = g_error_new (TELEPATHY_ERRORS, NotAvailable, - "requested channel is not available with " - "handle type %u", handle_type); - break; - case TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED: - error = g_error_new (TELEPATHY_ERRORS, NotImplemented, - "unsupported channel type %s", type); - break; - default: - g_assert_not_reached(); } - if (error != NULL) { - g_assert (object_path == NULL); - DEBUG("Returned error: %s", error->message); - dbus_g_method_return_error(context, error); - g_error_free(error); - return; + tp_svc_connection_interface_aliasing_return_from_request_aliases( + context, aliases); + + g_free(aliases); + return; +} + +void +_contact_manager_contact_alias_cb(SalutContactManager *mgr, + SalutContact *contact, + gchar *alias, + gpointer data) { + SalutConnection *self = SALUT_CONNECTION(data); + GPtrArray *aliases; + GValue entry = {0, }; + TpHandle handle ; + + /* FIXME. The contact should probably know it's own handle */ + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(self), TP_HANDLE_TYPE_CONTACT); + + handle = tp_handle_lookup(handle_repo, contact->name, NULL, NULL); + if (handle == 0) { + DEBUG("Invalid handle updated"); + } + + g_value_init(&entry, TP_ALIAS_PAIR_TYPE); + g_value_take_boxed(&entry, + dbus_g_type_specialized_construct(TP_ALIAS_PAIR_TYPE)); + + dbus_g_type_struct_set(&entry, + 0, handle, + 1, alias, + G_MAXUINT); + aliases = g_ptr_array_sized_new(1); + g_ptr_array_add(aliases, g_value_get_boxed(&entry)); + + DEBUG("Emitting AliasesChanged"); + + tp_svc_connection_interface_aliasing_emit_aliases_changed(self, + aliases); + + g_value_unset(&entry); + g_ptr_array_free(aliases, TRUE); +} + +static void +salut_connection_aliasing_service_iface_init(gpointer g_iface, + gpointer iface_data) +{ + TpSvcConnectionInterfaceAliasingClass *klass = + (TpSvcConnectionInterfaceAliasingClass *) g_iface; + +#define IMPLEMENT(x) tp_svc_connection_interface_aliasing_implement_##x \ + (klass, salut_connection_##x) + IMPLEMENT(get_alias_flags); + IMPLEMENT(request_aliases); +#undef IMPLEMENT +} + +/* Connection baseclass function implementations */ +static void +salut_connection_create_handle_repos(TpBaseConnection *self, + TpHandleRepoIface *repos[NUM_TP_HANDLE_TYPES]) { + static const char *list_handle_strings[] = { + "publish", + "subscribe", + "known", + NULL + }; + + repos[TP_HANDLE_TYPE_CONTACT] = + TP_HANDLE_REPO_IFACE( + g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, + "handle-type", TP_HANDLE_TYPE_CONTACT, + NULL)); + + repos[TP_HANDLE_TYPE_ROOM] = + TP_HANDLE_REPO_IFACE( + g_object_new(TP_TYPE_DYNAMIC_HANDLE_REPO, + "handle-type", TP_HANDLE_TYPE_ROOM, + NULL)); + + repos[TP_HANDLE_TYPE_LIST] = + TP_HANDLE_REPO_IFACE( + g_object_new(TP_TYPE_STATIC_HANDLE_REPO, + "handle-type", TP_HANDLE_TYPE_LIST, + "handle-names", list_handle_strings, + NULL)); +} + +static GPtrArray* +salut_connection_create_channel_factories(TpBaseConnection *base) { + SalutConnection *self = SALUT_CONNECTION(base); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); + GPtrArray *factories = g_ptr_array_sized_new(3); + + priv->contact_manager = salut_contact_manager_new(self); + g_signal_connect(priv->contact_manager, "contact-status-changed", + G_CALLBACK(_contact_manager_contact_status_cb), self); + g_signal_connect(priv->contact_manager, "contact-alias-changed", + G_CALLBACK(_contact_manager_contact_alias_cb), self); + + priv->im_manager = salut_im_manager_new(self, priv->contact_manager); + + priv->muc_manager = salut_muc_manager_new(self, priv->im_manager); + + g_ptr_array_add(factories, priv->contact_manager); + g_ptr_array_add(factories, priv->im_manager); + g_ptr_array_add(factories, priv->muc_manager); + + return factories; +} + +static gchar * +salut_connection_get_unique_connection_name(TpBaseConnection *base) { + SalutConnection *self = SALUT_CONNECTION(base); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE(self); + + return g_strdup(priv->published_name); +} + +static void +salut_connection_shut_down(TpBaseConnection *self) { + _salut_connection_disconnect(SALUT_CONNECTION(self)); + tp_base_connection_finish_shutdown(self); +} + +static gboolean +salut_connection_start_connecting(TpBaseConnection *base, GError **error) { + SalutConnection *self = SALUT_CONNECTION(base); + SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); + GError *client_error = NULL; + +/* + tp_base_connection_change_status( + TP_BASE_CONNECTION(base), + TP_CONNECTION_STATUS_CONNECTING, + TP_CONNECTION_STATUS_REASON_REQUESTED); + */ + + priv->avahi_client = salut_avahi_client_new(SALUT_AVAHI_CLIENT_FLAG_NO_FAIL); + + g_signal_connect(priv->avahi_client, "state-changed::running", + G_CALLBACK(_salut_avahi_client_running_cb), self); + g_signal_connect(priv->avahi_client, "state-changed::failure", + G_CALLBACK(_salut_avahi_client_failure_cb), self); + + if (!salut_avahi_client_start(priv->avahi_client, &client_error)) { + *error = g_error_new(TP_ERRORS, TP_ERROR_NOT_AVAILABLE, + "Unstable to initialize the avahi client: %s", + client_error->message); + g_error_free(client_error); + goto error; } -got_channel: - DEBUG ("got channel for request, channel_type=%s, handle_type=%u, " - "handle=%u, suppress_handler=%u", type, handle_type, - handle, suppress_handler); - g_assert(object_path != NULL); - dbus_g_method_return(context, object_path); - g_free(object_path); -out: - ; + return TRUE; + +error: + tp_base_connection_change_status( + TP_BASE_CONNECTION(base), + TP_CONNECTION_STATUS_DISCONNECTED, + TP_CONNECTION_STATUS_REASON_NETWORK_ERROR); + return FALSE; +} + +/* Connection interface implementations */ +static void +salut_connection_get_interfaces (TpSvcConnection *self, + DBusGMethodInvocation *context) +{ + const gchar *interfaces [] = { + TP_IFACE_CONNECTION_INTERFACE_ALIASING, + TP_IFACE_CONNECTION_INTERFACE_PRESENCE, + NULL }; + + tp_svc_connection_return_from_get_interfaces(context, interfaces); } static void -hold_and_return_handles (DBusGMethodInvocation *context, - SalutConnection *conn, - GArray *handles, - guint handle_type) { +hold_unref_and_return_handles (DBusGMethodInvocation *context, + TpHandleRepoIface *repo, + GArray *handles) { GError *error; gchar *sender = dbus_g_method_get_sender(context); - guint i; + int i,j = 0; for (i = 0; i < handles->len; i++) { - Handle handle = (Handle) g_array_index (handles, guint, i); - if (!handle_client_hold (conn->handle_repo, sender, - handle, handle_type, &error)) { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; + TpHandle handle = (TpHandle) g_array_index (handles, guint, i); + if (!tp_handle_client_hold (repo, sender, handle, &error)) { + goto error; } + tp_handle_unref(repo, handle); } dbus_g_method_return (context, handles); + return; + +error: + dbus_g_method_return_error (context, error); + g_error_free (error); + for (j = 0; j < i; j++) { + TpHandle handle = (TpHandle) g_array_index (handles, guint, j); + tp_handle_client_release(repo, sender, handle, NULL); + } + /* j == i */ + for (; j < handles->len; j++) { + TpHandle handle = (TpHandle) g_array_index (handles, guint, j); + tp_handle_unref(repo, handle); + } } @@ -1605,19 +1228,24 @@ hold_and_return_handles (DBusGMethodInvocation *context, * or throw an error. */ void -salut_connection_request_handles (SalutConnection *self, +salut_connection_request_handles (TpSvcConnection *iface, guint handle_type, const gchar ** names, DBusGMethodInvocation *context) { + SalutConnection *self = SALUT_CONNECTION(iface); + TpBaseConnection *base = TP_BASE_CONNECTION(self); GError *error = NULL; const gchar **n; int count = 0; - int i; + int i, j; GArray *handles = NULL; + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(self), handle_type); + - ERROR_IF_NOT_CONNECTED_ASYNC(self, error, context); + ERROR_IF_NOT_CONNECTED_ASYNC(base, error, context); - if (!handle_type_is_valid(handle_type, &error)) { + if (!tp_handle_type_is_valid(handle_type, &error)) { DEBUG("Invalid handle type: %d", handle_type); dbus_g_method_return_error(context, error); g_error_free(error); @@ -1627,7 +1255,7 @@ salut_connection_request_handles (SalutConnection *self, for (n = names; *n != NULL; n++) { if (*n == '\0') { DEBUG("Request for empty name?!"); - error = g_error_new(TELEPATHY_ERRORS, InvalidArgument, + error = g_error_new(TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "Empty handle name"); dbus_g_method_return_error(context, error); g_error_free(error); @@ -1641,35 +1269,41 @@ salut_connection_request_handles (SalutConnection *self, case TP_HANDLE_TYPE_CONTACT: case TP_HANDLE_TYPE_LIST: case TP_HANDLE_TYPE_ROOM: - handles = g_array_sized_new(FALSE, FALSE, sizeof(Handle), count); + handles = g_array_sized_new(FALSE, FALSE, sizeof(TpHandle), count); for (i = 0; i < count ; i++) { - Handle handle; + TpHandle handle; const gchar *name = names[i]; - if (!handle_name_is_valid(handle_type, name, &error)) { + /* + if (!tp_handle_name_is_valid(handle_type, name, &error)) { dbus_g_method_return_error(context, error); g_error_free(error); g_array_free(handles, TRUE); return; } + */ - handle = handle_for_type (self->handle_repo, handle_type, name); + handle = tp_handle_ensure(handle_repo, name, NULL, &error); if (handle == 0) { - error = g_error_new (TELEPATHY_ERRORS, NotAvailable, + error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "requested handle %s wasn't available", name); dbus_g_method_return_error(context, error); g_error_free(error); + for (j = 0; j < i; j++) { + tp_handle_unref(handle_repo, + (TpHandle) g_array_index (handles, TpHandle, j)); + } g_array_free(handles, TRUE); return; } g_array_append_val(handles, handle); } - hold_and_return_handles (context, self, handles, handle_type); + hold_unref_and_return_handles (context, handle_repo, handles); g_array_free(handles, TRUE); break; default: DEBUG("Unimplemented handle type"); - error = g_error_new(TELEPATHY_ERRORS, NotAvailable, + error = g_error_new(TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "unimplemented handle type %u", handle_type); dbus_g_method_return_error(context, error); g_error_free(error); @@ -1678,203 +1312,15 @@ salut_connection_request_handles (SalutConnection *self, return; } -/** - * salut_connection_request_presence - * - * Implements DBus method RequestPresence - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_request_presence (SalutConnection *self, - const GArray * contacts, GError **error) { - - ERROR_IF_NOT_CONNECTED(self, *error); - if (!handles_are_valid(self->handle_repo, TP_HANDLE_TYPE_CONTACT, - contacts, FALSE, error)) - return FALSE; - - if (contacts->len) - emit_presence_update(self, contacts); - - return TRUE; -} - - -/** - * salut_connection_set_last_activity_time - * - * Implements DBus method SetLastActivityTime - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_connection_set_last_activity_time (SalutConnection *obj, guint time, GError **error) -{ - *error = g_error_new (TELEPATHY_ERRORS, NotImplemented, - "NotImplemented (%d)", __LINE__); - return FALSE; -} - - -/** - * salut_connection_set_status - * - * Implements DBus method SetStatus - * on interface org.freedesktop.Telepathy.Connection.Interface.Presence - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_set_status (SalutConnection *self, - GHashTable * statuses, GError **error) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - SalutPresenceId id = 0; - GHashTable *parameters = NULL; - const gchar *status_message = NULL; - GValue *message; - gboolean ret = TRUE; - - ERROR_IF_NOT_CONNECTED(self, *error); - - if (g_hash_table_size(statuses) != 1) { - DEBUG("Got more then one status"); - *error = g_error_new(TELEPATHY_ERRORS, InvalidArgument, - "Only one status may be set at a time in this protocol"); - return FALSE; - } - /* Don't feel like jumping through hoops with a foreach */ - for ( ; id < SALUT_PRESENCE_NR_PRESENCES; id++) { - parameters = g_hash_table_lookup(statuses, - salut_presence_statuses[id].name); - if (parameters) { - break; - } - } - - if (id == SALUT_PRESENCE_NR_PRESENCES) { - *error = g_error_new (TELEPATHY_ERRORS, InvalidArgument, - "Unknown status"); - return FALSE; - } - - message = g_hash_table_lookup(parameters, "message"); - if (message) { - if (!G_VALUE_HOLDS_STRING(message)) { - *error = g_error_new(TELEPATHY_ERRORS, InvalidArgument, - "Status argument 'message' requeires a string"); - return FALSE; - } - status_message = g_value_get_string(message); - } - - ret = salut_self_set_presence(priv->self, id, status_message, error); - /* FIXME turn into a TP ERROR */ - if (ret) { - emit_one_presence_update(self, self->self_handle); - } - - return ret; -} - -/** - * salut_connection_get_alias_flags - * - * Implements D-Bus method GetAliasFlags - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_get_alias_flags (SalutConnection *self, - guint *ret, - GError **error) +static void +salut_connection_connection_service_iface_init(gpointer g_iface, + gpointer iface_data) { - /* Aliases are set by the contacts - * Actually we concat the first and lastname property */ - *ret = 0; - return TRUE; -} - -/** - * salut_connection_request_aliases - * - * Implements D-Bus method RequestAliases - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_request_aliases (SalutConnection *self, - const GArray *contacts, - gchar ***ret, - GError **error) { - SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self); - int i; - gchar **aliases; - - DEBUG("Alias requested"); - - ERROR_IF_NOT_CONNECTED(self, *error); - if (!handles_are_valid(self->handle_repo, TP_HANDLE_TYPE_CONTACT, - contacts, FALSE, error)) { - return FALSE; - } - - aliases = g_new0(gchar *, contacts->len + 1); - for (i = 0; i < contacts->len; i++) { - Handle handle = g_array_index (contacts, Handle, i); - SalutContact *contact; - if (handle == self->self_handle) { - aliases[i] = g_strdup(salut_self_get_alias(priv->self)); - } else { - contact = salut_contact_manager_get_contact(priv->contact_manager, handle); - aliases[i] = g_strdup(salut_contact_get_alias(contact)); - g_object_unref(contact); - } - } - *ret = aliases; - return TRUE; -} - -/** - * salut_connection_set_aliases - * - * Implements D-Bus method SetAliases - * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_connection_set_aliases (SalutConnection *self, - GHashTable *aliases, - GError **error) { - *error = g_error_new(TELEPATHY_ERRORS, InvalidArgument, - "Aliases can't be set on salut"); - return FALSE; + TpSvcConnectionClass *klass = + (TpSvcConnectionClass *) g_iface; +#define IMPLEMENT(x) tp_svc_connection_implement_##x (klass, \ + salut_connection_##x) + IMPLEMENT(get_interfaces); + IMPLEMENT(request_handles); +#undef IMPLEMENT } diff --git a/src/salut-connection.h b/src/salut-connection.h index dd2ecc19..fe5c91c8 100644 --- a/src/salut-connection.h +++ b/src/salut-connection.h @@ -24,8 +24,9 @@ #include <glib-object.h> #include <dbus/dbus-glib.h> -#include "telepathy-constants.h" -#include "handle-types.h" +#include <telepathy-glib/enums.h> +#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/svc-connection.h> G_BEGIN_DECLS @@ -33,22 +34,16 @@ typedef struct _SalutConnection SalutConnection; typedef struct _SalutConnectionClass SalutConnectionClass; struct _SalutConnectionClass { - GObjectClass parent_class; + TpBaseConnectionClass parent_class; }; struct _SalutConnection { - GObject parent; - gchar *bus_name; - gchar *object_path; + TpBaseConnection parent; - /* Connection status */ - TpConnectionStatus status; - - /* handles handles handles */ - HandleRepo *handle_repo; - Handle self_handle; /* Our name on the network */ - gchar *name; + gchar*name; + + gpointer priv; }; GType salut_connection_get_type(void); @@ -67,132 +62,14 @@ GType salut_connection_get_type(void); #define SALUT_CONNECTION_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONNECTION, SalutConnectionClass)) -gboolean _salut_connection_register(SalutConnection *cn, char **bus_name, - char **object_path, GError **error); - -gboolean -salut_connection_add_status (SalutConnection *self, - const gchar *status, - GHashTable *parms, - GError **error); - -gboolean -salut_connection_clear_status (SalutConnection *self, - GError **error); - -gboolean -salut_connection_connect (SalutConnection *self, - GError **error); - -gboolean -salut_connection_disconnect (SalutConnection *self, - GError **error); - -gboolean -salut_connection_get_alias_flags (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_interfaces (SalutConnection *self, - gchar ***ret, - GError **error); - -gboolean -salut_connection_get_presence (SalutConnection *self, - const GArray *contacts, - GHashTable **ret, - GError **error); - -gboolean -salut_connection_get_protocol (SalutConnection *self, - gchar **ret, - GError **error); - -gboolean -salut_connection_get_self_handle (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_status (SalutConnection *self, - guint *ret, - GError **error); - -gboolean -salut_connection_get_statuses (SalutConnection *self, - GHashTable **ret, - GError **error); - -void -salut_connection_hold_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -void -salut_connection_inspect_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -gboolean -salut_connection_list_channels (SalutConnection *self, - GPtrArray **ret, - GError **error); - -void -salut_connection_release_handles (SalutConnection *self, - guint handle_type, - const GArray *handles, - DBusGMethodInvocation *context); - -gboolean -salut_connection_remove_status (SalutConnection *self, - const gchar *status, - GError **error); - -gboolean -salut_connection_request_aliases (SalutConnection *self, - const GArray *contacts, - gchar ***ret, - GError **error); - -void -salut_connection_request_channel (SalutConnection *self, - const gchar *type, - guint handle_type, - guint handle, - gboolean suppress_handler, - DBusGMethodInvocation *context); - -void -salut_connection_request_handles (SalutConnection *self, - guint handle_type, - const gchar **names, - DBusGMethodInvocation *context); - -gboolean -salut_connection_request_presence (SalutConnection *self, - const GArray *contacts, - GError **error); - -gboolean -salut_connection_set_aliases (SalutConnection *self, - GHashTable *aliases, - GError **error); - -gboolean -salut_connection_set_last_activity_time (SalutConnection *self, - guint time, - GError **error); - -gboolean -salut_connection_set_status (SalutConnection *self, - GHashTable *statuses, - GError **error); - +typedef enum { + LIST_HANDLE_PUBLISH = 1, + LIST_HANDLE_SUBSCRIBE, + LIST_HANDLE_KNOWN, + LIST_HANDLE_FIRST = LIST_HANDLE_PUBLISH, + LIST_HANDLE_LAST = LIST_HANDLE_KNOWN +} SalutConnectionListHandle; G_END_DECLS diff --git a/src/salut-contact-channel.c b/src/salut-contact-channel.c index 9250ebc0..a02730e0 100644 --- a/src/salut-contact-channel.c +++ b/src/salut-contact-channel.c @@ -22,29 +22,25 @@ #include <stdio.h> #include <stdlib.h> +#include "salut-connection.h" #include "salut-contact-channel.h" -#include "salut-contact-channel-signals-marshal.h" -#include "salut-contact-channel-glue.h" +#include <telepathy-glib/dbus.h> +#include <telepathy-glib/channel-iface.h> +#include <telepathy-glib/interfaces.h> +#include <telepathy-glib/util.h> -#include "handle-types.h" -#include "tp-channel-iface.h" -#include "salut-connection.h" -#include "telepathy-helpers.h" -#include "telepathy-interfaces.h" -#include "telepathy-errors.h" +static void +channel_iface_init(gpointer g_iface, gpointer iface_data); G_DEFINE_TYPE_WITH_CODE(SalutContactChannel, salut_contact_channel, - G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL)); - -/* signal enum */ -enum -{ - CLOSED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, channel_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP, + tp_group_mixin_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_CONTACT_LIST, NULL); +) /* properties */ enum @@ -64,7 +60,7 @@ struct _SalutContactChannelPrivate { SalutConnection *conn; gchar *object_path; - Handle handle; + TpHandle handle; gboolean dispose_has_run; }; @@ -85,8 +81,10 @@ salut_contact_channel_constructor (GType type, guint n_props, { GObject *obj; DBusGConnection *bus; - gboolean valid; SalutContactChannelPrivate *priv; + TpHandleRepoIface *handle_repo; + TpHandleRepoIface *contact_repo; + TpBaseConnection *base_conn; /* Parent constructor chain */ obj = G_OBJECT_CLASS(salut_contact_channel_parent_class)-> @@ -99,13 +97,20 @@ salut_contact_channel_constructor (GType type, guint n_props, dbus_g_connection_register_g_object(bus, priv->object_path, obj); /* Ref our handle */ - valid = handle_ref(priv->conn->handle_repo, TP_HANDLE_TYPE_LIST, priv->handle); - g_assert(valid); + base_conn = TP_BASE_CONNECTION(priv->conn); + + handle_repo = tp_base_connection_get_handles(base_conn, TP_HANDLE_TYPE_LIST); + contact_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_CONTACT); + + tp_handle_ref(handle_repo, priv->handle); /* Impossible to add/remove/rescind on any of our lists */ - group_mixin_init(obj, G_STRUCT_OFFSET(SalutContactChannel, group), - priv->conn->handle_repo, priv->conn->self_handle); - group_mixin_change_flags(obj, 0, 0); + tp_group_mixin_init(TP_SVC_CHANNEL_INTERFACE_GROUP(obj), + G_STRUCT_OFFSET(SalutContactChannel, group), + contact_repo, base_conn->self_handle); + + tp_group_mixin_change_flags(TP_SVC_CHANNEL_INTERFACE_GROUP(obj), 0, 0); return obj; } @@ -152,6 +157,7 @@ salut_contact_channel_set_property (GObject *object, { SalutContactChannel *chan = SALUT_CONTACT_CHANNEL (object); SalutContactChannelPrivate *priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE (chan); + const gchar *tmp; switch (property_id) { case PROP_OBJECT_PATH: @@ -164,6 +170,16 @@ salut_contact_channel_set_property (GObject *object, case PROP_CONNECTION: priv->conn = g_value_get_object (value); break; + case PROP_HANDLE_TYPE: + g_assert(g_value_get_uint(value) == 0 + || g_value_get_uint(value) == TP_HANDLE_TYPE_LIST); + break; + case PROP_CHANNEL_TYPE: + tmp = g_value_get_string(value); + g_assert(tmp == NULL + || !tp_strdiff(g_value_get_string(value), + TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -201,19 +217,9 @@ salut_contact_channel_class_init (SalutContactChannelClass *salut_contact_channe g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type"); g_object_class_override_property (object_class, PROP_HANDLE, "handle"); - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_contact_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_contact_channel_marshal_VOID__VOID, - G_TYPE_NONE, 0); - group_mixin_class_init(object_class, + tp_group_mixin_class_init((TpSvcChannelInterfaceGroupClass *)object_class, G_STRUCT_OFFSET(SalutContactChannelClass, group_class), NULL, NULL); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_contact_channel_class), &dbus_glib_salut_contact_channel_object_info); } void @@ -221,13 +227,19 @@ salut_contact_channel_dispose (GObject *object) { SalutContactChannel *self = SALUT_CONTACT_CHANNEL (object); SalutContactChannelPrivate *priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE (self); + TpBaseConnection *base_conn = TP_BASE_CONNECTION(priv->conn); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles (base_conn, + TP_HANDLE_TYPE_LIST); if (priv->dispose_has_run) return; priv->dispose_has_run = TRUE; - g_signal_emit(self, signals[CLOSED], 0); + tp_svc_channel_emit_closed(TP_SVC_CHANNEL(object)); + + tp_handle_unref(handle_repo, priv->handle); + /* release any references held by the object here */ @@ -243,78 +255,12 @@ salut_contact_channel_finalize (GObject *object) /* free any data held directly by the object here */ g_free(priv->object_path); - handle_unref(priv->conn->handle_repo, TP_HANDLE_TYPE_LIST, priv->handle); - group_mixin_finalize(object); - - G_OBJECT_CLASS (salut_contact_channel_parent_class)->finalize (object); -} - + tp_group_mixin_finalize(TP_SVC_CHANNEL_INTERFACE_GROUP(object)); -/** - * salut_contact_channel_add_members - * - * Implements DBus method AddMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_add_members (SalutContactChannel *self, - const GArray * contacts, - const gchar * message, - GError **error) -{ - return group_mixin_add_members (G_OBJECT (self), contacts, message, - error); -} - - -/** - * salut_contact_channel_close - * - * Implements DBus method Close - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_close (SalutContactChannel *obj, GError **error) -{ - *error = g_error_new (TELEPATHY_ERRORS, NotImplemented, - "you may not close contact list channels"); - return FALSE; -} - - -/** - * salut_contact_channel_get_all_members - * - * Implements DBus method GetAllMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_get_all_members (SalutContactChannel *self, - GArray ** ret, - GArray ** ret1, - GArray ** ret2, - GError **error) -{ - return group_mixin_get_all_members (G_OBJECT (self), ret, ret1, ret2, error); + G_OBJECT_CLASS (salut_contact_channel_parent_class)->finalize (object); } - /** * salut_contact_channel_get_channel_type * @@ -327,29 +273,12 @@ gboolean salut_contact_channel_get_all_members (SalutContactChannel *self, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean salut_contact_channel_get_channel_type (SalutContactChannel *obj, gchar ** ret, GError **error) -{ - *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_CONTACT_LIST); - return TRUE; -} - - -/** - * salut_contact_channel_get_group_flags - * - * Implements DBus method GetGroupFlags - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_get_group_flags (SalutContactChannel *self, - guint* ret, GError **error) +static void +salut_contact_channel_get_channel_type (TpSvcChannel *iface, + DBusGMethodInvocation *context) { - return group_mixin_get_group_flags (G_OBJECT (self), ret, error); + tp_svc_channel_return_from_get_channel_type(context, + TP_IFACE_CHANNEL_TYPE_CONTACT_LIST); } @@ -365,37 +294,15 @@ gboolean salut_contact_channel_get_group_flags (SalutContactChannel *self, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean salut_contact_channel_get_handle (SalutContactChannel *self, - guint* ret, - guint* ret1, GError **error) +static void +salut_contact_channel_get_handle (TpSvcChannel *iface, + DBusGMethodInvocation *context) { + SalutContactChannel *self = SALUT_CONTACT_CHANNEL(iface); SalutContactChannelPrivate *priv = SALUT_CONTACT_CHANNEL_GET_PRIVATE(self); - *ret = TP_HANDLE_TYPE_LIST; - *ret1 = priv->handle; - return TRUE; -} - -/** - * salut_contact_channel_get_handle_owners - * - * Implements DBus method GetHandleOwners - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_get_handle_owners (SalutContactChannel *self, - const GArray * handles, - GArray ** ret, - GError **error) -{ - return group_mixin_get_handle_owners (G_OBJECT (self), handles, ret, - error); - return TRUE; + tp_svc_channel_return_from_get_handle (context, TP_HANDLE_TYPE_LIST, + priv->handle); } @@ -411,135 +318,24 @@ gboolean salut_contact_channel_get_handle_owners (SalutContactChannel *self, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean salut_contact_channel_get_interfaces (SalutContactChannel *obj, - gchar *** ret, - GError **error) -{ +static void +salut_contact_channel_get_interfaces (TpSvcChannel *iface, + DBusGMethodInvocation *context) { const char *interfaces[] = { TP_IFACE_CHANNEL_INTERFACE_GROUP, NULL }; - *ret = g_strdupv ((gchar **) interfaces); - return TRUE; -} - - -/** - * salut_contact_channel_get_local_pending_members - * - * Implements DBus method GetLocalPendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_local_pending_members (SalutContactChannel *self, - GArray ** ret, GError **error) -{ - return group_mixin_get_local_pending_members (G_OBJECT (self), ret, - error); -} - -/** - * salut_contact_channel_get_local_pending_members_with_info - * - * Implements D-Bus method GetLocalPendingMembersWithInfo - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_local_pending_members_with_info ( - SalutContactChannel *self, - GPtrArray **ret, - GError **error) -{ - return group_mixin_get_local_pending_members_with_info(G_OBJECT (self), ret, - error); -} - - -/** - * salut_contact_channel_get_members - * - * Implements DBus method GetMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_get_members (SalutContactChannel *self, - GArray ** ret, GError **error) -{ - return group_mixin_get_members (G_OBJECT (self), ret, error); -} - - -/** - * salut_contact_channel_get_remote_pending_members - * - * Implements DBus method GetRemotePendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_get_remote_pending_members (SalutContactChannel *self, - GArray ** ret, GError **error) -{ - return group_mixin_get_remote_pending_members (G_OBJECT (self), ret, error); -} - - -/** - * salut_contact_channel_get_self_handle - * - * Implements DBus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean salut_contact_channel_get_self_handle (SalutContactChannel *self, - guint* ret, GError **error) -{ - return group_mixin_get_self_handle (G_OBJECT (self), ret, error); + tp_svc_channel_return_from_get_interfaces (context, interfaces); } -/** - * salut_contact_channel_remove_members - * - * Implements DBus method RemoveMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_contact_channel_remove_members (SalutContactChannel *self, - const GArray * contacts, - const gchar * message, GError **error) +static void +channel_iface_init(gpointer g_iface, gpointer iface_data) { - return group_mixin_remove_members(G_OBJECT (self), contacts, message, error); + TpSvcChannelClass *klass = (TpSvcChannelClass *)g_iface; + +#define IMPLEMENT(x) tp_svc_channel_implement_##x (\ + klass, salut_contact_channel_##x) + IMPLEMENT(get_channel_type); + IMPLEMENT(get_handle); + IMPLEMENT(get_interfaces); +#undef IMPLEMENT } - diff --git a/src/salut-contact-channel.h b/src/salut-contact-channel.h index da6f5453..2c1200a7 100644 --- a/src/salut-contact-channel.h +++ b/src/salut-contact-channel.h @@ -22,7 +22,7 @@ #define __SALUT_CONTACT_CHANNEL_H__ #include <glib-object.h> -#include "group-mixin.h" +#include <telepathy-glib/group-mixin.h> G_BEGIN_DECLS @@ -31,12 +31,12 @@ typedef struct _SalutContactChannelClass SalutContactChannelClass; struct _SalutContactChannelClass { GObjectClass parent_class; - GroupMixinClass group_class; + TpGroupMixinClass group_class; }; struct _SalutContactChannel { GObject parent; - GroupMixin group; + TpGroupMixin group; }; GType salut_contact_channel_get_type(void); @@ -55,84 +55,6 @@ GType salut_contact_channel_get_type(void); #define SALUT_CONTACT_CHANNEL_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONTACT_CHANNEL, SalutContactChannelClass)) - -gboolean -salut_contact_channel_add_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_contact_channel_close (SalutContactChannel *self, - GError **error); - -gboolean -salut_contact_channel_get_all_members (SalutContactChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error); - -gboolean -salut_contact_channel_get_channel_type (SalutContactChannel *self, - gchar **ret, - GError **error); - -gboolean -salut_contact_channel_get_group_flags (SalutContactChannel *self, - guint *ret, - GError **error); - -gboolean -salut_contact_channel_get_handle (SalutContactChannel *self, - guint *ret, - guint *ret1, - GError **error); - -gboolean -salut_contact_channel_get_handle_owners (SalutContactChannel *self, - const GArray *handles, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_interfaces (SalutContactChannel *self, - gchar ***ret, - GError **error); - -gboolean -salut_contact_channel_get_local_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_local_pending_members_with_info (SalutContactChannel *self, - GPtrArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_remote_pending_members (SalutContactChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_contact_channel_get_self_handle (SalutContactChannel *self, - guint *ret, - GError **error); - -gboolean -salut_contact_channel_remove_members (SalutContactChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - - - G_END_DECLS #endif /* #ifndef __SALUT_CONTACT_CHANNEL_H__*/ diff --git a/src/salut-contact-manager.c b/src/salut-contact-manager.c index 7280981e..d989e3f2 100644 --- a/src/salut-contact-manager.c +++ b/src/salut-contact-manager.c @@ -31,21 +31,18 @@ #include "salut-avahi-service-browser.h" #include "salut-avahi-enums.h" -#include "telepathy-errors.h" -#include "telepathy-interfaces.h" -#include "telepathy-constants.h" -#include "tp-channel-factory-iface.h" -#include "handle-types.h" -#include "gintset.h" +#include <telepathy-glib/channel-factory-iface.h> +#include <telepathy-glib/interfaces.h> #define DEBUG_FLAG DEBUG_CONTACTS #include "debug.h" - static void salut_contact_manager_factory_iface_init(gpointer *g_iface, gpointer *iface_data); static SalutContactChannel * -salut_contact_manager_get_channel(SalutContactManager *mgr, Handle handle); +salut_contact_manager_get_channel(SalutContactManager *mgr, + TpHandle handle, + gboolean *created); static void _contact_finalized_cb(gpointer data, GObject *old_object); @@ -106,25 +103,25 @@ salut_contact_manager_class_init (SalutContactManagerClass *salut_contact_manage object_class->finalize = salut_contact_manager_finalize; signals[CONTACT_STATUS_CHANGED] = g_signal_new("contact-status-changed", - G_OBJECT_CLASS_TYPE(salut_contact_manager_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - salut_contact_manager_marshal_VOID__OBJECT_INT_STRING, - G_TYPE_NONE, 3, - SALUT_TYPE_CONTACT, - SALUT_TYPE_PRESENCE_ID, - G_TYPE_STRING); + G_OBJECT_CLASS_TYPE(salut_contact_manager_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + salut_contact_manager_marshal_VOID__OBJECT_INT_STRING, + G_TYPE_NONE, 3, + SALUT_TYPE_CONTACT, + SALUT_TYPE_PRESENCE_ID, + G_TYPE_STRING); signals[CONTACT_ALIAS_CHANGED] = g_signal_new("contact-alias-changed", - G_OBJECT_CLASS_TYPE(salut_contact_manager_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - salut_contact_manager_marshal_VOID__OBJECT_STRING, - G_TYPE_NONE, 2, - SALUT_TYPE_CONTACT, - G_TYPE_STRING); + G_OBJECT_CLASS_TYPE(salut_contact_manager_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + salut_contact_manager_marshal_VOID__OBJECT_STRING, + G_TYPE_NONE, 2, + SALUT_TYPE_CONTACT, + G_TYPE_STRING); } static gboolean @@ -154,26 +151,6 @@ salut_contact_manager_dispose (GObject *object) DEBUG("Disposing contact manager"); priv->dispose_has_run = TRUE; - if (priv->connection) { - g_object_unref(priv->connection); - priv->connection = NULL; - } - - if (priv->client) { - g_object_unref(priv->client); - priv->client = NULL; - } - - if (priv->browser) { - g_object_unref(priv->browser); - priv->browser = NULL; - } - - if (priv->contacts) { - g_hash_table_foreach_remove(priv->contacts, dispose_contact, object); - g_hash_table_destroy(priv->contacts); - priv->contacts = NULL; - } /* release any references held by the object here */ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object)); @@ -194,33 +171,36 @@ salut_contact_manager_finalize (GObject *object) } static void -change_all_groups(SalutContactManager *mgr, GIntSet *add, GIntSet *rem) { - Handle i; +change_all_groups(SalutContactManager *mgr, TpIntSet *add, TpIntSet *rem) { + TpHandle i; SalutContactChannel *c; - GIntSet *empty = g_intset_new(); + TpIntSet *empty = tp_intset_new(); for (i = LIST_HANDLE_FIRST; i <= LIST_HANDLE_LAST; i++) { - c = salut_contact_manager_get_channel(mgr, i); - group_mixin_change_members(G_OBJECT(c), "", add, rem, - empty, empty, 0, 0); + c = salut_contact_manager_get_channel(mgr, i, NULL); + tp_group_mixin_change_members(TP_SVC_CHANNEL_INTERFACE_GROUP(c), + "", add, rem, + empty, empty, 0, 0); } - g_intset_destroy(empty); + tp_intset_destroy(empty); } static void contact_found_cb(SalutContact *contact, gpointer userdata) { SalutContactManager *mgr = SALUT_CONTACT_MANAGER(userdata); SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE(mgr); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(priv->connection), TP_HANDLE_TYPE_CONTACT); - GIntSet *to_add = g_intset_new(); - GIntSet *to_rem = g_intset_new(); - Handle handle; + TpIntSet *to_add = tp_intset_new(); + TpIntSet *to_rem = tp_intset_new(); + TpHandle handle; - handle = handle_for_contact(priv->connection->handle_repo, contact->name); - g_intset_add(to_add, handle); + handle = tp_handle_ensure(handle_repo, contact->name, NULL, NULL); + tp_intset_add(to_add, handle); change_all_groups(mgr, to_add, to_rem); /* Add an extra ref, to ensure keeping this untill we got the lost signal */ - g_intset_destroy(to_add); - g_intset_destroy(to_rem); + tp_intset_destroy(to_add); + tp_intset_destroy(to_rem); } static void @@ -244,16 +224,23 @@ static void contact_lost_cb(SalutContact *contact, gpointer userdata) { SalutContactManager *mgr = SALUT_CONTACT_MANAGER(userdata); SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE(mgr); - GIntSet *to_add = g_intset_new(); - GIntSet *to_rem = g_intset_new(); - Handle handle; + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(priv->connection), TP_HANDLE_TYPE_CONTACT); + + TpIntSet *to_add = tp_intset_new(); + TpIntSet *to_rem = tp_intset_new(); + TpHandle handle; DEBUG("Removing %s from contacts", contact->name); - handle = handle_for_contact(priv->connection->handle_repo, contact->name); - g_intset_add(to_rem, handle); + handle = tp_handle_lookup(handle_repo, contact->name, NULL, NULL); + + g_assert(handle != 0); + + tp_intset_add(to_rem, handle); change_all_groups(mgr, to_add, to_rem); - g_intset_destroy(to_add); - g_intset_destroy(to_rem); + + tp_intset_destroy(to_add); + tp_intset_destroy(to_rem); g_object_unref(contact); } @@ -342,6 +329,21 @@ salut_contact_manager_factory_iface_close_all(TpChannelFactoryIface *iface) { priv->channels = NULL; } + if (priv->client) { + g_object_unref(priv->client); + priv->client = NULL; + } + + if (priv->browser) { + g_object_unref(priv->browser); + priv->browser = NULL; + } + + if (priv->contacts) { + g_hash_table_foreach_remove(priv->contacts, dispose_contact, mgr); + g_hash_table_destroy(priv->contacts); + priv->contacts = NULL; + } } static void @@ -350,6 +352,7 @@ salut_contact_manager_factory_iface_connecting(TpChannelFactoryIface *iface) { static void salut_contact_manager_factory_iface_connected(TpChannelFactoryIface *iface) { + } static void @@ -391,13 +394,18 @@ salut_contact_manager_factory_iface_request(TpChannelFactoryIface *iface, const gchar *chan_type, TpHandleType handle_type, guint handle, - TpChannelIface **ret) { + gpointer request, + TpChannelIface **ret, + GError **error) { SalutContactManager *mgr = SALUT_CONTACT_MANAGER(iface); SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE(mgr); SalutContactChannel *chan; + gboolean created; + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(priv->connection), TP_HANDLE_TYPE_LIST); /* We only support contact list channels */ - if (strcmp(chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)) { + if (tp_strdiff(chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED; } @@ -407,14 +415,14 @@ salut_contact_manager_factory_iface_request(TpChannelFactoryIface *iface, } /* Most be a valid list handle */ - if (!handle_is_valid(priv->connection->handle_repo, TP_HANDLE_TYPE_LIST, - handle, NULL)) { + if (!tp_handle_is_valid(handle_repo, handle, NULL)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; } - chan = salut_contact_manager_get_channel(mgr, handle); + chan = salut_contact_manager_get_channel(mgr, handle, &created); *ret = TP_CHANNEL_IFACE(chan); - return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE; + return created ? TP_CHANNEL_FACTORY_REQUEST_STATUS_CREATED + : TP_CHANNEL_FACTORY_REQUEST_STATUS_EXISTING; } static void salut_contact_manager_factory_iface_init(gpointer *g_iface, @@ -432,8 +440,11 @@ static void salut_contact_manager_factory_iface_init(gpointer *g_iface, /* private functions */ static SalutContactChannel * salut_contact_manager_new_channel(SalutContactManager *mgr, - Handle handle) { + TpHandle handle) { SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE(mgr); + TpBaseConnection *base_conn = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_LIST); SalutContactChannel *chan; const gchar *name; gchar *path; @@ -441,10 +452,9 @@ salut_contact_manager_new_channel(SalutContactManager *mgr, g_assert(g_hash_table_lookup(priv->channels, GINT_TO_POINTER(handle)) == NULL); - name = handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_LIST, handle); + name = tp_handle_inspect(handle_repo, handle); path = g_strdup_printf("%s/ContactChannel/%s", - priv->connection->object_path, name); + base_conn->object_path, name); chan = g_object_new(SALUT_TYPE_CONTACT_CHANNEL, "connection", priv->connection, @@ -453,57 +463,61 @@ salut_contact_manager_new_channel(SalutContactManager *mgr, NULL); g_free(path); g_hash_table_insert(priv->channels, GINT_TO_POINTER(handle), chan); - g_signal_emit_by_name(mgr, "new-channel", chan); + tp_channel_factory_iface_emit_new_channel(mgr, TP_CHANNEL_IFACE(chan), NULL); return chan; } static SalutContactChannel * -salut_contact_manager_get_channel(SalutContactManager *mgr, Handle handle) { +salut_contact_manager_get_channel(SalutContactManager *mgr, + TpHandle handle, gboolean *created) +{ SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE(mgr); SalutContactChannel *chan; - g_assert(handle_is_valid(priv->connection->handle_repo, TP_HANDLE_TYPE_LIST, - handle, NULL)); chan = g_hash_table_lookup(priv->channels, GINT_TO_POINTER(handle)); - if (chan == NULL) + if (created != NULL) { + *created = (chan == NULL); + } + if (chan == NULL) { chan= salut_contact_manager_new_channel(mgr, handle); + } return chan; } /* public functions */ SalutContactManager * -salut_contact_manager_new(SalutConnection *connection, - SalutAvahiClient *client) { +salut_contact_manager_new(SalutConnection *connection) { SalutContactManager *ret = NULL; SalutContactManagerPrivate *priv; ret = g_object_new(SALUT_TYPE_CONTACT_MANAGER, NULL); priv = SALUT_CONTACT_MANAGER_GET_PRIVATE (ret); + priv->connection = connection; priv->browser = salut_avahi_service_browser_new("_presence._tcp"); + return ret; +} + +gboolean +salut_contact_manager_start(SalutContactManager *mgr, + SalutAvahiClient *client, GError **error) { + SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE (mgr); + + g_assert(priv->client == NULL); priv->client = client; g_object_ref(client); - priv->connection = connection; - g_object_ref(connection); - g_signal_connect(priv->browser, "new-service", - G_CALLBACK(browser_found), ret); + G_CALLBACK(browser_found), mgr); g_signal_connect(priv->browser, "removed-service", - G_CALLBACK(browser_removed), ret); + G_CALLBACK(browser_removed), mgr); g_signal_connect(priv->browser, "failure", - G_CALLBACK(browser_failed), ret); - - return ret; -} + G_CALLBACK(browser_failed), mgr); -gboolean -salut_contact_manager_start(SalutContactManager *mgr, GError **error) { - SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE (mgr); if (!salut_avahi_service_browser_attach(priv->browser, priv->client, error)) { return FALSE; } @@ -511,10 +525,11 @@ salut_contact_manager_start(SalutContactManager *mgr, GError **error) { } SalutContact * -salut_contact_manager_get_contact(SalutContactManager *mgr, Handle handle) { +salut_contact_manager_get_contact(SalutContactManager *mgr, TpHandle handle) { SalutContactManagerPrivate *priv = SALUT_CONTACT_MANAGER_GET_PRIVATE (mgr); - const char *name = handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_CONTACT, handle); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + TP_BASE_CONNECTION(priv->connection), TP_HANDLE_TYPE_CONTACT); + const char *name = tp_handle_inspect(handle_repo, handle); SalutContact *ret; g_return_val_if_fail(name, NULL); diff --git a/src/salut-contact-manager.h b/src/salut-contact-manager.h index 948ee14b..11c761ca 100644 --- a/src/salut-contact-manager.h +++ b/src/salut-contact-manager.h @@ -20,10 +20,10 @@ #define __SALUT_CONTACT_MANAGER_H__ #include <glib-object.h> + #include "salut-connection.h" #include "salut-avahi-client.h" #include "salut-contact.h" -#include "handle-types.h" G_BEGIN_DECLS @@ -56,14 +56,15 @@ GType salut_contact_manager_get_type(void); (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_CONTACT_MANAGER, SalutContactManagerClass)) SalutContactManager * -salut_contact_manager_new(SalutConnection *connection, - SalutAvahiClient *client); +salut_contact_manager_new(SalutConnection *connection); -gboolean salut_contact_manager_start(SalutContactManager *mgr, GError **error); +gboolean salut_contact_manager_start(SalutContactManager *mgr, + SalutAvahiClient *client, + GError **error); SalutContact * -salut_contact_manager_get_contact(SalutContactManager *mgr, Handle handle); +salut_contact_manager_get_contact(SalutContactManager *mgr, TpHandle handle); GList * salut_contact_manager_find_contacts_by_address(SalutContactManager *mgr, diff --git a/src/salut-im-channel.c b/src/salut-im-channel.c index 20f5e44d..d4e7a532 100644 --- a/src/salut-im-channel.c +++ b/src/salut-im-channel.c @@ -31,26 +31,32 @@ #include "salut-im-channel.h" #include "salut-im-channel-signals-marshal.h" -#include "salut-im-channel-glue.h" + +#include "salut-connection.h" +#include "salut-contact.h" +#include "text-helper.h" #include <gibber/gibber-linklocal-transport.h> #include <gibber/gibber-xmpp-connection.h> #include <gibber/gibber-xmpp-stanza.h> #include <gibber/gibber-namespaces.h> -#include "salut-connection.h" -#include "salut-contact.h" -#include "handle-repository.h" -#include "tp-channel-iface.h" -#include "telepathy-helpers.h" -#include "telepathy-interfaces.h" -#include "telepathy-errors.h" +#include <telepathy-glib/text-mixin.h> +#include <telepathy-glib/channel-iface.h> +#include <telepathy-glib/interfaces.h> +#include <telepathy-glib/dbus.h> -#include "text-mixin.h" +static void +channel_iface_init(gpointer g_iface, gpointer iface_data); +static void +text_iface_init(gpointer g_iface, gpointer iface_data); G_DEFINE_TYPE_WITH_CODE(SalutImChannel, salut_im_channel, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(TP_TYPE_CHANNEL_IFACE, NULL)); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL, channel_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_CHANNEL_IFACE, NULL); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, text_iface_init); +); /* Channel state */ typedef enum { @@ -62,7 +68,6 @@ typedef enum { /* signal enum */ enum { - CLOSED, RECEIVED_STANZA, LAST_SIGNAL }; @@ -88,7 +93,7 @@ struct _SalutImChannelPrivate { gboolean dispose_has_run; gchar *object_path; - Handle handle; + TpHandle handle; SalutContact *contact; SalutConnection *connection; GibberXmppConnection *xmpp_connection; @@ -111,6 +116,28 @@ struct _SalutImChannelMessage { GibberXmppStanza *stanza; }; +static void +salut_im_channel_do_close(SalutImChannel *self) { + SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); + ChannelState oldstate = priv->state; + + priv->state = CHANNEL_NOT_CONNECTED; + + switch (oldstate) { + case CHANNEL_NOT_CONNECTED: + /* FIXME return an error ? */ + break; + case CHANNEL_CONNECTING: + case CHANNEL_CONNECTED: + /* FIXME decent connection closing? */ + gibber_xmpp_connection_close(priv->xmpp_connection); + break; + } + + DEBUG("Emitting closed signal for %s", priv->object_path); + tp_svc_channel_emit_closed(self); +} + static SalutImChannelMessage * salut_im_channel_message_new(guint type, const gchar *text, GibberXmppStanza *stanza) { @@ -151,8 +178,9 @@ salut_im_channel_message_free(SalutImChannelMessage *message) { g_free(message); } -static gboolean _send_message(GObject *object, guint type, const gchar *text, - GibberXmppStanza *stanza, GError **error); +static gboolean _send_message(SalutImChannel *self, + guint type, const gchar *text, GibberXmppStanza *stanza, GError **error); + static void salut_im_channel_init (SalutImChannel *obj) { @@ -210,6 +238,7 @@ salut_im_channel_set_property (GObject *object, { SalutImChannel *chan = SALUT_IM_CHANNEL (object); SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (chan); + const gchar *tmp; switch (property_id) { case PROP_OBJECT_PATH: @@ -226,6 +255,16 @@ salut_im_channel_set_property (GObject *object, case PROP_CONNECTION: priv->connection = g_value_get_object (value); break; + case PROP_HANDLE_TYPE: + g_assert(g_value_get_uint(value) == 0 + || g_value_get_uint(value) == TP_HANDLE_TYPE_CONTACT); + break; + case PROP_CHANNEL_TYPE: + tmp = g_value_get_string(value); + g_assert(tmp == NULL + || !tp_strdiff(g_value_get_string(value), + TP_IFACE_CHANNEL_TYPE_TEXT)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -238,8 +277,9 @@ salut_im_channel_constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *obj; DBusGConnection *bus; - gboolean valid; SalutImChannelPrivate *priv; + TpBaseConnection *base_conn; + TpHandleRepoIface *contact_repo; /* Parent constructor chain */ obj = G_OBJECT_CLASS(salut_im_channel_parent_class)-> @@ -248,18 +288,21 @@ salut_im_channel_constructor (GType type, guint n_props, priv = SALUT_IM_CHANNEL_GET_PRIVATE (SALUT_IM_CHANNEL (obj)); /* Ref our handle */ - valid = handle_ref(priv->connection->handle_repo, TP_HANDLE_TYPE_CONTACT, - priv->handle); - g_assert(valid); + base_conn = TP_BASE_CONNECTION(priv->connection); + + contact_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_CONTACT); + + tp_handle_ref(contact_repo, priv->handle); /* Initialize text mixin */ - text_mixin_init(obj, G_STRUCT_OFFSET(SalutImChannel, text), - priv->connection->handle_repo); + tp_text_mixin_init(obj, G_STRUCT_OFFSET(SalutImChannel, text), + contact_repo); - text_mixin_set_message_types(obj, - TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, - G_MAXUINT); + tp_text_mixin_set_message_types(obj, + TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, + TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, + G_MAXUINT); /* Connect to the bus */ bus = tp_get_bus (); @@ -328,20 +371,8 @@ salut_im_channel_class_init (SalutImChannelClass *salut_im_channel_class) G_TYPE_BOOLEAN, 1, GIBBER_TYPE_XMPP_STANZA); - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_im_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - salut_im_channel_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - text_mixin_class_init(object_class, - G_STRUCT_OFFSET(SalutImChannelClass, text_class), - _send_message); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_im_channel_class), &dbus_glib_salut_im_channel_object_info); + tp_text_mixin_class_init(object_class, + G_STRUCT_OFFSET(SalutImChannelClass, text_class)); } void @@ -349,15 +380,19 @@ salut_im_channel_dispose (GObject *object) { SalutImChannel *self = SALUT_IM_CHANNEL (object); SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); - + TpBaseConnection *base_conn = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles (base_conn, + TP_HANDLE_TYPE_CONTACT); if (priv->dispose_has_run) return; + tp_handle_unref(handle_repo, priv->handle); + priv->dispose_has_run = TRUE; if (priv->state != CHANNEL_NOT_CONNECTED) { - salut_im_channel_close(self, NULL); + salut_im_channel_do_close(self); } if (priv->xmpp_connection) { @@ -365,8 +400,6 @@ salut_im_channel_dispose (GObject *object) priv->xmpp_connection = NULL; } - handle_unref(priv->connection->handle_repo, TP_HANDLE_TYPE_CONTACT, - priv->handle); g_object_unref(priv->contact); priv->contact = NULL; @@ -388,7 +421,7 @@ salut_im_channel_finalize (GObject *object) g_queue_foreach(priv->out_queue, (GFunc)salut_im_channel_message_free, NULL); g_queue_free(priv->out_queue); - text_mixin_finalize(G_OBJECT(self)); + tp_text_mixin_finalize(G_OBJECT(self)); G_OBJECT_CLASS (salut_im_channel_parent_class)->finalize (object); } @@ -399,11 +432,10 @@ _sendout_message(SalutImChannel * self, guint timestamp, SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); if (gibber_xmpp_connection_send(priv->xmpp_connection, stanza, NULL)) { - text_mixin_emit_sent(G_OBJECT(self), timestamp, type, text); + tp_svc_channel_type_text_emit_sent(self, timestamp, type, text); } else { - text_mixin_emit_send_error(G_OBJECT(self), - CHANNEL_TEXT_SEND_ERROR_UNKNOWN, - timestamp, type, text); + tp_svc_channel_type_text_emit_send_error(self, + TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN, timestamp, type, text); } } @@ -433,9 +465,8 @@ _error_flush_queue(SalutImChannel *self) { while ((msg = g_queue_pop_head(priv->out_queue)) != NULL) { DEBUG("Sending out SendError for msg: %s", msg->text); if (msg->text != NULL) { - text_mixin_emit_send_error(G_OBJECT(self), - CHANNEL_TEXT_SEND_ERROR_OFFLINE, - msg->time, msg->type, msg->text); + tp_svc_channel_type_text_emit_send_error(self, + TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE, msg->time, msg->type, msg->text); } salut_im_channel_message_free(msg); } @@ -459,8 +490,9 @@ salut_im_channel_received_stanza(SalutImChannel *self, * or whatever */ return; } - if (!text_mixin_parse_incoming_message(stanza, &from, &msgtype, - &body, &body_offset)) { + + if (!text_helper_parse_incoming_message(stanza, &from, &msgtype, + &body, &body_offset)) { DEBUG("Stanza not a text message, ignoring"); return; } @@ -472,8 +504,8 @@ salut_im_channel_received_stanza(SalutImChannel *self, } /* FIXME validate the from */ - text_mixin_receive(G_OBJECT(self), msgtype, priv->handle, - time(NULL), body_offset); + tp_text_mixin_receive(G_OBJECT(self), msgtype, priv->handle, + time(NULL), body_offset); } static void @@ -642,9 +674,8 @@ _send_channel_message(SalutImChannel *self, SalutImChannelMessage *msg) { } static gboolean -_send_message(GObject *object, guint type, const gchar *text, +_send_message(SalutImChannel *self, guint type, const gchar *text, GibberXmppStanza *stanza, GError **error) { - SalutImChannel *self = SALUT_IM_CHANNEL(object); SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); SalutImChannelMessage *msg; @@ -700,26 +731,6 @@ salut_im_channel_add_connection(SalutImChannel *chan, } /** - * salut_im_channel_acknowledge_pending_messages - * - * Implements DBus method AcknowledgePendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_acknowledge_pending_messages (SalutImChannel *self, - const GArray * ids, - GError **error) { - return text_mixin_acknowledge_pending_messages(G_OBJECT(self), ids, error); -} - - -/** * salut_im_channel_close * * Implements DBus method Close @@ -731,27 +742,10 @@ salut_im_channel_acknowledge_pending_messages (SalutImChannel *self, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_im_channel_close (SalutImChannel *self, GError **error) { - SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); - ChannelState oldstate = priv->state; - - priv->state = CHANNEL_NOT_CONNECTED; - - switch (oldstate) { - case CHANNEL_NOT_CONNECTED: - /* FIXME return an error ? */ - break; - case CHANNEL_CONNECTING: - case CHANNEL_CONNECTED: - /* FIXME decent connection closing? */ - gibber_xmpp_connection_close(priv->xmpp_connection); - break; - } - - DEBUG("Emitting closed signal for %s", priv->object_path); - g_signal_emit(self, signals[CLOSED], 0); - return TRUE; +static void +salut_im_channel_close (TpSvcChannel *iface, DBusGMethodInvocation *context) { + salut_im_channel_do_close(SALUT_IM_CHANNEL(iface)); + tp_svc_channel_return_from_close(context); } @@ -767,12 +761,11 @@ salut_im_channel_close (SalutImChannel *self, GError **error) { * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_im_channel_get_channel_type (SalutImChannel *obj, gchar ** ret, - GError **error) { - *ret = g_strdup(TP_IFACE_CHANNEL_TYPE_TEXT); - - return TRUE; +static void +salut_im_channel_get_channel_type (TpSvcChannel *iface, + DBusGMethodInvocation *context) { + tp_svc_channel_return_from_get_channel_type(context, + TP_IFACE_CHANNEL_TYPE_TEXT); } @@ -788,15 +781,14 @@ salut_im_channel_get_channel_type (SalutImChannel *obj, gchar ** ret, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_im_channel_get_handle (SalutImChannel *obj, guint* ret, guint* ret1, - GError **error) { - SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (obj); - - *ret = TP_HANDLE_TYPE_CONTACT; - *ret1 = priv->handle; +static void +salut_im_channel_get_handle (TpSvcChannel *iface, + DBusGMethodInvocation *context) { + SalutImChannel *self = SALUT_IM_CHANNEL(iface); + SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE (self); - return TRUE; + tp_svc_channel_return_from_get_handle (context, TP_HANDLE_TYPE_CONTACT, + priv->handle); } @@ -812,55 +804,27 @@ salut_im_channel_get_handle (SalutImChannel *obj, guint* ret, guint* ret1, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_im_channel_get_interfaces (SalutImChannel *obj, gchar *** ret, - GError **error) { +static void +salut_im_channel_get_interfaces (TpSvcChannel *iface, + DBusGMethodInvocation *context) { const char *interfaces[] = { NULL }; - *ret = g_strdupv ((gchar **) interfaces); - - return TRUE; -} - - -/** - * salut_im_channel_get_message_types - * - * Implements DBus method GetMessageTypes - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_get_message_types (SalutImChannel *obj, GArray ** ret, - GError **error) { - return text_mixin_get_message_types(G_OBJECT(obj), ret, error); + tp_svc_channel_return_from_get_interfaces (context, interfaces); } +static void +channel_iface_init(gpointer g_iface, gpointer iface_data) { + TpSvcChannelClass *klass = (TpSvcChannelClass *)g_iface; -/** - * salut_im_channel_list_pending_messages - * - * Implements DBus method ListPendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occured, DBus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_im_channel_list_pending_messages (SalutImChannel *self, gboolean clear, - GPtrArray ** ret, GError **error) { - return text_mixin_list_pending_messages(G_OBJECT(self), clear, ret, error); +#define IMPLEMENT(x) tp_svc_channel_implement_##x (\ + klass, salut_im_channel_##x) + IMPLEMENT(close); + IMPLEMENT(get_channel_type); + IMPLEMENT(get_handle); + IMPLEMENT(get_interfaces); +#undef IMPLEMENT } - /** * salut_im_channel_send * @@ -873,11 +837,44 @@ salut_im_channel_list_pending_messages (SalutImChannel *self, gboolean clear, * * Returns: TRUE if successful, FALSE if an error was thrown. */ -gboolean -salut_im_channel_send (SalutImChannel *self, - guint type, const gchar * text, GError **error) { +static void +salut_im_channel_send (TpSvcChannelTypeText *channel, + guint type, const gchar * text, + DBusGMethodInvocation *context) { + SalutImChannel *self = SALUT_IM_CHANNEL(channel); SalutImChannelPrivate *priv = SALUT_IM_CHANNEL_GET_PRIVATE(self); - text_mixin_send(G_OBJECT(self), type, priv->connection->name, - priv->contact->name, text, error); - return TRUE; + GError *error = NULL; + + GibberXmppStanza *stanza = + text_helper_create_message(priv->connection->name, + priv->contact->name, type, text, &error); + + if (stanza == NULL) { + dbus_g_method_return_error(context, error); + g_error_free(error); + return; + } + + if (!_send_message(self, type, text, stanza, &error)) { + g_object_unref(G_OBJECT(stanza)); + dbus_g_method_return_error(context, error); + g_error_free(error); + return; + } + + g_object_unref(G_OBJECT(stanza)); + tp_svc_channel_type_text_return_from_send(context); } + + +static void +text_iface_init(gpointer g_iface, gpointer iface_data) { + TpSvcChannelTypeTextClass *klass = (TpSvcChannelTypeTextClass *)g_iface; + + tp_text_mixin_iface_init (g_iface, iface_data); +#define IMPLEMENT(x) tp_svc_channel_type_text_implement_##x (\ + klass, salut_im_channel_##x) + IMPLEMENT(send); +#undef IMPLEMENT +} + diff --git a/src/salut-im-channel.h b/src/salut-im-channel.h index ed268b8e..e6fbc1bb 100644 --- a/src/salut-im-channel.h +++ b/src/salut-im-channel.h @@ -21,10 +21,11 @@ #define __SALUT_IM_CHANNEL_H__ #include <glib-object.h> -#include "text-mixin.h" #include <gibber/gibber-xmpp-stanza.h> #include <gibber/gibber-xmpp-connection.h> +#include <telepathy-glib/text-mixin.h> + G_BEGIN_DECLS typedef struct _SalutImChannel SalutImChannel; @@ -32,12 +33,12 @@ typedef struct _SalutImChannelClass SalutImChannelClass; struct _SalutImChannelClass { GObjectClass parent_class; - TextMixinClass text_class; + TpTextMixinClass text_class; }; struct _SalutImChannel { GObject parent; - TextMixin text; + TpTextMixin text; }; GType salut_im_channel_get_type(void); @@ -64,16 +65,6 @@ void salut_im_channel_send_stanza(SalutImChannel * self, void salut_im_channel_received_stanza(SalutImChannel *chan, GibberXmppStanza *stanza); -gboolean salut_im_channel_acknowledge_pending_messages (SalutImChannel *self, const GArray * ids, GError **error); -gboolean salut_im_channel_close (SalutImChannel *self, GError **error); -gboolean salut_im_channel_get_channel_type (SalutImChannel *self, gchar ** ret, GError **error); -gboolean salut_im_channel_get_handle (SalutImChannel *self, guint* ret, guint* ret1, GError **error); -gboolean salut_im_channel_get_interfaces (SalutImChannel *self, gchar *** ret, GError **error); -gboolean salut_im_channel_get_message_types (SalutImChannel *self, GArray ** ret, GError **error); -gboolean salut_im_channel_list_pending_messages (SalutImChannel *self, gboolean clear, GPtrArray ** ret, GError **error); -gboolean salut_im_channel_send (SalutImChannel *self, guint type, const gchar * text, GError **error); - - G_END_DECLS #endif /* #ifndef __SALUT_IM_CHANNEL_H__*/ diff --git a/src/salut-im-manager.c b/src/salut-im-manager.c index e03dbd58..7d26ed47 100644 --- a/src/salut-im-manager.c +++ b/src/salut-im-manager.c @@ -31,13 +31,8 @@ #include <gibber/gibber-xmpp-stanza.h> #include <gibber/gibber-namespaces.h> -#include "telepathy-errors.h" -#include "telepathy-interfaces.h" -#include "telepathy-constants.h" -#include "tp-channel-factory-iface.h" -#include "handle-types.h" -#include "handle-repository.h" -#include "gintset.h" +#include <telepathy-glib/channel-factory-iface.h> +#include <telepathy-glib/interfaces.h> #define DEBUG_FLAG DEBUG_IM #include "debug.h" @@ -46,7 +41,7 @@ static void salut_im_manager_factory_iface_init(gpointer *g_iface, gpointer *iface_data); static SalutImChannel * -salut_im_manager_new_channel(SalutImManager *mgr, Handle handle); +salut_im_manager_new_channel(SalutImManager *mgr, TpHandle handle); G_DEFINE_TYPE_WITH_CODE(SalutImManager, salut_im_manager, G_TYPE_OBJECT, @@ -124,11 +119,6 @@ salut_im_manager_dispose (GObject *object) priv->contact_manager = NULL; } - if (priv->connection) { - g_object_unref(priv->connection); - priv->connection = NULL; - } - if (priv->channels) { t = priv->channels; priv->channels = NULL; @@ -219,13 +209,19 @@ salut_im_manager_factory_iface_request(TpChannelFactoryIface *iface, const gchar *chan_type, TpHandleType handle_type, guint handle, - TpChannelIface **ret) { + gpointer request, + TpChannelIface **ret, + GError **error) { SalutImManager *mgr = SALUT_IM_MANAGER(iface); SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE(mgr); SalutImChannel *chan; + gboolean created = FALSE; + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles( + base_connection, TP_HANDLE_TYPE_CONTACT); /* We only support text channels */ - if (strcmp(chan_type, TP_IFACE_CHANNEL_TYPE_TEXT)) { + if (tp_strdiff(chan_type, TP_IFACE_CHANNEL_TYPE_TEXT)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED; } @@ -235,13 +231,12 @@ salut_im_manager_factory_iface_request(TpChannelFactoryIface *iface, } /* Most be a valid contact handle */ - if (!handle_is_valid(priv->connection->handle_repo, TP_HANDLE_TYPE_CONTACT, - handle, NULL)) { + if (!tp_handle_is_valid(handle_repo, TP_HANDLE_TYPE_CONTACT, NULL)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; } /* Don't support opening a channel to our self handle */ - if (handle == priv->connection->self_handle) { + if (handle == base_connection->self_handle) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; } @@ -250,10 +245,11 @@ salut_im_manager_factory_iface_request(TpChannelFactoryIface *iface, *ret = TP_CHANNEL_IFACE(chan); } else { *ret = TP_CHANNEL_IFACE(salut_im_manager_new_channel(mgr, handle)); + created = TRUE; } - return *ret != NULL ? TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE - : TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; + return created ? TP_CHANNEL_FACTORY_REQUEST_STATUS_CREATED + : TP_CHANNEL_FACTORY_REQUEST_STATUS_EXISTING; } static void salut_im_manager_factory_iface_init(gpointer *g_iface, @@ -273,7 +269,7 @@ static void im_channel_closed_cb(SalutImChannel *chan, gpointer user_data) { SalutImManager *self = SALUT_IM_MANAGER(user_data); SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE(self); - Handle handle; + TpHandle handle; if (priv->channels) { g_object_get(chan, "handle", &handle, NULL); @@ -283,8 +279,11 @@ im_channel_closed_cb(SalutImChannel *chan, gpointer user_data) { } static SalutImChannel * -salut_im_manager_new_channel(SalutImManager *mgr, Handle handle) { +salut_im_manager_new_channel(SalutImManager *mgr, TpHandle handle) { SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE(mgr); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *handle_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_CONTACT); SalutImChannel *chan; SalutContact *contact; const gchar *name; @@ -298,10 +297,10 @@ salut_im_manager_new_channel(SalutImManager *mgr, Handle handle) { if (contact == NULL) { return NULL; } - name = handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_CONTACT, handle); + + name = tp_handle_inspect(handle_repo, handle); path = g_strdup_printf("%s/IMChannel/%u", - priv->connection->object_path, handle); + base_connection->object_path, handle); chan = g_object_new(SALUT_TYPE_IM_CHANNEL, "connection", priv->connection, "contact", contact, @@ -311,7 +310,7 @@ salut_im_manager_new_channel(SalutImManager *mgr, Handle handle) { g_object_unref(contact); g_free(path); g_hash_table_insert(priv->channels, GINT_TO_POINTER(handle), chan); - g_signal_emit_by_name(mgr, "new-channel", chan); + tp_channel_factory_iface_emit_new_channel(mgr, TP_CHANNEL_IFACE(chan), NULL); g_signal_connect(chan, "closed", G_CALLBACK(im_channel_closed_cb), mgr); return chan; @@ -332,14 +331,13 @@ salut_im_manager_new(SalutConnection *connection, g_object_ref(contact_manager); priv->connection = connection; - g_object_ref(connection); return ret; } SalutImChannel * salut_im_manager_get_channel_for_handle(SalutImManager *mgr, - Handle handle) { + TpHandle handle) { SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE(mgr); SalutImChannel *chan; chan = g_hash_table_lookup(priv->channels, GINT_TO_POINTER(handle)); @@ -358,10 +356,15 @@ found_contact_for_connection(SalutImManager *mgr, SalutContact *contact, GibberXmppStanza *stanza) { SalutImManagerPrivate *priv = SALUT_IM_MANAGER_GET_PRIVATE(mgr); - Handle handle; + TpHandle handle; SalutImChannel *chan; - handle = handle_for_contact(priv->connection->handle_repo, contact->name); + TpBaseConnection *base_conn = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *handle_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_CONTACT); + + handle = tp_handle_lookup(handle_repo, contact->name, NULL, NULL); + g_assert(handle != 0); chan = g_hash_table_lookup(priv->channels, GINT_TO_POINTER(handle)); if (chan == NULL) { diff --git a/src/salut-im-manager.h b/src/salut-im-manager.h index eccc14b5..5588e752 100644 --- a/src/salut-im-manager.h +++ b/src/salut-im-manager.h @@ -22,8 +22,8 @@ #include <glib-object.h> #include "salut-contact-manager.h" #include "salut-im-channel.h" + #include <gibber/gibber-linklocal-transport.h> -#include "handle-types.h" G_BEGIN_DECLS @@ -61,7 +61,7 @@ salut_im_manager_new(SalutConnection *connection, SalutImChannel * salut_im_manager_get_channel_for_handle(SalutImManager *mgr, - Handle handle); + TpHandle handle); void salut_im_manager_handle_connection(SalutImManager *mgr, GibberLLTransport *transport); diff --git a/src/salut-muc-channel.c b/src/salut-muc-channel.c index c539d1ff..5bf783f9 100644 --- a/src/salut-muc-channel.c +++ b/src/salut-muc-channel.c @@ -28,33 +28,36 @@ #include "salut-muc-channel.h" #include "salut-muc-channel-signals-marshal.h" -#include "salut-muc-channel-glue.h" #include <gibber/gibber-transport.h> +#include <telepathy-glib/channel-iface.h> +#include <telepathy-glib/interfaces.h> +#include <telepathy-glib/dbus.h> +#include <telepathy-glib/errors.h> +#include <telepathy-glib/util.h> + #include "salut-muc-transport-iface.h" #include "salut-muc-connection.h" #include "salut-connection.h" #include "salut-im-manager.h" -#include "telepathy-interfaces.h" -#include "telepathy-helpers.h" -#include "telepathy-errors.h" -#include "tp-channel-iface.h" #include "namespaces.h" +#include "text-helper.h" -G_DEFINE_TYPE_WITH_CODE(SalutMucChannel, salut_muc_channel, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL)); - -/* signal enum */ -enum -{ - CLOSED, - LAST_SIGNAL -}; +static void +channel_iface_init(gpointer g_iface, gpointer iface_data); +static void +text_iface_init(gpointer g_iface, gpointer iface_data); -static guint signals[LAST_SIGNAL] = {0}; +G_DEFINE_TYPE_WITH_CODE(SalutMucChannel, salut_muc_channel, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL, channel_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_CHANNEL_IFACE, NULL); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP, + tp_group_mixin_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, text_iface_init); +) /* properties */ enum @@ -77,7 +80,7 @@ struct _SalutMucChannelPrivate { gboolean dispose_has_run; gchar *object_path; - Handle handle; + TpHandle handle; SalutConnection *connection; SalutImManager *im_manager; SalutMucConnection *muc_connection; @@ -90,10 +93,11 @@ struct _SalutMucChannelPrivate /* Callback functions */ static void salut_muc_channel_send_presence(SalutMucChannel *self, gboolean joining); -static gboolean salut_muc_channel_send_stanza(GObject *object, guint type, - const gchar *text, - GibberXmppStanza *stanza, - GError **error); +static gboolean salut_muc_channel_send_stanza(SalutMucChannel *self, + guint type, + const gchar *text, + GibberXmppStanza *stanza, + GError **error); static void salut_muc_channel_received_stanza(GibberXmppConnection *conn, GibberXmppStanza *stanza, gpointer user_data); @@ -154,6 +158,7 @@ salut_muc_channel_set_property (GObject *object, { SalutMucChannel *chan = SALUT_MUC_CHANNEL (object); SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (chan); + const gchar *tmp; switch (property_id) { case PROP_OBJECT_PATH: @@ -177,6 +182,16 @@ salut_muc_channel_set_property (GObject *object, case PROP_MUCCONNECTION: priv->muc_connection = g_value_get_object (value); break; + case PROP_HANDLE_TYPE: + g_assert(g_value_get_uint(value) == 0 + || g_value_get_uint(value) == TP_HANDLE_TYPE_ROOM); + break; + case PROP_CHANNEL_TYPE: + tmp = g_value_get_string(value); + g_assert(tmp == NULL + || !tp_strdiff(g_value_get_string(value), + TP_IFACE_CHANNEL_TYPE_TEXT)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -190,8 +205,10 @@ salut_muc_channel_constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *obj; DBusGConnection *bus; - gboolean valid; SalutMucChannelPrivate *priv; + TpBaseConnection *base_conn; + TpHandleRepoIface *handle_repo; + TpHandleRepoIface *contact_repo; /* Parent constructor chain */ obj = G_OBJECT_CLASS(salut_muc_channel_parent_class)-> @@ -200,15 +217,20 @@ salut_muc_channel_constructor (GType type, guint n_props, priv = SALUT_MUC_CHANNEL_GET_PRIVATE (SALUT_MUC_CHANNEL (obj)); /* Ref our handle */ - valid = handle_ref(priv->connection->handle_repo, TP_HANDLE_TYPE_ROOM, - priv->handle); - g_assert(valid); - + base_conn = TP_BASE_CONNECTION(priv->connection); + + handle_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_ROOM); + + tp_handle_ref(handle_repo, priv->handle); + /* Text mixin initialisation */ - text_mixin_init(obj, G_STRUCT_OFFSET(SalutMucChannel, text), - priv->connection->handle_repo); + contact_repo = tp_base_connection_get_handles(base_conn, + TP_HANDLE_TYPE_CONTACT); + tp_text_mixin_init(obj, G_STRUCT_OFFSET(SalutMucChannel, text), + contact_repo); - text_mixin_set_message_types(obj, + tp_text_mixin_set_message_types(obj, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, G_MAXUINT); @@ -217,11 +239,12 @@ salut_muc_channel_constructor (GType type, guint n_props, bus = tp_get_bus (); dbus_g_connection_register_g_object(bus, priv->object_path, obj); - group_mixin_init(obj, G_STRUCT_OFFSET(SalutMucChannel, group), - priv->connection->handle_repo, - priv->connection->self_handle); - group_mixin_change_flags(obj, - TP_CHANNEL_GROUP_FLAG_CAN_ADD|TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD, 0); + tp_group_mixin_init(TP_SVC_CHANNEL_INTERFACE_GROUP(obj), + G_STRUCT_OFFSET(SalutMucChannel, group), + contact_repo, base_conn->self_handle); + + tp_group_mixin_change_flags(TP_SVC_CHANNEL_INTERFACE_GROUP(obj), + TP_CHANNEL_GROUP_FLAG_CAN_ADD|TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD, 0); return obj; } @@ -247,12 +270,17 @@ invitation_append_parameter(gpointer key, gpointer value, gpointer data) { } static GibberXmppStanza * -create_invitation(SalutMucChannel *self, Handle handle, const gchar *message) { +create_invitation(SalutMucChannel *self, TpHandle handle, const gchar *message) { SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *contact_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *room_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_ROOM); GibberXmppStanza *msg; GibberXmppNode *x_node, *invite_node; - const gchar *name = handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_CONTACT, handle); + + const gchar *name = tp_handle_inspect(contact_repo, handle); msg = gibber_xmpp_stanza_new("message"); @@ -272,8 +300,7 @@ create_invitation(SalutMucChannel *self, Handle handle, const gchar *message) { } gibber_xmpp_node_add_child_with_content(invite_node, "roomname", - handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_ROOM, priv->handle)); + tp_handle_inspect(room_repo, priv->handle)); g_hash_table_foreach( (GHashTable *)salut_muc_connection_get_parameters(priv->muc_connection), invitation_append_parameter, invite_node); @@ -282,41 +309,41 @@ create_invitation(SalutMucChannel *self, Handle handle, const gchar *message) { } static gboolean -muc_channel_add_member(GObject *obj, Handle handle, +muc_channel_add_member(TpSvcChannelInterfaceGroup *iface, TpHandle handle, const gchar *message, GError **error) { - SalutMucChannel *self = SALUT_MUC_CHANNEL(obj); + SalutMucChannel *self = SALUT_MUC_CHANNEL(iface); SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); SalutImChannel *im_channel; GibberXmppStanza *stanza; - if (handle == priv->connection->self_handle) { - GIntSet *empty; - GIntSet *add; + if (handle == base_connection->self_handle) { + TpIntSet *empty; + TpIntSet *add; gboolean ret = TRUE; - empty = g_intset_new(); - add = g_intset_new(); - g_intset_add(add, handle); + empty = tp_intset_new(); + add = tp_intset_new(); + tp_intset_add(add, handle); /* Add to members */ if (salut_muc_channel_connect(self, NULL)) { - group_mixin_change_members(G_OBJECT(self), message, - add, empty, empty, empty, - priv->connection->self_handle, + tp_group_mixin_change_members(TP_SVC_CHANNEL_INTERFACE_GROUP(self), + message, add, empty, empty, empty, base_connection->self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); } else { g_set_error(error, - TELEPATHY_ERRORS, NetworkError, + TP_ERRORS, TP_ERROR_NETWORK_ERROR, "Failed to connect to the group"); ret = FALSE; } - g_intset_destroy(empty); - g_intset_destroy(add); + tp_intset_destroy(empty); + tp_intset_destroy(add); return ret; } im_channel = salut_im_manager_get_channel_for_handle(priv->im_manager, handle); if (im_channel == NULL) { - *error = g_error_new(TELEPATHY_ERRORS, NotAvailable, + *error = g_error_new(TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "Couldn't contact the contact"); return FALSE; } @@ -396,24 +423,12 @@ salut_muc_channel_class_init (SalutMucChannelClass *salut_muc_channel_class) { g_object_class_install_property (object_class, PROP_IM_MANAGER, param_spec); - signals[CLOSED] = - g_signal_new ("closed", - G_OBJECT_CLASS_TYPE (salut_muc_channel_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - text_mixin_class_init(object_class, - G_STRUCT_OFFSET(SalutMucChannelClass, text_class), - salut_muc_channel_send_stanza); + tp_text_mixin_class_init(object_class, + G_STRUCT_OFFSET(SalutMucChannelClass, text_class)); - group_mixin_class_init(object_class, + tp_group_mixin_class_init((TpSvcChannelInterfaceGroupClass *)object_class, G_STRUCT_OFFSET(SalutMucChannelClass, group_class), muc_channel_add_member, NULL); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (salut_muc_channel_class), &dbus_glib_salut_muc_channel_object_info); } void @@ -436,10 +451,7 @@ salut_muc_channel_dispose (GObject *object) priv->muc_connection = NULL; } - - /* release any references held by the object here */ - if (G_OBJECT_CLASS (salut_muc_channel_parent_class)->dispose) G_OBJECT_CLASS (salut_muc_channel_parent_class)->dispose (object); } @@ -453,466 +465,73 @@ salut_muc_channel_finalize (GObject *object) /* free any data held directly by the object here */ g_free(priv->object_path); - text_mixin_finalize(object); + tp_text_mixin_finalize(object); + tp_group_mixin_finalize(TP_SVC_CHANNEL_INTERFACE_GROUP(object)); G_OBJECT_CLASS (salut_muc_channel_parent_class)->finalize (object); } void -salut_muc_channel_invited(SalutMucChannel *self, Handle invitor, +salut_muc_channel_invited(SalutMucChannel *self, TpHandle invitor, const gchar *stanza) { SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *contact_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_CONTACT); + TpHandleRepoIface *room_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_ROOM); /* Got invited to this muc channel */ DEBUG("Got an invitation to %s from %s", - handle_inspect(priv->connection->handle_repo, TP_HANDLE_TYPE_ROOM, - priv->handle), - handle_inspect(priv->connection->handle_repo, TP_HANDLE_TYPE_CONTACT, - invitor) + tp_handle_inspect(room_repo, priv->handle), + tp_handle_inspect(contact_repo, invitor) ); + /* If we are already a member, no further actions are needed */ - if (handle_set_is_member(self->group.members, - priv->connection->self_handle)) { + if (tp_handle_set_is_member(self->group.members, + base_connection->self_handle)) { return; } - if (invitor == priv->connection->self_handle) { + if (invitor == base_connection->self_handle) { /* Invited ourselves, go straight to members */ GError *error = NULL; - GArray *members = g_array_sized_new (FALSE, FALSE, sizeof (Handle), 1); - g_array_append_val(members, priv->connection->self_handle); - group_mixin_add_members(G_OBJECT(self), members, "", &error); + GArray *members = g_array_sized_new (FALSE, FALSE, sizeof(TpHandle), 1); + g_array_append_val(members, base_connection->self_handle); + tp_group_mixin_add_members(TP_SVC_CHANNEL_INTERFACE_GROUP(self), + members, "", &error); g_array_free(members, TRUE); } else { - GIntSet *empty = g_intset_new(); - GIntSet *local_pending = g_intset_new(); - g_intset_add(local_pending, priv->connection->self_handle); - group_mixin_change_members(G_OBJECT(self), stanza, - empty, empty, - local_pending, empty, - invitor, - TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); - g_intset_destroy(local_pending); - g_intset_destroy(empty); - } -} - -/** - * salut_muc_channel_acknowledge_pending_messages - * - * Implements D-Bus method AcknowledgePendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_acknowledge_pending_messages (SalutMucChannel *self, - const GArray *ids, - GError **error) { - return text_mixin_acknowledge_pending_messages(G_OBJECT(self), ids, error); -} - - -/** - * salut_muc_channel_add_members - * - * Implements D-Bus method AddMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_add_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *stanza, - GError **error) { - return group_mixin_add_members (G_OBJECT (self), contacts, stanza, - error); -} - - -/** - * salut_muc_channel_close - * - * Implements D-Bus method Close - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_close (SalutMucChannel *self, - GError **error) { - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); - - - if (priv->presence_timeout_id != 0) { - g_source_remove(priv->presence_timeout_id); - priv->presence_timeout_id = 0; + TpIntSet *empty = tp_intset_new(); + TpIntSet *local_pending = tp_intset_new(); + tp_intset_add(local_pending, base_connection->self_handle); + tp_group_mixin_change_members(TP_SVC_CHANNEL_INTERFACE_GROUP(self), stanza, + empty, empty, + local_pending, empty, + invitor, + TP_CHANNEL_GROUP_CHANGE_REASON_INVITED); + tp_intset_destroy(local_pending); + tp_intset_destroy(empty); } - - salut_muc_channel_send_presence(self, FALSE); - gibber_transport_disconnect( - GIBBER_XMPP_CONNECTION(priv->muc_connection)->transport); - - return TRUE; } -/** - * salut_muc_channel_get_all_members - * - * Implements D-Bus method GetAllMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_all_members (SalutMucChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error) -{ - return group_mixin_get_all_members (G_OBJECT (self), ret, ret1, ret2, error); -} - - -/** - * salut_muc_channel_get_channel_type - * - * Implements D-Bus method GetChannelType - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_channel_type (SalutMucChannel *self, - gchar **ret, - GError **error) { - *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_TEXT); - return TRUE; -} - - -/** - * salut_muc_channel_get_group_flags - * - * Implements D-Bus method GetGroupFlags - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_group_flags (SalutMucChannel *self, - guint *ret, - GError **error) -{ - return group_mixin_get_group_flags (G_OBJECT (self), ret, error); -} - - -/** - * salut_muc_channel_get_handle - * - * Implements D-Bus method GetHandle - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_handle (SalutMucChannel *self, - guint *ret, - guint *ret1, - GError **error) -{ - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); - *ret = TP_HANDLE_TYPE_ROOM; - *ret1 = priv->handle; - - return TRUE; -} - - -/** - * salut_muc_channel_get_handle_owners - * - * Implements D-Bus method GetHandleOwners - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_handle_owners (SalutMucChannel *self, - const GArray *handles, - GArray **ret, - GError **error) -{ - *ret = g_array_sized_new(FALSE, FALSE, - sizeof(Handle), handles->len); - *ret = g_array_insert_vals(*ret, 0, handles->data, handles->len); - return TRUE; -} - - -/** - * salut_muc_channel_get_interfaces - * - * Implements D-Bus method GetInterfaces - * on interface org.freedesktop.Telepathy.Channel - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_interfaces (SalutMucChannel *self, - gchar ***ret, - GError **error) { - const char *interfaces[] = { TP_IFACE_CHANNEL_INTERFACE_GROUP, - NULL }; - - *ret = g_strdupv ((gchar **) interfaces); - return TRUE; -} - - -/** - * salut_muc_channel_get_local_pending_members - * - * Implements D-Bus method GetLocalPendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_local_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error) { - return group_mixin_get_local_pending_members (G_OBJECT (self), ret, error); -} - - -/** - * salut_muc_channel_get_local_pending_members_with_info - * - * Implements D-Bus method GetLocalPendingMembersWithInfo - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_local_pending_members_with_info ( - SalutMucChannel *self, - GPtrArray **ret, - GError **error) -{ - return group_mixin_get_local_pending_members_with_info(G_OBJECT (self), ret, - error); -} - - -/** - * salut_muc_channel_get_members - * - * Implements D-Bus method GetMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_members (SalutMucChannel *self, - GArray **ret, - GError **error) -{ - return group_mixin_get_members (G_OBJECT (self), ret, error); -} - - -/** - * salut_muc_channel_get_message_types - * - * Implements D-Bus method GetMessageTypes - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_message_types (SalutMucChannel *self, - GArray **ret, - GError **error) { - return text_mixin_get_message_types(G_OBJECT(self), ret, error); -} - - -/** - * salut_muc_channel_get_remote_pending_members - * - * Implements D-Bus method GetRemotePendingMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_remote_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error) { - return group_mixin_get_remote_pending_members (G_OBJECT (self), ret, error); -} - - -/** - * salut_muc_channel_get_self_handle - * - * Implements D-Bus method GetSelfHandle - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_get_self_handle (SalutMucChannel *self, - guint *ret, - GError **error) { - return group_mixin_get_self_handle (G_OBJECT (self), ret, error); -} - - -/** - * salut_muc_channel_list_pending_messages - * - * Implements D-Bus method ListPendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_list_pending_messages (SalutMucChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error) { - return text_mixin_list_pending_messages(G_OBJECT(self), clear, ret, error); -} - - -/** - * salut_muc_channel_remove_members - * - * Implements D-Bus method RemoveMembers - * on interface org.freedesktop.Telepathy.Channel.Interface.Group - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_remove_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *stanza, - GError **error) +/* Private functions */ +static gboolean +salut_muc_channel_send_stanza(SalutMucChannel *self, guint type, + const gchar *text, + GibberXmppStanza *stanza, + GError **error) { - return group_mixin_remove_members(G_OBJECT (self), contacts, stanza, error); -} - - -/** - * salut_muc_channel_send - * - * Implements D-Bus method Send - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean -salut_muc_channel_send (SalutMucChannel *self, - guint type, const gchar *text, - GError **error) { SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self); - return text_mixin_send(G_OBJECT(self), type, - priv->connection->name, - priv->muc_name, text, error); -} - -/* Private functions */ -static gboolean salut_muc_channel_send_stanza(GObject *object, guint type, - const gchar *text, - GibberXmppStanza *stanza, - GError **error) { - SalutMucChannel *self = SALUT_MUC_CHANNEL(object); - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(object); if (!gibber_xmpp_connection_send(GIBBER_XMPP_CONNECTION(priv->muc_connection), stanza, error)) { - text_mixin_emit_send_error(G_OBJECT(self), CHANNEL_TEXT_SEND_ERROR_UNKNOWN, - time(NULL), type, text); + tp_svc_channel_type_text_emit_send_error(self, + TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN, time(NULL), type, text); return FALSE; } - text_mixin_emit_sent(G_OBJECT(self), time(NULL), type, text); + + tp_svc_channel_type_text_emit_sent(self, time(NULL), type, text); return TRUE; } @@ -948,13 +567,13 @@ salut_muc_channel_presence_timeout(gpointer data) { static void salut_muc_channel_change_members(SalutMucChannel *self, - Handle from_handle, + TpHandle from_handle, gboolean joining) { SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self); gboolean is_member; - GIntSet *empty, *changes; + TpIntSet *empty, *changes; - is_member = handle_set_is_member(self->group.members, from_handle); + is_member = tp_handle_set_is_member(self->group.members, from_handle); if (is_member == joining) { return; } @@ -966,18 +585,18 @@ salut_muc_channel_change_members(SalutMucChannel *self, salut_muc_channel_presence_timeout, self); } - empty = g_intset_new(); - changes = g_intset_new(); - g_intset_add(changes, from_handle); - group_mixin_change_members(G_OBJECT(self), + empty = tp_intset_new(); + changes = tp_intset_new(); + tp_intset_add(changes, from_handle); + tp_group_mixin_change_members(TP_SVC_CHANNEL_INTERFACE_GROUP(self), "", joining ? changes : empty, joining ? empty : changes, empty, empty, from_handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); - g_intset_destroy(changes); - g_intset_destroy(empty); + tp_intset_destroy(changes); + tp_intset_destroy(empty); } static void @@ -986,9 +605,12 @@ salut_muc_channel_received_stanza(GibberXmppConnection *conn, gpointer user_data) { SalutMucChannel *self = SALUT_MUC_CHANNEL(user_data); SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *contact_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_CONTACT); const gchar *from, *to, *body, *body_offset; TpChannelTextMessageType msgtype; - Handle from_handle; + TpHandle from_handle; to = gibber_xmpp_node_get_attribute(stanza->node, "to"); if (strcmp(to, priv->muc_name)) { @@ -1000,8 +622,8 @@ salut_muc_channel_received_stanza(GibberXmppConnection *conn, salut_muc_channel_received_presence(self, stanza); } - if (!text_mixin_parse_incoming_message(stanza, &from, &msgtype, - &body, &body_offset)) { + if (!text_helper_parse_incoming_message(stanza, &from, &msgtype, + &body, &body_offset)) { DEBUG("Couldn't parse stanza"); return; } @@ -1011,7 +633,7 @@ salut_muc_channel_received_stanza(GibberXmppConnection *conn, return; } - from_handle = handle_for_contact(priv->connection->handle_repo, from); + from_handle = tp_handle_lookup(contact_repo, from, NULL, NULL); if (from_handle == 0) { /* FIXME, unknown contact.. Need some way to handle this safely, * just adding the contact is somewhat scary */ @@ -1022,17 +644,20 @@ salut_muc_channel_received_stanza(GibberXmppConnection *conn, salut_muc_channel_change_members(self, from_handle, TRUE); /* FIXME validate the from and the to */ /* FIXME fix the text-mixin to actually get a to */ - text_mixin_receive(G_OBJECT(self), msgtype, from_handle, - time(NULL), body_offset); + tp_text_mixin_receive(G_OBJECT(self), msgtype, from_handle, + time(NULL), body_offset); } static void salut_muc_channel_received_presence(SalutMucChannel *channel, GibberXmppStanza *stanza) { SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(channel); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *contact_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_CONTACT); gboolean joining = TRUE; const gchar *type; const gchar *from; - Handle from_handle; + TpHandle from_handle; type = gibber_xmpp_node_get_attribute(stanza->node, "type"); if (type != NULL && strcmp(type, "unavailable") == 0) { @@ -1047,7 +672,7 @@ static void salut_muc_channel_received_presence(SalutMucChannel *channel, DEBUG("Presence from: %s (joining: %d)", from, joining); - from_handle = handle_for_contact(priv->connection->handle_repo, from); + from_handle = tp_handle_lookup(contact_repo, from, NULL, NULL); if (from_handle == 0) { DEBUG("Unknown contact"); return; @@ -1058,8 +683,8 @@ static void salut_muc_channel_received_presence(SalutMucChannel *channel, static gboolean salut_muc_channel_dummy_timeout(gpointer data) { - SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(data); - priv->presence_timeout_id = 0; + SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(data); + priv->presence_timeout_id = 0; return FALSE; } @@ -1098,6 +723,7 @@ salut_muc_channel_connected(GibberTransport *transport, priv->presence_timeout_id = g_timeout_add(4000, salut_muc_channel_dummy_timeout, self); + g_assert(priv->presence_timeout_id != 0); salut_muc_channel_send_presence(self, TRUE); } @@ -1105,5 +731,165 @@ static void salut_muc_channel_disconnected(GibberTransport *transport, gpointer user_data) { SalutMucChannel *self = SALUT_MUC_CHANNEL(user_data); - g_signal_emit(self, signals[CLOSED], 0); + tp_svc_channel_emit_closed(self); +} + +/* channel interfaces */ +/** + * salut_muc_channel_get_interfaces + * + * Implements D-Bus method GetInterfaces + * on interface org.freedesktop.Telepathy.Channel + * + * @error: Used to return a pointer to a GError detailing any error + * that occurred, D-Bus will throw the error only if this + * function returns FALSE. + * + * Returns: TRUE if successful, FALSE if an error was thrown. + */ +static void +salut_muc_channel_get_interfaces (TpSvcChannel *iface, + DBusGMethodInvocation *context) { + const char *interfaces[] = { TP_IFACE_CHANNEL_INTERFACE_GROUP, NULL }; + + tp_svc_channel_return_from_get_interfaces (context, interfaces); +} + + +/** + * salut_muc_channel_get_handle + * + * Implements D-Bus method GetHandle + * on interface org.freedesktop.Telepathy.Channel + * + * @error: Used to return a pointer to a GError detailing any error + * that occurred, D-Bus will throw the error only if this + * function returns FALSE. + * + * Returns: TRUE if successful, FALSE if an error was thrown. + */ +static void +salut_muc_channel_get_handle (TpSvcChannel *iface, + DBusGMethodInvocation *context) +{ + SalutMucChannel *self = SALUT_MUC_CHANNEL(iface); + SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); + + tp_svc_channel_return_from_get_handle (context, TP_HANDLE_TYPE_CONTACT, + priv->handle); } +/** + * salut_muc_channel_get_channel_type + * + * Implements D-Bus method GetChannelType + * on interface org.freedesktop.Telepathy.Channel + * + * @error: Used to return a pointer to a GError detailing any error + * that occurred, D-Bus will throw the error only if this + * function returns FALSE. + * + * Returns: TRUE if successful, FALSE if an error was thrown. + */ +static void +salut_muc_channel_get_channel_type (TpSvcChannel *iface, + DBusGMethodInvocation *context) { + tp_svc_channel_return_from_get_channel_type(context, + TP_IFACE_CHANNEL_TYPE_TEXT); +} + +/** + * salut_muc_channel_close + * + * Implements D-Bus method Close + * on interface org.freedesktop.Telepathy.Channel + * + * @error: Used to return a pointer to a GError detailing any error + * that occurred, D-Bus will throw the error only if this + * function returns FALSE. + * + * Returns: TRUE if successful, FALSE if an error was thrown. + */ +static void +salut_muc_channel_close (TpSvcChannel *iface, DBusGMethodInvocation *context) { + SalutMucChannel *self = SALUT_MUC_CHANNEL(iface); + SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE (self); + + DEBUG("Disposing muc channel: %d", priv->presence_timeout_id); + + if (priv->presence_timeout_id != 0) { + g_source_remove(priv->presence_timeout_id); + priv->presence_timeout_id = 0; + } + + salut_muc_channel_send_presence(self, FALSE); + gibber_transport_disconnect( + GIBBER_XMPP_CONNECTION(priv->muc_connection)->transport); + + tp_svc_channel_return_from_close(context); +} + +static void +channel_iface_init(gpointer g_iface, gpointer iface_data) { + TpSvcChannelClass *klass = (TpSvcChannelClass *)g_iface; + +#define IMPLEMENT(x) tp_svc_channel_implement_##x (\ + klass, salut_muc_channel_##x) + IMPLEMENT(close); + IMPLEMENT(get_channel_type); + IMPLEMENT(get_handle); + IMPLEMENT(get_interfaces); +#undef IMPLEMENT +} + + +/** + * salut_muc_channel_send + * + * Implements D-Bus method Send + * on interface org.freedesktop.Telepathy.Channel.Type.Text + * + * @error: Used to return a pointer to a GError detailing any error + * that occurred, D-Bus will throw the error only if this + * function returns FALSE. + * + * Returns: TRUE if successful, FALSE if an error was thrown. + */ +static void +salut_muc_channel_send (TpSvcChannelTypeText *channel, + guint type, const gchar * text, + DBusGMethodInvocation *context) { + SalutMucChannel *self = SALUT_MUC_CHANNEL(channel); + SalutMucChannelPrivate *priv = SALUT_MUC_CHANNEL_GET_PRIVATE(self); + GError *error = NULL; + + GibberXmppStanza *stanza = + text_helper_create_message(priv->connection->name, + priv->muc_name, type, text, &error); + + if (stanza == NULL) { + dbus_g_method_return_error(context, error); + g_error_free(error); + return; + } + + if (!salut_muc_channel_send_stanza(self, type, text, stanza, &error)) { + g_object_unref(G_OBJECT(stanza)); + dbus_g_method_return_error(context, error); + g_error_free(error); + } + + g_object_unref(G_OBJECT(stanza)); + tp_svc_channel_type_text_return_from_send(context); +} + +static void +text_iface_init(gpointer g_iface, gpointer iface_data) { + TpSvcChannelTypeTextClass *klass = (TpSvcChannelTypeTextClass *)g_iface; + + tp_text_mixin_iface_init (g_iface, iface_data); +#define IMPLEMENT(x) tp_svc_channel_type_text_implement_##x (\ + klass, salut_muc_channel_##x) + IMPLEMENT(send); +#undef IMPLEMENT +} + diff --git a/src/salut-muc-channel.h b/src/salut-muc-channel.h index 2740396d..17e34771 100644 --- a/src/salut-muc-channel.h +++ b/src/salut-muc-channel.h @@ -22,8 +22,9 @@ #define __SALUT_MUC_CHANNEL_H__ #include <glib-object.h> -#include "group-mixin.h" -#include "text-mixin.h" + +#include <telepathy-glib/text-mixin.h> +#include <telepathy-glib/group-mixin.h> G_BEGIN_DECLS @@ -32,14 +33,14 @@ typedef struct _SalutMucChannelClass SalutMucChannelClass; struct _SalutMucChannelClass { GObjectClass parent_class; - GroupMixinClass group_class; - TextMixinClass text_class; + TpGroupMixinClass group_class; + TpTextMixinClass text_class; }; struct _SalutMucChannel { GObject parent; - GroupMixin group; - TextMixin text; + TpGroupMixin group; + TpTextMixin text; }; GType salut_muc_channel_get_type(void); @@ -60,107 +61,7 @@ GType salut_muc_channel_get_type(void); void salut_muc_channel_invited(SalutMucChannel *self, - Handle invitor, const gchar *message); - -/* Binding function */ -gboolean -salut_muc_channel_acknowledge_pending_messages (SalutMucChannel *self, - const GArray *ids, - GError **error); - -gboolean -salut_muc_channel_add_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_muc_channel_close (SalutMucChannel *self, - GError **error); - -gboolean -salut_muc_channel_get_all_members (SalutMucChannel *self, - GArray **ret, - GArray **ret1, - GArray **ret2, - GError **error); - -gboolean -salut_muc_channel_get_channel_type (SalutMucChannel *self, - gchar **ret, - GError **error); - -gboolean -salut_muc_channel_get_group_flags (SalutMucChannel *self, - guint *ret, - GError **error); - -gboolean -salut_muc_channel_get_handle (SalutMucChannel *self, - guint *ret, - guint *ret1, - GError **error); - -gboolean -salut_muc_channel_get_handle_owners (SalutMucChannel *self, - const GArray *handles, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_interfaces (SalutMucChannel *self, - gchar ***ret, - GError **error); - -gboolean -salut_muc_channel_get_local_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_local_pending_members_with_info (SalutMucChannel *self, - GPtrArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_message_types (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_remote_pending_members (SalutMucChannel *self, - GArray **ret, - GError **error); - -gboolean -salut_muc_channel_get_self_handle (SalutMucChannel *self, - guint *ret, - GError **error); - -gboolean -salut_muc_channel_list_pending_messages (SalutMucChannel *self, - gboolean clear, - GPtrArray **ret, - GError **error); - -gboolean -salut_muc_channel_remove_members (SalutMucChannel *self, - const GArray *contacts, - const gchar *message, - GError **error); - -gboolean -salut_muc_channel_send (SalutMucChannel *self, - guint type, - const gchar *text, - GError **error); - - + TpHandle invitor, const gchar *message); G_END_DECLS diff --git a/src/salut-muc-connection.c b/src/salut-muc-connection.c index 89d83c31..34be691b 100644 --- a/src/salut-muc-connection.c +++ b/src/salut-muc-connection.c @@ -306,7 +306,7 @@ salut_muc_connection_new(const gchar *name, } priv->address = g_strdup(address); priv->port = g_strdup(port); - priv->rmulticast = (strcmp(protocol, PROTO_RMULTICAST) == 0); + priv->rmulticast = (strcmp(priv->protocol, PROTO_RMULTICAST) == 0); priv->mtransport = gibber_multicast_transport_new(); if (priv->rmulticast) { diff --git a/src/salut-muc-manager.c b/src/salut-muc-manager.c index f91f1419..89b2a572 100644 --- a/src/salut-muc-manager.c +++ b/src/salut-muc-manager.c @@ -22,8 +22,6 @@ #include <stdlib.h> #include <string.h> -#include "util.h" - #include "salut-muc-manager.h" #include "salut-muc-manager-signals-marshal.h" @@ -32,12 +30,9 @@ #include "salut-muc-channel.h" #include "salut-contact-manager.h" -#include "telepathy-errors.h" -#include "telepathy-constants.h" -#include "telepathy-interfaces.h" -#include "tp-channel-factory-iface.h" +#include <telepathy-glib/channel-factory-iface.h> +#include <telepathy-glib/interfaces.h> -#include "handle-repository.h" #include "namespaces.h" #define DEBUG_FLAG DEBUG_MUC @@ -115,10 +110,6 @@ salut_muc_manager_dispose (GObject *object) g_object_unref(priv->im_manager); priv->im_manager = NULL; } - if (priv->connection != NULL) { - g_object_unref(priv->connection); - priv->im_manager = NULL; - } if (priv->channels) { t = priv->channels; @@ -202,7 +193,7 @@ static void muc_channel_closed_cb(SalutMucChannel *chan, gpointer user_data) { SalutMucManager *self = SALUT_MUC_MANAGER(user_data); SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE(self); - Handle handle; + TpHandle handle; if (priv->channels) { g_object_get(chan, "handle", &handle, NULL); @@ -226,9 +217,12 @@ _get_connection_parameters(SalutMucManager *mgr, const gchar *protocol) { } static SalutMucChannel * -salut_muc_manager_new_channel(SalutMucManager *mgr, Handle handle, +salut_muc_manager_new_channel(SalutMucManager *mgr, TpHandle handle, GObject *connection) { SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE(mgr); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *room_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_ROOM); SalutMucChannel *chan; const gchar *name; gchar *path = NULL; @@ -239,10 +233,9 @@ salut_muc_manager_new_channel(SalutMucManager *mgr, Handle handle, /* FIXME The name of the muc and the handel might need to be different at * some point.. E.g. if two rooms are called the same */ - name = handle_inspect(priv->connection->handle_repo, - TP_HANDLE_TYPE_ROOM, handle); + name = tp_handle_inspect(room_repo, handle); path = g_strdup_printf("%s/MucChannel/%u", - priv->connection->object_path, handle); + base_connection->object_path, handle); chan = g_object_new(SALUT_TYPE_MUC_CHANNEL, "connection", priv->connection, "im-manager", priv->im_manager, @@ -255,7 +248,7 @@ salut_muc_manager_new_channel(SalutMucManager *mgr, Handle handle, g_hash_table_insert(priv->channels, GINT_TO_POINTER(handle), chan); g_signal_connect(chan, "closed", G_CALLBACK(muc_channel_closed_cb), mgr); - g_signal_emit_by_name(mgr, "new-channel", chan); + tp_channel_factory_iface_emit_new_channel(mgr, TP_CHANNEL_IFACE(chan), NULL); return chan; } @@ -265,13 +258,21 @@ salut_muc_manager_factory_iface_request(TpChannelFactoryIface *iface, const gchar *chan_type, TpHandleType handle_type, guint handle, - TpChannelIface **ret) { + gpointer request, + TpChannelIface **ret, + GError **error) { SalutMucManager *mgr = SALUT_MUC_MANAGER(iface); SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE(mgr); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *room_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_ROOM); SalutMucChannel *chan; + gboolean created = FALSE; + + DEBUG("Muc request"); /* We only support text channels */ - if (strcmp(chan_type, TP_IFACE_CHANNEL_TYPE_TEXT)) { + if (tp_strdiff(chan_type, TP_IFACE_CHANNEL_TYPE_TEXT)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED; } @@ -281,33 +282,34 @@ salut_muc_manager_factory_iface_request(TpChannelFactoryIface *iface, } /* Most be a valid room handle */ - if (!handle_is_valid(priv->connection->handle_repo, TP_HANDLE_TYPE_ROOM, - handle, NULL)) { + if (!tp_handle_is_valid(room_repo, handle, NULL)) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; } chan = g_hash_table_lookup(priv->channels, GINT_TO_POINTER(handle)); if (chan != NULL) { *ret = TP_CHANNEL_IFACE(chan); + created = FALSE; } else { GObject *connection = _get_connection(mgr, - handle_inspect( - priv->connection->handle_repo, - TP_HANDLE_TYPE_ROOM, handle), + tp_handle_inspect( + room_repo, handle), NULL, NULL, NULL); + created = TRUE; if (connection == NULL) { return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE; } chan = salut_muc_manager_new_channel(mgr, handle, connection); /* We requested the channel, so invite ourselves to it */ if (chan) { - salut_muc_channel_invited(chan, priv->connection->self_handle, ""); + salut_muc_channel_invited(chan, base_connection->self_handle, ""); *ret = TP_CHANNEL_IFACE(chan); } + g_assert(chan != NULL); } - return *ret != NULL ? TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE - : TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE; + return created ? TP_CHANNEL_FACTORY_REQUEST_STATUS_CREATED + : TP_CHANNEL_FACTORY_REQUEST_STATUS_EXISTING; } static void salut_muc_manager_factory_iface_init(gpointer *g_iface, @@ -326,7 +328,10 @@ static gboolean _received_stanza(SalutImChannel *imchannel, GibberXmppStanza *message, gpointer data) { SalutMucManager *self = SALUT_MUC_MANAGER(data); - SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE(data); + SalutMucManagerPrivate *priv = SALUT_MUC_MANAGER_GET_PRIVATE(self); + TpBaseConnection *base_connection = TP_BASE_CONNECTION(priv->connection); + TpHandleRepoIface *room_repo = + tp_base_connection_get_handles(base_connection, TP_HANDLE_TYPE_ROOM); GibberXmppNode *node; GibberXmppNode *invite; GibberXmppNode *room_node; @@ -336,8 +341,8 @@ _received_stanza(SalutImChannel *imchannel, const gchar *reason = NULL; const gchar *protocol = NULL; const gchar **params; - Handle room_handle; - Handle invitor_handle; + TpHandle room_handle; + TpHandle invitor_handle; const gchar **p; GHashTable *params_hash; GObject *transport = NULL; @@ -396,7 +401,7 @@ _received_stanza(SalutImChannel *imchannel, /* FIXME proper serialisation of handle name */ /* Create the group if it doesn't exist and myself to local_pending */ - room_handle = handle_for_room(priv->connection->handle_repo, room); + room_handle = tp_handle_ensure(room_repo, room, NULL, NULL); /* FIXME handle properly */ g_assert(room_handle != 0); @@ -411,8 +416,7 @@ _received_stanza(SalutImChannel *imchannel, } if (transport == NULL) { - handle_unref(priv->connection->handle_repo, - TP_HANDLE_TYPE_ROOM, room_handle); + tp_handle_unref(room_repo, room_handle); /* FIXME some kinda error to the user maybe ? Ignore for now */ goto discard; } @@ -437,7 +441,7 @@ discard: static void _new_im_channel(TpChannelFactoryIface *channel_iface, - TpChannelIface *channel, + TpChannelIface *channel, gpointer request, gpointer data) { SalutImChannel *imchannel = SALUT_IM_CHANNEL(channel); SalutMucManager *self = SALUT_MUC_MANAGER(data); @@ -465,7 +469,6 @@ salut_muc_manager_new(SalutConnection *connection, G_CALLBACK(_new_im_channel), ret); priv->connection = connection; - g_object_ref(connection); return ret; } diff --git a/src/salut-presence.h b/src/salut-presence.h index 1a0aaaf0..f6a40d04 100644 --- a/src/salut-presence.h +++ b/src/salut-presence.h @@ -21,7 +21,7 @@ #define __SALUT_PRESENCE_H__ #include <glib-object.h> -#include "telepathy-constants.h" +#include <telepathy-glib/enums.h> G_BEGIN_DECLS @@ -43,10 +43,10 @@ typedef enum { } SalutPresenceId; static const SalutPresenceStatusInfo salut_presence_statuses[] = { - { "available", "avail", TP_CONN_PRESENCE_TYPE_AVAILABLE }, - { "away", "away", TP_CONN_PRESENCE_TYPE_AWAY }, - { "dnd", "dnd", TP_CONN_PRESENCE_TYPE_AWAY }, - { "offline", "offline", TP_CONN_PRESENCE_TYPE_OFFLINE }, + { "available", "avail", TP_CONNECTION_PRESENCE_TYPE_AVAILABLE }, + { "away", "away", TP_CONNECTION_PRESENCE_TYPE_AWAY }, + { "dnd", "dnd", TP_CONNECTION_PRESENCE_TYPE_AWAY }, + { "offline", "offline", TP_CONNECTION_PRESENCE_TYPE_OFFLINE }, { NULL, NULL, 0} }; diff --git a/src/salut-self.c b/src/salut-self.c index 1e25714e..398cc2dc 100644 --- a/src/salut-self.c +++ b/src/salut-self.c @@ -31,9 +31,9 @@ #include "salut-self-signals-marshal.h" #include <gibber/gibber-linklocal-transport.h> +#include <telepathy-glib/errors.h> #include "salut-avahi-entry-group.h" -#include "telepathy-errors.h" #define DEBUG_FLAG DEBUG_SELF #include <debug.h> @@ -221,6 +221,8 @@ salut_self_new(SalutAvahiClient *client, SalutSelfPrivate *priv; GString *alias = NULL; + g_assert(client != NULL); + SalutSelf *ret = g_object_new(SALUT_TYPE_SELF, NULL); priv = SALUT_SELF_GET_PRIVATE (ret); @@ -387,7 +389,7 @@ salut_self_announce(SalutSelf *self, GError **error) { port = self_start_listening(self); if (port < 0) { if (error != NULL) { - *error = g_error_new(TELEPATHY_ERRORS, NetworkError, + *error = g_error_new(TP_ERRORS, TP_ERROR_NETWORK_ERROR, "Failed to start listening"); } return FALSE; diff --git a/src/salut.c b/src/salut.c index 13e60932..1eeb2fdc 100644 --- a/src/salut.c +++ b/src/salut.c @@ -1,49 +1,16 @@ #include "config.h" #include <glib.h> -#include <dbus/dbus-glib.h> -#include <avahi-glib/glib-watch.h> -#include <avahi-glib/glib-malloc.h> +#include <telepathy-glib/run.h> -#include "telepathy-errors.h" -#include "telepathy-errors-enumtypes.h" #include "salut-connection-manager.h" #include "debug.h" -GMainLoop *mainloop = NULL; -SalutConnectionManager *manager = NULL; -guint timeout_id; - -#define DIE_TIME 5000 - -static gboolean -kill_connection_manager(gpointer data) { - if (!debug_flag_is_set(DEBUG_PERSIST)) { - g_debug("No more connections, time to die"); - g_object_unref(manager); - g_main_loop_quit(mainloop); - } else { - g_debug("Would have exited if the persisted flag hadn't been set"); - } - timeout_id = 0; - return FALSE; -} - -static void -new_connection(SalutConnectionManager *conn, gchar *bus_name, - gchar *object_path, gchar *proto) { - if (timeout_id != 0) { - g_source_remove(timeout_id); - } -} - -static void -no_more_connections(SalutConnectionManager *manager, gpointer data) { - if (timeout_id != 0) { - g_source_remove(timeout_id); - } - timeout_id = g_timeout_add(DIE_TIME, kill_connection_manager, NULL); +static TpBaseConnectionManager * +salut_create_connection_manager(void) { + return TP_BASE_CONNECTION_MANAGER( + g_object_new(SALUT_TYPE_CONNECTION_MANAGER, NULL)); } int @@ -52,24 +19,10 @@ main(int argc, char **argv) { g_set_prgname("telepathy-salut"); debug_set_flags_from_env(); - mainloop = g_main_loop_new (NULL, FALSE); - - dbus_g_error_domain_register(TELEPATHY_ERRORS, - "org.freedesktop.Telepathy.Error", TELEPATHY_TYPE_ERRORS); - - timeout_id = g_timeout_add(DIE_TIME, kill_connection_manager, NULL); - - manager = g_object_new(SALUT_TYPE_CONNECTION_MANAGER, NULL); - g_signal_connect(manager, "new-connection", - G_CALLBACK(new_connection), NULL); - g_signal_connect(manager, "no-more-connections", - G_CALLBACK(no_more_connections), NULL); - - _salut_connection_manager_register(manager); - - g_main_loop_run(mainloop); - return 0; + return tp_run_connection_manager("telepathy-salut", VERSION, + salut_create_connection_manager, + argc, argv); } diff --git a/src/telepathy-constants.h b/src/telepathy-constants.h deleted file mode 100644 index 9ea16323..00000000 --- a/src/telepathy-constants.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * telepathy-constants.h - constants used in telepathy - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __TELEPATHY_CONSTANTS_H__ -#define __TELEPATHY_CONSTANTS_H__ - -#include <glib.h> -G_BEGIN_DECLS - -typedef enum { -TP_CHANNEL_GROUP_CHANGE_REASON_NONE = 0, -TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE = 1, -TP_CHANNEL_GROUP_CHANGE_REASON_KICKED = 2, -TP_CHANNEL_GROUP_CHANGE_REASON_BUSY = 3, -TP_CHANNEL_GROUP_CHANGE_REASON_INVITED = 4, -TP_CHANNEL_GROUP_CHANGE_REASON_BANNED = 5 -} TpChannelGroupChangeReason; - -typedef enum { -TP_CONN_ALIAS_FLAG_USER_SET = 1 -} TpConnAliasFlags; - -typedef enum { -TP_CONN_CAPABILITY_FLAG_CREATE = 1, -TP_CONN_CAPABILITY_FLAG_INVITE = 2 -} TpConnectionCapabilityFlags; - -typedef enum { -TP_CONN_CAPABILITY_TYPE_CREATE = 0, -TP_CONN_CAPABILITY_TYPE_INVITE = 1 -} TpConnectionCapabilityType; - -typedef enum { -TP_HANDLE_TYPE_NONE = 0, -TP_HANDLE_TYPE_CONTACT = 1, -TP_HANDLE_TYPE_ROOM = 2, -TP_HANDLE_TYPE_LIST = 3 -} TpHandleType; - -typedef enum { -TP_CONN_MGR_PARAM_FLAG_REQUIRED = 1, -TP_CONN_MGR_PARAM_FLAG_REGISTER = 2, -TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT = 4 -} TpConnectionManagerParamFlags; - -typedef enum { -TP_CONN_PRESENCE_TYPE_UNSET = 0, -TP_CONN_PRESENCE_TYPE_OFFLINE = 1, -TP_CONN_PRESENCE_TYPE_AVAILABLE = 2, -TP_CONN_PRESENCE_TYPE_AWAY = 3, -TP_CONN_PRESENCE_TYPE_EXTENDED_AWAY = 4, -TP_CONN_PRESENCE_TYPE_HIDDEN = 5 -} TpConnectionPresenceType; - -typedef enum { -TP_CONN_STATUS_CONNECTED = 0, -TP_CONN_STATUS_CONNECTING = 1, -TP_CONN_STATUS_DISCONNECTED = 2 -} TpConnectionStatus; - -typedef enum { -TP_CONN_STATUS_REASON_NONE_SPECIFIED = 0, -TP_CONN_STATUS_REASON_REQUESTED = 1, -TP_CONN_STATUS_REASON_NETWORK_ERROR = 2, -TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED = 3, -TP_CONN_STATUS_REASON_ENCRYPTION_ERROR = 4, -TP_CONN_STATUS_REASON_NAME_IN_USE = 5, -TP_CONN_STATUS_REASON_CERT_NOT_PROVIDED = 6, -TP_CONN_STATUS_REASON_CERT_UNTRUSTED = 7, -TP_CONN_STATUS_REASON_CERT_EXPIRED = 8, -TP_CONN_STATUS_REASON_CERT_NOT_ACTIVATED = 9, -TP_CONN_STATUS_REASON_CERT_HOSTNAME_MISMATCH = 10, -TP_CONN_STATUS_REASON_CERT_FINGERPRINT_MISMATCH = 11, -TP_CONN_STATUS_REASON_CERT_SELF_SIGNED = 12, -TP_CONN_STATUS_REASON_CERT_OTHER_ERROR = 13 -} TpConnectionStatusReason; - -typedef enum { -TP_CHANNEL_CONTACT_SEARCH_STATE_BEFORE = 0, -TP_CHANNEL_CONTACT_SEARCH_STATE_DURING = 1, -TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER = 2 -} TpChannelContactSearchState; - -typedef enum { -TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL = 0, -TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION = 1, -TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE = 2 -} TpChannelTextMessageType; - -typedef enum { -TP_CHANNEL_GROUP_FLAG_CAN_ADD = 1, -TP_CHANNEL_GROUP_FLAG_CAN_REMOVE = 2, -TP_CHANNEL_GROUP_FLAG_CAN_RESCIND = 4, -TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD = 8, -TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE = 16, -TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT = 32, -TP_CHANNEL_GROUP_FLAG_MESSAGE_REJECT = 64, -TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND = 128, -TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES = 256, -} TpChannelGroupFlags; - -typedef enum { -TP_CHANNEL_HOLD_STATE_NONE = 0, -TP_CHANNEL_HOLD_STATE_SEND_ONLY = 1, -TP_CHANNEL_HOLD_STATE_RECV_ONLY = 2, -TP_CHANNEL_HOLD_STATE_BOTH = 3 -} TpChannelHoldState; - -typedef enum { -TP_CHANNEL_PASSWORD_FLAG_PROVIDE = 8 -} TpChannelPasswordFlags; - -typedef enum { -TP_CHANNEL_TEXT_MESSAGE_FLAG_TRUNCATED = 1 -} TpChannelTextMessageFlags; - -typedef enum { -TP_MEDIA_STREAM_TYPE_AUDIO = 0, -TP_MEDIA_STREAM_TYPE_VIDEO = 1 -} TpMediaStreamType; - -typedef enum { -TP_MEDIA_STREAM_DIRECTION_NONE = 0, -TP_MEDIA_STREAM_DIRECTION_SEND = 1, -TP_MEDIA_STREAM_DIRECTION_RECIEVE = 2, -TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3 -} TpMediaStreamDirection; - -typedef enum { -TP_MEDIA_STREAM_PENDING_NONE = 0, -TP_MEDIA_STREAM_PENDING_LOCAL_SEND = 1, -TP_MEDIA_STREAM_PENDING_REMOTE_SEND = 2 -} TpMediaStreamPendingSend; - -typedef enum { -TP_MEDIA_STREAM_ERROR_UNKNOWN = 0, -TP_MEDIA_STREAM_ERROR_EOS = 1 -} TpMediaStreamError; - -typedef enum { -TP_MEDIA_STREAM_PROTO_UDP = 0, -TP_MEDIA_STREAM_PROTO_TCP = 1 -} TpMediaStreamProto; - -typedef enum { -TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL = 0, -TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED = 1, -TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY = 2 -} TpMediaStreamTransportType; - -typedef enum { -TP_CODEC_MEDIA_TYPE_AUDIO = 0, -TP_CODEC_MEDIA_TYPE_VIDEO = 1, -} TpCodecMediaType; - -typedef enum { -TP_MEDIA_STREAM_STATE_DISCONNECTED = 0, -TP_MEDIA_STREAM_STATE_CONNECTING = 1, -TP_MEDIA_STREAM_STATE_CONNECTED = 2 -} TpMediaStreamState; - -typedef enum { -TP_PROPERTY_FLAG_READ = 1, -TP_PROPERTY_FLAG_WRITE = 2 -} TpPropertyFlags; - -G_END_DECLS - - -#endif diff --git a/src/telepathy-errors.c b/src/telepathy-errors.c deleted file mode 100644 index b1bb876a..00000000 --- a/src/telepathy-errors.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * telepathy-errors.c - Source for D-Bus error types used in telepathy - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <glib.h> -#include "telepathy-errors.h" - -GQuark -telepathy_errors_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("telepathy_errors"); - return quark; -} diff --git a/src/telepathy-errors.h b/src/telepathy-errors.h deleted file mode 100644 index 71616761..00000000 --- a/src/telepathy-errors.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * telepathy-errors.h - Header for Telepathy error types - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __TELEPATHY_ERRORS_H__ -#define __TELEPATHY_ERRORS_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef enum -{ - ChannelBanned, /** You are banned from the channel. - */ - ChannelFull, /** The channel is full. - */ - ChannelInviteOnly, /** The requested channel is invite-only. - */ - Disconnected, /** The connection is not currently connected and cannot - * be used. - */ - InvalidArgument, /** Raised when one of the provided arguments is invalid. - */ - InvalidHandle, /** The contact name specified is unknown on this channel - * or connection. - */ - NetworkError, /** Raised when there is an error reading from or writing - * to the network. - */ - NotAvailable, /** Raised when the requested functionality is temporarily - * unavailable. - */ - NotImplemented, /** Raised when the requested method, channel, etc is not - * available on this connection. - */ - PermissionDenied, /** The user is not permitted to perform the requested - * operation. - */ -} TelepathyErrors; - -GQuark telepathy_errors_quark (void); -#define TELEPATHY_ERRORS telepathy_errors_quark () - -G_END_DECLS - -#endif /* #ifndef __TELEPATHY_ERRORS_H__*/ diff --git a/src/telepathy-helpers.c b/src/telepathy-helpers.c deleted file mode 100644 index d44d5551..00000000 --- a/src/telepathy-helpers.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * telepathy-helpers.c - Source for some Telepathy D-Bus helper functions - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#include <dbus/dbus-glib.h> -#include "telepathy-helpers.h" - -DBusGConnection * -tp_get_bus () -{ - static DBusGConnection *bus = NULL; - - if (bus == NULL) - { - GError *error = NULL; - - bus = dbus_g_bus_get (DBUS_BUS_STARTER, &error); - - if (bus == NULL) - g_error ("Failed to connect to starter bus: %s", error->message); - } - - return bus; -} - -DBusGProxy * -tp_get_bus_proxy () -{ - static DBusGProxy *bus_proxy = NULL; - - if (bus_proxy == NULL) - { - DBusGConnection *bus = tp_get_bus (); - - bus_proxy = dbus_g_proxy_new_for_name (bus, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus"); - - if (bus_proxy == NULL) - g_error ("Failed to get proxy object for bus."); - } - - return bus_proxy; -} - -static void _list_builder (gpointer key, gpointer value, gpointer data); - -GSList * -tp_hash_to_key_value_list (GHashTable *hash) -{ - GSList *ret = NULL; - - g_hash_table_foreach (hash, _list_builder, &ret); - - return ret; -} - -void -tp_key_value_list_free (GSList *list) -{ - GSList *iter; - - for (iter = list; iter; iter = g_slist_next(iter)) - { - g_free (iter->data); - } - - g_slist_free (list); -} - -static void _list_builder (gpointer key, gpointer value, gpointer data) -{ - GSList **list = (GSList **) data; - TpKeyValue *kv = g_new0 (TpKeyValue, 1); - - kv->key = key; - kv->value = value; - - *list = g_slist_prepend (*list, kv); -} - diff --git a/src/telepathy-helpers.h b/src/telepathy-helpers.h deleted file mode 100644 index 7e84f7fb..00000000 --- a/src/telepathy-helpers.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * telepathy-helpers.h - Header for various helper functions - * for telepathy implementation - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __TELEPATHY_HELPERS_H__ -#define __TELEPATHY_HELPERS_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -typedef struct -{ - gpointer key; - gpointer value; -} TpKeyValue; - -DBusGConnection * tp_get_bus (); -DBusGProxy * tp_get_bus_proxy (); -GSList *tp_hash_to_key_value_list (GHashTable *hash); -void tp_key_value_list_free (GSList *list); - -G_END_DECLS - -#endif /* __TELEPATHY_HELPERS_H__ */ - diff --git a/src/telepathy-interfaces.h b/src/telepathy-interfaces.h deleted file mode 100644 index e71d7875..00000000 --- a/src/telepathy-interfaces.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * telepathy-interfaces.h - Header for Telepathy interface names - * Copyright (C) 2005 Collabora Ltd. - * Copyright (C) 2005 Nokia Corporation - * - * 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 - */ - -#ifndef __TELEPATHY_INTERFACES_H__ -#define __TELEPATHY_INTERFACES_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define TP_IFACE_CHANNEL_INTERFACE \ - "org.freedesktop.Telepathy.Channel" -#define TP_IFACE_CHANNEL_INTERFACE_DTMF \ - "org.freedesktop.Telepathy.Channel.Interface.DTMF" -#define TP_IFACE_CHANNEL_INTERFACE_GROUP \ - "org.freedesktop.Telepathy.Channel.Interface.Group" -#define TP_IFACE_CHANNEL_INTERFACE_HOLD \ - "org.freedesktop.Telepathy.Channel.Interface.Hold" -#define TP_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING \ - "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling" -#define TP_IFACE_CHANNEL_INTERFACE_PASSWORD \ - "org.freedesktop.Telepathy.Channel.Interface.Password" -#define TP_IFACE_CHANNEL_INTERFACE_TRANSFER \ - "org.freedesktop.Telepathy.Channel.Interface.Transfer" -#define TP_IFACE_CHANNEL_TYPE_CONTACT_LIST \ - "org.freedesktop.Telepathy.Channel.Type.ContactList" -#define TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH \ - "org.freedesktop.Telepathy.Channel.Type.ContactSearch" -#define TP_IFACE_CHANNEL_TYPE_ROOM_LIST \ - "org.freedesktop.Telepathy.Channel.Type.RoomList" -#define TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA \ - "org.freedesktop.Telepathy.Channel.Type.StreamedMedia" -#define TP_IFACE_CHANNEL_TYPE_TEXT \ - "org.freedesktop.Telepathy.Channel.Type.Text" -#define TP_IFACE_CONN_INTERFACE \ - "org.freedesktop.Telepathy.Connection" -#define TP_IFACE_CONN_INTERFACE_ALIASING \ - "org.freedesktop.Telepathy.Connection.Interface.Aliasing" -#define TP_IFACE_CONN_INTERFACE_CAPABILITIES \ - "org.freedesktop.Telepathy.Connection.Interface.Capabilities" -#define TP_IFACE_CONN_INTERFACE_CONTACT_INFO \ - "org.freedesktop.Telepathy.Connection.Interface.ContactInfo" -#define TP_IFACE_CONN_INTERFACE_FORWARDING \ - "org.freedesktop.Telepathy.Connection.Interface.Forwarding" -#define TP_IFACE_CONN_INTERFACE_PRESENCE \ - "org.freedesktop.Telepathy.Connection.Interface.Presence" -#define TP_IFACE_CONN_INTERFACE_PRIVACY \ - "org.freedesktop.Telepathy.Connection.Interface.Privacy" -#define TP_IFACE_CONN_INTERFACE_RENAMING \ - "org.freedesktop.Telepathy.Connection.Interface.Renaming" -#define TP_IFACE_CONN_MGR_INTERFACE \ - "org.freedesktop.Telepathy.ConnectionManager" -#define TP_IFACE_MEDIA_SESSION_HANDLER \ - "org.freedesktop.Telepathy.Media.SessionHandler" -#define TP_IFACE_MEDIA_STREAM_HANDLER \ - "org.freedesktop.Telepathy.Media.StreamHandler" -#define TP_IFACE_PROPERTIES \ - "org.freedesktop.Telepathy.Properties" - -G_END_DECLS - -#endif /* #ifndef __TELEPATHY_INTERFACES_H__*/ diff --git a/src/text-helper.c b/src/text-helper.c new file mode 100644 index 00000000..1ed91b17 --- /dev/null +++ b/src/text-helper.c @@ -0,0 +1,154 @@ +/* + * text-helper.c - Source for TextHelper + * Copyright (C) 2006 Collabora Ltd. + * Copyright (C) 2006 Nokia Corporation + * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> + * @author Robert McQueen <robert.mcqueen@collabora.co.uk> + * @author Senko Rasic <senko@senko.net> + * @author Sjoerd Simons <sjoerd@luon.net> + * + * 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 + */ + +#define _GNU_SOURCE /* Needed for strptime (_XOPEN_SOURCE can also be used). */ + +#include <dbus/dbus-glib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include <gibber/gibber-namespaces.h> + +#include <telepathy-glib/errors.h> + +#define DEBUG_FLAG DEBUG_IM +#include "debug.h" + +#include "text-helper.h" + +static void +add_text(GibberXmppStanza *stanza, const gchar *text) { + GibberXmppNode *htmlnode; + + gibber_xmpp_node_add_child_with_content(stanza->node, "body", text); + + /* Add plain xhtml-im node */ + htmlnode = gibber_xmpp_node_add_child_ns(stanza->node, "html", + GIBBER_XMPP_NS_XHTML_IM); + gibber_xmpp_node_add_child_with_content_ns(htmlnode, + "body", text, GIBBER_W3C_NS_XHTML); +} + +GibberXmppStanza * +text_helper_create_message(const gchar *from, const gchar *to, + TpChannelTextMessageType type, + const gchar *text, + GError **error) +{ + GibberXmppStanza *stanza; + + if (type > TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE) { + DEBUG ("invalid message type %u", type); + + g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "invalid message type: %u", type); + + return NULL; + } + stanza = gibber_xmpp_stanza_new("message"); + + switch (type) { + case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: + case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: + gibber_xmpp_node_set_attribute(stanza->node, "type", "chat"); + break; + case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: + case TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY: + gibber_xmpp_node_set_attribute(stanza->node, "type", "normal"); + break; + } + + gibber_xmpp_node_set_attribute(stanza->node, "from", from); + gibber_xmpp_node_set_attribute(stanza->node, "to", to); + + if (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) + { + gchar *tmp; + tmp = g_strconcat ("/me ", text, NULL); + add_text(stanza, tmp); + g_free (tmp); + } + else + { + add_text(stanza, text); + } + + return stanza; +} + +gboolean +text_helper_parse_incoming_message (GibberXmppStanza *stanza, + const gchar **from, + TpChannelTextMessageType *msgtype, + const gchar **body, + const gchar **body_offset) +{ + const gchar *type; + GibberXmppNode *node; + + *from = gibber_xmpp_node_get_attribute (stanza->node, "from"); + type = gibber_xmpp_node_get_attribute (stanza->node, "type"); + /* + * Parse body if it exists. + */ + node = gibber_xmpp_node_get_child (stanza->node, "body"); + + if (node) + { + *body = node->content; + } + else + { + *body = NULL; + } + + + /* Messages starting with /me are ACTION messages, and the /me should be + * removed. type="chat" messages are NORMAL. everything else is + * something that doesn't necessarily expect a reply or ongoing + * conversation ("normal") or has been auto-sent, so we make it NOTICE in + * all other cases. */ + + *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE; + *body_offset = *body; + + if (*body) + { + if (0 == strncmp (*body, "/me ", 4)) + { + *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION; + *body_offset = *body + 4; + } + else if (type != NULL && (0 == strcmp (type, "chat") || + 0 == strcmp (type, "groupchat"))) + { + *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL; + *body_offset = *body; + } + } + + return TRUE; +} diff --git a/src/util.c b/src/text-helper.h index 1991e9d4..b0d4d8e0 100644 --- a/src/util.c +++ b/src/text-helper.h @@ -1,8 +1,7 @@ /* - * util.c - Source for Gabble utility functions + * text-helper.h - Header for TextHelper * Copyright (C) 2006 Collabora Ltd. * Copyright (C) 2006 Nokia Corporation - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,16 +18,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <glib.h> -#include <string.h> +#ifndef __TEXT_HELPER_H__ +#define __TEXT_HELPER_H__ -#include "util.h" +#include <telepathy-glib/enums.h> +#include <gibber/gibber-xmpp-stanza.h> -/* extend a pointer by an offset, provided the offset is not 0 */ -gpointer -mixin_offset_cast (gpointer instance, guint offset) -{ - g_return_val_if_fail (offset != 0, NULL); - return ((guchar *) instance + offset); -} +/* Utility functions for the helper user */ +gboolean +text_helper_parse_incoming_message (GibberXmppStanza *stanza, + const gchar **from, TpChannelTextMessageType *msgtype, + const gchar **body, const gchar **body_offset); + +GibberXmppStanza * +text_helper_create_message (const gchar *from, + const gchar *to, TpChannelTextMessageType type, + const gchar *text, GError **error); + +G_END_DECLS + +#endif /* #ifndef __TEXT_HELPER_H__ */ diff --git a/src/text-mixin-signals-marshal.list b/src/text-mixin-signals-marshal.list deleted file mode 100644 index da94b09b..00000000 --- a/src/text-mixin-signals-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -VOID:UINT,UINT,UINT,UINT,UINT,STRING -VOID:UINT,UINT,UINT,STRING -VOID:UINT,UINT,STRING diff --git a/src/text-mixin.c b/src/text-mixin.c deleted file mode 100644 index a16507f1..00000000 --- a/src/text-mixin.c +++ /dev/null @@ -1,689 +0,0 @@ -/* - * text-mixin.c - Source for TextMixin - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * @author Senko Rasic <senko@senko.net> - * @author Sjoerd Simons <sjoerd@luon.net> - * - * 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 - */ - -#define _GNU_SOURCE /* Needed for strptime (_XOPEN_SOURCE can also be used). */ - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include <gibber/gibber-namespaces.h> - -#include "telepathy-constants.h" -#include "telepathy-errors.h" - -#define DEBUG_FLAG DEBUG_IM - -#include "debug.h" -#include "util.h" - -#include "text-mixin.h" -#include "text-mixin-signals-marshal.h" - -#define TP_TYPE_PENDING_MESSAGE_STRUCT (dbus_g_type_get_struct ("GValueArray", \ - G_TYPE_UINT, \ - G_TYPE_UINT, \ - G_TYPE_UINT, \ - G_TYPE_UINT, \ - G_TYPE_UINT, \ - G_TYPE_STRING, \ - G_TYPE_INVALID)) - -/* allocator */ - -typedef struct _Allocator Allocator; -struct _Allocator -{ - gulong size; - guint limit; - guint count; -}; - -#define ga_new0(alloc, type) \ - ((type *) allocator_alloc0 (alloc)) - -static void -allocator_init (Allocator *alloc, gulong size, guint limit) -{ - g_assert (alloc != NULL); - g_assert (size > 0); - g_assert (limit > 0); - - alloc->size = size; - alloc->limit = limit; -} - -static gpointer allocator_alloc0 (Allocator *alloc) -{ - gpointer ret; - - g_assert (alloc != NULL); - g_assert (alloc->count <= alloc->limit); - - if (alloc->count == alloc->limit) - { - ret = NULL; - } - else - { - ret = g_malloc0 (alloc->size); - alloc->count++; - } - - return ret; -} - -static void allocator_free (Allocator *alloc, gpointer thing) -{ - g_assert (alloc != NULL); - g_assert (thing != NULL); - - g_free (thing); - alloc->count--; -} - -/* pending message */ -#define MAX_PENDING_MESSAGES 256 -#define MAX_MESSAGE_SIZE 1024 - 1 - -typedef struct _PendingMessage PendingMessage; -struct _PendingMessage -{ - guint id; - time_t timestamp; - Handle sender; - TpChannelTextMessageType type; - char *text; - guint flags; -}; - -/** - * text_mixin_class_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObjectClass - */ -GQuark -text_mixin_class_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string("TextMixinClassOffsetQuark"); - return offset_quark; -} - -/** - * text_mixin_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObject - */ -GQuark -text_mixin_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string("TextMixinOffsetQuark"); - return offset_quark; -} - - -/* TextMixin */ -void -text_mixin_class_init (GObjectClass *obj_cls, glong offset, - TextMixinSendFunc send) { - TextMixinClass *mixin_cls; - - g_assert (G_IS_OBJECT_CLASS (obj_cls)); - - g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls), - TEXT_MIXIN_CLASS_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin_cls = TEXT_MIXIN_CLASS (obj_cls); - - mixin_cls->lost_message_signal_id = g_signal_new ("lost-message", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - mixin_cls->received_signal_id = g_signal_new ("received", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - text_mixin_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING, - G_TYPE_NONE, 6, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - mixin_cls->send_error_signal_id = g_signal_new ("send-error", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - text_mixin_marshal_VOID__UINT_UINT_UINT_STRING, - G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - mixin_cls->sent_signal_id = g_signal_new ("sent", - G_OBJECT_CLASS_TYPE (obj_cls), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - text_mixin_marshal_VOID__UINT_UINT_STRING, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING); - - mixin_cls->send = send; -} - -void -text_mixin_init (GObject *obj, - glong offset, - HandleRepo *handle_repo) { - TextMixin *mixin; - - g_assert (G_IS_OBJECT (obj)); - - g_type_set_qdata (G_OBJECT_TYPE (obj), - TEXT_MIXIN_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin = TEXT_MIXIN (obj); - - mixin->pending = g_queue_new (); - mixin->handle_repo = handle_repo; - mixin->recv_id = 0; - mixin->msg_types = g_array_sized_new (FALSE, FALSE, sizeof (guint), 4); - - mixin->message_lost = FALSE; -} - -void -text_mixin_set_message_types (GObject *obj, - ...) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - va_list args; - guint type; - - va_start (args, obj); - - while ((type = va_arg (args, guint)) != G_MAXUINT) - g_array_append_val (mixin->msg_types, type); - - va_end (args); -} - -static void _pending_free (PendingMessage *msg); -static Allocator * _pending_get_alloc (); - -void -text_mixin_finalize (GObject *obj) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - PendingMessage *msg; - - /* free any data held directly by the object here */ - - while ((msg = g_queue_pop_head(mixin->pending))) - { - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender); - _pending_free (msg); - } - - g_queue_free (mixin->pending); - - g_array_free (mixin->msg_types, TRUE); -} - -/** - * _pending_get_alloc - * - * Returns a Allocator for creating up to 256 pending messages, but no - * more. - */ -static Allocator * -_pending_get_alloc () -{ - static Allocator alloc = { 0, }; - - if (0 == alloc.size) - allocator_init (&alloc, sizeof(PendingMessage), MAX_PENDING_MESSAGES); - - return &alloc; -} - -#define _pending_new0() \ - (ga_new0 (_pending_get_alloc (), PendingMessage)) - -/** - * _pending_free - * - * Free up a PendingMessage struct. - */ -static void _pending_free (PendingMessage *msg) -{ - g_free (msg->text); - allocator_free (_pending_get_alloc (), msg); -} - -/** - * _text_mixin_receive - * - */ -gboolean text_mixin_receive (GObject *obj, - TpChannelTextMessageType type, - Handle sender, - time_t timestamp, - const char *text) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - TextMixinClass *mixin_cls = TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - - gchar *end; - PendingMessage *msg; - gsize len; - - msg = _pending_new0 (); - - if (msg == NULL) - { - DEBUG ("no more pending messages available, giving up"); - - if (!mixin->message_lost) - { - g_signal_emit (obj, mixin_cls->lost_message_signal_id, 0); - mixin->message_lost = TRUE; - } - - return FALSE; - } - - len = strlen (text); - - if (len > MAX_MESSAGE_SIZE) - { - DEBUG ("message exceeds maximum size, truncating"); - - msg->flags |= TP_CHANNEL_TEXT_MESSAGE_FLAG_TRUNCATED; - - end = g_utf8_find_prev_char (text, text+MAX_MESSAGE_SIZE); - if (end) - len = end-text; - else - len = 0; - } - - msg->text = g_try_malloc (len + 1); - - if (msg->text == NULL) - { - DEBUG ("unable to allocate message, giving up"); - - if (!mixin->message_lost) - { - g_signal_emit (obj, mixin_cls->lost_message_signal_id, 0); - mixin->message_lost = TRUE; - } - - _pending_free (msg); - - return FALSE; - } - - g_strlcpy (msg->text, text, len + 1); - - msg->id = mixin->recv_id++; - msg->timestamp = timestamp; - msg->sender = sender; - msg->type = type; - - handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender); - g_queue_push_tail (mixin->pending, msg); - - g_signal_emit (obj, mixin_cls->received_signal_id, 0, - msg->id, - msg->timestamp, - msg->sender, - msg->type, - msg->flags, - msg->text); - - DEBUG ("queued message %u", msg->id); - - mixin->message_lost = FALSE; - - return TRUE; -} - -static gint -compare_pending_message (gconstpointer haystack, - gconstpointer needle) -{ - PendingMessage *msg = (PendingMessage *) haystack; - guint id = GPOINTER_TO_INT (needle); - - return (msg->id != id); -} - -/** - * text_mixin_acknowledge_pending_messages - * - * Implements D-Bus method AcknowledgePendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean text_mixin_acknowledge_pending_messages (GObject *obj, const GArray * ids, GError **error) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - GList **nodes; - PendingMessage *msg; - guint i; - - nodes = g_new(GList *, ids->len); - - for (i = 0; i < ids->len; i++) - { - guint id = g_array_index(ids, guint, i); - - nodes[i] = g_queue_find_custom (mixin->pending, - GINT_TO_POINTER (id), - compare_pending_message); - - if (nodes[i] == NULL) - { - DEBUG ("invalid message id %u", id); - - g_set_error (error, TELEPATHY_ERRORS, InvalidArgument, - "invalid message id %u", id); - - g_free(nodes); - return FALSE; - } - } - - for (i = 0; i < ids->len; i++) - { - msg = (PendingMessage *) nodes[i]->data; - - DEBUG ("acknowleding message id %u", msg->id); - - g_queue_remove (mixin->pending, msg); - - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender); - _pending_free (msg); - } - - g_free(nodes); - return TRUE; -} - -/** - * text_mixin_list_pending_messages - * - * Implements D-Bus method ListPendingMessages - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean text_mixin_list_pending_messages (GObject *obj, gboolean clear, GPtrArray ** ret, GError **error) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - guint count; - GPtrArray *messages; - GList *cur; - - count = g_queue_get_length (mixin->pending); - messages = g_ptr_array_sized_new (count); - - for (cur = (clear ? g_queue_pop_head_link(mixin->pending) - : g_queue_peek_head_link(mixin->pending)); - cur != NULL; - cur = (clear ? g_queue_pop_head_link(mixin->pending) - : cur->next)) - { - PendingMessage *msg = (PendingMessage *) cur->data; - GValue val = { 0, }; - - g_value_init (&val, TP_TYPE_PENDING_MESSAGE_STRUCT); - g_value_take_boxed (&val, - dbus_g_type_specialized_construct (TP_TYPE_PENDING_MESSAGE_STRUCT)); - dbus_g_type_struct_set (&val, - 0, msg->id, - 1, msg->timestamp, - 2, msg->sender, - 3, msg->type, - 4, msg->flags, - 5, msg->text, - G_MAXUINT); - - g_ptr_array_add (messages, g_value_get_boxed (&val)); - } - - *ret = messages; - - return TRUE; -} - -static void -add_text(GibberXmppStanza *stanza, const gchar *text) { - GibberXmppNode *htmlnode; - - gibber_xmpp_node_add_child_with_content(stanza->node, "body", text); - - /* Add plain xhtml-im node */ - htmlnode = gibber_xmpp_node_add_child_ns(stanza->node, "html", - GIBBER_XMPP_NS_XHTML_IM); - gibber_xmpp_node_add_child_with_content_ns(htmlnode, - "body", text, GIBBER_W3C_NS_XHTML); -} - -/** - * text_mixin_send - * - * Implements D-Bus method Send - * on interface org.freedesktop.Telepathy.Channel.Type.Text - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -gboolean text_mixin_send (GObject *obj, guint type, - const char *from, - const char *to, - const gchar *text, - GError **error) -{ - TextMixinClass *mixin_cls = TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - GibberXmppStanza *stanza; - gboolean result; - - if (type > TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE) { - DEBUG ("invalid message type %u", type); - - g_set_error (error, TELEPATHY_ERRORS, InvalidArgument, - "invalid message type: %u", type); - - return FALSE; - } - stanza = gibber_xmpp_stanza_new("message"); - - switch (type) { - case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: - case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: - gibber_xmpp_node_set_attribute(stanza->node, "type", "chat"); - break; - case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: - gibber_xmpp_node_set_attribute(stanza->node, "type", "normal"); - break; - } - - gibber_xmpp_node_set_attribute(stanza->node, "from", from); - gibber_xmpp_node_set_attribute(stanza->node, "to", to); - - if (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) - { - gchar *tmp; - tmp = g_strconcat ("/me ", text, NULL); - add_text(stanza, tmp); - g_free (tmp); - } - else - { - add_text(stanza, text); - } - - result = mixin_cls->send(obj, type, text, stanza, error); - g_object_unref (G_OBJECT(stanza)); - - if (!result) - return FALSE; - - return TRUE; -} - -void -text_mixin_emit_sent (GObject *obj, - time_t timestamp, - guint type, - const char *text) -{ - TextMixinClass *mixin_cls = TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS - (obj)); - - g_signal_emit (obj, mixin_cls->sent_signal_id, 0, - timestamp, - type, - text); -} - -gboolean -text_mixin_get_message_types (GObject *obj, GArray **ret, GError **error) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - guint i; - - *ret = g_array_sized_new (FALSE, FALSE, sizeof (guint), - mixin->msg_types->len); - - for (i = 0; i < mixin->msg_types->len; i++) - { - g_array_append_val (*ret, g_array_index (mixin->msg_types, guint, i)); - } - - return TRUE; -} - - -void -text_mixin_clear (GObject *obj) -{ - TextMixin *mixin = TEXT_MIXIN (obj); - PendingMessage *msg; - - while ((msg = g_queue_pop_head(mixin->pending))) - { - handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender); - _pending_free (msg); - } -} - -gboolean -text_mixin_parse_incoming_message (GibberXmppStanza *stanza, - const gchar **from, - TpChannelTextMessageType *msgtype, - const gchar **body, - const gchar **body_offset) -{ - const gchar *type; - GibberXmppNode *node; - - *from = gibber_xmpp_node_get_attribute (stanza->node, "from"); - type = gibber_xmpp_node_get_attribute (stanza->node, "type"); - /* - * Parse body if it exists. - */ - node = gibber_xmpp_node_get_child (stanza->node, "body"); - - if (node) - { - *body = node->content; - } - else - { - *body = NULL; - } - - - /* Messages starting with /me are ACTION messages, and the /me should be - * removed. type="chat" messages are NORMAL. everything else is - * something that doesn't necessarily expect a reply or ongoing - * conversation ("normal") or has been auto-sent, so we make it NOTICE in - * all other cases. */ - - *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE; - *body_offset = *body; - - if (*body) - { - if (0 == strncmp (*body, "/me ", 4)) - { - *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION; - *body_offset = *body + 4; - } - else if (type != NULL && (0 == strcmp (type, "chat") || - 0 == strcmp (type, "groupchat"))) - { - *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL; - *body_offset = *body; - } - } - - return TRUE; -} - -void -text_mixin_emit_send_error (GObject *obj, - TextMixinSendError error, - time_t timestamp, - TpChannelTextMessageType type, - const gchar *text) -{ - TextMixinClass *mixin_cls = TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - - g_signal_emit (obj, mixin_cls->send_error_signal_id, 0, error, timestamp, type, text, 0); -} - diff --git a/src/text-mixin.h b/src/text-mixin.h deleted file mode 100644 index c18b56b6..00000000 --- a/src/text-mixin.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * text-mixin.h - Header for TextMixin - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * - * 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 - */ - -#ifndef __TEXT_MIXIN_H__ -#define __TEXT_MIXIN_H__ - -#include "handle-repository.h" -#include "handle-set.h" -#include "util.h" - -#include <gibber/gibber-xmpp-stanza.h> - -typedef enum { - CHANNEL_TEXT_SEND_ERROR_UNKNOWN = 0, - CHANNEL_TEXT_SEND_ERROR_OFFLINE, - CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT, - CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED, - CHANNEL_TEXT_SEND_ERROR_TOO_LONG, - CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED, - - CHANNEL_TEXT_SEND_NO_ERROR = -1 -} TextMixinSendError; - -G_BEGIN_DECLS - -typedef struct _TextMixinClass TextMixinClass; -typedef struct _TextMixin TextMixin; - -typedef gboolean (*TextMixinSendFunc) (GObject *obj, - guint type, - const gchar *text, - GibberXmppStanza *stanza, - GError **error); - -struct _TextMixinClass { - guint lost_message_signal_id; - guint received_signal_id; - guint send_error_signal_id; - guint sent_signal_id; - - TextMixinSendFunc send; -}; - -struct _TextMixin { - HandleRepo *handle_repo; - guint recv_id; - gboolean message_lost; - - GQueue *pending; - - GArray *msg_types; -}; - -GType text_mixin_get_type(void); - -/* TYPE MACROS */ -#define TEXT_MIXIN_CLASS_OFFSET_QUARK (text_mixin_class_get_offset_quark()) -#define TEXT_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), TEXT_MIXIN_CLASS_OFFSET_QUARK))) -#define TEXT_MIXIN_CLASS(o) ((TextMixinClass *) mixin_offset_cast (o, TEXT_MIXIN_CLASS_OFFSET (o))) - -#define TEXT_MIXIN_OFFSET_QUARK (text_mixin_get_offset_quark()) -#define TEXT_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), TEXT_MIXIN_OFFSET_QUARK))) -#define TEXT_MIXIN(o) ((TextMixin *) mixin_offset_cast (o, TEXT_MIXIN_OFFSET (o))) - -GQuark text_mixin_class_get_offset_quark (void); -GQuark text_mixin_get_offset_quark (void); - -void text_mixin_class_init (GObjectClass *obj_cls, glong offset, - TextMixinSendFunc send); -void text_mixin_init (GObject *obj, glong offset, HandleRepo *handle_repo); -void text_mixin_set_message_types (GObject *obj, ...); -void text_mixin_finalize (GObject *obj); - -/* D-Bus method implementations */ -gboolean text_mixin_acknowledge_pending_messages (GObject *obj, const GArray * ids, GError **error); -gboolean text_mixin_list_pending_messages (GObject *obj, gboolean clear, GPtrArray ** ret, GError **error); -gboolean text_mixin_send (GObject *obj, guint type, const char *from, const char * to, const gchar * text, GError **error); -gboolean text_mixin_get_message_types (GObject *obj, GArray **ret, GError **error); - -/* Utility functions for the mixin user */ -gboolean text_mixin_parse_incoming_message (GibberXmppStanza *stanza, const gchar **from, TpChannelTextMessageType *msgtype, const gchar **body, const gchar **body_offset); -gboolean text_mixin_receive (GObject *obj, TpChannelTextMessageType type, Handle sender, time_t timestamp, const char *text); -void text_mixin_emit_sent (GObject *obj, time_t timestamp, guint type, const char *text); -void text_mixin_emit_send_error(GObject *obj, TextMixinSendError error, time_t timestamp, TpChannelTextMessageType type, const gchar *text); -void text_mixin_clear (GObject *obj); - -G_END_DECLS - -#endif /* #ifndef __TEXT_MIXIN_H__ */ - diff --git a/src/tp-channel-factory-iface-signals-marshal.list b/src/tp-channel-factory-iface-signals-marshal.list deleted file mode 100644 index 86c0c398..00000000 --- a/src/tp-channel-factory-iface-signals-marshal.list +++ /dev/null @@ -1 +0,0 @@ -VOID:OBJECT,POINTER diff --git a/src/tp-channel-factory-iface.c b/src/tp-channel-factory-iface.c deleted file mode 100644 index 87b786fc..00000000 --- a/src/tp-channel-factory-iface.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * tp-channel-factory-iface.c - Stubs for Telepathy Channel Factory interface - * - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * - * 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 - */ - -#include <glib-object.h> - -#include "tp-channel-factory-iface.h" -#include "tp-channel-factory-iface-signals-marshal.h" -#include "tp-channel-iface.h" - -static void -tp_channel_factory_iface_base_init (gpointer klass) -{ - static gboolean initialized = FALSE; - - if (!initialized) { - initialized = TRUE; - - g_signal_new ("new-channel", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); - - g_signal_new ("channel-error", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - tp_channel_factory_iface_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_POINTER); - } -} - -GType -tp_channel_factory_iface_get_type (void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof (TpChannelFactoryIfaceClass), - tp_channel_factory_iface_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL /* instance_init */ - }; - - type = g_type_register_static (G_TYPE_INTERFACE, "TpChannelFactoryIface", &info, 0); - } - - return type; -} - -void -tp_channel_factory_iface_close_all (TpChannelFactoryIface *self) -{ - TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->close_all (self); -} - -void -tp_channel_factory_iface_connecting (TpChannelFactoryIface *self) -{ - TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->connecting (self); -} - -void -tp_channel_factory_iface_connected (TpChannelFactoryIface *self) -{ - TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->connected (self); -} - -void -tp_channel_factory_iface_disconnected (TpChannelFactoryIface *self) -{ - TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->disconnected (self); -} - -void -tp_channel_factory_iface_foreach (TpChannelFactoryIface *self, - TpChannelFunc func, - gpointer data) -{ - TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->foreach (self, func, data); -} - -TpChannelFactoryRequestStatus -tp_channel_factory_iface_request (TpChannelFactoryIface *self, - const gchar *chan_type, - TpHandleType handle_type, - guint handle, - TpChannelIface **ret) -{ - return (TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->request (self, chan_type, - handle_type, handle, ret)); -} diff --git a/src/tp-channel-factory-iface.h b/src/tp-channel-factory-iface.h deleted file mode 100644 index 75befd0f..00000000 --- a/src/tp-channel-factory-iface.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * tp-channel-factory-iface.h - Headers for Telepathy Channel Factory interface - * - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * - * 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 - */ - -#ifndef __TP_CHANNEL_FACTORY_IFACE_H__ -#define __TP_CHANNEL_FACTORY_IFACE_H__ - -#include <glib-object.h> - -#include "telepathy-constants.h" -#include "tp-channel-iface.h" - -G_BEGIN_DECLS - -#define TP_TYPE_CHANNEL_FACTORY_IFACE tp_channel_factory_iface_get_type() - -#define TP_CHANNEL_FACTORY_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIface)) - -#define TP_CHANNEL_FACTORY_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIfaceClass)) - -#define TP_IS_CHANNEL_FACTORY_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TP_TYPE_CHANNEL_FACTORY_IFACE)) - -#define TP_IS_CHANNEL_FACTORY_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TP_TYPE_CHANNEL_FACTORY_IFACE)) - -#define TP_CHANNEL_FACTORY_IFACE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \ - TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIfaceClass)) - -typedef struct _TpChannelFactoryIface TpChannelFactoryIface; -typedef struct _TpChannelFactoryIfaceClass TpChannelFactoryIfaceClass; - -typedef enum { - TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED = 0, - TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE, - TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE, - TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE, - TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED -} TpChannelFactoryRequestStatus; - -struct _TpChannelFactoryIfaceClass { - GTypeInterface parent_class; - - void (*close_all) (TpChannelFactoryIface *); - void (*connecting) (TpChannelFactoryIface *); - void (*connected) (TpChannelFactoryIface *); - void (*disconnected) (TpChannelFactoryIface *); - void (*foreach) (TpChannelFactoryIface *, TpChannelFunc func, gpointer data); - TpChannelFactoryRequestStatus (*request) (TpChannelFactoryIface *, const gchar *chan_type, TpHandleType handle_type, guint handle, TpChannelIface **ret); -}; - -GType tp_channel_factory_iface_get_type (void); - -void tp_channel_factory_iface_close_all (TpChannelFactoryIface *); -void tp_channel_factory_iface_connecting (TpChannelFactoryIface *); -void tp_channel_factory_iface_connected (TpChannelFactoryIface *); -void tp_channel_factory_iface_disconnected (TpChannelFactoryIface *); -void tp_channel_factory_iface_foreach (TpChannelFactoryIface *, TpChannelFunc func, gpointer data); -TpChannelFactoryRequestStatus tp_channel_factory_iface_request (TpChannelFactoryIface *, const gchar *chan_type, TpHandleType handle_type, guint handle, TpChannelIface **ret); - -G_END_DECLS - -#endif /* __TP_CHANNEL_FACTORY_IFACE_H__ */ diff --git a/src/tp-channel-iface.c b/src/tp-channel-iface.c deleted file mode 100644 index 19f197e4..00000000 --- a/src/tp-channel-iface.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * tp-channel-iface.c - Stubs for Telepathy Channel interface - * - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * - * 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 - */ - -#include "tp-channel-iface.h" - -static void -tp_channel_iface_base_init (gpointer klass) -{ - static gboolean initialized = FALSE; - - if (!initialized) { - GParamSpec *param_spec; - - initialized = TRUE; - - param_spec = g_param_spec_string ("object-path", "D-Bus object path", - "The D-Bus object path used for this " - "object on the bus.", - NULL, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_interface_install_property (klass, param_spec); - - param_spec = g_param_spec_string ("channel-type", "Telepathy channel type", - "The D-Bus interface representing the " - "type of this channel.", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_interface_install_property (klass, param_spec); - - param_spec = g_param_spec_uint ("handle-type", "Contact handle type", - "The TpHandleType representing a " - "contact handle.", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_interface_install_property (klass, param_spec); - - param_spec = g_param_spec_uint ("handle", "Contact handle", - "The GabbleHandle representing the contact " - "with whom this channel communicates.", - 0, G_MAXUINT32, 0, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_BLURB); - g_object_interface_install_property (klass, param_spec); - } -} - -GType -tp_channel_iface_get_type (void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof (TpChannelIfaceClass), - tp_channel_iface_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL /* instance_init */ - }; - - type = g_type_register_static (G_TYPE_INTERFACE, "TpChannelIface", &info, 0); - } - - return type; -} diff --git a/src/tp-channel-iface.h b/src/tp-channel-iface.h deleted file mode 100644 index 0bdc562d..00000000 --- a/src/tp-channel-iface.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * tp-channel-iface.h - Headers for Telepathy Channel interface - * - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * - * 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 - */ - -#ifndef __TP_CHANNEL_IFACE_H__ -#define __TP_CHANNEL_IFACE_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define TP_TYPE_CHANNEL_IFACE tp_channel_iface_get_type() - -#define TP_CHANNEL_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TP_TYPE_CHANNEL_IFACE, TpChannelIface)) - -#define TP_CHANNEL_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TP_TYPE_CHANNEL_IFACE, TpChannelIfaceClass)) - -#define TP_IS_CHANNEL_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TP_TYPE_CHANNEL_IFACE)) - -#define TP_IS_CHANNEL_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TP_TYPE_CHANNEL_IFACE)) - -#define TP_CHANNEL_IFACE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \ - TP_TYPE_CHANNEL_IFACE, TpChannelIfaceClass)) - -typedef struct _TpChannelIface TpChannelIface; -typedef struct _TpChannelIfaceClass TpChannelIfaceClass; -typedef void (* TpChannelFunc) (TpChannelIface *, gpointer); - -struct _TpChannelIfaceClass { - GTypeInterface parent_class; -}; - -GType tp_channel_iface_get_type (void); - -G_END_DECLS - -#endif /* __TP_CHANNEL_IFACE_H__ */ diff --git a/src/util.h b/src/util.h deleted file mode 100644 index bc7f809f..00000000 --- a/src/util.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * util.h - Headers for Gabble utility functions - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * - * 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 - */ - -#include <glib.h> - -#ifndef __SALUT_UTIL_H__ -#define __SALUT_UTIL_H__ - -gpointer mixin_offset_cast (gpointer instance, guint offset); -#endif /* __SALUT_UTIL_H__ */ diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c index 2bcf5675..77121f56 100644 --- a/src/write-mgr-file.c +++ b/src/write-mgr-file.c @@ -20,21 +20,17 @@ #include <stdio.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-protocol.h> - -#include "telepathy-constants.h" #include "salut-connection-manager.h" static gchar * mgr_file_contents (const char *busname, const char *objpath, - const SalutProtocolSpec *protocols, + const TpCMProtocolSpec *protocols, GError **error) { GKeyFile *f = g_key_file_new(); - const SalutProtocolSpec *protocol; - const SalutParamSpec *row; + const TpCMProtocolSpec *protocol; + const TpCMParamSpec *row; g_key_file_set_string(f, "ConnectionManager", "Name", "Salut"); g_key_file_set_string(f, "ConnectionManager", "BusName", busname); @@ -89,8 +85,8 @@ main (void) { GError *error = NULL; - gchar *s = mgr_file_contents(SALUT_CONN_MGR_BUS_NAME, - SALUT_CONN_MGR_OBJECT_PATH, + gchar *s = mgr_file_contents(TP_CM_BUS_NAME_BASE "salut", + TP_CM_OBJECT_PATH_BASE "salut", salut_protocols, &error); if (!s) { |