aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/.gitignore4
-rw-r--r--libempathy/Makefile.am191
-rw-r--r--libempathy/empathy-account-manager.c641
-rw-r--r--libempathy/empathy-account-manager.h68
-rw-r--r--libempathy/empathy-call-factory.c174
-rw-r--r--libempathy/empathy-call-factory.h75
-rw-r--r--libempathy/empathy-call-handler.c467
-rw-r--r--libempathy/empathy-call-handler.h77
-rw-r--r--libempathy/empathy-chatroom-manager.c741
-rw-r--r--libempathy/empathy-chatroom-manager.dtd17
-rw-r--r--libempathy/empathy-chatroom-manager.h74
-rw-r--r--libempathy/empathy-chatroom.c434
-rw-r--r--libempathy/empathy-chatroom.h78
-rw-r--r--libempathy/empathy-contact-factory.c187
-rw-r--r--libempathy/empathy-contact-factory.h79
-rw-r--r--libempathy/empathy-contact-groups.c285
-rw-r--r--libempathy/empathy-contact-groups.dtd17
-rw-r--r--libempathy/empathy-contact-groups.h38
-rw-r--r--libempathy/empathy-contact-list.c231
-rw-r--r--libempathy/empathy-contact-list.h98
-rw-r--r--libempathy/empathy-contact-manager.c563
-rw-r--r--libempathy/empathy-contact-manager.h63
-rw-r--r--libempathy/empathy-contact-monitor.c418
-rw-r--r--libempathy/empathy-contact-monitor.h63
-rw-r--r--libempathy/empathy-contact.c1118
-rw-r--r--libempathy/empathy-contact.h147
-rw-r--r--libempathy/empathy-debug.c110
-rw-r--r--libempathy/empathy-debug.h90
-rw-r--r--libempathy/empathy-dispatch-operation.c617
-rw-r--r--libempathy/empathy-dispatch-operation.h118
-rw-r--r--libempathy/empathy-dispatcher.c1590
-rw-r--r--libempathy/empathy-dispatcher.h98
-rw-r--r--libempathy/empathy-idle.c680
-rw-r--r--libempathy/empathy-idle.h73
-rw-r--r--libempathy/empathy-irc-network-manager.c777
-rw-r--r--libempathy/empathy-irc-network-manager.h80
-rw-r--r--libempathy/empathy-irc-network.c361
-rw-r--r--libempathy/empathy-irc-network.h80
-rw-r--r--libempathy/empathy-irc-networks.dtd18
-rw-r--r--libempathy/empathy-irc-server.c229
-rw-r--r--libempathy/empathy-irc-server.h64
-rw-r--r--libempathy/empathy-log-manager.c459
-rw-r--r--libempathy/empathy-log-manager.h105
-rw-r--r--libempathy/empathy-log-manager.xsl148
-rw-r--r--libempathy/empathy-log-store-empathy.c779
-rw-r--r--libempathy/empathy-log-store-empathy.h66
-rw-r--r--libempathy/empathy-log-store.c173
-rw-r--r--libempathy/empathy-log-store.h101
-rw-r--r--libempathy/empathy-message.c520
-rw-r--r--libempathy/empathy-message.h82
-rw-r--r--libempathy/empathy-status-presets.c407
-rw-r--r--libempathy/empathy-status-presets.dtd14
-rw-r--r--libempathy/empathy-status-presets.h46
-rw-r--r--libempathy/empathy-time.c124
-rw-r--r--libempathy/empathy-time.h47
-rw-r--r--libempathy/empathy-tp-call.c671
-rw-r--r--libempathy/empathy-tp-call.h90
-rw-r--r--libempathy/empathy-tp-chat.c1421
-rw-r--r--libempathy/empathy-tp-chat.h81
-rw-r--r--libempathy/empathy-tp-contact-factory.c1540
-rw-r--r--libempathy/empathy-tp-contact-factory.h72
-rw-r--r--libempathy/empathy-tp-contact-list.c1121
-rw-r--r--libempathy/empathy-tp-contact-list.h58
-rw-r--r--libempathy/empathy-tp-file.c1024
-rw-r--r--libempathy/empathy-tp-file.h87
-rw-r--r--libempathy/empathy-tp-group.c981
-rw-r--r--libempathy/empathy-tp-group.h93
-rw-r--r--libempathy/empathy-tp-roomlist.c450
-rw-r--r--libempathy/empathy-tp-roomlist.h59
-rw-r--r--libempathy/empathy-tp-tube.c436
-rw-r--r--libempathy/empathy-tp-tube.h86
-rw-r--r--libempathy/empathy-tube-handler.c226
-rw-r--r--libempathy/empathy-tube-handler.h64
-rw-r--r--libempathy/empathy-types.h29
-rw-r--r--libempathy/empathy-utils.c472
-rw-r--r--libempathy/empathy-utils.h94
-rw-r--r--libempathy/irc-networks.xml542
-rw-r--r--libempathy/libempathy.pc.in12
78 files changed, 0 insertions, 24113 deletions
diff --git a/libempathy/.gitignore b/libempathy/.gitignore
deleted file mode 100644
index 8617dcbd0..000000000
--- a/libempathy/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-empathy-chandler-glue.h
-empathy-marshal.*
-empathy-filter-glue.h
-tp-stream-engine-gen.h
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
deleted file mode 100644
index 387068282..000000000
--- a/libempathy/Makefile.am
+++ /dev/null
@@ -1,191 +0,0 @@
-AM_CPPFLAGS = \
- -I. \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -DDATADIR=\""$(datadir)"\" \
- -DLOCALEDIR=\""$(datadir)/locale"\" \
- $(LIBEMPATHY_CFLAGS) \
- $(WARN_CFLAGS)
-
-BUILT_SOURCES = \
- empathy-marshal.h \
- empathy-marshal.c \
- empathy-marshal.list \
- empathy-enum-types.h \
- empathy-enum-types.c
-
-lib_LTLIBRARIES = libempathy.la
-
-libempathy_la_SOURCES = \
- empathy-account-manager.c \
- empathy-chatroom.c \
- empathy-chatroom-manager.c \
- empathy-call-factory.c \
- empathy-call-handler.c \
- empathy-contact.c \
- empathy-contact-factory.c \
- empathy-contact-groups.c \
- empathy-contact-list.c \
- empathy-contact-manager.c \
- empathy-contact-monitor.c \
- empathy-debug.c \
- empathy-dispatcher.c \
- empathy-dispatch-operation.c \
- empathy-idle.c \
- empathy-irc-network.c \
- empathy-irc-network-manager.c \
- empathy-irc-server.c \
- empathy-log-manager.c \
- empathy-log-store.c \
- empathy-log-store-empathy.c \
- empathy-message.c \
- empathy-status-presets.c \
- empathy-time.c \
- empathy-tp-call.c \
- empathy-tp-chat.c \
- empathy-tp-contact-factory.c \
- empathy-tp-contact-list.c \
- empathy-tp-file.c \
- empathy-tp-group.c \
- empathy-tp-roomlist.c \
- empathy-tp-tube.c \
- empathy-tube-handler.c \
- empathy-utils.c
-
-# do not distribute generated files
-nodist_libempathy_la_SOURCES =\
- $(BUILT_SOURCES)
-
-libempathy_la_LIBADD = \
- $(top_builddir)/extensions/libemp-extensions.la \
- $(LIBEMPATHY_LIBS)
-
-libempathy_la_LDFLAGS = \
- -version-info ${LIBEMPATHY_CURRENT}:${LIBEMPATHY_REVISION}:${LIBEMPATHY_AGE} \
- -export-symbols-regex ^empathy_
-
-libempathy_headers = \
- empathy-account-manager.h \
- empathy-chatroom.h \
- empathy-chatroom-manager.h \
- empathy-call-factory.h \
- empathy-call-handler.h \
- empathy-contact.h \
- empathy-contact-factory.h \
- empathy-contact-groups.h \
- empathy-contact-list.h \
- empathy-contact-manager.h \
- empathy-contact-monitor.h \
- empathy-debug.h \
- empathy-dispatcher.h \
- empathy-dispatch-operation.h \
- empathy-idle.h \
- empathy-irc-network.h \
- empathy-irc-network-manager.h \
- empathy-irc-server.h \
- empathy-log-manager.h \
- empathy-log-store.h \
- empathy-log-store-empathy.h \
- empathy-message.h \
- empathy-status-presets.h \
- empathy-time.h \
- empathy-tp-call.h \
- empathy-tp-chat.h \
- empathy-tp-contact-factory.h \
- empathy-tp-contact-list.h \
- empathy-tp-file.h \
- empathy-tp-group.h \
- empathy-tp-roomlist.h \
- empathy-tp-tube.h \
- empathy-tube-handler.h \
- empathy-types.h \
- empathy-utils.h
-
-libempathy_includedir = $(includedir)/libempathy/
-libempathy_include_HEADERS = \
- $(libempathy_headers) \
- empathy-enum-types.h
-
-empathy-marshal.list: $(libempathy_la_SOURCES) Makefile.am
- ( cd $(srcdir) && \
- sed -n -e 's/.*empathy_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \
- $(libempathy_la_SOURCES) ) \
- | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp
- if cmp -s $@.tmp $@; then \
- rm $@.tmp; \
- else \
- mv $@.tmp $@; \
- fi
-
-%-marshal.h: %-marshal.list Makefile
- $(GLIB_GENMARSHAL) --header --prefix=_$(subst -,_,$*)_marshal $< > $*-marshal.h
-
-%-marshal.c: %-marshal.list Makefile
- echo "#include \"empathy-marshal.h\"" > $@ && \
- $(GLIB_GENMARSHAL) --body --prefix=_$(subst -,_,$*)_marshal $< >> $*-marshal.c
-
-empathy-enum-types.h: stamp-empathy-enum-types.h
- @true
-stamp-empathy-enum-types.h: $(libempathy_headers) Makefile
- (cd $(srcdir) \
- && glib-mkenums \
- --fhead "#ifndef __LIBEMPATHY_ENUM_TYPES_H__\n" \
- --fhead "#define __LIBEMPATHY_ENUM_TYPES_H__ 1\n\n" \
- --fhead "#include <glib-object.h>\n\n" \
- --fhead "G_BEGIN_DECLS\n\n" \
- --ftail "G_END_DECLS\n\n" \
- --ftail "#endif /* __LIBEMPATHY_ENUM_TYPES_H__ */\n" \
- --fprod "#include <libempathy/@filename@>\n" \
- --eprod "#define EMPATHY_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \
- --eprod "GType @enum_name@_get_type (void);\n" \
- $(libempathy_headers) ) > xgen-gth \
- && (cmp -s xgen-gth empathy-enum-type.h || cp xgen-gth empathy-enum-types.h) \
- && rm -f xgen-gth \
- && echo timestamp > $(@F)
-
-empathy-enum-types.c: $(libempathy_headers) Makefile
- (cd $(srcdir) \
- && glib-mkenums \
- --fhead "#include <config.h>\n" \
- --fhead "#include <glib-object.h>\n" \
- --fhead "#include \"empathy-enum-types.h\"\n\n" \
- --fprod "\n/* enumerations from \"@filename@\" */" \
- --vhead "static const G@Type@Value _@enum_name@_values[] = {" \
- --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
- --vtail " { 0, NULL, NULL }\n};\n\n" \
- --vtail "GType\n@enum_name@_get_type (void)\n{\n" \
- --vtail " static GType type = 0;\n\n" \
- --vtail " if (!type)\n" \
- --vtail " type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \
- --vtail " return type;\n}\n\n" \
- $(libempathy_headers) ) > xgen-gtc \
- && cp xgen-gtc $(@F) \
- && rm -f xgen-gtc
-
-dtddir = $(datadir)/empathy
-dtd_DATA = \
- empathy-status-presets.dtd \
- empathy-contact-groups.dtd \
- empathy-chatroom-manager.dtd \
- empathy-irc-networks.dtd
-
-stylesheetdir = $(datadir)/empathy
-stylesheet_DATA = \
- empathy-log-manager.xsl
-
-ircnetworksdir = $(datadir)/empathy
-ircnetworks_DATA = \
- irc-networks.xml
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libempathy.pc
-
-EXTRA_DIST = \
- empathy-marshal.list \
- $(stylesheet_DATA) \
- $(dtd_DATA) \
- $(ircnetworks_DATA)
-
-CLEANFILES = \
- $(BUILT_SOURCES) \
- stamp-empathy-enum-types.h
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
deleted file mode 100644
index ab372f32e..000000000
--- a/libempathy/empathy-account-manager.c
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <libmissioncontrol/mc-account-monitor.h>
-
-#include "empathy-account-manager.h"
-#include "empathy-marshal.h"
-#include "empathy-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountManager)
-
-typedef struct {
- McAccountMonitor *monitor;
- MissionControl *mc;
-
- GHashTable *accounts;
- int connected;
- int connecting;
- gboolean dispose_run;
-} EmpathyAccountManagerPriv;
-
-typedef struct {
- McPresence presence;
- TpConnectionStatus status;
- gboolean is_enabled;
-
- guint source_id;
-} AccountData;
-
-enum {
- ACCOUNT_CREATED,
- ACCOUNT_DELETED,
- ACCOUNT_ENABLED,
- ACCOUNT_DISABLED,
- ACCOUNT_CHANGED,
- ACCOUNT_CONNECTION_CHANGED,
- ACCOUNT_PRESENCE_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-static EmpathyAccountManager *manager_singleton = NULL;
-
-G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT);
-
-static AccountData *
-account_data_new (McPresence presence,
- TpConnectionStatus status,
- gboolean is_enabled)
-{
- AccountData *retval;
-
- retval = g_slice_new0 (AccountData);
- retval->presence = presence;
- retval->status = status;
- retval->is_enabled = is_enabled;
- retval->source_id = 0;
-
- return retval;
-}
-
-static AccountData *
-account_data_new_default (MissionControl *mc,
- McAccount *account)
-{
- McPresence actual_p;
- TpConnectionStatus actual_c;
- GError *err = NULL;
-
- actual_p = mission_control_get_presence_actual (mc, &err);
- if (err != NULL)
- {
- actual_p = MC_PRESENCE_UNSET;
- g_clear_error (&err);
- }
-
- actual_c = mission_control_get_connection_status (mc, account, &err);
-
- if (err != NULL)
- {
- actual_c = TP_CONNECTION_STATUS_DISCONNECTED;
- g_error_free (err);
- }
-
- return account_data_new (actual_p, actual_c, mc_account_is_enabled (account));
-}
-
-static void
-account_data_free (AccountData *data)
-{
- if (data->source_id > 0)
- {
- g_source_remove (data->source_id);
- data->source_id = 0;
- }
-
- g_slice_free (AccountData, data);
-}
-
-static void
-account_created_cb (McAccountMonitor *mon,
- gchar *account_name,
- EmpathyAccountManager *manager)
-{
- McAccount *account;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- TpConnectionStatus initial_status;
-
- account = mc_account_lookup (account_name);
-
- if (account)
- {
- AccountData *data;
-
- data = account_data_new_default (priv->mc, account);
-
- initial_status = mission_control_get_connection_status (priv->mc,
- account, NULL);
-
- if (initial_status == TP_CONNECTION_STATUS_CONNECTED)
- priv->connected++;
- else if (initial_status == TP_CONNECTION_STATUS_CONNECTING)
- priv->connecting++;
-
- /* the reference returned by mc_account_lookup is owned by the
- * hash table.
- */
- g_hash_table_insert (priv->accounts, account, data);
-
- g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
- }
-}
-
-static void
-account_deleted_cb (McAccountMonitor *mon,
- gchar *account_name,
- EmpathyAccountManager *manager)
-{
- McAccount *account;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- account = mc_account_lookup (account_name);
-
- if (account)
- {
- g_hash_table_remove (priv->accounts, account);
- g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
- g_object_unref (account);
- }
-}
-
-static void
-account_changed_cb (McAccountMonitor *mon,
- gchar *account_name,
- EmpathyAccountManager *manager)
-{
- McAccount *account;
-
- account = mc_account_lookup (account_name);
-
- if (account)
- {
- g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account);
- g_object_unref (account);
- }
-}
-
-static void
-account_disabled_cb (McAccountMonitor *mon,
- gchar *account_name,
- EmpathyAccountManager *manager)
-{
- McAccount *account;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- AccountData *data;
-
- account = mc_account_lookup (account_name);
-
- if (account)
- {
- data = g_hash_table_lookup (priv->accounts, account);
- g_assert (data);
- data->is_enabled = FALSE;
-
- g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
- g_object_unref (account);
- }
-}
-
-static void
-account_enabled_cb (McAccountMonitor *mon,
- gchar *account_name,
- EmpathyAccountManager *manager)
-{
- McAccount *account;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- AccountData *data;
-
- account = mc_account_lookup (account_name);
-
- if (account)
- {
- data = g_hash_table_lookup (priv->accounts, account);
- g_assert (data);
- data->is_enabled = TRUE;
-
- g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
- g_object_unref (account);
- }
-}
-
-static void
-update_connection_numbers (EmpathyAccountManager *manager,
- TpConnectionStatus status,
- TpConnectionStatus old_s)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (status == TP_CONNECTION_STATUS_CONNECTED)
- {
- priv->connected++;
- if (old_s == TP_CONNECTION_STATUS_CONNECTING)
- priv->connecting--;
- }
-
- if (status == TP_CONNECTION_STATUS_CONNECTING)
- {
- priv->connecting++;
- if (old_s == TP_CONNECTION_STATUS_CONNECTED)
- priv->connected--;
- }
-
- if (status == TP_CONNECTION_STATUS_DISCONNECTED)
- {
- if (old_s == TP_CONNECTION_STATUS_CONNECTED)
- priv->connected--;
-
- if (old_s == TP_CONNECTION_STATUS_CONNECTING)
- priv->connecting--;
- }
-}
-
-static gboolean
-remove_data_timeout (gpointer _data)
-{
- AccountData *data = _data;
-
- data->source_id = 0;
-
- return FALSE;
-}
-
-typedef struct {
- TpConnectionStatus status;
- McPresence presence;
- TpConnectionStatusReason reason;
- gchar *unique_name;
- EmpathyAccountManager *manager;
-} ChangedSignalData;
-
-static gboolean
-account_status_changed_idle_cb (ChangedSignalData *signal_data)
-{
- McAccount *account;
- AccountData *data;
- McPresence presence, old_p;
- TpConnectionStatus status, old_s;
- gboolean emit_presence = FALSE, emit_connection = FALSE;
- EmpathyAccountManager *manager = signal_data->manager;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- presence = signal_data->presence;
- status = signal_data->status;
- account = mc_account_lookup (signal_data->unique_name);
-
- if (account)
- {
- data = g_hash_table_lookup (priv->accounts, account);
- g_assert (data);
-
- old_p = data->presence;
- old_s = data->status;
-
- if (old_p != presence)
- {
- data->presence = presence;
- emit_presence = TRUE;
- }
-
- if (old_s != status)
- {
- data->status = status;
- update_connection_numbers (manager, status, old_s);
-
- if (status == TP_CONNECTION_STATUS_CONNECTED)
- {
- if (data->source_id > 0) {
- g_source_remove (data->source_id);
- data->source_id = 0;
- }
-
- data->source_id = g_timeout_add_seconds (10,
- remove_data_timeout,
- data);
- }
- emit_connection = TRUE;
- }
-
- if (emit_presence)
- g_signal_emit (manager, signals[ACCOUNT_PRESENCE_CHANGED], 0,
- account, presence, old_p);
-
- if (emit_connection)
- g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
- account, signal_data->reason, status, old_s);
-
- g_object_unref (account);
- }
-
- g_object_unref (signal_data->manager);
- g_free (signal_data->unique_name);
- g_slice_free (ChangedSignalData, signal_data);
-
- return FALSE;
-}
-
-static void
-account_status_changed_cb (MissionControl *mc,
- TpConnectionStatus status,
- McPresence presence,
- TpConnectionStatusReason reason,
- const gchar *unique_name,
- EmpathyAccountManager *manager)
-{
- ChangedSignalData *data;
-
- data = g_slice_new0 (ChangedSignalData);
- data->status = status;
- data->presence = presence;
- data->reason = reason;
- data->unique_name = g_strdup (unique_name);
- data->manager = g_object_ref (manager);
-
- g_idle_add ((GSourceFunc) account_status_changed_idle_cb, data);
-}
-
-static void
-empathy_account_manager_init (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
- GList *mc_accounts, *l;
- AccountData *data;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
- manager->priv = priv;
- priv->monitor = mc_account_monitor_new ();
- priv->mc = empathy_mission_control_dup_singleton ();
- priv->connected = priv->connecting = 0;
- priv->dispose_run = FALSE;
-
- priv->accounts = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal,
- g_object_unref,
- (GDestroyNotify) account_data_free);
-
- mc_accounts = mc_accounts_list ();
-
- for (l = mc_accounts; l; l = l->next)
- {
- data = account_data_new_default (priv->mc, l->data);
-
- account_created_cb (priv->monitor, (char *) mc_account_get_unique_name (l->data), manager);
- }
-
- g_signal_connect (priv->monitor, "account-created",
- G_CALLBACK (account_created_cb), manager);
- g_signal_connect (priv->monitor, "account-deleted",
- G_CALLBACK (account_deleted_cb), manager);
- g_signal_connect (priv->monitor, "account-disabled",
- G_CALLBACK (account_disabled_cb), manager);
- g_signal_connect (priv->monitor, "account-enabled",
- G_CALLBACK (account_enabled_cb), manager);
- g_signal_connect (priv->monitor, "account-changed",
- G_CALLBACK (account_changed_cb), manager);
-
- dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged",
- G_CALLBACK (account_status_changed_cb),
- manager, NULL);
-
- mc_accounts_list_free (mc_accounts);
-}
-
-static void
-do_finalize (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- g_hash_table_unref (priv->accounts);
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->finalize (obj);
-}
-
-static void
-do_dispose (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
- "AccountStatusChanged",
- G_CALLBACK (account_status_changed_cb),
- obj);
-
- if (priv->monitor)
- {
- g_signal_handlers_disconnect_by_func (priv->monitor,
- account_created_cb, obj);
- g_signal_handlers_disconnect_by_func (priv->monitor,
- account_deleted_cb, obj);
- g_signal_handlers_disconnect_by_func (priv->monitor,
- account_disabled_cb, obj);
- g_signal_handlers_disconnect_by_func (priv->monitor,
- account_enabled_cb, obj);
- g_signal_handlers_disconnect_by_func (priv->monitor,
- account_changed_cb, obj);
- g_object_unref (priv->monitor);
- priv->monitor = NULL;
- }
-
- if (priv->mc)
- g_object_unref (priv->mc);
-
- g_hash_table_remove_all (priv->accounts);
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj);
-}
-
-static GObject*
-do_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *retval;
-
- if (!manager_singleton)
- {
- retval = G_OBJECT_CLASS (empathy_account_manager_parent_class)->constructor (type,
- n_construct_params,
- construct_params);
- manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
- g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
- }
- else
- {
- retval = g_object_ref (manager_singleton);
- }
-
- return retval;
-}
-
-static void
-empathy_account_manager_class_init (EmpathyAccountManagerClass *klass)
-{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
-
- oclass->finalize = do_finalize;
- oclass->dispose = do_dispose;
- oclass->constructor = do_constructor;
-
- signals[ACCOUNT_CREATED] =
- g_signal_new ("account-created",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, MC_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DELETED] =
- g_signal_new ("account-deleted",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, MC_TYPE_ACCOUNT);
-
- signals[ACCOUNT_ENABLED] =
- g_signal_new ("account-enabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, MC_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DISABLED] =
- g_signal_new ("account-disabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, MC_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CHANGED] =
- g_signal_new ("account-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, MC_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CONNECTION_CHANGED] =
- g_signal_new ("account-connection-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_INT_UINT_UINT,
- G_TYPE_NONE,
- 4, MC_TYPE_ACCOUNT,
- G_TYPE_INT, /* reason */
- G_TYPE_UINT, /* actual connection */
- G_TYPE_UINT); /* previous connection */
-
- signals[ACCOUNT_PRESENCE_CHANGED] =
- g_signal_new ("account-presence-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_INT_INT,
- G_TYPE_NONE,
- 3, MC_TYPE_ACCOUNT,
- G_TYPE_INT, /* actual presence */
- G_TYPE_INT); /* previous presence */
-
- g_type_class_add_private (oclass, sizeof (EmpathyAccountManagerPriv));
-}
-
-/* public methods */
-
-EmpathyAccountManager *
-empathy_account_manager_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_ACCOUNT_MANAGER, NULL);
-}
-
-int
-empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connected;
-}
-
-int
-empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connecting;
-}
-
-gboolean
-empathy_account_manager_is_account_just_connected (EmpathyAccountManager *manager,
- McAccount *account)
-{
- EmpathyAccountManagerPriv *priv;
- AccountData *data;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), FALSE);
-
- priv = GET_PRIV (manager);
- data = g_hash_table_lookup (priv->accounts, account);
-
- g_assert (data);
-
- return (data->source_id > 0);
-}
-
-/**
- * empathy_account_manager_get_count:
- * @manager: a #EmpathyAccountManager
- *
- * Get the number of accounts.
- *
- * Returns: the number of accounts.
- **/
-int
-empathy_account_manager_get_count (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return g_hash_table_size (priv->accounts);
-}
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
deleted file mode 100644
index b9aecb09f..000000000
--- a/libempathy/empathy-account-manager.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_ACCOUNT_MANAGER_H__
-#define __EMPATHY_ACCOUNT_MANAGER_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_ACCOUNT_MANAGER (empathy_account_manager_get_type ())
-#define EMPATHY_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManager))
-#define EMPATHY_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-#define EMPATHY_IS_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_IS_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_ACCOUNT_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-
-typedef struct _EmpathyAccountManager EmpathyAccountManager;
-typedef struct _EmpathyAccountManagerClass EmpathyAccountManagerClass;
-
-struct _EmpathyAccountManager {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyAccountManagerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_account_manager_get_type (void);
-
-/* public methods */
-
-EmpathyAccountManager * empathy_account_manager_dup_singleton (void);
-int empathy_account_manager_get_connected_accounts
- (EmpathyAccountManager *manager);
-int empathy_account_manager_get_connecting_accounts
- (EmpathyAccountManager *manager);
-gboolean empathy_account_manager_is_account_just_connected
- (EmpathyAccountManager *manager,
- McAccount *account);
-int empathy_account_manager_get_count
- (EmpathyAccountManager *manager);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_ACCOUNT_MANAGER_H__ */
-
diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c
deleted file mode 100644
index f412139be..000000000
--- a/libempathy/empathy-call-factory.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * empathy-call-factory.c - Source for EmpathyCallFactory
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 <stdio.h>
-#include <stdlib.h>
-
-#include "empathy-marshal.h"
-#include "empathy-call-factory.h"
-#include "empathy-utils.h"
-
-G_DEFINE_TYPE(EmpathyCallFactory, empathy_call_factory, G_TYPE_OBJECT)
-
-/* signal enum */
-enum
-{
- NEW_CALL_HANDLER,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-/* private structure */
-typedef struct {
- gboolean dispose_has_run;
-} EmpathyCallFactoryPriv;
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallFactory)
-
-static GObject *call_factory = NULL;
-
-static void
-empathy_call_factory_init (EmpathyCallFactory *obj)
-{
- EmpathyCallFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
- EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPriv);
-
- obj->priv = priv;
-}
-
-static GObject *
-empathy_call_factory_constructor (GType type, guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- g_return_val_if_fail (call_factory == NULL, NULL);
-
- call_factory = G_OBJECT_CLASS (empathy_call_factory_parent_class)->constructor
- (type, n_construct_params, construct_params);
- g_object_add_weak_pointer (call_factory, (gpointer)&call_factory);
-
- return call_factory;
-}
-
-static void
-empathy_call_factory_finalize (GObject *object)
-{
- /* free any data held directly by the object here */
-
- if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize)
- G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize (object);
-}
-
-static void
-empathy_call_factory_dispose (GObject *object)
-{
- EmpathyCallFactoryPriv *priv = GET_PRIV (object);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- /* release any references held by the object here */
-
- if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose)
- G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose (object);
-}
-
-static void
-empathy_call_factory_class_init (
- EmpathyCallFactoryClass *empathy_call_factory_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_factory_class);
-
- g_type_class_add_private (empathy_call_factory_class,
- sizeof (EmpathyCallFactoryPriv));
-
- object_class->constructor = empathy_call_factory_constructor;
- object_class->dispose = empathy_call_factory_dispose;
- object_class->finalize = empathy_call_factory_finalize;
-
- signals[NEW_CALL_HANDLER] =
- g_signal_new ("new-call-handler",
- G_TYPE_FROM_CLASS (empathy_call_factory_class),
- G_SIGNAL_RUN_LAST, 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_BOOLEAN,
- G_TYPE_NONE,
- 2, EMPATHY_TYPE_CALL_HANDLER, G_TYPE_BOOLEAN);
-}
-
-EmpathyCallFactory *
-empathy_call_factory_initialise (void)
-{
- g_return_val_if_fail (call_factory == NULL, NULL);
-
- return EMPATHY_CALL_FACTORY (g_object_new (EMPATHY_TYPE_CALL_FACTORY, NULL));
-}
-
-EmpathyCallFactory *
-empathy_call_factory_get (void)
-{
- g_return_val_if_fail (call_factory != NULL, NULL);
-
- return EMPATHY_CALL_FACTORY (call_factory);
-}
-
-void
-empathy_call_factory_new_call (EmpathyCallFactory *factory,
- EmpathyContact *contact)
-{
- EmpathyCallHandler *handler;
-
- g_return_if_fail (factory != NULL);
- g_return_if_fail (contact != NULL);
-
- handler = empathy_call_handler_new_for_contact (contact);
-
- g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
- handler, TRUE);
-
- g_object_unref (handler);
-}
-
-void
-empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
- EmpathyDispatchOperation *operation)
-{
- EmpathyCallHandler *handler;
- EmpathyTpCall *call;
-
- g_return_if_fail (factory != NULL);
- g_return_if_fail (operation != NULL);
-
- call = EMPATHY_TP_CALL (
- empathy_dispatch_operation_get_channel_wrapper (operation));
-
- handler = empathy_call_handler_new_for_channel (call);
- empathy_dispatch_operation_claim (operation);
-
- /* FIXME should actually look at the channel */
- g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
- handler, FALSE);
-
- g_object_unref (handler);
-}
-
diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h
deleted file mode 100644
index 13b16b692..000000000
--- a/libempathy/empathy-call-factory.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * empathy-call-factory.h - Header for EmpathyCallFactory
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 __EMPATHY_CALL_FACTORY_H__
-#define __EMPATHY_CALL_FACTORY_H__
-
-#include <glib-object.h>
-
-#include <libempathy/empathy-dispatch-operation.h>
-#include <libempathy/empathy-call-handler.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyCallFactory EmpathyCallFactory;
-typedef struct _EmpathyCallFactoryClass EmpathyCallFactoryClass;
-
-struct _EmpathyCallFactoryClass {
- GObjectClass parent_class;
-};
-
-struct _EmpathyCallFactory {
- GObject parent;
- gpointer priv;
-};
-
-GType empathy_call_factory_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_CALL_FACTORY \
- (empathy_call_factory_get_type())
-#define EMPATHY_CALL_FACTORY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_CALL_FACTORY, \
- EmpathyCallFactory))
-#define EMPATHY_CALL_FACTORY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_CALL_FACTORY, \
- EmpathyCallFactoryClass))
-#define EMPATHY_IS_CALL_FACTORY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_CALL_FACTORY))
-#define EMPATHY_IS_CALL_FACTORY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_CALL_FACTORY))
-#define EMPATHY_CALL_FACTORY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CALL_FACTORY, \
- EmpathyCallFactoryClass))
-
-
-EmpathyCallFactory *empathy_call_factory_initialise (void);
-
-EmpathyCallFactory *empathy_call_factory_get (void);
-
-void empathy_call_factory_new_call (EmpathyCallFactory *factory,
- EmpathyContact *contact);
-
-void empathy_call_factory_claim_channel (EmpathyCallFactory *factory,
- EmpathyDispatchOperation *operation);
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_CALL_FACTORY_H__*/
diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c
deleted file mode 100644
index 072542c82..000000000
--- a/libempathy/empathy-call-handler.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * empathy-call-handler.c - Source for EmpathyCallHandler
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 <stdio.h>
-#include <stdlib.h>
-
-#include <telepathy-glib/util.h>
-
-#include <telepathy-farsight/channel.h>
-#include <telepathy-farsight/stream.h>
-
-#include "empathy-call-handler.h"
-#include "empathy-dispatcher.h"
-#include "empathy-marshal.h"
-#include "empathy-utils.h"
-
-G_DEFINE_TYPE(EmpathyCallHandler, empathy_call_handler, G_TYPE_OBJECT)
-
-/* signal enum */
-enum {
- CONFERENCE_ADDED,
- SRC_PAD_ADDED,
- SINK_PAD_ADDED,
- REQUEST_RESOURCE,
- CLOSED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-enum {
- PROP_TP_CALL = 1,
- PROP_GST_BUS,
- PROP_CONTACT
-};
-
-/* private structure */
-
-typedef struct {
- gboolean dispose_has_run;
- EmpathyTpCall *call;
- EmpathyContact *contact;
- TfChannel *tfchannel;
-} EmpathyCallHandlerPriv;
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallHandler)
-
-static void
-empathy_call_handler_dispose (GObject *object)
-{
- EmpathyCallHandlerPriv *priv = GET_PRIV (object);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- if (priv->contact != NULL)
- g_object_unref (priv->contact);
-
- priv->contact = NULL;
-
- if (priv->tfchannel != NULL)
- g_object_unref (priv->tfchannel);
-
- priv->tfchannel = NULL;
-
- if (priv->call != NULL)
- {
- empathy_tp_call_close (priv->call);
- g_object_unref (priv->call);
- }
-
- priv->call = NULL;
-
- /* release any references held by the object here */
- if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose)
- G_OBJECT_CLASS (empathy_call_handler_parent_class)->dispose (object);
-}
-
-static void
-empathy_call_handler_finalize (GObject *object)
-{
- /* free any data held directly by the object here */
- if (G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize)
- G_OBJECT_CLASS (empathy_call_handler_parent_class)->finalize (object);
-}
-
-static void
-empathy_call_handler_init (EmpathyCallHandler *obj)
-{
- EmpathyCallHandlerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
- EMPATHY_TYPE_CALL_HANDLER, EmpathyCallHandlerPriv);
-
- obj->priv = priv;
-}
-
-static void
-empathy_call_handler_set_property (GObject *object,
- guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EmpathyCallHandlerPriv *priv = GET_PRIV (object);
-
- switch (property_id)
- {
- case PROP_CONTACT:
- priv->contact = g_value_dup_object (value);
- break;
- case PROP_TP_CALL:
- priv->call = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-empathy_call_handler_get_property (GObject *object,
- guint property_id, GValue *value, GParamSpec *pspec)
-{
- EmpathyCallHandlerPriv *priv = GET_PRIV (object);
-
- switch (property_id)
- {
- case PROP_CONTACT:
- g_value_set_object (value, priv->contact);
- break;
- case PROP_TP_CALL:
- g_value_set_object (value, priv->call);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-
-static void
-empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- g_type_class_add_private (klass, sizeof (EmpathyCallHandlerPriv));
-
- object_class->set_property = empathy_call_handler_set_property;
- object_class->get_property = empathy_call_handler_get_property;
- object_class->dispose = empathy_call_handler_dispose;
- object_class->finalize = empathy_call_handler_finalize;
-
- param_spec = g_param_spec_object ("contact",
- "contact", "The remote contact",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CONTACT, param_spec);
-
- param_spec = g_param_spec_object ("tp-call",
- "tp-call", "The calls channel wrapper",
- EMPATHY_TYPE_TP_CALL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_TP_CALL, param_spec);
-
- signals[CONFERENCE_ADDED] =
- g_signal_new ("conference-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, FS_TYPE_CONFERENCE);
-
- signals[SRC_PAD_ADDED] =
- g_signal_new ("src-pad-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- _empathy_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE,
- 2, GST_TYPE_PAD, G_TYPE_UINT);
-
- signals[SINK_PAD_ADDED] =
- g_signal_new ("sink-pad-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- _empathy_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE,
- 2, GST_TYPE_PAD, G_TYPE_UINT);
-
- signals[REQUEST_RESOURCE] =
- g_signal_new ("request-resource", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0,
- g_signal_accumulator_true_handled, NULL,
- _empathy_marshal_BOOLEAN__UINT_UINT,
- G_TYPE_BOOLEAN, 2, G_TYPE_UINT, G_TYPE_UINT);
-
- signals[CLOSED] =
- g_signal_new ("closed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-}
-
-EmpathyCallHandler *
-empathy_call_handler_new_for_contact (EmpathyContact *contact)
-{
- return EMPATHY_CALL_HANDLER (g_object_new (EMPATHY_TYPE_CALL_HANDLER,
- "contact", contact, NULL));
-}
-
-EmpathyCallHandler *
-empathy_call_handler_new_for_channel (EmpathyTpCall *call)
-{
- return EMPATHY_CALL_HANDLER (g_object_new (EMPATHY_TYPE_CALL_HANDLER,
- "tp-call", call, NULL));
-}
-
-void
-empathy_call_handler_bus_message (EmpathyCallHandler *handler,
- GstBus *bus, GstMessage *message)
-{
- EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
-
- if (priv->tfchannel == NULL)
- return;
-
- tf_channel_bus_message (priv->tfchannel, message);
-}
-
-static void
-empathy_call_handler_tf_channel_session_created_cb (TfChannel *tfchannel,
- FsConference *conference, FsParticipant *participant,
- EmpathyCallHandler *self)
-{
- g_signal_emit (G_OBJECT (self), signals[CONFERENCE_ADDED], 0,
- GST_ELEMENT (conference));
-}
-
-static void
-empathy_call_handler_tf_stream_src_pad_added_cb (TfStream *stream,
- GstPad *pad, FsCodec *codec, EmpathyCallHandler *handler)
-{
- guint media_type;
-
- g_object_get (stream, "media-type", &media_type, NULL);
-
- g_signal_emit (G_OBJECT (handler), signals[SRC_PAD_ADDED], 0,
- pad, media_type);
-}
-
-
-static gboolean
-empathy_call_handler_tf_stream_request_resource_cb (TfStream *stream,
- guint direction, EmpathyTpCall *call)
-{
- gboolean ret;
- guint media_type;
-
- g_object_get (G_OBJECT (stream), "media-type", &media_type, NULL);
-
- g_signal_emit (G_OBJECT (call),
- signals[REQUEST_RESOURCE], 0, media_type, direction, &ret);
-
- return ret;
-}
-
-static void
-empathy_call_handler_tf_channel_stream_created_cb (TfChannel *tfchannel,
- TfStream *stream, EmpathyCallHandler *handler)
-{
- guint media_type;
- GstPad *spad;
-
- g_signal_connect (stream, "src-pad-added",
- G_CALLBACK (empathy_call_handler_tf_stream_src_pad_added_cb), handler);
- g_signal_connect (stream, "request-resource",
- G_CALLBACK (empathy_call_handler_tf_stream_request_resource_cb),
- handler);
-
- g_object_get (stream, "media-type", &media_type,
- "sink-pad", &spad, NULL);
-
- g_signal_emit (G_OBJECT (handler), signals[SINK_PAD_ADDED], 0,
- spad, media_type);
-
- gst_object_unref (spad);
-}
-
-static void
-empathy_call_handler_tf_channel_closed_cb (TfChannel *tfchannel,
- EmpathyCallHandler *handler)
-{
- g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0);
-}
-
-static GList *
-empathy_call_handler_tf_channel_codec_config_get_defaults (FsCodec *codecs)
-{
- GList *l = NULL;
- int i;
-
- for (i = 0; codecs[i].encoding_name != NULL; i++)
- l = g_list_append (l, fs_codec_copy (codecs + i));
-
- return l;
-}
-
-static GList *
-empathy_call_handler_tf_channel_codec_config_cb (TfChannel *channel,
- guint stream_id, FsMediaType media_type, guint direction, gpointer user_data)
-{
- FsCodec audio_codecs[] = {
- { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000, },
- { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000, },
-
- { FS_CODEC_ID_DISABLE, "DV", FS_MEDIA_TYPE_AUDIO, },
- { FS_CODEC_ID_DISABLE, "MPA", FS_MEDIA_TYPE_AUDIO, },
- { FS_CODEC_ID_DISABLE, "VORBIS", FS_MEDIA_TYPE_AUDIO, },
- { FS_CODEC_ID_DISABLE, "MP3", FS_MEDIA_TYPE_AUDIO, },
- { 0, NULL, 0,}
- };
- FsCodec video_codecs[] = {
- { FS_CODEC_ID_ANY, "H264", FS_MEDIA_TYPE_VIDEO, },
- { FS_CODEC_ID_ANY, "THEORA", FS_MEDIA_TYPE_VIDEO, },
- { FS_CODEC_ID_ANY, "H263", FS_MEDIA_TYPE_VIDEO, },
-
- { FS_CODEC_ID_DISABLE, "DV", FS_MEDIA_TYPE_VIDEO, },
- { FS_CODEC_ID_DISABLE, "JPEG", FS_MEDIA_TYPE_VIDEO, },
- { FS_CODEC_ID_DISABLE, "MPV", FS_MEDIA_TYPE_VIDEO, },
- { 0, NULL, 0}
- };
-
- switch (media_type)
- {
- case FS_MEDIA_TYPE_AUDIO:
- return empathy_call_handler_tf_channel_codec_config_get_defaults
- (audio_codecs);
- case FS_MEDIA_TYPE_VIDEO:
- return empathy_call_handler_tf_channel_codec_config_get_defaults
- (video_codecs);
- }
-
- return NULL;
-}
-
-static void
-empathy_call_handler_start_tpfs (EmpathyCallHandler *self)
-{
- EmpathyCallHandlerPriv *priv = GET_PRIV (self);
- TpChannel *channel;
-
- g_object_get (priv->call, "channel", &channel, NULL);
-
- g_assert (channel != NULL);
-
- priv->tfchannel = tf_channel_new (channel);
-
- /* Set up the telepathy farsight channel */
- g_signal_connect (priv->tfchannel, "session-created",
- G_CALLBACK (empathy_call_handler_tf_channel_session_created_cb), self);
- g_signal_connect (priv->tfchannel, "stream-created",
- G_CALLBACK (empathy_call_handler_tf_channel_stream_created_cb), self);
- g_signal_connect (priv->tfchannel, "closed",
- G_CALLBACK (empathy_call_handler_tf_channel_closed_cb), self);
- g_signal_connect (priv->tfchannel, "stream-get-codec-config",
- G_CALLBACK (empathy_call_handler_tf_channel_codec_config_cb), self);
-
- g_object_unref (channel);
-}
-
-static void
-empathy_call_handler_request_cb (EmpathyDispatchOperation *operation,
- const GError *error, gpointer user_data)
-{
- EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data);
- EmpathyCallHandlerPriv *priv = GET_PRIV (self);
-
- if (error != NULL)
- return;
-
- priv->call = EMPATHY_TP_CALL (
- empathy_dispatch_operation_get_channel_wrapper (operation));
-
- g_object_ref (priv->call);
-
- empathy_call_handler_start_tpfs (self);
-
- empathy_tp_call_to (priv->call, priv->contact);
-
- empathy_dispatch_operation_claim (operation);
-}
-
-static void
-empathy_call_handler_contact_ready_cb (EmpathyContact *contact,
- const GError *error, gpointer user_data, GObject *object)
-{
- EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (object);
- EmpathyCallHandlerPriv *priv = GET_PRIV (self);
- EmpathyDispatcher *dispatcher;
- McAccount *account;
- GStrv allowed;
- GValue *value;
- GHashTable *request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- g_assert (priv->contact != NULL);
-
- dispatcher = empathy_dispatcher_dup_singleton ();
- account = empathy_contact_get_account (priv->contact);
- allowed = empathy_dispatcher_find_channel_class (dispatcher, account,
- TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_HANDLE_TYPE_CONTACT);
-
- if (!tp_strv_contains ((const gchar * const *)allowed,
- TP_IFACE_CHANNEL ".TargetHandle"))
- g_assert_not_reached ();
-
- /* org.freedesktop.Telepathy.Channel.ChannelType */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value);
-
- /* org.freedesktop.Telepathy.Channel.TargetHandleType */
- value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value);
-
- /* org.freedesktop.Telepathy.Channel.TargetHandle*/
- value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (value, empathy_contact_get_handle (priv->contact));
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value);
-
- empathy_dispatcher_create_channel (dispatcher, account,
- request, empathy_call_handler_request_cb, self);
-
- g_object_unref (dispatcher);
-}
-
-void
-empathy_call_handler_start_call (EmpathyCallHandler *handler)
-{
-
- EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
-
- if (priv->call == NULL)
- {
- empathy_contact_call_when_ready (priv->contact,
- EMPATHY_CONTACT_READY_HANDLE,
- empathy_call_handler_contact_ready_cb, NULL, NULL, G_OBJECT (handler));
- }
- else
- {
- empathy_call_handler_start_tpfs (handler);
- empathy_tp_call_accept_incoming_call (priv->call);
- }
-}
diff --git a/libempathy/empathy-call-handler.h b/libempathy/empathy-call-handler.h
deleted file mode 100644
index db2396dc7..000000000
--- a/libempathy/empathy-call-handler.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * empathy-call-handler.h - Header for EmpathyCallHandler
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 __EMPATHY_CALL_HANDLER_H__
-#define __EMPATHY_CALL_HANDLER_H__
-
-#include <glib-object.h>
-
-#include <gst/gst.h>
-
-#include <libempathy/empathy-tp-call.h>
-#include <libempathy/empathy-contact.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyCallHandler EmpathyCallHandler;
-typedef struct _EmpathyCallHandlerClass EmpathyCallHandlerClass;
-
-struct _EmpathyCallHandlerClass {
- GObjectClass parent_class;
-};
-
-struct _EmpathyCallHandler {
- GObject parent;
- gpointer priv;
-};
-
-GType empathy_call_handler_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_CALL_HANDLER \
- (empathy_call_handler_get_type())
-#define EMPATHY_CALL_HANDLER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_CALL_HANDLER, \
- EmpathyCallHandler))
-#define EMPATHY_CALL_HANDLER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_CALL_HANDLER, \
- EmpathyCallHandlerClass))
-#define EMPATHY_IS_CALL_HANDLER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_CALL_HANDLER))
-#define EMPATHY_IS_CALL_HANDLER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_CALL_HANDLER))
-#define EMPATHY_CALL_HANDLER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CALL_HANDLER, \
- EmpathyCallHandlerClass))
-
-EmpathyCallHandler * empathy_call_handler_new_for_contact (
- EmpathyContact *contact);
-
-EmpathyCallHandler * empathy_call_handler_new_for_channel (
- EmpathyTpCall *call);
-
-void empathy_call_handler_start_call (EmpathyCallHandler *handler);
-
-void empathy_call_handler_bus_message (EmpathyCallHandler *handler,
- GstBus *bus, GstMessage *message);
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_CALL_HANDLER_H__*/
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
deleted file mode 100644
index 6765d9e48..000000000
--- a/libempathy/empathy-chatroom-manager.c
+++ /dev/null
@@ -1,741 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Martyn Russell <martyn@imendio.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "empathy-tp-chat.h"
-#include "empathy-chatroom-manager.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-#define CHATROOMS_XML_FILENAME "chatrooms.xml"
-#define CHATROOMS_DTD_FILENAME "empathy-chatroom-manager.dtd"
-#define SAVE_TIMER 4
-
-static EmpathyChatroomManager *chatroom_manager_singleton = NULL;
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroomManager)
-typedef struct {
- GList *chatrooms;
- gchar *file;
- /* source id of the autosave timer */
- gint save_timer_id;
-} EmpathyChatroomManagerPriv;
-
-static void chatroom_manager_finalize (GObject *object);
-static gboolean chatroom_manager_get_all (EmpathyChatroomManager *manager);
-static gboolean chatroom_manager_file_parse (EmpathyChatroomManager *manager,
- const gchar *filename);
-static void chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
- xmlNodePtr node);
-static gboolean chatroom_manager_file_save (EmpathyChatroomManager *manager);
-static void reset_save_timeout (EmpathyChatroomManager *self);
-
-enum {
- CHATROOM_ADDED,
- CHATROOM_REMOVED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-/* properties */
-enum
-{
- PROP_FILE = 1,
- LAST_PROPERTY
-};
-
-G_DEFINE_TYPE (EmpathyChatroomManager, empathy_chatroom_manager, G_TYPE_OBJECT);
-
-static void
-empathy_chatroom_manager_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_FILE:
- g_value_set_string (value, priv->file);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_chatroom_manager_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_FILE:
- g_free (priv->file);
- priv->file = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static GObject *
-empathy_chatroom_manager_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *obj;
- EmpathyChatroomManager *self;
- EmpathyChatroomManagerPriv *priv;
-
- if (chatroom_manager_singleton != NULL)
- return g_object_ref (chatroom_manager_singleton);
-
- /* Parent constructor chain */
- obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->
- constructor (type, n_props, props);
-
- self = EMPATHY_CHATROOM_MANAGER (obj);
- priv = GET_PRIV (self);
-
- chatroom_manager_singleton = self;
- g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton);
-
- if (priv->file == NULL)
- {
- /* Set the default file path */
- gchar *dir;
-
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
- if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
-
- priv->file = g_build_filename (dir, CHATROOMS_XML_FILENAME, NULL);
- g_free (dir);
- }
-
- chatroom_manager_get_all (self);
- return obj;
-}
-
-static void
-empathy_chatroom_manager_class_init (EmpathyChatroomManagerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- object_class->constructor = empathy_chatroom_manager_constructor;
- object_class->get_property = empathy_chatroom_manager_get_property;
- object_class->set_property = empathy_chatroom_manager_set_property;
- object_class->finalize = chatroom_manager_finalize;
-
- param_spec = g_param_spec_string (
- "file",
- "path of the favorite file",
- "The path of the XML file containing user's favorites",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_FILE, param_spec);
-
- signals[CHATROOM_ADDED] =
- g_signal_new ("chatroom-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CHATROOM);
- signals[CHATROOM_REMOVED] =
- g_signal_new ("chatroom-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CHATROOM);
-
- g_type_class_add_private (object_class,
- sizeof (EmpathyChatroomManagerPriv));
-}
-
-static void
-empathy_chatroom_manager_init (EmpathyChatroomManager *manager)
-{
- EmpathyChatroomManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManagerPriv);
-
- manager->priv = priv;
-}
-
-static void
-chatroom_changed_cb (EmpathyChatroom *chatroom,
- GParamSpec *spec,
- EmpathyChatroomManager *self)
-{
- reset_save_timeout (self);
-}
-
-static void
-chatroom_manager_finalize (GObject *object)
-{
- EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (object);
- EmpathyChatroomManagerPriv *priv;
- GList *l;
-
- priv = GET_PRIV (object);
-
- if (priv->save_timer_id > 0)
- {
- /* have to save before destroy the object */
- g_source_remove (priv->save_timer_id);
- priv->save_timer_id = 0;
- chatroom_manager_file_save (self);
- }
-
- for (l = priv->chatrooms; l != NULL; l = g_list_next (l))
- {
- EmpathyChatroom *chatroom = l->data;
-
- g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb,
- self);
-
- g_object_unref (chatroom);
- }
-
- g_list_free (priv->chatrooms);
- g_free (priv->file);
-
- (G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)->finalize) (object);
-}
-
-EmpathyChatroomManager *
-empathy_chatroom_manager_dup_singleton (const gchar *file)
-{
- return EMPATHY_CHATROOM_MANAGER (g_object_new (EMPATHY_TYPE_CHATROOM_MANAGER,
- "file", file, NULL));
-}
-
-static gboolean
-save_timeout (EmpathyChatroomManager *self)
-{
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
-
- priv->save_timer_id = 0;
- chatroom_manager_file_save (self);
-
- return FALSE;
-}
-
-static void
-reset_save_timeout (EmpathyChatroomManager *self)
-{
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
-
- if (priv->save_timer_id > 0)
- {
- g_source_remove (priv->save_timer_id);
- }
-
- priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER,
- (GSourceFunc) save_timeout, self);
-}
-
-static void
-add_chatroom (EmpathyChatroomManager *self,
- EmpathyChatroom *chatroom)
-{
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
-
- priv->chatrooms = g_list_prepend (priv->chatrooms, g_object_ref (chatroom));
-
- g_signal_connect (chatroom, "notify",
- G_CALLBACK (chatroom_changed_cb), self);
-}
-
-gboolean
-empathy_chatroom_manager_add (EmpathyChatroomManager *manager,
- EmpathyChatroom *chatroom)
-{
- EmpathyChatroomManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), FALSE);
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE);
-
- priv = GET_PRIV (manager);
-
- /* don't add more than once */
- if (!empathy_chatroom_manager_find (manager,
- empathy_chatroom_get_account (chatroom),
- empathy_chatroom_get_room (chatroom))) {
- gboolean favorite;
-
- g_object_get (chatroom, "favorite", &favorite, NULL);
-
- add_chatroom (manager, chatroom);
-
- if (favorite)
- {
- reset_save_timeout (manager);
- }
-
- g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-empathy_chatroom_manager_remove (EmpathyChatroomManager *manager,
- EmpathyChatroom *chatroom)
-{
- EmpathyChatroomManagerPriv *priv;
- GList *l;
-
- g_return_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager));
- g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
-
- priv = GET_PRIV (manager);
-
- for (l = priv->chatrooms; l; l = l->next) {
- EmpathyChatroom *this_chatroom;
-
- this_chatroom = l->data;
-
- if (this_chatroom == chatroom ||
- empathy_chatroom_equal (chatroom, this_chatroom)) {
- gboolean favorite;
- priv->chatrooms = g_list_delete_link (priv->chatrooms, l);
-
- g_object_get (chatroom, "favorite", &favorite, NULL);
-
- if (favorite)
- {
- reset_save_timeout (manager);
- }
-
- g_signal_emit (manager, signals[CHATROOM_REMOVED], 0, this_chatroom);
-
- g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb,
- manager);
-
- g_object_unref (this_chatroom);
- break;
- }
- }
-}
-
-EmpathyChatroom *
-empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
- McAccount *account,
- const gchar *room)
-{
- EmpathyChatroomManagerPriv *priv;
- GList *l;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (room != NULL, NULL);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->chatrooms; l; l = l->next) {
- EmpathyChatroom *chatroom;
- McAccount *this_account;
- const gchar *this_room;
-
- chatroom = l->data;
- this_account = empathy_chatroom_get_account (chatroom);
- this_room = empathy_chatroom_get_room (chatroom);
-
- if (this_account && this_room &&
- empathy_account_equal (account, this_account) &&
- strcmp (this_room, room) == 0) {
- return chatroom;
- }
- }
-
- return NULL;
-}
-
-GList *
-empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
- McAccount *account)
-{
- EmpathyChatroomManagerPriv *priv;
- GList *chatrooms, *l;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), NULL);
-
- priv = GET_PRIV (manager);
-
- if (!account) {
- return g_list_copy (priv->chatrooms);
- }
-
- chatrooms = NULL;
- for (l = priv->chatrooms; l; l = l->next) {
- EmpathyChatroom *chatroom;
-
- chatroom = l->data;
-
- if (empathy_account_equal (account,
- empathy_chatroom_get_account (chatroom))) {
- chatrooms = g_list_append (chatrooms, chatroom);
- }
- }
-
- return chatrooms;
-}
-
-guint
-empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,
- McAccount *account)
-{
- EmpathyChatroomManagerPriv *priv;
- GList *l;
- guint count = 0;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- if (!account) {
- return g_list_length (priv->chatrooms);
- }
-
- for (l = priv->chatrooms; l; l = l->next) {
- EmpathyChatroom *chatroom;
-
- chatroom = l->data;
-
- if (empathy_account_equal (account,
- empathy_chatroom_get_account (chatroom))) {
- count++;
- }
- }
-
- return count;
-}
-
-/*
- * API to save/load and parse the chatrooms file.
- */
-
-static gboolean
-chatroom_manager_get_all (EmpathyChatroomManager *manager)
-{
- EmpathyChatroomManagerPriv *priv;
-
- priv = GET_PRIV (manager);
-
- /* read file in */
- if (g_file_test (priv->file, G_FILE_TEST_EXISTS) &&
- !chatroom_manager_file_parse (manager, priv->file))
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-chatroom_manager_file_parse (EmpathyChatroomManager *manager,
- const gchar *filename)
-{
- EmpathyChatroomManagerPriv *priv;
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr chatrooms;
- xmlNodePtr node;
-
- priv = GET_PRIV (manager);
-
- DEBUG ("Attempting to parse file:'%s'...", filename);
-
- ctxt = xmlNewParserCtxt ();
-
- /* Parse and validate the file. */
- doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
- if (!doc) {
- g_warning ("Failed to parse file:'%s'", filename);
- xmlFreeParserCtxt (ctxt);
- return FALSE;
- }
-
- if (!empathy_xml_validate (doc, CHATROOMS_DTD_FILENAME)) {
- g_warning ("Failed to validate file:'%s'", filename);
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
- return FALSE;
- }
-
- /* The root node, chatrooms. */
- chatrooms = xmlDocGetRootElement (doc);
-
- for (node = chatrooms->children; node; node = node->next) {
- if (strcmp ((gchar *) node->name, "chatroom") == 0) {
- chatroom_manager_parse_chatroom (manager, node);
- }
- }
-
- DEBUG ("Parsed %d chatrooms", g_list_length (priv->chatrooms));
-
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
-
- return TRUE;
-}
-
-static void
-chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
- xmlNodePtr node)
-{
- EmpathyChatroomManagerPriv *priv;
- EmpathyChatroom *chatroom;
- McAccount *account;
- xmlNodePtr child;
- gchar *str;
- gchar *name;
- gchar *room;
- gchar *account_id;
- gboolean auto_connect;
-
- priv = GET_PRIV (manager);
-
- /* default values. */
- name = NULL;
- room = NULL;
- auto_connect = TRUE;
- account_id = NULL;
-
- for (child = node->children; child; child = child->next) {
- gchar *tag;
-
- if (xmlNodeIsText (child)) {
- continue;
- }
-
- tag = (gchar *) child->name;
- str = (gchar *) xmlNodeGetContent (child);
-
- if (strcmp (tag, "name") == 0) {
- name = g_strdup (str);
- }
- else if (strcmp (tag, "room") == 0) {
- room = g_strdup (str);
- }
- else if (strcmp (tag, "auto_connect") == 0) {
- if (strcmp (str, "yes") == 0) {
- auto_connect = TRUE;
- } else {
- auto_connect = FALSE;
- }
- }
- else if (strcmp (tag, "account") == 0) {
- account_id = g_strdup (str);
- }
-
- xmlFree (str);
- }
-
- account = mc_account_lookup (account_id);
- if (!account) {
- g_free (name);
- g_free (room);
- g_free (account_id);
- return;
- }
-
- chatroom = empathy_chatroom_new_full (account, room, name, auto_connect);
- g_object_set (chatroom, "favorite", TRUE, NULL);
- add_chatroom (manager, chatroom);
- g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);
-
- g_object_unref (account);
- g_free (name);
- g_free (room);
- g_free (account_id);
-}
-
-static gboolean
-chatroom_manager_file_save (EmpathyChatroomManager *manager)
-{
- EmpathyChatroomManagerPriv *priv;
- xmlDocPtr doc;
- xmlNodePtr root;
- GList *l;
-
- priv = GET_PRIV (manager);
-
- doc = xmlNewDoc ("1.0");
- root = xmlNewNode (NULL, "chatrooms");
- xmlDocSetRootElement (doc, root);
-
- for (l = priv->chatrooms; l; l = l->next) {
- EmpathyChatroom *chatroom;
- xmlNodePtr node;
- const gchar *account_id;
- gboolean favorite;
-
- chatroom = l->data;
-
- g_object_get (chatroom, "favorite", &favorite, NULL);
- if (!favorite)
- continue;
-
- account_id = mc_account_get_unique_name (empathy_chatroom_get_account (chatroom));
-
- node = xmlNewChild (root, NULL, "chatroom", NULL);
- xmlNewTextChild (node, NULL, "name", empathy_chatroom_get_name (chatroom));
- xmlNewTextChild (node, NULL, "room", empathy_chatroom_get_room (chatroom));
- xmlNewTextChild (node, NULL, "account", account_id);
- xmlNewTextChild (node, NULL, "auto_connect", empathy_chatroom_get_auto_connect (chatroom) ? "yes" : "no");
- }
-
- /* Make sure the XML is indented properly */
- xmlIndentTreeOutput = 1;
-
- DEBUG ("Saving file:'%s'", priv->file);
- xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);
- xmlFreeDoc (doc);
-
- xmlCleanupParser ();
- xmlMemoryDump ();
-
- return TRUE;
-}
-
-static void
-chatroom_manager_chat_destroyed_cb (EmpathyTpChat *chat,
- gpointer user_data)
-{
- EmpathyChatroomManager *manager = EMPATHY_CHATROOM_MANAGER (user_data);
- McAccount *account = empathy_tp_chat_get_account (chat);
- EmpathyChatroom *chatroom;
- const gchar *roomname;
- gboolean favorite;
-
- roomname = empathy_tp_chat_get_id (chat);
- chatroom = empathy_chatroom_manager_find (manager, account, roomname);
-
- if (chatroom == NULL)
- return;
-
- g_object_set (chatroom, "tp-chat", NULL, NULL);
- g_object_get (chatroom, "favorite", &favorite, NULL);
-
- if (!favorite)
- {
- /* Remove the chatroom from the list, unless it's in the list of
- * favourites..
- * FIXME this policy should probably not be in libempathy */
- empathy_chatroom_manager_remove (manager, chatroom);
- }
-}
-
-static void
-chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
- EmpathyDispatchOperation *operation, gpointer user_data)
-{
- EmpathyChatroomManager *manager = EMPATHY_CHATROOM_MANAGER (user_data);
- EmpathyChatroom *chatroom;
- TpChannel *channel;
- EmpathyTpChat *chat;
- const gchar *roomname;
- GQuark channel_type;
- TpHandleType handle_type;
- McAccount *account;
-
- channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
-
- /* Observe Text channels to rooms only */
- if (channel_type != TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
- return;
-
- channel = empathy_dispatch_operation_get_channel (operation);
- tp_channel_get_handle (channel, &handle_type);
-
- if (handle_type != TP_HANDLE_TYPE_ROOM)
- return;
-
- chat = EMPATHY_TP_CHAT (
- empathy_dispatch_operation_get_channel_wrapper (operation));
- account = empathy_tp_chat_get_account (chat);
-
- roomname = empathy_tp_chat_get_id (chat);
-
- chatroom = empathy_chatroom_manager_find (manager, account, roomname);
-
- if (chatroom == NULL)
- {
- chatroom = empathy_chatroom_new_full (account, roomname, roomname,
- FALSE);
- g_object_set (G_OBJECT (chatroom), "tp-chat", chat, NULL);
- empathy_chatroom_manager_add (manager, chatroom);
- g_object_unref (chatroom);
- }
- else
- {
- g_object_set (G_OBJECT (chatroom), "tp-chat", chat, NULL);
- }
-
- /* A TpChat is always destroyed as it only gets unreffed after the channel
- * has been invalidated in the dispatcher.. */
- g_signal_connect (chat, "destroy",
- G_CALLBACK (chatroom_manager_chat_destroyed_cb),
- manager);
-}
-
-void
-empathy_chatroom_manager_observe (EmpathyChatroomManager *manager,
- EmpathyDispatcher *dispatcher)
-{
- g_signal_connect (dispatcher, "observe",
- G_CALLBACK (chatroom_manager_observe_channel_cb), manager);
-}
diff --git a/libempathy/empathy-chatroom-manager.dtd b/libempathy/empathy-chatroom-manager.dtd
deleted file mode 100644
index df6b953f6..000000000
--- a/libempathy/empathy-chatroom-manager.dtd
+++ /dev/null
@@ -1,17 +0,0 @@
-<!--
- DTD for Empathys Chat Rooms.
- by Martyn Russell <martyn@imendio.com>
- v0.2
--->
-
-<!-- Root element. -->
-<!ELEMENT chatrooms (chatroom*)>
-
-<!ELEMENT chatroom
- (name,room,account,(auto_connect?))>
-
-<!ELEMENT name (#PCDATA)>
-<!ELEMENT room (#PCDATA)>
-<!ELEMENT auto_connect (#PCDATA)>
-<!ELEMENT account (#PCDATA)>
-
diff --git a/libempathy/empathy-chatroom-manager.h b/libempathy/empathy-chatroom-manager.h
deleted file mode 100644
index 4077a3ccd..000000000
--- a/libempathy/empathy-chatroom-manager.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Martyn Russell <martyn@imendio.com>
- */
-
-#ifndef __EMPATHY_CHATROOM_MANAGER_H__
-#define __EMPATHY_CHATROOM_MANAGER_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-chatroom.h"
-#include "empathy-dispatcher.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CHATROOM_MANAGER (empathy_chatroom_manager_get_type ())
-#define EMPATHY_CHATROOM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManager))
-#define EMPATHY_CHATROOM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManagerClass))
-#define EMPATHY_IS_CHATROOM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHATROOM_MANAGER))
-#define EMPATHY_IS_CHATROOM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHATROOM_MANAGER))
-#define EMPATHY_CHATROOM_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManagerClass))
-
-typedef struct _EmpathyChatroomManager EmpathyChatroomManager;
-typedef struct _EmpathyChatroomManagerClass EmpathyChatroomManagerClass;
-
-struct _EmpathyChatroomManager {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyChatroomManagerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_chatroom_manager_get_type (void) G_GNUC_CONST;
-EmpathyChatroomManager *empathy_chatroom_manager_dup_singleton (const gchar *file);
-gboolean empathy_chatroom_manager_add (EmpathyChatroomManager *manager,
- EmpathyChatroom *chatroom);
-void empathy_chatroom_manager_remove (EmpathyChatroomManager *manager,
- EmpathyChatroom *chatroom);
-EmpathyChatroom * empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
- McAccount *account,
- const gchar *room);
-GList * empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
- McAccount *account);
-guint empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,
- McAccount *account);
-void empathy_chatroom_manager_observe (EmpathyChatroomManager *manager,
- EmpathyDispatcher *dispatcher);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CHATROOM_MANAGER_H__ */
diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c
deleted file mode 100644
index ef89994c0..000000000
--- a/libempathy/empathy-chatroom.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <glib.h>
-#include <telepathy-glib/util.h>
-
-#include "empathy-chatroom.h"
-#include "empathy-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroom)
-typedef struct {
- McAccount *account;
- gchar *room;
- gchar *name;
- gboolean auto_connect;
- gboolean favorite;
- EmpathyTpChat *tp_chat;
-} EmpathyChatroomPriv;
-
-
-static void chatroom_finalize (GObject *object);
-static void chatroom_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void chatroom_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-
-enum {
- PROP_0,
- PROP_ACCOUNT,
- PROP_ROOM,
- PROP_NAME,
- PROP_AUTO_CONNECT,
- PROP_FAVORITE,
- PROP_TP_CHAT,
-};
-
-G_DEFINE_TYPE (EmpathyChatroom, empathy_chatroom, G_TYPE_OBJECT);
-
-static void
-empathy_chatroom_class_init (EmpathyChatroomClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = chatroom_finalize;
- object_class->get_property = chatroom_get_property;
- object_class->set_property = chatroom_set_property;
-
- g_object_class_install_property (object_class,
- PROP_ACCOUNT,
- g_param_spec_object ("account",
- "Chatroom Account",
- "The account associated with an chatroom",
- MC_TYPE_ACCOUNT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_ROOM,
- g_param_spec_string ("room",
- "Chatroom Room",
- "Chatroom represented as 'room@server'",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- "Chatroom Name",
- "Chatroom name",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_AUTO_CONNECT,
- g_param_spec_boolean ("auto_connect",
- "Chatroom Auto Connect",
- "Connect on startup",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_FAVORITE,
- g_param_spec_boolean ("favorite",
- "Favorite",
- "TRUE if the chatroom is in user's favorite list",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property (object_class,
- PROP_TP_CHAT,
- g_param_spec_object ("tp-chat",
- "Chatroom channel wrapper",
- "The wrapper for the chatroom channel if there is one",
- EMPATHY_TYPE_TP_CHAT,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (EmpathyChatroomPriv));
-}
-
-static void
-empathy_chatroom_init (EmpathyChatroom *chatroom)
-{
- EmpathyChatroomPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chatroom,
- EMPATHY_TYPE_CHATROOM, EmpathyChatroomPriv);
-
- chatroom->priv = priv;
-}
-
-static void
-chatroom_finalize (GObject *object)
-{
- EmpathyChatroomPriv *priv;
-
- priv = GET_PRIV (object);
-
- if (priv->tp_chat != NULL)
- g_object_unref (priv->tp_chat);
-
- g_object_unref (priv->account);
- g_free (priv->room);
- g_free (priv->name);
-
- (G_OBJECT_CLASS (empathy_chatroom_parent_class)->finalize) (object);
-}
-
-static void
-chatroom_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyChatroomPriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- g_value_set_object (value, priv->account);
- break;
- case PROP_ROOM:
- g_value_set_string (value, priv->room);
- break;
- case PROP_NAME:
- g_value_set_string (value, priv->name);
- break;
- case PROP_AUTO_CONNECT:
- g_value_set_boolean (value, priv->auto_connect);
- break;
- case PROP_FAVORITE:
- g_value_set_boolean (value, priv->favorite);
- break;
- case PROP_TP_CHAT:
- g_value_set_object (value, priv->tp_chat);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-chatroom_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyChatroomPriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- empathy_chatroom_set_account (EMPATHY_CHATROOM (object),
- g_value_get_object (value));
- break;
- case PROP_ROOM:
- empathy_chatroom_set_room (EMPATHY_CHATROOM (object),
- g_value_get_string (value));
- break;
- case PROP_NAME:
- empathy_chatroom_set_name (EMPATHY_CHATROOM (object),
- g_value_get_string (value));
- break;
- case PROP_AUTO_CONNECT:
- empathy_chatroom_set_auto_connect (EMPATHY_CHATROOM (object),
- g_value_get_boolean (value));
- break;
- case PROP_FAVORITE:
- priv->favorite = g_value_get_boolean (value);
- if (!priv->favorite)
- {
- empathy_chatroom_set_auto_connect (EMPATHY_CHATROOM (object),
- FALSE);
- }
- break;
- case PROP_TP_CHAT: {
- GObject *chat = g_value_dup_object (value);
-
- if (chat == (GObject *) priv->tp_chat)
- break;
-
- g_assert (chat == NULL || priv->tp_chat == NULL);
-
- if (priv->tp_chat != NULL) {
- g_object_unref (priv->tp_chat);
- priv->tp_chat = NULL;
- } else {
- priv->tp_chat = EMPATHY_TP_CHAT (chat);
- }
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-EmpathyChatroom *
-empathy_chatroom_new (McAccount *account)
-{
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
-
- return g_object_new (EMPATHY_TYPE_CHATROOM,
- "account", account,
- NULL);
-}
-
-EmpathyChatroom *
-empathy_chatroom_new_full (McAccount *account,
- const gchar *room,
- const gchar *name,
- gboolean auto_connect)
-{
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (room != NULL, NULL);
-
- return g_object_new (EMPATHY_TYPE_CHATROOM,
- "account", account,
- "room", room,
- "name", name,
- "auto_connect", auto_connect,
- NULL);
-}
-
-McAccount *
-empathy_chatroom_get_account (EmpathyChatroom *chatroom)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL);
-
- priv = GET_PRIV (chatroom);
- return priv->account;
-}
-
-void
-empathy_chatroom_set_account (EmpathyChatroom *chatroom,
- McAccount *account)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
- g_return_if_fail (MC_IS_ACCOUNT (account));
-
- priv = GET_PRIV (chatroom);
-
- if (account == priv->account) {
- return;
- }
- if (priv->account) {
- g_object_unref (priv->account);
- }
- priv->account = g_object_ref (account);
-
- g_object_notify (G_OBJECT (chatroom), "account");
-}
-
-const gchar *
-empathy_chatroom_get_room (EmpathyChatroom *chatroom)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL);
-
- priv = GET_PRIV (chatroom);
- return priv->room;
-}
-
-void
-empathy_chatroom_set_room (EmpathyChatroom *chatroom,
- const gchar *room)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
- g_return_if_fail (room != NULL);
-
- priv = GET_PRIV (chatroom);
-
- g_free (priv->room);
- priv->room = g_strdup (room);
-
- g_object_notify (G_OBJECT (chatroom), "room");
-}
-
-const gchar *
-empathy_chatroom_get_name (EmpathyChatroom *chatroom)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL);
-
- priv = GET_PRIV (chatroom);
-
- if (EMP_STR_EMPTY (priv->name)) {
- return priv->room;
- }
-
- return priv->name;
-}
-
-void
-empathy_chatroom_set_name (EmpathyChatroom *chatroom,
- const gchar *name)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
-
- priv = GET_PRIV (chatroom);
-
- g_free (priv->name);
- priv->name = NULL;
- if (name) {
- priv->name = g_strdup (name);
- }
-
- g_object_notify (G_OBJECT (chatroom), "name");
-}
-
-gboolean
-empathy_chatroom_get_auto_connect (EmpathyChatroom *chatroom)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE);
-
- priv = GET_PRIV (chatroom);
- return priv->auto_connect;
-}
-
-void
-empathy_chatroom_set_auto_connect (EmpathyChatroom *chatroom,
- gboolean auto_connect)
-{
- EmpathyChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom));
-
- priv = GET_PRIV (chatroom);
-
- priv->auto_connect = auto_connect;
-
- if (priv->auto_connect)
- {
- /* auto_connect implies favorite */
- priv->favorite = TRUE;
- g_object_notify (G_OBJECT (chatroom), "favorite");
- }
-
- g_object_notify (G_OBJECT (chatroom), "auto-connect");
-}
-
-gboolean
-empathy_chatroom_equal (gconstpointer v1,
- gconstpointer v2)
-{
- McAccount *account_a;
- McAccount *account_b;
- const gchar *room_a;
- const gchar *room_b;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (v1), FALSE);
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (v2), FALSE);
-
- account_a = empathy_chatroom_get_account (EMPATHY_CHATROOM (v1));
- account_b = empathy_chatroom_get_account (EMPATHY_CHATROOM (v2));
-
- room_a = empathy_chatroom_get_room (EMPATHY_CHATROOM (v1));
- room_b = empathy_chatroom_get_room (EMPATHY_CHATROOM (v2));
-
- return empathy_account_equal (account_a, account_b) && !tp_strdiff (room_a,
- room_b);
-}
-
-EmpathyTpChat *
-empathy_chatroom_get_tp_chat (EmpathyChatroom *chatroom) {
- EmpathyChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL);
-
- priv = GET_PRIV (chatroom);
-
- return priv->tp_chat;
-}
diff --git a/libempathy/empathy-chatroom.h b/libempathy/empathy-chatroom.h
deleted file mode 100644
index 3261c8d25..000000000
--- a/libempathy/empathy-chatroom.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_CHATROOM_H__
-#define __EMPATHY_CHATROOM_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include <libempathy/empathy-tp-chat.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CHATROOM (empathy_chatroom_get_type ())
-#define EMPATHY_CHATROOM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHATROOM, EmpathyChatroom))
-#define EMPATHY_CHATROOM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CHATROOM, EmpathyChatroomClass))
-#define EMPATHY_IS_CHATROOM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHATROOM))
-#define EMPATHY_IS_CHATROOM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHATROOM))
-#define EMPATHY_CHATROOM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHATROOM, EmpathyChatroomClass))
-
-#define EMPATHY_TYPE_CHATROOM_INVITE (empathy_chatroom_invite_get_gtype ())
-
-typedef struct _EmpathyChatroom EmpathyChatroom;
-typedef struct _EmpathyChatroomClass EmpathyChatroomClass;
-
-struct _EmpathyChatroom {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyChatroomClass {
- GObjectClass parent_class;
-};
-
-GType empathy_chatroom_get_type (void) G_GNUC_CONST;
-EmpathyChatroom *empathy_chatroom_new (McAccount *account);
-EmpathyChatroom *empathy_chatroom_new_full (McAccount *account,
- const gchar *room,
- const gchar *name,
- gboolean auto_connect);
-McAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom);
-void empathy_chatroom_set_account (EmpathyChatroom *chatroom,
- McAccount *account);
-const gchar * empathy_chatroom_get_room (EmpathyChatroom *chatroom);
-void empathy_chatroom_set_room (EmpathyChatroom *chatroom,
- const gchar *room);
-const gchar * empathy_chatroom_get_name (EmpathyChatroom *chatroom);
-void empathy_chatroom_set_name (EmpathyChatroom *chatroom,
- const gchar *name);
-gboolean empathy_chatroom_get_auto_connect (EmpathyChatroom *chatroom);
-void empathy_chatroom_set_auto_connect (EmpathyChatroom *chatroom,
- gboolean auto_connect);
-gboolean empathy_chatroom_equal (gconstpointer v1,
- gconstpointer v2);
-EmpathyTpChat * empathy_chatroom_get_tp_chat (EmpathyChatroom *chatroom);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CHATROOM_H__ */
diff --git a/libempathy/empathy-contact-factory.c b/libempathy/empathy-contact-factory.c
deleted file mode 100644
index c35005774..000000000
--- a/libempathy/empathy-contact-factory.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include "empathy-contact-factory.h"
-#include "empathy-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactFactory)
-typedef struct {
- GHashTable *accounts;
-} EmpathyContactFactoryPriv;
-
-G_DEFINE_TYPE (EmpathyContactFactory, empathy_contact_factory, G_TYPE_OBJECT);
-
-static EmpathyContactFactory * factory_singleton = NULL;
-
-EmpathyTpContactFactory *
-empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
- McAccount *account)
-{
- EmpathyContactFactoryPriv *priv = GET_PRIV (factory);
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = g_hash_table_lookup (priv->accounts, account);
- if (!tp_factory) {
- tp_factory = empathy_tp_contact_factory_new (account);
- g_hash_table_insert (priv->accounts, account, tp_factory);
- }
-
- return g_object_ref (tp_factory);
-}
-
-EmpathyContact *
-empathy_contact_factory_get_user (EmpathyContactFactory *factory,
- McAccount *account)
-{
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_get_user (tp_factory);
-}
-
-EmpathyContact *
-empathy_contact_factory_get_from_id (EmpathyContactFactory *factory,
- McAccount *account,
- const gchar *id)
-{
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_get_from_id (tp_factory, id);
-}
-
-EmpathyContact *
-empathy_contact_factory_get_from_handle (EmpathyContactFactory *factory,
- McAccount *account,
- guint handle)
-{
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_get_from_handle (tp_factory, handle);
-}
-
-GList *
-empathy_contact_factory_get_from_handles (EmpathyContactFactory *factory,
- McAccount *account,
- const GArray *handles)
-{
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_get_from_handles (tp_factory, handles);
-}
-
-void
-empathy_contact_factory_set_alias (EmpathyContactFactory *factory,
- EmpathyContact *contact,
- const gchar *alias)
-{
- EmpathyTpContactFactory *tp_factory;
- McAccount *account;
-
- account = empathy_contact_get_account (contact);
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_set_alias (tp_factory, contact, alias);
-}
-
-void
-empathy_contact_factory_set_avatar (EmpathyContactFactory *factory,
- McAccount *account,
- const gchar *data,
- gsize size,
- const gchar *mime_type)
-{
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (factory, account);
-
- return empathy_tp_contact_factory_set_avatar (tp_factory,
- data, size, mime_type);
-}
-
-static void
-contact_factory_finalize (GObject *object)
-{
- EmpathyContactFactoryPriv *priv = GET_PRIV (object);
-
- g_hash_table_destroy (priv->accounts);
-
- G_OBJECT_CLASS (empathy_contact_factory_parent_class)->finalize (object);
-}
-
-static GObject *
-contact_factory_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *retval;
-
- if (factory_singleton) {
- retval = g_object_ref (factory_singleton);
- } else {
- retval = G_OBJECT_CLASS (empathy_contact_factory_parent_class)->constructor
- (type, n_props, props);
-
- factory_singleton = EMPATHY_CONTACT_FACTORY (retval);
- g_object_add_weak_pointer (retval, (gpointer) &factory_singleton);
- }
-
- return retval;
-}
-
-static void
-empathy_contact_factory_class_init (EmpathyContactFactoryClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = contact_factory_finalize;
- object_class->constructor = contact_factory_constructor;
-
- g_type_class_add_private (object_class, sizeof (EmpathyContactFactoryPriv));
-}
-
-static void
-empathy_contact_factory_init (EmpathyContactFactory *factory)
-{
- EmpathyContactFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (factory,
- EMPATHY_TYPE_CONTACT_FACTORY, EmpathyContactFactoryPriv);
-
- factory->priv = priv;
- priv->accounts = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal,
- g_object_unref,
- g_object_unref);
-}
-
-EmpathyContactFactory *
-empathy_contact_factory_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_CONTACT_FACTORY, NULL);
-}
-
diff --git a/libempathy/empathy-contact-factory.h b/libempathy/empathy-contact-factory.h
deleted file mode 100644
index 16df02bcd..000000000
--- a/libempathy/empathy-contact-factory.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_CONTACT_FACTORY_H__
-#define __EMPATHY_CONTACT_FACTORY_H__
-
-#include <glib.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-contact.h"
-#include "empathy-tp-contact-factory.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONTACT_FACTORY (empathy_contact_factory_get_type ())
-#define EMPATHY_CONTACT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_FACTORY, EmpathyContactFactory))
-#define EMPATHY_CONTACT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CONTACT_FACTORY, EmpathyContactFactoryClass))
-#define EMPATHY_IS_CONTACT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_FACTORY))
-#define EMPATHY_IS_CONTACT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_FACTORY))
-#define EMPATHY_CONTACT_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_FACTORY, EmpathyContactFactoryClass))
-
-typedef struct _EmpathyContactFactory EmpathyContactFactory;
-typedef struct _EmpathyContactFactoryClass EmpathyContactFactoryClass;
-
-struct _EmpathyContactFactory {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyContactFactoryClass {
- GObjectClass parent_class;
-};
-
-GType empathy_contact_factory_get_type (void) G_GNUC_CONST;
-EmpathyContactFactory *empathy_contact_factory_dup_singleton (void);
-EmpathyTpContactFactory *empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
- McAccount *account);
-EmpathyContact * empathy_contact_factory_get_user (EmpathyContactFactory *factory,
- McAccount *account);
-EmpathyContact * empathy_contact_factory_get_from_id (EmpathyContactFactory *factory,
- McAccount *account,
- const gchar *id);
-EmpathyContact * empathy_contact_factory_get_from_handle (EmpathyContactFactory *factory,
- McAccount *account,
- guint handle);
-GList * empathy_contact_factory_get_from_handles (EmpathyContactFactory *factory,
- McAccount *account,
- const GArray *handles);
-void empathy_contact_factory_set_alias (EmpathyContactFactory *factory,
- EmpathyContact *contact,
- const gchar *alias);
-void empathy_contact_factory_set_avatar (EmpathyContactFactory *factory,
- McAccount *account,
- const gchar *data,
- gsize size,
- const gchar *mime_type);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_FACTORY_H__ */
diff --git a/libempathy/empathy-contact-groups.c b/libempathy/empathy-contact-groups.c
deleted file mode 100644
index 6973a960a..000000000
--- a/libempathy/empathy-contact-groups.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2005-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Martyn Russell <martyn@imendio.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "empathy-utils.h"
-#include "empathy-contact-groups.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include "empathy-debug.h"
-
-#define CONTACT_GROUPS_XML_FILENAME "contact-groups.xml"
-#define CONTACT_GROUPS_DTD_FILENAME "empathy-contact-groups.dtd"
-
-typedef struct {
- gchar *name;
- gboolean expanded;
-} ContactGroup;
-
-static void contact_groups_file_parse (const gchar *filename);
-static gboolean contact_groups_file_save (void);
-static ContactGroup *contact_group_new (const gchar *name,
- gboolean expanded);
-static void contact_group_free (ContactGroup *group);
-
-static GList *groups = NULL;
-
-void
-empathy_contact_groups_get_all (void)
-{
- gchar *dir;
- gchar *file_with_path;
-
- /* If already set up clean up first */
- if (groups) {
- g_list_foreach (groups, (GFunc)contact_group_free, NULL);
- g_list_free (groups);
- groups = NULL;
- }
-
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
- file_with_path = g_build_filename (dir, CONTACT_GROUPS_XML_FILENAME, NULL);
- g_free (dir);
-
- if (g_file_test (file_with_path, G_FILE_TEST_EXISTS)) {
- contact_groups_file_parse (file_with_path);
- }
-
- g_free (file_with_path);
-}
-
-static void
-contact_groups_file_parse (const gchar *filename)
-{
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr contacts;
- xmlNodePtr account;
- xmlNodePtr node;
-
- DEBUG ("Attempting to parse file:'%s'...", filename);
-
- ctxt = xmlNewParserCtxt ();
-
- /* Parse and validate the file. */
- doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
- if (!doc) {
- g_warning ("Failed to parse file:'%s'", filename);
- xmlFreeParserCtxt (ctxt);
- return;
- }
-
- if (!empathy_xml_validate (doc, CONTACT_GROUPS_DTD_FILENAME)) {
- g_warning ("Failed to validate file:'%s'", filename);
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
- return;
- }
-
- /* The root node, contacts. */
- contacts = xmlDocGetRootElement (doc);
-
- account = NULL;
- node = contacts->children;
- while (node) {
- if (strcmp ((gchar *) node->name, "account") == 0) {
- account = node;
- break;
- }
- node = node->next;
- }
-
- node = NULL;
- if (account) {
- node = account->children;
- }
-
- while (node) {
- if (strcmp ((gchar *) node->name, "group") == 0) {
- gchar *name;
- gchar *expanded_str;
- gboolean expanded;
- ContactGroup *contact_group;
-
- name = (gchar *) xmlGetProp (node, "name");
- expanded_str = (gchar *) xmlGetProp (node, "expanded");
-
- if (expanded_str && strcmp (expanded_str, "yes") == 0) {
- expanded = TRUE;
- } else {
- expanded = FALSE;
- }
-
- contact_group = contact_group_new (name, expanded);
- groups = g_list_append (groups, contact_group);
-
- xmlFree (name);
- xmlFree (expanded_str);
- }
-
- node = node->next;
- }
-
- DEBUG ("Parsed %d contact groups", g_list_length (groups));
-
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
-}
-
-static ContactGroup *
-contact_group_new (const gchar *name,
- gboolean expanded)
-{
- ContactGroup *group;
-
- group = g_new0 (ContactGroup, 1);
-
- group->name = g_strdup (name);
- group->expanded = expanded;
-
- return group;
-}
-
-static void
-contact_group_free (ContactGroup *group)
-{
- g_return_if_fail (group != NULL);
-
- g_free (group->name);
-
- g_free (group);
-}
-
-static gboolean
-contact_groups_file_save (void)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
- xmlNodePtr node;
- GList *l;
- gchar *dir;
- gchar *file;
-
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
- g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
- file = g_build_filename (dir, CONTACT_GROUPS_XML_FILENAME, NULL);
- g_free (dir);
-
- doc = xmlNewDoc ("1.0");
- root = xmlNewNode (NULL, "contacts");
- xmlDocSetRootElement (doc, root);
-
- node = xmlNewChild (root, NULL, "account", NULL);
- xmlNewProp (node, "name", "Default");
-
- for (l = groups; l; l = l->next) {
- ContactGroup *cg;
- xmlNodePtr subnode;
-
- cg = l->data;
-
- subnode = xmlNewChild (node, NULL, "group", NULL);
- xmlNewProp (subnode, "expanded", cg->expanded ? "yes" : "no");
- xmlNewProp (subnode, "name", cg->name);
- }
-
- /* Make sure the XML is indented properly */
- xmlIndentTreeOutput = 1;
-
- DEBUG ("Saving file:'%s'", file);
- xmlSaveFormatFileEnc (file, doc, "utf-8", 1);
- xmlFreeDoc (doc);
-
- xmlCleanupParser ();
- xmlMemoryDump ();
-
- g_free (file);
-
- return TRUE;
-}
-
-gboolean
-empathy_contact_group_get_expanded (const gchar *group)
-{
- GList *l;
- gboolean default_val = TRUE;
-
- g_return_val_if_fail (group != NULL, default_val);
-
- for (l = groups; l; l = l->next) {
- ContactGroup *cg = l->data;
-
- if (!cg || !cg->name) {
- continue;
- }
-
- if (strcmp (cg->name, group) == 0) {
- return cg->expanded;
- }
- }
-
- return default_val;
-}
-
-void
-empathy_contact_group_set_expanded (const gchar *group,
- gboolean expanded)
-{
- GList *l;
- ContactGroup *cg;
- gboolean changed = FALSE;
-
- g_return_if_fail (group != NULL);
-
- for (l = groups; l; l = l->next) {
- ContactGroup *cg = l->data;
-
- if (!cg || !cg->name) {
- continue;
- }
-
- if (strcmp (cg->name, group) == 0) {
- cg->expanded = expanded;
- changed = TRUE;
- break;
- }
- }
-
- /* if here... we don't have a ContactGroup for the group. */
- if (!changed) {
- cg = contact_group_new (group, expanded);
- groups = g_list_append (groups, cg);
- }
-
- contact_groups_file_save ();
-}
diff --git a/libempathy/empathy-contact-groups.dtd b/libempathy/empathy-contact-groups.dtd
deleted file mode 100644
index b4de2260a..000000000
--- a/libempathy/empathy-contact-groups.dtd
+++ /dev/null
@@ -1,17 +0,0 @@
-<!--
- DTD for Empathys contact groups.
- by Martyn Russell <mr@gnome.org>
--->
-
-<!-- Root element. -->
-<!ELEMENT contacts (account)>
-
-<!ELEMENT account (group)+>
-<!ATTLIST account
- name CDATA #REQUIRED>
-
-<!-- Groups in the roster. -->
-<!ELEMENT group EMPTY>
-<!ATTLIST group
- name CDATA #REQUIRED
- expanded CDATA #REQUIRED>
diff --git a/libempathy/empathy-contact-groups.h b/libempathy/empathy-contact-groups.h
deleted file mode 100644
index e2e9810e3..000000000
--- a/libempathy/empathy-contact-groups.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2005 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Martyn Russell <martyn@imendio.com>
- */
-
-#ifndef __EMPATHY_CONTACT_GROUPS_H__
-#define __EMPATHY_CONTACT_GROUPS_H__
-
-G_BEGIN_DECLS
-
-#include <glib.h>
-
-void empathy_contact_groups_get_all (void);
-
-gboolean empathy_contact_group_get_expanded (const gchar *group);
-void empathy_contact_group_set_expanded (const gchar *group,
- gboolean expanded);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_GROUPS_H__ */
diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c
deleted file mode 100644
index 1fe894e99..000000000
--- a/libempathy/empathy-contact-list.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include "config.h"
-
-#include "empathy-contact-list.h"
-#include "empathy-marshal.h"
-
-static void contact_list_base_init (gpointer klass);
-
-GType
-empathy_contact_list_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo type_info = {
- sizeof (EmpathyContactListIface),
- contact_list_base_init,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EmpathyContactList",
- &type_info, 0);
-
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
- }
-
- return type;
-}
-
-static void
-contact_list_base_init (gpointer klass)
-{
- static gboolean initialized = FALSE;
-
- if (!initialized) {
- g_signal_new ("members-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
- G_TYPE_NONE,
- 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
-
- g_signal_new ("pendings-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
- G_TYPE_NONE,
- 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
-
- g_signal_new ("groups-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
- G_TYPE_NONE,
- 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
-
- initialized = TRUE;
- }
-}
-
-void
-empathy_contact_list_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
- }
-}
-
-void
-empathy_contact_list_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
- }
-}
-
-GList *
-empathy_contact_list_get_members (EmpathyContactList *list)
-{
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
- return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
- }
-
- return NULL;
-}
-
-EmpathyContactMonitor *
-empathy_contact_list_get_monitor (EmpathyContactList *list)
-{
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor) {
- return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor (list);
- }
-
- return NULL;
-}
-
-GList *
-empathy_contact_list_get_pendings (EmpathyContactList *list)
-{
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
- return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
- }
-
- return NULL;
-}
-
-GList *
-empathy_contact_list_get_all_groups (EmpathyContactList *list)
-{
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
- return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
- }
-
- return NULL;
-}
-
-GList *
-empathy_contact_list_get_groups (EmpathyContactList *list,
- EmpathyContact *contact)
-{
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
- return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
- }
-
- return NULL;
-}
-
-void
-empathy_contact_list_add_to_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (group != NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
- }
-}
-
-void
-empathy_contact_list_remove_from_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (group != NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
- }
-}
-
-void
-empathy_contact_list_rename_group (EmpathyContactList *list,
- const gchar *old_group,
- const gchar *new_group)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (old_group != NULL);
- g_return_if_fail (new_group != NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
- }
-}
-
-void
-empathy_contact_list_remove_group (EmpathyContactList *list,
- const gchar *group)
-{
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
- g_return_if_fail (group != NULL);
-
- if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
- EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
- }
-}
-
diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h
deleted file mode 100644
index 5eabf32c3..000000000
--- a/libempathy/empathy-contact-list.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_CONTACT_LIST_H__
-#define __EMPATHY_CONTACT_LIST_H__
-
-#include <glib-object.h>
-
-#include "empathy-types.h"
-#include "empathy-contact.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONTACT_LIST (empathy_contact_list_get_type ())
-#define EMPATHY_CONTACT_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyContactList))
-#define EMPATHY_IS_CONTACT_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST))
-#define EMPATHY_CONTACT_LIST_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyContactListIface))
-
-typedef struct _EmpathyContactListIface EmpathyContactListIface;
-
-struct _EmpathyContactListIface {
- GTypeInterface base_iface;
-
- /* VTabled */
- void (*add) (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
- void (*remove) (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
- GList * (*get_members) (EmpathyContactList *list);
- GList * (*get_pendings) (EmpathyContactList *list);
- GList * (*get_all_groups) (EmpathyContactList *list);
- GList * (*get_groups) (EmpathyContactList *list,
- EmpathyContact *contact);
- void (*add_to_group) (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group);
- void (*remove_from_group) (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group);
- void (*rename_group) (EmpathyContactList *list,
- const gchar *old_group,
- const gchar *new_group);
- void (*remove_group) (EmpathyContactList *list,
- const gchar *group);
- EmpathyContactMonitor *
- (*get_monitor) (EmpathyContactList *list);
-};
-
-GType empathy_contact_list_get_type (void) G_GNUC_CONST;
-void empathy_contact_list_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
-void empathy_contact_list_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
-GList * empathy_contact_list_get_members (EmpathyContactList *list);
-GList * empathy_contact_list_get_pendings (EmpathyContactList *list);
-GList * empathy_contact_list_get_all_groups (EmpathyContactList *list);
-GList * empathy_contact_list_get_groups (EmpathyContactList *list,
- EmpathyContact *contact);
-void empathy_contact_list_add_to_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group);
-void empathy_contact_list_remove_from_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group);
-void empathy_contact_list_rename_group (EmpathyContactList *list,
- const gchar *old_group,
- const gchar *new_group);
-void empathy_contact_list_remove_group (EmpathyContactList *list,
- const gchar *group);
-EmpathyContactMonitor *
- empathy_contact_list_get_monitor (EmpathyContactList *list);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_LIST_H__ */
-
diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c
deleted file mode 100644
index 409f41c44..000000000
--- a/libempathy/empathy-contact-manager.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <telepathy-glib/enums.h>
-
-#include "empathy-contact-manager.h"
-#include "empathy-account-manager.h"
-#include "empathy-contact-monitor.h"
-#include "empathy-contact-list.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactManager)
-typedef struct {
- GHashTable *lists;
- EmpathyAccountManager *account_manager;
- EmpathyContactMonitor *contact_monitor;
-} EmpathyContactManagerPriv;
-
-static void contact_manager_iface_init (EmpathyContactListIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyContactManager, empathy_contact_manager, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
- contact_manager_iface_init));
-
-static EmpathyContactManager *manager_singleton = NULL;
-
-static void
-contact_manager_members_changed_cb (EmpathyTpContactList *list,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- gchar *message,
- gboolean is_member,
- EmpathyContactManager *manager)
-{
- g_signal_emit_by_name (manager, "members-changed",
- contact, actor, reason, message, is_member);
-}
-
-static void
-contact_manager_pendings_changed_cb (EmpathyTpContactList *list,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- gchar *message,
- gboolean is_pending,
- EmpathyContactManager *manager)
-{
- g_signal_emit_by_name (manager, "pendings-changed",
- contact, actor, reason, message, is_pending);
-}
-
-static void
-contact_manager_groups_changed_cb (EmpathyTpContactList *list,
- EmpathyContact *contact,
- gchar *group,
- gboolean is_member,
- EmpathyContactManager *manager)
-{
- g_signal_emit_by_name (manager, "groups-changed",
- contact, group, is_member);
-}
-
-static void contact_manager_destroy_cb (EmpathyTpContactList *list,
- EmpathyContactManager *manager);
-
-static void
-contact_manager_disconnect_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- EmpathyTpContactList *list = value;
- EmpathyContactManager *manager = user_data;
-
- /* Disconnect signals from the list */
- g_signal_handlers_disconnect_by_func (list,
- contact_manager_members_changed_cb,
- manager);
- g_signal_handlers_disconnect_by_func (list,
- contact_manager_pendings_changed_cb,
- manager);
- g_signal_handlers_disconnect_by_func (list,
- contact_manager_groups_changed_cb,
- manager);
- g_signal_handlers_disconnect_by_func (list,
- contact_manager_destroy_cb,
- manager);
-}
-
-static void
-contact_manager_destroy_cb (EmpathyTpContactList *list,
- EmpathyContactManager *manager)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- McAccount *account;
-
- account = empathy_tp_contact_list_get_account (list);
-
- DEBUG ("Removing account: %s", mc_account_get_display_name (account));
-
- contact_manager_disconnect_foreach (account, list, manager);
- g_hash_table_remove (priv->lists, account);
-}
-
-static void
-contact_manager_add_account (EmpathyContactManager *manager,
- McAccount *account)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyTpContactList *list;
-
- if (g_hash_table_lookup (priv->lists, account)) {
- return;
- }
-
- DEBUG ("Adding new account: %s", mc_account_get_display_name (account));
-
- list = empathy_tp_contact_list_new (account);
- if (!list) {
- return;
- }
-
- g_hash_table_insert (priv->lists, g_object_ref (account), list);
-
- /* Connect signals */
- g_signal_connect (list, "members-changed",
- G_CALLBACK (contact_manager_members_changed_cb),
- manager);
- g_signal_connect (list, "pendings-changed",
- G_CALLBACK (contact_manager_pendings_changed_cb),
- manager);
- g_signal_connect (list, "groups-changed",
- G_CALLBACK (contact_manager_groups_changed_cb),
- manager);
- g_signal_connect (list, "destroy",
- G_CALLBACK (contact_manager_destroy_cb),
- manager);
-}
-
-static void
-contact_manager_connection_changed_cb (EmpathyAccountManager *account_manager,
- McAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
- EmpathyContactManager *manager)
-{
- if (current != TP_CONNECTION_STATUS_CONNECTED) {
- /* We only care about newly connected accounts */
- return;
- }
-
- contact_manager_add_account (manager, account);
-}
-
-static void
-contact_manager_finalize (GObject *object)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (object);
-
- g_hash_table_foreach (priv->lists,
- contact_manager_disconnect_foreach,
- object);
- g_hash_table_destroy (priv->lists);
-
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- contact_manager_connection_changed_cb,
- object);
- g_object_unref (priv->account_manager);
-
- if (priv->contact_monitor) {
- g_object_unref (priv->contact_monitor);
- }
-}
-
-static GObject *
-contact_manager_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *retval;
-
- if (manager_singleton) {
- retval = g_object_ref (manager_singleton);
- } else {
- retval = G_OBJECT_CLASS (empathy_contact_manager_parent_class)->constructor
- (type, n_props, props);
-
- manager_singleton = EMPATHY_CONTACT_MANAGER (retval);
- g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
- }
-
- return retval;
-}
-
-static void
-empathy_contact_manager_class_init (EmpathyContactManagerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = contact_manager_finalize;
- object_class->constructor = contact_manager_constructor;
-
- g_type_class_add_private (object_class, sizeof (EmpathyContactManagerPriv));
-}
-
-static void
-empathy_contact_manager_init (EmpathyContactManager *manager)
-{
- GSList *accounts, *l;
- MissionControl *mc;
- EmpathyContactManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv);
-
- manager->priv = priv;
- priv->lists = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal,
- (GDestroyNotify) g_object_unref,
- (GDestroyNotify) g_object_unref);
- priv->account_manager = empathy_account_manager_dup_singleton ();
- priv->contact_monitor = NULL;
-
- g_signal_connect (priv->account_manager,
- "account-connection-changed",
- G_CALLBACK (contact_manager_connection_changed_cb), manager);
-
- mc = empathy_mission_control_dup_singleton ();
-
- /* Get ContactList for existing connections */
- accounts = mission_control_get_online_connections (mc, NULL);
- for (l = accounts; l; l = l->next) {
- contact_manager_add_account (manager, l->data);
- g_object_unref (l->data);
- }
-
- g_slist_free (accounts);
- g_object_unref (mc);
-}
-
-EmpathyContactManager *
-empathy_contact_manager_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_CONTACT_MANAGER, NULL);
-}
-
-EmpathyTpContactList *
-empathy_contact_manager_get_list (EmpathyContactManager *manager,
- McAccount *account)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
-
- return g_hash_table_lookup (priv->lists, account);
-}
-
-static void
-contact_manager_add (EmpathyContactList *manager,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyContactList *list;
- McAccount *account;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- account = empathy_contact_get_account (contact);
- list = g_hash_table_lookup (priv->lists, account);
-
- if (list) {
- empathy_contact_list_add (list, contact, message);
- }
-}
-
-static void
-contact_manager_remove (EmpathyContactList *manager,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyContactList *list;
- McAccount *account;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- account = empathy_contact_get_account (contact);
- list = g_hash_table_lookup (priv->lists, account);
-
- if (list) {
- empathy_contact_list_remove (list, contact, message);
- }
-}
-
-static void
-contact_manager_get_members_foreach (McAccount *account,
- EmpathyTpContactList *list,
- GList **contacts)
-{
- GList *l;
-
- l = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (list));
- *contacts = g_list_concat (*contacts, l);
-}
-
-static GList *
-contact_manager_get_members (EmpathyContactList *manager)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- GList *contacts = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
-
- g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_get_members_foreach,
- &contacts);
-
- return contacts;
-}
-
-static EmpathyContactMonitor *
-contact_manager_get_monitor (EmpathyContactList *manager)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
-
- if (priv->contact_monitor == NULL) {
- priv->contact_monitor = empathy_contact_monitor_new_for_iface (manager);
- }
-
- return priv->contact_monitor;
-}
-
-static void
-contact_manager_get_pendings_foreach (McAccount *account,
- EmpathyTpContactList *list,
- GList **contacts)
-{
- GList *l;
-
- l = empathy_contact_list_get_pendings (EMPATHY_CONTACT_LIST (list));
- *contacts = g_list_concat (*contacts, l);
-}
-
-static GList *
-contact_manager_get_pendings (EmpathyContactList *manager)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- GList *contacts = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
-
- g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_get_pendings_foreach,
- &contacts);
-
- return contacts;
-}
-
-static void
-contact_manager_get_all_groups_foreach (McAccount *account,
- EmpathyTpContactList *list,
- GList **all_groups)
-{
- GList *groups, *l;
-
- groups = empathy_contact_list_get_all_groups (EMPATHY_CONTACT_LIST (list));
- for (l = groups; l; l = l->next) {
- if (!g_list_find_custom (*all_groups,
- l->data,
- (GCompareFunc) strcmp)) {
- *all_groups = g_list_prepend (*all_groups, l->data);
- } else {
- g_free (l->data);
- }
- }
-
- g_list_free (groups);
-}
-
-static GList *
-contact_manager_get_all_groups (EmpathyContactList *manager)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- GList *groups = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
-
- g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_get_all_groups_foreach,
- &groups);
-
- return groups;
-}
-
-static GList *
-contact_manager_get_groups (EmpathyContactList *manager,
- EmpathyContact *contact)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyContactList *list;
- McAccount *account;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
-
- account = empathy_contact_get_account (contact);
- list = g_hash_table_lookup (priv->lists, account);
-
- if (list) {
- return empathy_contact_list_get_groups (list, contact);
- }
-
- return NULL;
-}
-
-static void
-contact_manager_add_to_group (EmpathyContactList *manager,
- EmpathyContact *contact,
- const gchar *group)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyContactList *list;
- McAccount *account;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- account = empathy_contact_get_account (contact);
- list = g_hash_table_lookup (priv->lists, account);
-
- if (list) {
- empathy_contact_list_add_to_group (list, contact, group);
- }
-}
-
-static void
-contact_manager_remove_from_group (EmpathyContactList *manager,
- EmpathyContact *contact,
- const gchar *group)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyContactList *list;
- McAccount *account;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- account = empathy_contact_get_account (contact);
- list = g_hash_table_lookup (priv->lists, account);
-
- if (list) {
- empathy_contact_list_remove_from_group (list, contact, group);
- }
-}
-
-typedef struct {
- const gchar *old_group;
- const gchar *new_group;
-} RenameGroupData;
-
-static void
-contact_manager_rename_group_foreach (McAccount *account,
- EmpathyTpContactList *list,
- RenameGroupData *data)
-{
- empathy_contact_list_rename_group (EMPATHY_CONTACT_LIST (list),
- data->old_group,
- data->new_group);
-}
-
-static void
-contact_manager_rename_group (EmpathyContactList *manager,
- const gchar *old_group,
- const gchar *new_group)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- RenameGroupData data;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- data.old_group = old_group;
- data.new_group = new_group;
- g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_rename_group_foreach,
- &data);
-}
-
-static void contact_manager_remove_group_foreach (McAccount *account,
- EmpathyTpContactList *list,
- const gchar *group)
-{
- empathy_contact_list_remove_group (EMPATHY_CONTACT_LIST (list),
- group);
-}
-
-static void
-contact_manager_remove_group (EmpathyContactList *manager,
- const gchar *group)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
-
- g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_remove_group_foreach,
- (gpointer) group);
-}
-
-static void
-contact_manager_iface_init (EmpathyContactListIface *iface)
-{
- iface->add = contact_manager_add;
- iface->remove = contact_manager_remove;
- iface->get_members = contact_manager_get_members;
- iface->get_monitor = contact_manager_get_monitor;
- iface->get_pendings = contact_manager_get_pendings;
- iface->get_all_groups = contact_manager_get_all_groups;
- iface->get_groups = contact_manager_get_groups;
- iface->add_to_group = contact_manager_add_to_group;
- iface->remove_from_group = contact_manager_remove_from_group;
- iface->rename_group = contact_manager_rename_group;
- iface->remove_group = contact_manager_remove_group;
-}
-
-gboolean
-empathy_contact_manager_can_add (EmpathyContactManager *manager,
- McAccount *account)
-{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
- EmpathyTpContactList *list;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE);
-
- list = g_hash_table_lookup (priv->lists, account);
- if (list == NULL)
- return FALSE;
-
- return empathy_tp_contact_list_can_add (list);
-}
-
diff --git a/libempathy/empathy-contact-manager.h b/libempathy/empathy-contact-manager.h
deleted file mode 100644
index 57e8764e4..000000000
--- a/libempathy/empathy-contact-manager.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_CONTACT_MANAGER_H__
-#define __EMPATHY_CONTACT_MANAGER_H__
-
-#include <glib.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-contact.h"
-#include "empathy-tp-contact-list.h"
-#include "empathy-contact-list.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONTACT_MANAGER (empathy_contact_manager_get_type ())
-#define EMPATHY_CONTACT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManager))
-#define EMPATHY_CONTACT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerClass))
-#define EMPATHY_IS_CONTACT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_MANAGER))
-#define EMPATHY_IS_CONTACT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_MANAGER))
-#define EMPATHY_CONTACT_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerClass))
-
-typedef struct _EmpathyContactManager EmpathyContactManager;
-typedef struct _EmpathyContactManagerClass EmpathyContactManagerClass;
-
-struct _EmpathyContactManager {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyContactManagerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_contact_manager_get_type (void) G_GNUC_CONST;
-EmpathyContactManager *empathy_contact_manager_dup_singleton (void);
-EmpathyTpContactList * empathy_contact_manager_get_list (EmpathyContactManager *manager,
- McAccount *account);
-gboolean empathy_contact_manager_can_add (EmpathyContactManager *manager,
- McAccount *account);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_MANAGER_H__ */
diff --git a/libempathy/empathy-contact-monitor.c b/libempathy/empathy-contact-monitor.c
deleted file mode 100644
index 2213a330b..000000000
--- a/libempathy/empathy-contact-monitor.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <glib-object.h>
-#include <libmissioncontrol/mc-enum-types.h>
-
-#include "empathy-contact-monitor.h"
-#include "empathy-contact-list.h"
-
-#include "empathy-contact.h"
-#include "empathy-utils.h"
-#include "empathy-marshal.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactMonitor)
-
-typedef struct {
- EmpathyContactList *iface;
- GList *contacts;
-
- gboolean dispose_run;
-} EmpathyContactMonitorPriv;
-
-enum {
- CONTACT_ADDED,
- CONTACT_AVATAR_CHANGED,
- CONTACT_CAPABILITIES_CHANGED,
- CONTACT_NAME_CHANGED,
- CONTACT_PRESENCE_CHANGED,
- CONTACT_PRESENCE_MESSAGE_CHANGED,
- CONTACT_REMOVED,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_IFACE
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (EmpathyContactMonitor, empathy_contact_monitor, G_TYPE_OBJECT);
-
-static void
-contact_monitor_presence_changed_cb (EmpathyContact *contact,
- McPresence current_presence,
- McPresence previous_presence,
- EmpathyContactMonitor *self)
-{
- g_signal_emit (self, signals[CONTACT_PRESENCE_CHANGED], 0, contact,
- current_presence, previous_presence);
-}
-
-static void
-contact_monitor_presence_message_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec,
- EmpathyContactMonitor *self)
-{
- const char *status;
-
- /* use the status so that we always have a presence message */
- status = empathy_contact_get_status (contact);
-
- g_signal_emit (self, signals[CONTACT_PRESENCE_MESSAGE_CHANGED], 0,
- contact, status);
-}
-
-static void
-contact_monitor_name_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec,
- EmpathyContactMonitor *self)
-{
- const char *name;
-
- name = empathy_contact_get_name (contact);
-
- g_signal_emit (self, signals[CONTACT_NAME_CHANGED], 0, contact, name);
-}
-
-static void
-contact_monitor_avatar_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec,
- EmpathyContactMonitor *self)
-{
- /* don't emit a pixbuf in the signal, as we don't depend on GTK+ here
- */
-
- g_signal_emit (self, signals[CONTACT_AVATAR_CHANGED], 0, contact);
-}
-
-static void
-contact_monitor_capabilities_changed_cb (EmpathyContact *contact,
- GParamSpec *pspec,
- EmpathyContactMonitor *self)
-{
- g_signal_emit (self, signals[CONTACT_CAPABILITIES_CHANGED], 0, contact);
-}
-
-static void
-contact_add (EmpathyContactMonitor *monitor,
- EmpathyContact *contact)
-{
- EmpathyContactMonitorPriv *priv = GET_PRIV (monitor);
-
- g_signal_connect (contact, "presence-changed",
- G_CALLBACK (contact_monitor_presence_changed_cb),
- monitor);
- g_signal_connect (contact, "notify::presence-message",
- G_CALLBACK (contact_monitor_presence_message_changed_cb),
- monitor);
- g_signal_connect (contact, "notify::name",
- G_CALLBACK (contact_monitor_name_changed_cb),
- monitor);
- g_signal_connect (contact, "notify::avatar",
- G_CALLBACK (contact_monitor_avatar_changed_cb),
- monitor);
- g_signal_connect (contact, "notify::capabilities",
- G_CALLBACK (contact_monitor_capabilities_changed_cb),
- monitor);
-
- priv->contacts = g_list_prepend (priv->contacts, g_object_ref (contact));
-
- g_signal_emit (monitor, signals[CONTACT_ADDED], 0, contact);
-}
-
-static void
-contact_remove (EmpathyContactMonitor *monitor,
- EmpathyContact *contact)
-{
- EmpathyContactMonitorPriv *priv = GET_PRIV (monitor);
-
- g_signal_handlers_disconnect_by_func (contact,
- G_CALLBACK (contact_monitor_presence_changed_cb),
- monitor);
- g_signal_handlers_disconnect_by_func (contact,
- G_CALLBACK (contact_monitor_presence_message_changed_cb),
- monitor);
- g_signal_handlers_disconnect_by_func (contact,
- G_CALLBACK (contact_monitor_name_changed_cb),
- monitor);
- g_signal_handlers_disconnect_by_func (contact,
- G_CALLBACK (contact_monitor_avatar_changed_cb),
- monitor);
- g_signal_handlers_disconnect_by_func (contact,
- G_CALLBACK (contact_monitor_capabilities_changed_cb),
- monitor);
-
- priv->contacts = g_list_remove (priv->contacts, contact);
-
- g_signal_emit (monitor, signals[CONTACT_REMOVED], 0, contact);
-
- g_object_unref (contact);
-}
-
-static void
-contact_remove_foreach (EmpathyContact *contact,
- EmpathyContactMonitor *monitor)
-{
- contact_remove (monitor, contact);
-}
-
-static void
-cl_members_changed_cb (EmpathyContactList *cl,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- gchar *message,
- gboolean is_member,
- EmpathyContactMonitor *monitor)
-{
- if (is_member)
- contact_add (monitor, contact);
- else
- contact_remove (monitor, contact);
-}
-
-static void
-do_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (param_id)
- {
- case PROP_IFACE:
- empathy_contact_monitor_set_iface (EMPATHY_CONTACT_MONITOR (object),
- g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-do_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyContactMonitorPriv *priv = GET_PRIV (object);
-
- switch (param_id)
- {
- case PROP_IFACE:
- g_value_set_object (value, priv->iface);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-do_finalize (GObject *obj)
-{
- EmpathyContactMonitorPriv *priv;
-
- priv = GET_PRIV (obj);
-
- if (priv->contacts)
- {
- g_list_free (priv->contacts);
- priv->contacts = NULL;
- }
-
- if (priv->iface)
- g_signal_handlers_disconnect_by_func (priv->iface,
- cl_members_changed_cb, obj);
-
- G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->finalize (obj);
-}
-
-static void
-do_dispose (GObject *obj)
-{
- EmpathyContactMonitorPriv *priv;
-
- priv = GET_PRIV (obj);
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- if (priv->contacts)
- g_list_foreach (priv->contacts,
- (GFunc) contact_remove_foreach, obj);
-
- if (priv->iface)
- g_signal_handlers_disconnect_by_func (priv->iface,
- cl_members_changed_cb, obj);
-
- G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->dispose (obj);
-}
-
-static void
-empathy_contact_monitor_class_init (EmpathyContactMonitorClass *klass)
-{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
-
- oclass->finalize = do_finalize;
- oclass->dispose = do_dispose;
- oclass->get_property = do_get_property;
- oclass->set_property = do_set_property;
-
- g_object_class_install_property (oclass,
- PROP_IFACE,
- g_param_spec_object ("iface",
- "Monitor's iface",
- "The contact list we're monitoring",
- EMPATHY_TYPE_CONTACT_LIST,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- signals[CONTACT_ADDED] =
- g_signal_new ("contact-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CONTACT);
- signals[CONTACT_AVATAR_CHANGED] =
- g_signal_new ("contact-avatar-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CONTACT);
- signals[CONTACT_CAPABILITIES_CHANGED] =
- g_signal_new ("contact-capabilities-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CONTACT);
- signals[CONTACT_NAME_CHANGED] =
- g_signal_new ("contact-name-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_STRING,
- G_TYPE_NONE,
- 2, EMPATHY_TYPE_CONTACT,
- G_TYPE_STRING);
- signals[CONTACT_PRESENCE_CHANGED] =
- g_signal_new ("contact-presence-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_ENUM_ENUM,
- G_TYPE_NONE,
- 3, EMPATHY_TYPE_CONTACT,
- MC_TYPE_PRESENCE,
- MC_TYPE_PRESENCE);
- signals[CONTACT_PRESENCE_MESSAGE_CHANGED] =
- g_signal_new ("contact-presence-message-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_STRING,
- G_TYPE_NONE,
- 2, EMPATHY_TYPE_CONTACT,
- G_TYPE_STRING);
- signals[CONTACT_REMOVED] =
- g_signal_new ("contact-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CONTACT);
-
- g_type_class_add_private (klass, sizeof (EmpathyContactMonitorPriv));
-}
-
-static void
-empathy_contact_monitor_init (EmpathyContactMonitor *self)
-{
- EmpathyContactMonitorPriv *priv =
- G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_CONTACT_MONITOR,
- EmpathyContactMonitorPriv);
-
- self->priv = priv;
- priv->contacts = NULL;
- priv->iface = NULL;
- priv->dispose_run = FALSE;
-}
-
-/* public methods */
-
-void
-empathy_contact_monitor_set_iface (EmpathyContactMonitor *self,
- EmpathyContactList *iface)
-{
- EmpathyContactMonitorPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT_MONITOR (self));
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST (iface));
-
- priv = GET_PRIV (self);
-
- if (priv->contacts != NULL)
- {
- g_list_foreach (priv->contacts,
- (GFunc) contact_remove_foreach, self);
- g_list_free (priv->contacts);
- priv->contacts = NULL;
- }
-
- priv->iface = iface;
-
- g_signal_connect (iface, "members-changed",
- G_CALLBACK (cl_members_changed_cb), self);
-}
-
-EmpathyContactMonitor *
-empathy_contact_monitor_new_for_iface (EmpathyContactList *iface)
-{
- EmpathyContactMonitor *retval;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (iface), NULL);
-
- retval = g_object_new (EMPATHY_TYPE_CONTACT_MONITOR,
- "iface", iface, NULL);
-
- return retval;
-}
-
diff --git a/libempathy/empathy-contact-monitor.h b/libempathy/empathy-contact-monitor.h
deleted file mode 100644
index 76b943668..000000000
--- a/libempathy/empathy-contact-monitor.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_CONTACT_MONITOR_H__
-#define __EMPATHY_CONTACT_MONITOR_H__
-
-#include <glib-object.h>
-
-#include "empathy-types.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONTACT_MONITOR (empathy_contact_monitor_get_type ())
-#define EMPATHY_CONTACT_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_MONITOR, EmpathyContactMonitor))
-#define EMPATHY_CONTACT_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CONTACT_MONITOR, EmpathyContactMonitorClass))
-#define EMPATHY_IS_CONTACT_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_MONITOR))
-#define EMPATHY_IS_CONTACT_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_MONITOR))
-#define EMPATHY_CONTACT_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_MONITOR, EmpathyContactMonitorClass))
-
-typedef struct _EmpathyContactMonitorClass EmpathyContactMonitorClass;
-
-struct _EmpathyContactMonitor {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyContactMonitorClass {
- GObjectClass parent_class;
-};
-
-GType empathy_contact_monitor_get_type (void);
-
-/* public methods */
-
-void
-empathy_contact_monitor_set_iface (EmpathyContactMonitor *self,
- EmpathyContactList *iface);
-
-EmpathyContactMonitor *
-empathy_contact_monitor_new_for_iface (EmpathyContactList *iface);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_MONITOR_H__ */
-
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
deleted file mode 100644
index 59d55fd4d..000000000
--- a/libempathy/empathy-contact.c
+++ /dev/null
@@ -1,1118 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2004 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Mikael Hallendal <micke@imendio.com>
- * Martyn Russell <martyn@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-enum-types.h>
-
-#include "empathy-contact.h"
-#include "empathy-contact-factory.h"
-#include "empathy-utils.h"
-#include "empathy-enum-types.h"
-#include "empathy-marshal.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
-typedef struct {
- EmpathyContactFactory *factory;
- gchar *id;
- gchar *name;
- EmpathyAvatar *avatar;
- McAccount *account;
- McPresence presence;
- gchar *presence_message;
- guint handle;
- EmpathyCapabilities capabilities;
- gboolean is_user;
- guint hash;
- EmpathyContactReady ready;
- GList *ready_callbacks;
-} EmpathyContactPriv;
-
-typedef struct {
- EmpathyContactReady ready;
- EmpathyContactReadyCb *callback;
- gpointer user_data;
- GDestroyNotify destroy;
- GObject *weak_object;
-} ReadyCbData;
-
-static void contact_finalize (GObject *object);
-static void contact_get_property (GObject *object, guint param_id,
- GValue *value, GParamSpec *pspec);
-static void contact_set_property (GObject *object, guint param_id,
- const GValue *value, GParamSpec *pspec);
-
-G_DEFINE_TYPE (EmpathyContact, empathy_contact, G_TYPE_OBJECT);
-
-enum
-{
- PROP_0,
- PROP_ID,
- PROP_NAME,
- PROP_AVATAR,
- PROP_ACCOUNT,
- PROP_PRESENCE,
- PROP_PRESENCE_MESSAGE,
- PROP_HANDLE,
- PROP_CAPABILITIES,
- PROP_IS_USER,
- PROP_READY
-};
-
-enum {
- PRESENCE_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-contact_dispose (GObject *object)
-{
- EmpathyContactPriv *priv = GET_PRIV (object);
-
- if (priv->account)
- g_object_unref (priv->account);
- priv->account = NULL;
-
- if (priv->factory)
- g_object_unref (priv->factory);
- priv->factory = NULL;
-
- G_OBJECT_CLASS (empathy_contact_parent_class)->dispose (object);
-}
-
-static void
-empathy_contact_class_init (EmpathyContactClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = contact_finalize;
- object_class->dispose = contact_dispose;
- object_class->get_property = contact_get_property;
- object_class->set_property = contact_set_property;
-
- g_object_class_install_property (object_class,
- PROP_ID,
- g_param_spec_string ("id",
- "Contact id",
- "String identifying contact",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- "Contact Name",
- "The name of the contact",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_AVATAR,
- g_param_spec_boxed ("avatar",
- "Avatar image",
- "The avatar image",
- EMPATHY_TYPE_AVATAR,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_ACCOUNT,
- g_param_spec_object ("account",
- "Contact Account",
- "The account associated with the contact",
- MC_TYPE_ACCOUNT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_PRESENCE,
- g_param_spec_uint ("presence",
- "Contact presence",
- "Presence of contact",
- MC_PRESENCE_UNSET,
- LAST_MC_PRESENCE,
- MC_PRESENCE_UNSET,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_PRESENCE_MESSAGE,
- g_param_spec_string ("presence-message",
- "Contact presence message",
- "Presence message of contact",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_HANDLE,
- g_param_spec_uint ("handle",
- "Contact Handle",
- "The handle of the contact",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_CAPABILITIES,
- g_param_spec_flags ("capabilities",
- "Contact Capabilities",
- "Capabilities of the contact",
- EMPATHY_TYPE_CAPABILITIES,
- EMPATHY_CAPABILITIES_UNKNOWN,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_IS_USER,
- g_param_spec_boolean ("is-user",
- "Contact is-user",
- "Is contact the user",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_READY,
- g_param_spec_flags ("ready",
- "Contact ready flags",
- "Flags for ready properties",
- EMPATHY_TYPE_CONTACT_READY,
- EMPATHY_CONTACT_READY_NONE,
- G_PARAM_READABLE));
-
- signals[PRESENCE_CHANGED] =
- g_signal_new ("presence-changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__ENUM_ENUM,
- G_TYPE_NONE,
- 2, MC_TYPE_PRESENCE,
- MC_TYPE_PRESENCE);
-
- g_type_class_add_private (object_class, sizeof (EmpathyContactPriv));
-}
-
-static void
-empathy_contact_init (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (contact,
- EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
-
- contact->priv = priv;
-
- /* Keep a ref to the factory to be sure it is not finalized while there is
- * still contacts alive. */
- priv->factory = empathy_contact_factory_dup_singleton ();
-}
-
-static void
-contact_finalize (GObject *object)
-{
- EmpathyContactPriv *priv;
- GList *l;
-
- priv = GET_PRIV (object);
-
- DEBUG ("finalize: %p", object);
-
- g_free (priv->name);
- g_free (priv->id);
- g_free (priv->presence_message);
-
- for (l = priv->ready_callbacks; l != NULL; l = g_list_next (l))
- {
- ReadyCbData *d = (ReadyCbData *)l->data;
-
- if (d->destroy != NULL)
- d->destroy (d->user_data);
- g_slice_free (ReadyCbData, d);
- }
-
- g_list_free (priv->ready_callbacks);
- priv->ready_callbacks = NULL;
-
- if (priv->avatar)
- empathy_avatar_unref (priv->avatar);
-
- G_OBJECT_CLASS (empathy_contact_parent_class)->finalize (object);
-}
-
-static void
-contact_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyContactPriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id)
- {
- case PROP_ID:
- g_value_set_string (value, priv->id);
- break;
- case PROP_NAME:
- g_value_set_string (value,
- empathy_contact_get_name (EMPATHY_CONTACT (object)));
- break;
- case PROP_AVATAR:
- g_value_set_boxed (value, priv->avatar);
- break;
- case PROP_ACCOUNT:
- g_value_set_object (value, priv->account);
- break;
- case PROP_PRESENCE:
- g_value_set_uint (value, priv->presence);
- break;
- case PROP_PRESENCE_MESSAGE:
- g_value_set_string (value, priv->presence_message);
- break;
- case PROP_HANDLE:
- g_value_set_uint (value, priv->handle);
- break;
- case PROP_CAPABILITIES:
- g_value_set_flags (value, priv->capabilities);
- break;
- case PROP_IS_USER:
- g_value_set_boolean (value, priv->is_user);
- break;
- case PROP_READY:
- g_value_set_flags (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-contact_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyContactPriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id)
- {
- case PROP_ID:
- empathy_contact_set_id (EMPATHY_CONTACT (object),
- g_value_get_string (value));
- break;
- case PROP_NAME:
- empathy_contact_set_name (EMPATHY_CONTACT (object),
- g_value_get_string (value));
- break;
- case PROP_AVATAR:
- empathy_contact_set_avatar (EMPATHY_CONTACT (object),
- g_value_get_boxed (value));
- break;
- case PROP_ACCOUNT:
- empathy_contact_set_account (EMPATHY_CONTACT (object),
- MC_ACCOUNT (g_value_get_object (value)));
- break;
- case PROP_PRESENCE:
- empathy_contact_set_presence (EMPATHY_CONTACT (object),
- g_value_get_uint (value));
- break;
- case PROP_PRESENCE_MESSAGE:
- empathy_contact_set_presence_message (EMPATHY_CONTACT (object),
- g_value_get_string (value));
- break;
- case PROP_HANDLE:
- empathy_contact_set_handle (EMPATHY_CONTACT (object),
- g_value_get_uint (value));
- break;
- case PROP_CAPABILITIES:
- empathy_contact_set_capabilities (EMPATHY_CONTACT (object),
- g_value_get_flags (value));
- break;
- case PROP_IS_USER:
- empathy_contact_set_is_user (EMPATHY_CONTACT (object),
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static gboolean
-contact_is_ready (EmpathyContact *contact, EmpathyContactReady ready)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- /* When the name is NULL, empathy_contact_get_name() fallback to the id.
- * When the caller want to wait the name to be ready, it also want to wait
- * the id to be ready in case of fallback. */
- if ((ready & EMPATHY_CONTACT_READY_NAME) && EMP_STR_EMPTY (priv->name))
- ready |= EMPATHY_CONTACT_READY_ID;
-
- return (priv->ready & ready) == ready;
-}
-
-static void
-contact_weak_object_notify (gpointer data, GObject *old_object)
-{
- EmpathyContact *contact = EMPATHY_CONTACT (data);
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- GList *l, *ln;
-
- for (l = priv->ready_callbacks ; l != NULL ; l = ln )
- {
- ReadyCbData *d = (ReadyCbData *)l->data;
- ln = g_list_next (l);
-
- if (d->weak_object == old_object)
- {
- if (d->destroy != NULL)
- d->destroy (d->user_data);
-
- priv->ready_callbacks = g_list_delete_link (priv->ready_callbacks,
- l);
-
- g_slice_free (ReadyCbData, d);
- }
- }
-}
-
-static void
-contact_call_ready_callback (EmpathyContact *contact, const GError *error,
- ReadyCbData *data)
-{
- data->callback (contact, error, data->user_data, data->weak_object);
- if (data->destroy != NULL)
- data->destroy (data->user_data);
-
- if (data->weak_object)
- g_object_weak_unref (data->weak_object,
- contact_weak_object_notify, contact);
-}
-
-
-static void
-contact_set_ready_flag (EmpathyContact *contact,
- EmpathyContactReady flag)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- if (!(priv->ready & flag))
- {
- GList *l, *ln;
-
- priv->ready |= flag;
- g_object_notify (G_OBJECT (contact), "ready");
-
- for (l = priv->ready_callbacks ; l != NULL ; l = ln )
- {
- ReadyCbData *d = (ReadyCbData *)l->data;
- ln = g_list_next (l);
-
- if (contact_is_ready (contact, d->ready))
- {
- contact_call_ready_callback (contact, NULL, d);
- priv->ready_callbacks = g_list_delete_link
- (priv->ready_callbacks, l);
- g_slice_free (ReadyCbData, d);
- }
- }
- }
-}
-
-EmpathyContact *
-empathy_contact_new (McAccount *account)
-{
- return g_object_new (EMPATHY_TYPE_CONTACT,
- "account", account,
- NULL);
-}
-
-EmpathyContact *
-empathy_contact_new_full (McAccount *account,
- const gchar *id,
- const gchar *name)
-{
- return g_object_new (EMPATHY_TYPE_CONTACT,
- "account", account,
- "name", name,
- "id", id,
- NULL);
-}
-
-const gchar *
-empathy_contact_get_id (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- priv = GET_PRIV (contact);
-
- return priv->id;
-}
-
-void
-empathy_contact_set_id (EmpathyContact *contact,
- const gchar *id)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (id != NULL);
-
- priv = GET_PRIV (contact);
-
- /* We temporally ref the contact because it could be destroyed
- * during the signal emition */
- g_object_ref (contact);
- if (tp_strdiff (id, priv->id))
- {
- g_free (priv->id);
- priv->id = g_strdup (id);
-
- g_object_notify (G_OBJECT (contact), "id");
- if (EMP_STR_EMPTY (priv->name))
- g_object_notify (G_OBJECT (contact), "name");
- }
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID);
-
- g_object_unref (contact);
-}
-
-const gchar *
-empathy_contact_get_name (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- priv = GET_PRIV (contact);
-
- if (EMP_STR_EMPTY (priv->name))
- return empathy_contact_get_id (contact);
-
- return priv->name;
-}
-
-void
-empathy_contact_set_name (EmpathyContact *contact,
- const gchar *name)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- g_object_ref (contact);
- if (tp_strdiff (name, priv->name))
- {
- g_free (priv->name);
- priv->name = g_strdup (name);
- g_object_notify (G_OBJECT (contact), "name");
- }
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME);
- g_object_unref (contact);
-}
-
-EmpathyAvatar *
-empathy_contact_get_avatar (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- priv = GET_PRIV (contact);
-
- return priv->avatar;
-}
-
-void
-empathy_contact_set_avatar (EmpathyContact *contact,
- EmpathyAvatar *avatar)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- if (priv->avatar == avatar)
- return;
-
- if (priv->avatar)
- {
- empathy_avatar_unref (priv->avatar);
- priv->avatar = NULL;
- }
-
- if (avatar)
- priv->avatar = empathy_avatar_ref (avatar);
-
- g_object_notify (G_OBJECT (contact), "avatar");
-}
-
-McAccount *
-empathy_contact_get_account (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- priv = GET_PRIV (contact);
-
- return priv->account;
-}
-
-void
-empathy_contact_set_account (EmpathyContact *contact,
- McAccount *account)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (MC_IS_ACCOUNT (account));
-
- priv = GET_PRIV (contact);
-
- if (account == priv->account)
- return;
-
- if (priv->account)
- g_object_unref (priv->account);
- priv->account = g_object_ref (account);
-
- g_object_notify (G_OBJECT (contact), "account");
-}
-
-McPresence
-empathy_contact_get_presence (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
-
- priv = GET_PRIV (contact);
-
- return priv->presence;
-}
-
-void
-empathy_contact_set_presence (EmpathyContact *contact,
- McPresence presence)
-{
- EmpathyContactPriv *priv;
- McPresence old_presence;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- if (presence == priv->presence)
- return;
-
- old_presence = priv->presence;
- priv->presence = presence;
-
- g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence, old_presence);
-
- g_object_notify (G_OBJECT (contact), "presence");
-}
-
-const gchar *
-empathy_contact_get_presence_message (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- priv = GET_PRIV (contact);
-
- return priv->presence_message;
-}
-
-void
-empathy_contact_set_presence_message (EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- if (!tp_strdiff (message, priv->presence_message))
- return;
-
- g_free (priv->presence_message);
- priv->presence_message = g_strdup (message);
-
- g_object_notify (G_OBJECT (contact), "presence-message");
-}
-
-guint
-empathy_contact_get_handle (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
-
- priv = GET_PRIV (contact);
-
- return priv->handle;
-}
-
-void
-empathy_contact_set_handle (EmpathyContact *contact,
- guint handle)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- g_object_ref (contact);
- if (handle != priv->handle)
- {
- priv->handle = handle;
- g_object_notify (G_OBJECT (contact), "handle");
- }
- contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE);
- g_object_unref (contact);
-}
-
-EmpathyCapabilities
-empathy_contact_get_capabilities (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), 0);
-
- priv = GET_PRIV (contact);
-
- return priv->capabilities;
-}
-
-void
-empathy_contact_set_capabilities (EmpathyContact *contact,
- EmpathyCapabilities capabilities)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- if (priv->capabilities == capabilities)
- return;
-
- priv->capabilities = capabilities;
-
- g_object_notify (G_OBJECT (contact), "capabilities");
-}
-
-gboolean
-empathy_contact_is_user (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- priv = GET_PRIV (contact);
-
- return priv->is_user;
-}
-
-void
-empathy_contact_set_is_user (EmpathyContact *contact,
- gboolean is_user)
-{
- EmpathyContactPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (contact);
-
- if (priv->is_user == is_user)
- return;
-
- priv->is_user = is_user;
-
- g_object_notify (G_OBJECT (contact), "is-user");
-}
-
-gboolean
-empathy_contact_is_online (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- priv = GET_PRIV (contact);
-
- return (priv->presence > MC_PRESENCE_OFFLINE);
-}
-
-const gchar *
-empathy_contact_get_status (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), "");
-
- priv = GET_PRIV (contact);
-
- if (priv->presence_message)
- return priv->presence_message;
-
- return empathy_presence_get_default_message (priv->presence);
-}
-
-gboolean
-empathy_contact_can_voip (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- priv = GET_PRIV (contact);
-
- return priv->capabilities & (EMPATHY_CAPABILITIES_AUDIO |
- EMPATHY_CAPABILITIES_VIDEO);
-}
-
-gboolean
-empathy_contact_can_send_files (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- priv = GET_PRIV (contact);
-
- return priv->capabilities & EMPATHY_CAPABILITIES_FT;
-}
-
-EmpathyContactReady
-empathy_contact_get_ready (EmpathyContact *contact)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- priv = GET_PRIV (contact);
-
- return priv->ready;
-}
-
-gboolean
-empathy_contact_equal (gconstpointer v1,
- gconstpointer v2)
-{
- McAccount *account_a;
- McAccount *account_b;
- const gchar *id_a;
- const gchar *id_b;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (v1), FALSE);
- g_return_val_if_fail (EMPATHY_IS_CONTACT (v2), FALSE);
-
- account_a = empathy_contact_get_account (EMPATHY_CONTACT (v1));
- account_b = empathy_contact_get_account (EMPATHY_CONTACT (v2));
-
- id_a = empathy_contact_get_id (EMPATHY_CONTACT (v1));
- id_b = empathy_contact_get_id (EMPATHY_CONTACT (v2));
-
- return empathy_account_equal (account_a, account_b) &&
- !tp_strdiff (id_a, id_b);
-}
-
-guint
-empathy_contact_hash (gconstpointer key)
-{
- EmpathyContactPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (key), +1);
-
- priv = GET_PRIV (EMPATHY_CONTACT (key));
-
- if (priv->hash == 0)
- {
- priv->hash = empathy_account_hash (priv->account) ^
- g_str_hash (priv->id);
- }
-
- return priv->hash;
-}
-
-void empathy_contact_call_when_ready (EmpathyContact *contact,
- EmpathyContactReady ready, EmpathyContactReadyCb *callback,
- gpointer user_data, GDestroyNotify destroy, GObject *weak_object)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
-
- g_return_if_fail (contact != NULL);
- g_return_if_fail (callback != NULL);
-
- if (contact_is_ready (contact, ready))
- {
- callback (contact, NULL, user_data, weak_object);
- if (destroy != NULL)
- destroy (user_data);
- }
- else
- {
- ReadyCbData *d = g_slice_new0 (ReadyCbData);
- d->ready = ready;
- d->callback = callback;
- d->user_data = user_data;
- d->destroy = destroy;
- d->weak_object = weak_object;
-
- if (weak_object != NULL)
- g_object_weak_ref (weak_object, contact_weak_object_notify, contact);
-
- priv->ready_callbacks = g_list_prepend (priv->ready_callbacks, d);
- }
-}
-
-static gboolean
-contact_is_ready_func (GObject *contact,
- gpointer user_data)
-{
- return contact_is_ready (EMPATHY_CONTACT (contact),
- GPOINTER_TO_UINT (user_data));
-}
-
-void
-empathy_contact_run_until_ready (EmpathyContact *contact,
- EmpathyContactReady ready,
- GMainLoop **loop)
-{
- empathy_run_until_ready_full (contact, "notify::ready",
- contact_is_ready_func, GUINT_TO_POINTER (ready),
- loop);
-}
-
-static gchar *
-contact_get_avatar_filename (EmpathyContact *contact,
- const gchar *token)
-{
- EmpathyContactPriv *priv = GET_PRIV (contact);
- gchar *avatar_path;
- gchar *avatar_file;
- gchar *token_escaped;
- gchar *contact_escaped;
-
- if (EMP_STR_EMPTY (priv->id))
- return NULL;
-
- contact_escaped = tp_escape_as_identifier (priv->id);
- token_escaped = tp_escape_as_identifier (token);
-
- avatar_path = g_build_filename (g_get_user_cache_dir (),
- PACKAGE_NAME,
- "avatars",
- mc_account_get_unique_name (priv->account),
- contact_escaped,
- NULL);
- g_mkdir_with_parents (avatar_path, 0700);
-
- avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
-
- g_free (contact_escaped);
- g_free (token_escaped);
- g_free (avatar_path);
-
- return avatar_file;
-}
-
-void
-empathy_contact_load_avatar_data (EmpathyContact *contact,
- const guchar *data,
- const gsize len,
- const gchar *format,
- const gchar *token)
-{
- EmpathyAvatar *avatar;
- gchar *filename;
- GError *error = NULL;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (data != NULL);
- g_return_if_fail (len > 0);
- g_return_if_fail (format != NULL);
- g_return_if_fail (!EMP_STR_EMPTY (token));
-
- /* Load and set the avatar */
- avatar = empathy_avatar_new (g_memdup (data, len), len, g_strdup (format),
- g_strdup (token));
- empathy_contact_set_avatar (contact, avatar);
- empathy_avatar_unref (avatar);
-
- /* Save to cache if not yet in it */
- filename = contact_get_avatar_filename (contact, token);
- if (filename && !g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- if (!empathy_avatar_save_to_file (avatar, filename, &error))
- {
- DEBUG ("Failed to save avatar in cache: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- }
- else
- DEBUG ("Avatar saved to %s", filename);
- }
- g_free (filename);
-}
-
-gboolean
-empathy_contact_load_avatar_cache (EmpathyContact *contact,
- const gchar *token)
-{
- EmpathyAvatar *avatar = NULL;
- gchar *filename;
- gchar *data = NULL;
- gsize len;
- GError *error = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
- g_return_val_if_fail (!EMP_STR_EMPTY (token), FALSE);
-
- /* Load the avatar from file if it exists */
- filename = contact_get_avatar_filename (contact, token);
- if (filename && g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- if (!g_file_get_contents (filename, &data, &len, &error))
- {
- DEBUG ("Failed to load avatar from cache: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- }
- }
-
- if (data)
- {
- DEBUG ("Avatar loaded from %s", filename);
- avatar = empathy_avatar_new (data, len, NULL, g_strdup (token));
- empathy_contact_set_avatar (contact, avatar);
- empathy_avatar_unref (avatar);
- }
-
- g_free (filename);
-
- return data != NULL;
-}
-
-GType
-empathy_avatar_get_type (void)
-{
- static GType type_id = 0;
-
- if (!type_id)
- {
- type_id = g_boxed_type_register_static ("EmpathyAvatar",
- (GBoxedCopyFunc) empathy_avatar_ref,
- (GBoxedFreeFunc) empathy_avatar_unref);
- }
-
- return type_id;
-}
-
-EmpathyAvatar *
-empathy_avatar_new (guchar *data,
- gsize len,
- gchar *format,
- gchar *token)
-{
- EmpathyAvatar *avatar;
-
- avatar = g_slice_new0 (EmpathyAvatar);
- avatar->data = data;
- avatar->len = len;
- avatar->format = format;
- avatar->token = token;
- avatar->refcount = 1;
-
- return avatar;
-}
-
-void
-empathy_avatar_unref (EmpathyAvatar *avatar)
-{
- g_return_if_fail (avatar != NULL);
-
- avatar->refcount--;
- if (avatar->refcount == 0)
- {
- g_free (avatar->data);
- g_free (avatar->format);
- g_free (avatar->token);
- g_slice_free (EmpathyAvatar, avatar);
- }
-}
-
-EmpathyAvatar *
-empathy_avatar_ref (EmpathyAvatar *avatar)
-{
- g_return_val_if_fail (avatar != NULL, NULL);
-
- avatar->refcount++;
-
- return avatar;
-}
-
-/**
- * empathy_avatar_save_to_file:
- * @avatar: the avatar
- * @filename: name of a file to write avatar to
- * @error: return location for a GError, or NULL
- *
- * Save the avatar to a file named filename
- *
- * Returns: %TRUE on success, %FALSE if an error occurred
- */
-gboolean
-empathy_avatar_save_to_file (EmpathyAvatar *self,
- const gchar *filename,
- GError **error)
-{
- return g_file_set_contents (filename, self->data, self->len, error);
-}
-
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
deleted file mode 100644
index 52c969f61..000000000
--- a/libempathy/empathy-contact.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Mikael Hallendal <micke@imendio.com>
- * Martyn Russell <martyn@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_CONTACT_H__
-#define __EMPATHY_CONTACT_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-#include <libmissioncontrol/mission-control.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONTACT (empathy_contact_get_type ())
-#define EMPATHY_CONTACT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT, EmpathyContact))
-#define EMPATHY_CONTACT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CONTACT, EmpathyContactClass))
-#define EMPATHY_IS_CONTACT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT))
-#define EMPATHY_IS_CONTACT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT))
-#define EMPATHY_CONTACT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT, EmpathyContactClass))
-
-typedef struct _EmpathyContact EmpathyContact;
-typedef struct _EmpathyContactClass EmpathyContactClass;
-
-struct _EmpathyContact
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyContactClass
-{
- GObjectClass parent_class;
-};
-
-typedef struct {
- guchar *data;
- gsize len;
- gchar *format;
- gchar *token;
- guint refcount;
-} EmpathyAvatar;
-
-typedef enum {
- EMPATHY_CAPABILITIES_NONE = 0,
- EMPATHY_CAPABILITIES_AUDIO = 1 << 0,
- EMPATHY_CAPABILITIES_VIDEO = 1 << 1,
- EMPATHY_CAPABILITIES_FT = 1 << 2,
- EMPATHY_CAPABILITIES_UNKNOWN = 1 << 7
-} EmpathyCapabilities;
-
-typedef enum {
- EMPATHY_CONTACT_READY_NONE = 0,
- EMPATHY_CONTACT_READY_ID = 1 << 0,
- EMPATHY_CONTACT_READY_HANDLE = 1 << 1,
- EMPATHY_CONTACT_READY_NAME = 1 << 2,
- EMPATHY_CONTACT_READY_ALL = (1 << 3) - 1,
-} EmpathyContactReady;
-
-GType empathy_contact_get_type (void) G_GNUC_CONST;
-EmpathyContact * empathy_contact_new (McAccount *account);
-EmpathyContact * empathy_contact_new_full (McAccount *account, const gchar *id,
- const gchar *name);
-const gchar * empathy_contact_get_id (EmpathyContact *contact);
-void empathy_contact_set_id (EmpathyContact *contact, const gchar *id);
-const gchar * empathy_contact_get_name (EmpathyContact *contact);
-void empathy_contact_set_name (EmpathyContact *contact, const gchar *name);
-EmpathyAvatar * empathy_contact_get_avatar (EmpathyContact *contact);
-void empathy_contact_set_avatar (EmpathyContact *contact,
- EmpathyAvatar *avatar);
-McAccount * empathy_contact_get_account (EmpathyContact *contact);
-void empathy_contact_set_account (EmpathyContact *contact, McAccount *account);
-McPresence empathy_contact_get_presence (EmpathyContact *contact);
-void empathy_contact_set_presence (EmpathyContact *contact,
- McPresence presence);
-const gchar * empathy_contact_get_presence_message (EmpathyContact *contact);
-void empathy_contact_set_presence_message (EmpathyContact *contact,
- const gchar *message);
-guint empathy_contact_get_handle (EmpathyContact *contact);
-void empathy_contact_set_handle (EmpathyContact *contact, guint handle);
-EmpathyCapabilities empathy_contact_get_capabilities (EmpathyContact *contact);
-void empathy_contact_set_capabilities (EmpathyContact *contact,
- EmpathyCapabilities capabilities);
-EmpathyContactReady empathy_contact_get_ready (EmpathyContact *contact);
-gboolean empathy_contact_is_user (EmpathyContact *contact);
-void empathy_contact_set_is_user (EmpathyContact *contact,
- gboolean is_user);
-gboolean empathy_contact_is_online (EmpathyContact *contact);
-const gchar * empathy_contact_get_status (EmpathyContact *contact);
-gboolean empathy_contact_can_voip (EmpathyContact *contact);
-gboolean empathy_contact_can_send_files (EmpathyContact *contact);
-gboolean empathy_contact_equal (gconstpointer v1, gconstpointer v2);
-guint empathy_contact_hash (gconstpointer key);
-
-typedef void (EmpathyContactReadyCb)
- (EmpathyContact *contact, const GError *error, gpointer user_data,
- GObject *weak_object);
-void empathy_contact_call_when_ready (EmpathyContact *contact,
- EmpathyContactReady ready, EmpathyContactReadyCb *callback, gpointer
- user_data, GDestroyNotify destroy, GObject *weak_object);
-
-void empathy_contact_run_until_ready (EmpathyContact *contact,
- EmpathyContactReady ready, GMainLoop **loop);
-
-void empathy_contact_load_avatar_data (EmpathyContact *contact,
- const guchar *data, const gsize len, const gchar *format,
- const gchar *token);
-gboolean empathy_contact_load_avatar_cache (EmpathyContact *contact,
- const gchar *token);
-
-
-#define EMPATHY_TYPE_AVATAR (empathy_avatar_get_type ())
-GType empathy_avatar_get_type (void) G_GNUC_CONST;
-EmpathyAvatar * empathy_avatar_new (guchar *data,
- gsize len,
- gchar *format,
- gchar *token);
-EmpathyAvatar * empathy_avatar_ref (EmpathyAvatar *avatar);
-void empathy_avatar_unref (EmpathyAvatar *avatar);
-
-gboolean empathy_avatar_save_to_file (EmpathyAvatar *avatar,
- const gchar *filename, GError **error);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONTACT_H__ */
diff --git a/libempathy/empathy-debug.c b/libempathy/empathy-debug.c
deleted file mode 100644
index ec72bfcfc..000000000
--- a/libempathy/empathy-debug.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Collabora Ltd.
- * Copyright (C) 2007 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 "config.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include <telepathy-glib/debug.h>
-
-#include "empathy-debug.h"
-
-#ifdef ENABLE_DEBUG
-
-static EmpathyDebugFlags flags = 0;
-
-static GDebugKey keys[] = {
- { "Tp", EMPATHY_DEBUG_TP },
- { "Chat", EMPATHY_DEBUG_CHAT },
- { "Contact", EMPATHY_DEBUG_CONTACT },
- { "Account", EMPATHY_DEBUG_ACCOUNT },
- { "Irc", EMPATHY_DEBUG_IRC },
- { "Dispatcher", EMPATHY_DEBUG_DISPATCHER },
- { "Ft", EMPATHY_DEBUG_FT },
- { "Other", EMPATHY_DEBUG_OTHER },
- { 0, }
-};
-
-static void
-debug_set_flags (EmpathyDebugFlags new_flags)
-{
- flags |= new_flags;
-}
-
-void
-empathy_debug_set_flags (const gchar *flags_string)
-{
- guint nkeys;
-
- for (nkeys = 0; keys[nkeys].value; nkeys++);
-
- tp_debug_set_flags (flags_string);
-
- if (flags_string)
- debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
-}
-
-gboolean
-empathy_debug_flag_is_set (EmpathyDebugFlags flag)
-{
- return (flag & flags) != 0;
-}
-
-void
-empathy_debug (EmpathyDebugFlags flag,
- const gchar *format,
- ...)
-{
- if (flag & flags)
- {
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
- va_end (args);
- }
-}
-
-#else
-
-gboolean
-empathy_debug_flag_is_set (EmpathyDebugFlags flag)
-{
- return FALSE;
-}
-
-void
-empathy_debug (EmpathyDebugFlags flag, const gchar *format, ...)
-{
-}
-
-void
-empathy_debug_set_flags (const gchar *flags_string)
-{
-}
-
-#endif /* ENABLE_DEBUG */
-
diff --git a/libempathy/empathy-debug.h b/libempathy/empathy-debug.h
deleted file mode 100644
index 8b68fd24d..000000000
--- a/libempathy/empathy-debug.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Collabora Ltd.
- * Copyright (C) 2007 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 __EMPATHY_DEBUG_H__
-#define __EMPATHY_DEBUG_H__
-
-#include "config.h"
-
-
-#include <glib.h>
-#include <telepathy-glib/debug.h>
-
-G_BEGIN_DECLS
-
-/* Please keep this enum in sync with #keys in empathy-debug.c */
-typedef enum
-{
- EMPATHY_DEBUG_TP = 1 << 1,
- EMPATHY_DEBUG_CHAT = 1 << 2,
- EMPATHY_DEBUG_CONTACT = 1 << 3,
- EMPATHY_DEBUG_ACCOUNT = 1 << 4,
- EMPATHY_DEBUG_IRC = 1 << 5,
- EMPATHY_DEBUG_DISPATCHER = 1 << 6,
- EMPATHY_DEBUG_FT = 1 << 7,
- EMPATHY_DEBUG_OTHER = 1 << 8,
-} EmpathyDebugFlags;
-
-gboolean empathy_debug_flag_is_set (EmpathyDebugFlags flag);
-void empathy_debug (EmpathyDebugFlags flag, const gchar *format, ...)
- G_GNUC_PRINTF (2, 3);
-void empathy_debug_set_flags (const gchar *flags_string);
-G_END_DECLS
-
-#endif /* __EMPATHY_DEBUG_H__ */
-
-/* ------------------------------------ */
-
-/* Below this point is outside the __DEBUG_H__ guard - so it can take effect
- * more than once. So you can do:
- *
- * #define DEBUG_FLAG EMPATHY_DEBUG_ONE_THING
- * #include "internal-debug.h"
- * ...
- * DEBUG ("if we're debugging one thing");
- * ...
- * #undef DEBUG_FLAG
- * #define DEBUG_FLAG EMPATHY_DEBUG_OTHER_THING
- * #include "internal-debug.h"
- * ...
- * DEBUG ("if we're debugging the other thing");
- * ...
- */
-
-#ifdef DEBUG_FLAG
-#ifdef ENABLE_DEBUG
-
-#undef DEBUG
-#define DEBUG(format, ...) \
- empathy_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__)
-
-#undef DEBUGGING
-#define DEBUGGING empathy_debug_flag_is_set (DEBUG_FLAG)
-
-#else /* !defined (ENABLE_DEBUG) */
-
-#undef DEBUG
-#define DEBUG(format, ...) do {} while (0)
-
-#undef DEBUGGING
-#define DEBUGGING 0
-
-#endif /* !defined (ENABLE_DEBUG) */
-#endif /* defined (DEBUG_FLAG) */
diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c
deleted file mode 100644
index 1786e4169..000000000
--- a/libempathy/empathy-dispatch-operation.c
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * empathy-dispatch-operation.c - Source for EmpathyDispatchOperation
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 <stdio.h>
-#include <stdlib.h>
-
-#include "empathy-dispatch-operation.h"
-#include <libempathy/empathy-enum-types.h>
-#include <libempathy/empathy-tp-chat.h>
-#include <libempathy/empathy-tp-call.h>
-#include <libempathy/empathy-tp-file.h>
-
-#include "empathy-marshal.h"
-
-#include "extensions/extensions.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
-#include <libempathy/empathy-debug.h>
-
-G_DEFINE_TYPE(EmpathyDispatchOperation, empathy_dispatch_operation,
- G_TYPE_OBJECT)
-
-static void empathy_dispatch_operation_set_status (
- EmpathyDispatchOperation *self, EmpathyDispatchOperationState status);
-static void empathy_dispatch_operation_channel_ready_cb (TpChannel *channel,
- const GError *error, gpointer user_data);
-
-/* signal enum */
-enum
-{
- /* Ready for dispatching */
- READY,
- /* Approved by an approver, can only happens on incoming operations */
- APPROVED,
- /* Claimed by a handler */
- CLAIMED,
- /* Error, channel went away, inspecting it failed etc */
- INVALIDATED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-/* properties */
-enum {
- PROP_CONNECTION = 1,
- PROP_CHANNEL,
- PROP_CHANNEL_WRAPPER,
- PROP_CONTACT,
- PROP_INCOMING,
- PROP_STATUS,
-};
-
-/* private structure */
-typedef struct _EmpathyDispatchOperationPriv \
- EmpathyDispatchOperationPriv;
-
-struct _EmpathyDispatchOperationPriv
-{
- gboolean dispose_has_run;
- TpConnection *connection;
- TpChannel *channel;
- GObject *channel_wrapper;
- EmpathyContact *contact;
- EmpathyDispatchOperationState status;
- gboolean incoming;
- gboolean approved;
- gulong invalidated_handler;
- gulong ready_handler;
-};
-
-#define GET_PRIV(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_DISPATCH_OPERATION, \
- EmpathyDispatchOperationPriv))
-
-static void
-empathy_dispatch_operation_init (EmpathyDispatchOperation *obj)
-{
- //EmpathyDispatchOperationPriv *priv =
- // GET_PRIV (obj);
-
- /* allocate any data required by the object here */
-}
-
-static void empathy_dispatch_operation_dispose (GObject *object);
-static void empathy_dispatch_operation_finalize (GObject *object);
-
-static void
-empathy_dispatch_operation_set_property (GObject *object,
- guint property_id, const GValue *value, GParamSpec *pspec)
-{
- EmpathyDispatchOperation *operation = EMPATHY_DISPATCH_OPERATION (object);
- EmpathyDispatchOperationPriv *priv = GET_PRIV (operation);
-
- switch (property_id)
- {
- case PROP_CONNECTION:
- priv->connection = g_value_dup_object (value);
- break;
- case PROP_CHANNEL:
- priv->channel = g_value_dup_object (value);
- break;
- case PROP_CHANNEL_WRAPPER:
- priv->channel_wrapper = g_value_dup_object (value);
- break;
- case PROP_CONTACT:
- if (priv->contact != NULL)
- g_object_unref (priv->contact);
- priv->contact = g_value_dup_object (value);
- break;
- case PROP_INCOMING:
- priv->incoming = g_value_get_boolean (value);
- break;
- }
-}
-
-static void
-empathy_dispatch_operation_get_property (GObject *object,
- guint property_id, GValue *value, GParamSpec *pspec)
-{
- EmpathyDispatchOperation *operation = EMPATHY_DISPATCH_OPERATION (object);
- EmpathyDispatchOperationPriv *priv = GET_PRIV (operation);
-
- switch (property_id)
- {
- case PROP_CONNECTION:
- g_value_set_object (value, priv->connection);
- break;
- case PROP_CHANNEL:
- g_value_set_object (value, priv->channel);
- break;
- case PROP_CHANNEL_WRAPPER:
- g_value_set_object (value, priv->channel_wrapper);
- break;
- case PROP_CONTACT:
- g_value_set_object (value, priv->contact);
- break;
- case PROP_INCOMING:
- g_value_set_boolean (value, priv->incoming);
- break;
- case PROP_STATUS:
- g_value_set_enum (value, priv->status);
- break;
- }
-}
-
-static void
-empathy_dispatch_operation_invalidated (TpProxy *proxy, guint domain,
- gint code, char *message, EmpathyDispatchOperation *self)
-{
- empathy_dispatch_operation_set_status (self,
- EMPATHY_DISPATCHER_OPERATION_STATE_INVALIDATED);
-
- g_signal_emit (self, signals[INVALIDATED], 0, domain, code, message);
-}
-
-static void
-empathy_dispatch_operation_constructed (GObject *object)
-{
- EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (object);
- EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
-
- empathy_dispatch_operation_set_status (self,
- EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING);
-
- priv->invalidated_handler =
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (empathy_dispatch_operation_invalidated), self);
-
- tp_channel_call_when_ready (priv->channel,
- empathy_dispatch_operation_channel_ready_cb, self);
-}
-
-static void
-empathy_dispatch_operation_class_init (
- EmpathyDispatchOperationClass *empathy_dispatch_operation_class)
-{
- GObjectClass *object_class =
- G_OBJECT_CLASS (empathy_dispatch_operation_class);
- GParamSpec *param_spec;
-
- g_type_class_add_private (empathy_dispatch_operation_class,
- sizeof (EmpathyDispatchOperationPriv));
-
- object_class->set_property = empathy_dispatch_operation_set_property;
- object_class->get_property = empathy_dispatch_operation_get_property;
-
- object_class->dispose = empathy_dispatch_operation_dispose;
- object_class->finalize = empathy_dispatch_operation_finalize;
- object_class->constructed = empathy_dispatch_operation_constructed;
-
- signals[READY] = g_signal_new ("ready",
- G_OBJECT_CLASS_TYPE(empathy_dispatch_operation_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[APPROVED] = g_signal_new ("approved",
- G_OBJECT_CLASS_TYPE(empathy_dispatch_operation_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[CLAIMED] = g_signal_new ("claimed",
- G_OBJECT_CLASS_TYPE(empathy_dispatch_operation_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[INVALIDATED] = g_signal_new ("invalidated",
- G_OBJECT_CLASS_TYPE(empathy_dispatch_operation_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__UINT_INT_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_INT, G_TYPE_STRING);
-
- param_spec = g_param_spec_object ("connection",
- "connection", "The telepathy connection",
- TP_TYPE_CONNECTION,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CONNECTION,
- param_spec);
-
- param_spec = g_param_spec_object ("channel",
- "channel", "The telepathy channel",
- TP_TYPE_CHANNEL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CHANNEL,
- param_spec);
-
- param_spec = g_param_spec_object ("channel-wrapper",
- "channel wrapper", "The empathy specific channel wrapper",
- G_TYPE_OBJECT,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CHANNEL_WRAPPER,
- param_spec);
-
- param_spec = g_param_spec_object ("contact",
- "contact", "The empathy contact",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_CONTACT,
- param_spec);
-
- param_spec = g_param_spec_boolean ("incoming",
- "incoming", "Whether or not the channel is incoming",
- FALSE,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INCOMING,
- param_spec);
-
- param_spec = g_param_spec_enum ("status",
- "status", "Status of the dispatch operation",
- EMPATHY_TYPE_DISPATCH_OPERATION_STATE, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_STATUS, param_spec);
-}
-
-void
-empathy_dispatch_operation_dispose (GObject *object)
-{
- EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (object);
- EmpathyDispatchOperationPriv *priv =
- GET_PRIV (self);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- g_object_unref (priv->connection);
-
- if (priv->channel_wrapper != NULL)
- g_object_unref (priv->channel_wrapper);
-
- if (priv->ready_handler != 0)
- g_signal_handler_disconnect (priv->channel_wrapper,
- priv->invalidated_handler);
-
-
- g_signal_handler_disconnect (priv->channel, priv->invalidated_handler);
- g_object_unref (priv->channel);
-
-
- if (priv->contact != NULL)
- g_object_unref (priv->contact);
-
- if (G_OBJECT_CLASS (empathy_dispatch_operation_parent_class)->dispose)
- G_OBJECT_CLASS (empathy_dispatch_operation_parent_class)->dispose (object);
-}
-
-void
-empathy_dispatch_operation_finalize (GObject *object)
-{
- /* free any data held directly by the object here */
- G_OBJECT_CLASS (empathy_dispatch_operation_parent_class)->finalize (object);
-}
-
-static void
-empathy_dispatch_operation_set_status (EmpathyDispatchOperation *self,
- EmpathyDispatchOperationState status)
-{
- EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
-
- g_assert (status >= priv->status);
-
-
- if (priv->status != status)
- {
- DEBUG ("Dispatch operation %s status: %d -> %d",
- empathy_dispatch_operation_get_object_path (self),
- priv->status, status);
-
- priv->status = status;
- g_object_notify (G_OBJECT (self), "status");
-
- if (status == EMPATHY_DISPATCHER_OPERATION_STATE_PENDING)
- g_signal_emit (self, signals[READY], 0);
- }
-}
-
-static void
-empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object,
- GParamSpec *spec, gpointer user_data)
-{
- EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
- EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
-
- if (!empathy_tp_chat_is_ready (EMPATHY_TP_CHAT (priv->channel_wrapper)))
- return;
-
- g_signal_handler_disconnect (priv->channel_wrapper, priv->ready_handler);
- priv->ready_handler = 0;
-
- empathy_dispatch_operation_set_status (self,
- EMPATHY_DISPATCHER_OPERATION_STATE_PENDING);
-}
-
-static void
-empathy_dispatch_operation_channel_ready_cb (TpChannel *channel,
- const GError *error, gpointer user_data)
-{
- EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
- EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
- GQuark channel_type;
-
- /* The error will be handled in empathy_dispatch_operation_invalidated */
- if (error != NULL)
- return;
-
- g_assert (channel == priv->channel);
-
- /* If the channel wrapper is defined, we assume it's ready */
- if (priv->channel_wrapper != NULL)
- goto ready;
-
- channel_type = tp_channel_get_channel_type_id (channel);
-
- if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
- {
- EmpathyTpChat *chat= empathy_tp_chat_new (channel);
- priv->channel_wrapper = G_OBJECT (chat);
-
- if (!empathy_tp_chat_is_ready (chat))
- {
- priv->ready_handler = g_signal_connect (chat, "notify::ready",
- G_CALLBACK (empathy_dispatcher_operation_tp_chat_ready_cb), self);
- return;
- }
-
- }
- else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
- {
- EmpathyTpCall *call = empathy_tp_call_new (channel);
- priv->channel_wrapper = G_OBJECT (call);
-
- }
- else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
- {
- EmpathyTpFile *file = empathy_tp_file_new (channel);
- priv->channel_wrapper = G_OBJECT (file);
- }
-
-ready:
- empathy_dispatch_operation_set_status (self,
- EMPATHY_DISPATCHER_OPERATION_STATE_PENDING);
-}
-
-EmpathyDispatchOperation *
-empathy_dispatch_operation_new (TpConnection *connection, TpChannel *channel,
- EmpathyContact *contact, gboolean incoming)
-{
- return empathy_dispatch_operation_new_with_wrapper (connection, channel,
- contact, incoming, NULL);
-}
-
-EmpathyDispatchOperation *
-empathy_dispatch_operation_new_with_wrapper (TpConnection *connection,
- TpChannel *channel, EmpathyContact *contact, gboolean incoming,
- GObject *wrapper)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (channel != NULL, NULL);
-
- return EMPATHY_DISPATCH_OPERATION (
- g_object_new (EMPATHY_TYPE_DISPATCH_OPERATION,
- "connection", connection,
- "channel", channel,
- "channel-wrapper", wrapper,
- "contact", contact,
- "incoming", incoming,
- NULL));
-}
-
-void
-empathy_dispatch_operation_start (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation));
-
- priv = GET_PRIV (operation);
-
- g_return_if_fail (
- priv->status == EMPATHY_DISPATCHER_OPERATION_STATE_PENDING);
-
- if (priv->incoming && !priv->approved)
- empathy_dispatch_operation_set_status (operation,
- EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING);
- else
- empathy_dispatch_operation_set_status (operation,
- EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING);
-}
-
-void
-empathy_dispatch_operation_approve (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation));
-
- priv = GET_PRIV (operation);
-
- if (priv->status == EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING)
- {
- DEBUG ("Approving operation %s",
- empathy_dispatch_operation_get_object_path (operation));
-
- empathy_dispatch_operation_set_status (operation,
- EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING);
-
- g_signal_emit (operation, signals[APPROVED], 0);
- }
- else if (priv->status < EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING)
- {
- DEBUG ("Pre-approving operation %s",
- empathy_dispatch_operation_get_object_path (operation));
- priv->approved = TRUE;
- }
- else
- {
- DEBUG (
- "Ignoring approval for %s as it's already past the approval stage",
- empathy_dispatch_operation_get_object_path (operation));
- }
-}
-
-/* Returns whether or not the operation was successfully claimed */
-gboolean
-empathy_dispatch_operation_claim (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), FALSE);
-
- priv = GET_PRIV (operation);
-
- if (priv->status == EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED)
- return FALSE;
-
- empathy_dispatch_operation_set_status (operation,
- EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED);
-
- g_signal_emit (operation, signals[CLAIMED], 0);
-
- return TRUE;
-}
-
-TpConnection *
-empathy_dispatch_operation_get_tp_connection (
- EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), NULL);
-
- priv = GET_PRIV (operation);
-
- return g_object_ref (priv->connection);
-}
-
-TpChannel *
-empathy_dispatch_operation_get_channel (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), NULL);
-
- priv = GET_PRIV (operation);
-
- return priv->channel;
-}
-
-GObject *
-empathy_dispatch_operation_get_channel_wrapper (
- EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), NULL);
-
- priv = GET_PRIV (operation);
-
- return priv->channel_wrapper;
-}
-
-const gchar *
-empathy_dispatch_operation_get_channel_type (
- EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), NULL);
-
- priv = GET_PRIV (operation);
-
- return tp_channel_get_channel_type (priv->channel);
-}
-
-GQuark
-empathy_dispatch_operation_get_channel_type_id (
- EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), 0);
-
- priv = GET_PRIV (operation);
-
- return tp_channel_get_channel_type_id (priv->channel);
-}
-
-const gchar *
-empathy_dispatch_operation_get_object_path (
- EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), NULL);
-
- priv = GET_PRIV (operation);
-
- return tp_proxy_get_object_path (TP_PROXY (priv->channel));
-}
-
-EmpathyDispatchOperationState
-empathy_dispatch_operation_get_status (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation),
- EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING);
-
- priv = GET_PRIV (operation);
-
- return priv->status;
-}
-
-gboolean
-empathy_dispatch_operation_is_incoming (EmpathyDispatchOperation *operation)
-{
- EmpathyDispatchOperationPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (operation), FALSE);
-
- priv = GET_PRIV (operation);
-
- return priv->incoming;
-}
diff --git a/libempathy/empathy-dispatch-operation.h b/libempathy/empathy-dispatch-operation.h
deleted file mode 100644
index 3597bd0e8..000000000
--- a/libempathy/empathy-dispatch-operation.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * empathy-dispatch-operation.h - Header for EmpathyDispatchOperation
- * Copyright (C) 2008 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@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 __EMPATHY_DISPATCH_OPERATION_H__
-#define __EMPATHY_DISPATCH_OPERATION_H__
-
-#include <glib-object.h>
-
-#include <libempathy/empathy-contact.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyDispatchOperation EmpathyDispatchOperation;
-typedef struct _EmpathyDispatchOperationClass EmpathyDispatchOperationClass;
-
-struct _EmpathyDispatchOperationClass {
- GObjectClass parent_class;
-};
-
-struct _EmpathyDispatchOperation {
- GObject parent;
-};
-
-typedef enum {
- /* waiting for the channel information to be ready */
- EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING = 0,
- /* Information gathered ready to be dispatched */
- EMPATHY_DISPATCHER_OPERATION_STATE_PENDING,
- /* Send to approving bits for approval */
- EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING,
- /* Send to handlers for dispatching */
- EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING,
- /* somebody claimed the channel */
- EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED,
- /* dispatch operation invalidated, underlying channel died */
- EMPATHY_DISPATCHER_OPERATION_STATE_INVALIDATED,
-} EmpathyDispatchOperationState;
-
-GType empathy_dispatch_operation_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_DISPATCH_OPERATION \
- (empathy_dispatch_operation_get_type())
-#define EMPATHY_DISPATCH_OPERATION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_DISPATCH_OPERATION, \
- EmpathyDispatchOperation))
-#define EMPATHY_DISPATCH_OPERATION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_DISPATCH_OPERATION, \
- EmpathyDispatchOperationClass))
-#define EMPATHY_IS_DISPATCH_OPERATION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_DISPATCH_OPERATION))
-#define EMPATHY_IS_DISPATCH_OPERATION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_DISPATCH_OPERATION))
-#define EMPATHY_DISPATCH_OPERATION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_DISPATCH_OPERATION, \
- EmpathyDispatchOperationClass))
-
-EmpathyDispatchOperation *empathy_dispatch_operation_new (
- TpConnection *connection, TpChannel *channel, EmpathyContact *contact,
- gboolean incoming);
-
-EmpathyDispatchOperation *empathy_dispatch_operation_new_with_wrapper (
- TpConnection *connection, TpChannel *channel, EmpathyContact *contact,
- gboolean incoming, GObject *channel_wrapper);
-
-/* Start the dispatching process, goes to the APPROVING state for incoming
- * channels and DISPATCHING for outgoing ones */
-void empathy_dispatch_operation_start (EmpathyDispatchOperation *operation);
-
-void empathy_dispatch_operation_approve (EmpathyDispatchOperation *operation);
-
-/* Returns whether or not the operation was successfully claimed */
-gboolean empathy_dispatch_operation_claim (EmpathyDispatchOperation *operation);
-
-TpChannel *empathy_dispatch_operation_get_channel (
- EmpathyDispatchOperation *operation);
-
-GObject *empathy_dispatch_operation_get_channel_wrapper (
- EmpathyDispatchOperation *operation);
-
-TpConnection *empathy_dispatch_operation_get_tp_connection (
- EmpathyDispatchOperation *operation);
-
-const gchar *empathy_dispatch_operation_get_channel_type (
- EmpathyDispatchOperation *operation);
-
-GQuark empathy_dispatch_operation_get_channel_type_id (
- EmpathyDispatchOperation *operation);
-
-const gchar * empathy_dispatch_operation_get_object_path (
- EmpathyDispatchOperation *operation);
-
-EmpathyDispatchOperationState empathy_dispatch_operation_get_status (
- EmpathyDispatchOperation *operation);
-
-gboolean empathy_dispatch_operation_is_incoming (
- EmpathyDispatchOperation *operation);
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_DISPATCH_OPERATION_H__*/
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
deleted file mode 100644
index b3fd6a8a2..000000000
--- a/libempathy/empathy-dispatcher.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/* * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/proxy-subclass.h>
-#include <telepathy-glib/gtypes.h>
-
-#include <libmissioncontrol/mission-control.h>
-#include <libmissioncontrol/mc-account.h>
-
-#include <extensions/extensions.h>
-
-#include "empathy-dispatcher.h"
-#include "empathy-utils.h"
-#include "empathy-tube-handler.h"
-#include "empathy-account-manager.h"
-#include "empathy-contact-factory.h"
-#include "empathy-tp-file.h"
-#include "empathy-chatroom-manager.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
-#include <libempathy/empathy-debug.h>
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyDispatcher)
-typedef struct
-{
- EmpathyAccountManager *account_manager;
- MissionControl *mc;
- /* connection to connection data mapping */
- GHashTable *connections;
- /* accounts to connection mapping */
- GHashTable *accounts;
- gpointer token;
- GSList *tubes;
-
- /* channels which the dispatcher is listening "invalidated" */
- GList *channels;
-} EmpathyDispatcherPriv;
-
-G_DEFINE_TYPE (EmpathyDispatcher, empathy_dispatcher, G_TYPE_OBJECT);
-
-enum
-{
- OBSERVE,
- APPROVE,
- DISPATCH,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-static EmpathyDispatcher *dispatcher = NULL;
-
-typedef struct
-{
- EmpathyDispatcher *dispatcher;
- EmpathyDispatchOperation *operation;
- TpConnection *connection;
- gchar *channel_type;
- guint handle_type;
- guint handle;
- EmpathyContact *contact;
-
- /* Properties to pass to the channel when requesting it */
- GHashTable *request;
- EmpathyDispatcherRequestCb *cb;
- gpointer user_data;
- gpointer *request_data;
-} DispatcherRequestData;
-
-typedef struct
-{
- TpChannel *channel;
- /* Channel type specific wrapper object */
- GObject *channel_wrapper;
-} DispatchData;
-
-typedef struct
-{
- McAccount *account;
- /* ObjectPath => DispatchData.. */
- GHashTable *dispatched_channels;
- /* ObjectPath -> EmpathyDispatchOperations */
- GHashTable *dispatching_channels;
- /* ObjectPath -> EmpathyDispatchOperations */
- GHashTable *outstanding_channels;
- /* List of DispatcherRequestData */
- GList *outstanding_requests;
- /* List of requestable channel classes */
- GPtrArray *requestable_channels;
-} ConnectionData;
-
-static DispatchData *
-new_dispatch_data (TpChannel *channel,
- GObject *channel_wrapper)
-{
- DispatchData *d = g_slice_new0 (DispatchData);
- d->channel = g_object_ref (channel);
- if (channel_wrapper != NULL)
- d->channel_wrapper = g_object_ref (channel_wrapper);
-
- return d;
-}
-
-static void
-free_dispatch_data (DispatchData *data)
-{
- g_object_unref (data->channel);
- if (data->channel_wrapper != NULL)
- g_object_unref (data->channel_wrapper);
-
- g_slice_free (DispatchData, data);
-}
-
-static DispatcherRequestData *
-new_dispatcher_request_data (EmpathyDispatcher *dispatcher,
- TpConnection *connection,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- GHashTable *request,
- EmpathyContact *contact,
- EmpathyDispatcherRequestCb *cb,
- gpointer user_data)
-{
- DispatcherRequestData *result = g_slice_new0 (DispatcherRequestData);
-
- result->dispatcher = g_object_ref (dispatcher);
- result->connection = connection;
-
- result->channel_type = g_strdup (channel_type);
- result->handle_type = handle_type;
- result->handle = handle;
- result->request = request;
-
- if (contact != NULL)
- result->contact = g_object_ref (contact);
-
- result->cb = cb;
- result->user_data = user_data;
-
- return result;
-}
-
-static void
-free_dispatcher_request_data (DispatcherRequestData *r)
-{
- g_free (r->channel_type);
-
- if (r->dispatcher != NULL)
- g_object_unref (r->dispatcher);
-
- if (r->contact != NULL)
- g_object_unref (r->contact);
-
- if (r->request != NULL)
- g_hash_table_unref (r->request);
-
- g_slice_free (DispatcherRequestData, r);
-}
-
-static ConnectionData *
-new_connection_data (McAccount *account)
-{
- ConnectionData *cd = g_slice_new0 (ConnectionData);
- cd->account = g_object_ref (account);
-
- cd->dispatched_channels = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) free_dispatch_data);
-
- cd->dispatching_channels = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_object_unref);
-
- cd->outstanding_channels = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
- return cd;
-}
-
-static void
-free_connection_data (ConnectionData *cd)
-{
- GList *l;
- g_object_unref (cd->account);
- g_hash_table_destroy (cd->dispatched_channels);
- g_hash_table_destroy (cd->dispatching_channels);
- int i;
-
- for (l = cd->outstanding_requests ; l != NULL; l = g_list_delete_link (l,l))
- {
- free_dispatcher_request_data (l->data);
- }
-
- if (cd->requestable_channels != NULL)
- {
- for (i = 0 ; i < cd->requestable_channels->len ; i++)
- g_value_array_free (
- g_ptr_array_index (cd->requestable_channels, i));
- g_ptr_array_free (cd->requestable_channels, TRUE);
- }
-}
-
-static void
-dispatcher_connection_invalidated_cb (TpConnection *connection,
- guint domain,
- gint code,
- gchar *message,
- EmpathyDispatcher *dispatcher)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- ConnectionData *cd;
-
- DEBUG ("Error: %s", message);
- cd = g_hash_table_lookup (priv->connections, connection);
-
- g_hash_table_remove (priv->accounts, cd->account);
- g_hash_table_remove (priv->connections, connection);
-}
-
-static gboolean
-dispatcher_operation_can_start (EmpathyDispatcher *self,
- EmpathyDispatchOperation *operation,
- ConnectionData *cd)
-{
- GList *l;
- const gchar *channel_type =
- empathy_dispatch_operation_get_channel_type (operation);
-
- for (l = cd->outstanding_requests; l != NULL; l = g_list_next (l))
- {
- DispatcherRequestData *d = (DispatcherRequestData *) l->data;
-
- if (d->operation == NULL && !tp_strdiff (d->channel_type, channel_type))
- {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-dispatch_operation_flush_requests (EmpathyDispatcher *dispatcher,
- EmpathyDispatchOperation *operation,
- GError *error,
- ConnectionData *cd)
-{
- GList *l;
-
- l = cd->outstanding_requests;
- while (l != NULL)
- {
- DispatcherRequestData *d = (DispatcherRequestData *) l->data;
- GList *lt = l;
-
- l = g_list_next (l);
-
- if (d->operation == operation)
- {
- if (d->cb != NULL)
- {
- if (error != NULL)
- d->cb (NULL, error, d->user_data);
- else
- d->cb (operation, NULL, d->user_data);
- }
-
- cd->outstanding_requests = g_list_delete_link
- (cd->outstanding_requests, lt);
-
- free_dispatcher_request_data (d);
- }
- }
-}
-
-static void
-dispatcher_channel_invalidated_cb (TpProxy *proxy,
- guint domain,
- gint code,
- gchar *message,
- EmpathyDispatcher *dispatcher)
-{
- /* Channel went away... */
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpConnection *connection;
- EmpathyDispatchOperation *operation;
- ConnectionData *cd;
- const gchar *object_path;
-
- connection = tp_channel_borrow_connection (TP_CHANNEL (proxy));
-
- cd = g_hash_table_lookup (priv->connections, connection);
- /* Connection itself invalidated? */
- if (cd == NULL)
- return;
-
- object_path = tp_proxy_get_object_path (proxy);
-
- DEBUG ("Channel %s invalidated", object_path);
-
- g_hash_table_remove (cd->dispatched_channels, object_path);
- g_hash_table_remove (cd->dispatching_channels, object_path);
-
- priv->channels = g_list_remove (priv->channels, proxy);
-
- operation = g_hash_table_lookup (cd->outstanding_channels, object_path);
- if (operation != NULL)
- {
- GError error = { domain, code, message };
- dispatch_operation_flush_requests (dispatcher, operation, &error, cd);
- g_hash_table_remove (cd->outstanding_channels, object_path);
- g_object_unref (operation);
- }
-}
-
-static void
-dispatch_operation_approved_cb (EmpathyDispatchOperation *operation,
- EmpathyDispatcher *dispatcher)
-{
- g_assert (empathy_dispatch_operation_is_incoming (operation));
- DEBUG ("Send of for dispatching: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (dispatcher, signals[DISPATCH], 0, operation);
-}
-
-static void
-dispatch_operation_claimed_cb (EmpathyDispatchOperation *operation,
- EmpathyDispatcher *dispatcher)
-{
- /* Our job is done, remove the dispatch operation and mark the channel as
- * dispatched */
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpConnection *connection;
- ConnectionData *cd;
- const gchar *object_path;
-
- connection = empathy_dispatch_operation_get_tp_connection (operation);
- cd = g_hash_table_lookup (priv->connections, connection);
- g_assert (cd != NULL);
- g_object_unref (G_OBJECT (connection));
-
- object_path = empathy_dispatch_operation_get_object_path (operation);
-
- if (g_hash_table_lookup (cd->dispatched_channels, object_path) == NULL)
- {
- DispatchData *d;
- d = new_dispatch_data (
- empathy_dispatch_operation_get_channel (operation),
- empathy_dispatch_operation_get_channel_wrapper (operation));
- g_hash_table_insert (cd->dispatched_channels,
- g_strdup (object_path), d);
- }
- g_hash_table_remove (cd->dispatching_channels, object_path);
-
- DEBUG ("Channel claimed: %s", object_path);
-}
-
-static void
-dispatch_operation_ready_cb (EmpathyDispatchOperation *operation,
- EmpathyDispatcher *dispatcher)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpConnection *connection;
- ConnectionData *cd;
- EmpathyDispatchOperationState status;
-
- g_signal_connect (operation, "approved",
- G_CALLBACK (dispatch_operation_approved_cb), dispatcher);
-
- g_signal_connect (operation, "claimed",
- G_CALLBACK (dispatch_operation_claimed_cb), dispatcher);
-
- /* Signal the observers */
- DEBUG ("Send to observers: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (dispatcher, signals[OBSERVE], 0, operation);
-
- empathy_dispatch_operation_start (operation);
-
- /* Signal potential requestors */
- connection = empathy_dispatch_operation_get_tp_connection (operation);
- cd = g_hash_table_lookup (priv->connections, connection);
- g_assert (cd != NULL);
- g_object_unref (G_OBJECT (connection));
-
- g_object_ref (operation);
- g_object_ref (dispatcher);
-
- dispatch_operation_flush_requests (dispatcher, operation, NULL, cd);
- status = empathy_dispatch_operation_get_status (operation);
- g_object_unref (operation);
-
- if (status == EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED)
- return;
-
- if (status == EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING)
- {
- DEBUG ("Send to approvers: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (dispatcher, signals[APPROVE], 0, operation);
- }
- else
- {
- g_assert (status == EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING);
- DEBUG ("Send of for dispatching: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (dispatcher, signals[DISPATCH], 0, operation);
- }
-
- g_object_unref (dispatcher);
-}
-
-static void
-dispatcher_start_dispatching (EmpathyDispatcher *self,
- EmpathyDispatchOperation *operation,
- ConnectionData *cd)
-{
- const gchar *object_path =
- empathy_dispatch_operation_get_object_path (operation);
-
- DEBUG ("Dispatching process started for %s", object_path);
-
- if (g_hash_table_lookup (cd->dispatching_channels, object_path) == NULL)
- {
- g_assert (g_hash_table_lookup (cd->outstanding_channels,
- object_path) == NULL);
-
- g_hash_table_insert (cd->dispatching_channels,
- g_strdup (object_path), operation);
-
- switch (empathy_dispatch_operation_get_status (operation))
- {
- case EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING:
- g_signal_connect (operation, "ready",
- G_CALLBACK (dispatch_operation_ready_cb), dispatcher);
- break;
- case EMPATHY_DISPATCHER_OPERATION_STATE_PENDING:
- dispatch_operation_ready_cb (operation, dispatcher);
- break;
- default:
- g_assert_not_reached();
- }
-
- }
- else if (empathy_dispatch_operation_get_status (operation) >=
- EMPATHY_DISPATCHER_OPERATION_STATE_PENDING)
- {
- /* Already dispatching and the operation is pending, thus the observers
- * have seen it (if applicable), so we can flush the request right away.
- */
- dispatch_operation_flush_requests (self, operation, NULL, cd);
- }
-}
-
-static void
-dispatcher_flush_outstanding_operations (EmpathyDispatcher *self,
- ConnectionData *cd)
-{
- GHashTableIter iter;
- gpointer value;
-
- g_hash_table_iter_init (&iter, cd->outstanding_channels);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyDispatchOperation *operation = EMPATHY_DISPATCH_OPERATION (value);
-
- if (dispatcher_operation_can_start (self, operation, cd))
- {
- dispatcher_start_dispatching (dispatcher, operation, cd);
- g_hash_table_iter_remove (&iter);
- }
- }
-}
-
-static void
-dispatcher_connection_new_channel (EmpathyDispatcher *dispatcher,
- TpConnection *connection,
- const gchar *object_path,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- GHashTable *properties,
- gboolean incoming)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpChannel *channel;
- ConnectionData *cd;
- EmpathyDispatchOperation *operation;
- EmpathyContact *contact = NULL;
- int i;
- /* Channel types we never want to dispatch because they're either deprecated
- * or can't sensibly be dispatch (e.g. channels that should always be
- * requested) */
- const char *blacklist[] = {
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_IFACE_CHANNEL_TYPE_TUBES,
- TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
- NULL
- };
-
- cd = g_hash_table_lookup (priv->connections, connection);
-
- /* Don't bother with channels we have already dispatched or are dispatching
- * currently. This can happen when NewChannel(s) is fired after
- * RequestChannel/CreateChannel/EnsureChannel */
- if (g_hash_table_lookup (cd->dispatched_channels, object_path) != NULL)
- return;
-
- if (g_hash_table_lookup (cd->dispatching_channels, object_path) != NULL)
- return;
-
- /* Should never occur, but just in case a CM fires spurious NewChannel(s)
- * signals */
- if (g_hash_table_lookup (cd->outstanding_channels, object_path) != NULL)
- return;
-
- /* Only pick up non-requested text and file channels. For all other it
- * doesn't make sense to handle it if we didn't request it. The same goes
- * for channels we discovered by the Channels property or ListChannels */
- if (!incoming && tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)
- && tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
- {
- DEBUG ("Ignoring incoming channel of type %s on %s",
- channel_type, object_path);
- return;
- }
-
- for (i = 0 ; blacklist[i] != NULL; i++)
- {
- if (!tp_strdiff (channel_type, blacklist[i]))
- {
- DEBUG ("Ignoring blacklisted channel type %s on %s",
- channel_type, object_path);
- return;
- }
- }
-
- DEBUG ("New channel of type %s on %s", channel_type, object_path);
-
- if (properties == NULL)
- channel = tp_channel_new (connection, object_path, channel_type,
- handle_type, handle, NULL);
- else
- channel = tp_channel_new_from_properties (connection, object_path,
- properties, NULL);
-
- g_signal_connect (channel, "invalidated",
- G_CALLBACK (dispatcher_channel_invalidated_cb),
- dispatcher);
-
- priv->channels = g_list_prepend (priv->channels, channel);
-
- if (handle_type == TP_CONN_HANDLE_TYPE_CONTACT)
- {
- EmpathyContactFactory *factory = empathy_contact_factory_dup_singleton ();
- contact = empathy_contact_factory_get_from_handle (factory,
- cd->account, handle);
- g_object_unref (factory);
- }
-
- operation = empathy_dispatch_operation_new (connection, channel, contact,
- incoming);
-
- g_object_unref (channel);
-
- if (incoming)
- {
- /* Request could either be by us or by a remote party. If there are no
- * outstanding requests for this channel type we can assume it's remote.
- * Otherwise we wait untill they are all satisfied */
- if (dispatcher_operation_can_start (dispatcher, operation, cd))
- dispatcher_start_dispatching (dispatcher, operation, cd);
- else
- g_hash_table_insert (cd->outstanding_channels,
- g_strdup (object_path), operation);
- }
- else
- {
- dispatcher_start_dispatching (dispatcher, operation, cd);
- }
-}
-
-static void
-dispatcher_connection_new_channel_cb (TpConnection *connection,
- const gchar *object_path,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- gboolean suppress_handler,
- gpointer user_data,
- GObject *object)
-{
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
-
- /* Empathy heavily abuses surpress handler (don't try this at home), if
- * surpress handler is true then it is an outgoing channel, which is
- * requested either by us or some other party (like the megaphone applet).
- * Otherwise it's an incoming channel */
- dispatcher_connection_new_channel (dispatcher, connection,
- object_path, channel_type, handle_type, handle, NULL, !suppress_handler);
-}
-
-static void
-dispatcher_connection_new_channel_with_properties (EmpathyDispatcher *dispatcher,
- TpConnection *connection,
- const gchar *object_path,
- GHashTable *properties)
-{
- const gchar *channel_type;
- guint handle_type;
- guint handle;
- gboolean requested;
- gboolean valid;
-
-
- channel_type = tp_asv_get_string (properties,
- TP_IFACE_CHANNEL ".ChannelType");
- if (channel_type == NULL)
- {
- g_message ("%s had an invalid ChannelType property", object_path);
- return;
- }
-
- handle_type = tp_asv_get_uint32 (properties,
- TP_IFACE_CHANNEL ".TargetHandleType", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid TargetHandleType property", object_path);
- return;
- }
-
- handle = tp_asv_get_uint32 (properties,
- TP_IFACE_CHANNEL ".TargetHandle", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid TargetHandle property", object_path);
- return;
- }
-
- /* We assume there is no channel dispather, so we're the only one dispatching
- * it. Which means that a requested channel it is outgoing one */
- requested = tp_asv_get_boolean (properties,
- TP_IFACE_CHANNEL ".Requested", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid Requested property", object_path);
- return;
- }
-
- dispatcher_connection_new_channel (dispatcher, connection,
- object_path, channel_type, handle_type, handle, properties, !requested);
-}
-
-static void
-dispatcher_connection_new_channels_cb (TpConnection *connection,
- const GPtrArray *channels,
- gpointer user_data,
- GObject *object)
-{
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
- int i;
-
- for (i = 0; i < channels->len ; i++)
- {
- GValueArray *arr = g_ptr_array_index (channels, i);
- const gchar *object_path;
- GHashTable *properties;
-
- object_path = g_value_get_boxed (g_value_array_get_nth (arr, 0));
- properties = g_value_get_boxed (g_value_array_get_nth (arr, 1));
-
- dispatcher_connection_new_channel_with_properties (dispatcher,
- connection, object_path, properties);
- }
-}
-
-static void
-dispatcher_connection_got_all (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *object)
-{
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- GPtrArray *channels;
- GPtrArray *requestable_channels;
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- channels = tp_asv_get_boxed (properties, "Channels",
- TP_ARRAY_TYPE_CHANNEL_DETAILS_LIST);
-
- if (channels == NULL)
- DEBUG ("No Channels property !?! on connection");
- else
- dispatcher_connection_new_channels_cb (TP_CONNECTION (proxy),
- channels, NULL, object);
-
- requestable_channels = tp_asv_get_boxed (properties,
- "RequestableChannelClasses", TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
-
- if (requestable_channels == NULL)
- DEBUG ("No RequestableChannelClasses property !?! on connection");
- else
- {
- ConnectionData *cd;
-
- cd = g_hash_table_lookup (priv->connections, proxy);
- g_assert (cd != NULL);
-
- cd->requestable_channels = g_boxed_copy (
- TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, requestable_channels);
- }
-}
-
-static void
-dispatcher_connection_list_channels_cb (TpConnection *connection,
- const GPtrArray *channels,
- const GError *error,
- gpointer user_data,
- GObject *dispatcher)
-{
- int i;
-
- if (error)
- {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- for (i = 0; i < channels->len; i++)
- {
- GValueArray *values;
-
- values = g_ptr_array_index (channels, i);
- /* We don't have any extra info, so assume already existing channels are
- * incoming... */
- dispatcher_connection_new_channel (EMPATHY_DISPATCHER (dispatcher),
- connection,
- g_value_get_boxed (g_value_array_get_nth (values, 0)),
- g_value_get_string (g_value_array_get_nth (values, 1)),
- g_value_get_uint (g_value_array_get_nth (values, 2)),
- g_value_get_uint (g_value_array_get_nth (values, 3)),
- NULL, TRUE);
- }
-}
-
-static void
-dispatcher_connection_advertise_capabilities_cb (TpConnection *connection,
- const GPtrArray *capabilities,
- const GError *error,
- gpointer user_data,
- GObject *dispatcher)
-{
- if (error)
- DEBUG ("Error: %s", error->message);
-}
-
-static void
-dispatcher_connection_ready_cb (TpConnection *connection,
- const GError *error,
- gpointer dispatcher)
-{
- GPtrArray *capabilities;
- GType cap_type;
- GValue cap = {0, };
- const gchar *remove = NULL;
-
- if (error)
- {
- dispatcher_connection_invalidated_cb (connection, error->domain,
- error->code, error->message, dispatcher);
- return;
- }
-
- g_signal_connect (connection, "invalidated",
- G_CALLBACK (dispatcher_connection_invalidated_cb), dispatcher);
-
- if (tp_proxy_has_interface_by_id (TP_PROXY (connection),
- TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS))
- {
- tp_cli_connection_interface_requests_connect_to_new_channels (connection,
- dispatcher_connection_new_channels_cb,
- NULL, NULL, G_OBJECT (dispatcher), NULL);
-
- tp_cli_dbus_properties_call_get_all (connection, -1,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
- dispatcher_connection_got_all,
- NULL, NULL, dispatcher);
- }
- else
- {
- tp_cli_connection_connect_to_new_channel (connection,
- dispatcher_connection_new_channel_cb,
- NULL, NULL, G_OBJECT (dispatcher), NULL);
-
- tp_cli_connection_call_list_channels (connection, -1,
- dispatcher_connection_list_channels_cb, NULL, NULL,
- G_OBJECT (dispatcher));
-
- }
-
- /* Advertise VoIP capabilities */
- /* FIXME: Capabilities is leaked */
- capabilities = g_ptr_array_sized_new (1);
- cap_type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING,
- G_TYPE_UINT, G_TYPE_INVALID);
- g_value_init (&cap, cap_type);
- g_value_take_boxed (&cap, dbus_g_type_specialized_construct (cap_type));
- dbus_g_type_struct_set (&cap,
- 0, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
- 1, TP_CHANNEL_MEDIA_CAPABILITY_AUDIO |
- TP_CHANNEL_MEDIA_CAPABILITY_VIDEO |
- TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_STUN |
- TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P, G_MAXUINT);
- g_ptr_array_add (capabilities, g_value_get_boxed (&cap));
-
- tp_cli_connection_interface_capabilities_call_advertise_capabilities (
- connection, -1, capabilities, &remove,
- dispatcher_connection_advertise_capabilities_cb,
- NULL, NULL, G_OBJECT (dispatcher));
-}
-
-static void
-dispatcher_update_account (EmpathyDispatcher *dispatcher,
- McAccount *account)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpConnection *connection;
-
- connection = g_hash_table_lookup (priv->accounts, account);
- if (connection != NULL)
- return;
-
- connection = mission_control_get_tpconnection (priv->mc, account, NULL);
- if (connection == NULL)
- return;
-
- g_hash_table_insert (priv->connections, g_object_ref (connection),
- new_connection_data (account));
-
- g_hash_table_insert (priv->accounts, g_object_ref (account),
- g_object_ref (connection));
-
- tp_connection_call_when_ready (connection, dispatcher_connection_ready_cb,
- dispatcher);
-
- g_object_unref (connection);
-}
-
-static void
-dispatcher_account_connection_cb (EmpathyAccountManager *manager,
- McAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus status,
- TpConnectionStatus previous,
- EmpathyDispatcher *dispatcher)
-{
- dispatcher_update_account (dispatcher, account);
-}
-
-static GObject*
-dispatcher_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *retval;
-
- if (dispatcher == NULL)
- {
- retval = G_OBJECT_CLASS (empathy_dispatcher_parent_class)->constructor
- (type, n_construct_params, construct_params);
-
- dispatcher = EMPATHY_DISPATCHER (retval);
- g_object_add_weak_pointer (retval, (gpointer) &dispatcher);
- }
- else
- {
- retval = g_object_ref (dispatcher);
- }
-
- return retval;
-}
-
-static void
-dispatcher_finalize (GObject *object)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (object);
- GList *l;
- GHashTableIter iter;
- gpointer connection;
-
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- dispatcher_account_connection_cb, object);
-
- for (l = priv->channels; l; l = l->next)
- {
- g_signal_handlers_disconnect_by_func (l->data,
- dispatcher_channel_invalidated_cb, object);
- }
-
- g_list_free (priv->channels);
-
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, &connection, NULL))
- {
- g_signal_handlers_disconnect_by_func (connection,
- dispatcher_connection_invalidated_cb, object);
- }
-
- g_object_unref (priv->account_manager);
- g_object_unref (priv->mc);
-
- g_hash_table_destroy (priv->accounts);
- g_hash_table_destroy (priv->connections);
-}
-
-static void
-empathy_dispatcher_class_init (EmpathyDispatcherClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = dispatcher_finalize;
- object_class->constructor = dispatcher_constructor;
-
- signals[OBSERVE] =
- g_signal_new ("observe",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_DISPATCH_OPERATION);
-
- signals[APPROVE] =
- g_signal_new ("approve",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_DISPATCH_OPERATION);
-
- signals[DISPATCH] =
- g_signal_new ("dispatch",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_DISPATCH_OPERATION);
-
- g_type_class_add_private (object_class, sizeof (EmpathyDispatcherPriv));
-
-}
-
-static void
-empathy_dispatcher_init (EmpathyDispatcher *dispatcher)
-{
- GList *accounts, *l;
- EmpathyDispatcherPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (dispatcher,
- EMPATHY_TYPE_DISPATCHER, EmpathyDispatcherPriv);
-
- dispatcher->priv = priv;
- priv->mc = empathy_mission_control_dup_singleton ();
- priv->account_manager = empathy_account_manager_dup_singleton ();
-
- g_signal_connect (priv->account_manager,
- "account-connection-changed",
- G_CALLBACK (dispatcher_account_connection_cb),
- dispatcher);
-
- priv->accounts = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal, g_object_unref, g_object_unref);
-
- priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- g_object_unref, (GDestroyNotify) free_connection_data);
-
- priv->channels = NULL;
-
- accounts = mc_accounts_list_by_enabled (TRUE);
-
- for (l = accounts; l; l = l->next)
- {
- dispatcher_update_account (dispatcher, l->data);
- g_object_unref (l->data);
- }
- g_list_free (accounts);
-}
-
-EmpathyDispatcher *
-empathy_dispatcher_dup_singleton (void)
-{
- return EMPATHY_DISPATCHER (g_object_new (EMPATHY_TYPE_DISPATCHER, NULL));
-}
-
-static void
-dispatcher_request_failed (EmpathyDispatcher *dispatcher,
- DispatcherRequestData *request_data,
- const GError *error)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- ConnectionData *conn_data;
-
- conn_data = g_hash_table_lookup (priv->connections, request_data->connection);
- if (request_data->cb != NULL)
- request_data->cb (NULL, error, request_data->user_data);
-
- conn_data->outstanding_requests =
- g_list_remove (conn_data->outstanding_requests, request_data);
- free_dispatcher_request_data (request_data);
-}
-
-static void
-dispatcher_connection_new_requested_channel (EmpathyDispatcher *dispatcher,
- DispatcherRequestData *request_data,
- const gchar *object_path,
- GHashTable *properties,
- const GError *error)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- EmpathyDispatchOperation *operation = NULL;
- ConnectionData *conn_data;
-
- conn_data = g_hash_table_lookup (priv->connections,
- request_data->connection);
-
- if (error)
- {
- DEBUG ("Channel request failed: %s", error->message);
-
- dispatcher_request_failed (dispatcher, request_data, error);
-
- goto out;
- }
-
- operation = g_hash_table_lookup (conn_data->outstanding_channels,
- object_path);
-
- if (operation != NULL)
- g_hash_table_remove (conn_data->outstanding_channels, object_path);
- else
- operation = g_hash_table_lookup (conn_data->dispatching_channels,
- object_path);
-
- if (operation == NULL)
- {
- DispatchData *data = g_hash_table_lookup (conn_data->dispatched_channels,
- object_path);
-
- if (data != NULL)
- {
- operation = empathy_dispatch_operation_new_with_wrapper (
- request_data->connection,
- data->channel, request_data->contact, FALSE,
- data->channel_wrapper);
- }
- else
- {
- TpChannel *channel;
-
- if (properties != NULL)
- channel = tp_channel_new_from_properties (request_data->connection,
- object_path, properties, NULL);
- else
- channel = tp_channel_new (request_data->connection, object_path,
- request_data->channel_type, request_data->handle_type,
- request_data->handle, NULL);
-
- g_signal_connect (channel, "invalidated",
- G_CALLBACK (dispatcher_channel_invalidated_cb),
- request_data->dispatcher);
-
- priv->channels = g_list_prepend (priv->channels, channel);
-
- operation = empathy_dispatch_operation_new (request_data->connection,
- channel, request_data->contact, FALSE);
- g_object_unref (channel);
- }
- }
- else
- {
- /* Already existed set potential extra information */
- g_object_set (G_OBJECT (operation),
- "contact", request_data->contact,
- NULL);
- }
-
- request_data->operation = operation;
-
- /* (pre)-approve this right away as we requested it
- * This might cause the channel to be claimed, in which case the operation
- * will disappear. So ref it, and check the status before starting the
- * dispatching */
-
- g_object_ref (operation);
- empathy_dispatch_operation_approve (operation);
-
- if (empathy_dispatch_operation_get_status (operation) <
- EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING)
- dispatcher_start_dispatching (request_data->dispatcher, operation,
- conn_data);
-
- g_object_unref (operation);
-
-out:
- dispatcher_flush_outstanding_operations (request_data->dispatcher,
- conn_data);
-}
-
-static void
-dispatcher_request_channel_cb (TpConnection *connection,
- const gchar *object_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (weak_object);
- DispatcherRequestData *request_data = (DispatcherRequestData*) user_data;
-
- dispatcher_connection_new_requested_channel (dispatcher,
- request_data, object_path, NULL, error);
-}
-
-static void
-dispatcher_request_channel (DispatcherRequestData *request_data)
-{
- tp_cli_connection_call_request_channel (request_data->connection, -1,
- request_data->channel_type,
- request_data->handle_type,
- request_data->handle,
- TRUE, dispatcher_request_channel_cb,
- request_data, NULL, G_OBJECT (request_data->dispatcher));
-}
-
-void
-empathy_dispatcher_call_with_contact (EmpathyContact *contact,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton();
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- McAccount *account;
- TpConnection *connection;
- ConnectionData *cd;
- DispatcherRequestData *request_data;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- account = empathy_contact_get_account (contact);
- connection = g_hash_table_lookup (priv->accounts, account);
-
- g_assert (connection != NULL);
- cd = g_hash_table_lookup (priv->connections, connection);
- request_data = new_dispatcher_request_data (dispatcher, connection,
- TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_HANDLE_TYPE_NONE, 0, NULL,
- contact, callback, user_data);
-
- cd->outstanding_requests = g_list_prepend
- (cd->outstanding_requests, request_data);
-
- dispatcher_request_channel (request_data);
-
- g_object_unref (dispatcher);
-}
-
-static void
-dispatcher_chat_with_contact_cb (EmpathyContact *contact,
- const GError *error,
- gpointer user_data,
- GObject *object)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
-
- request_data->handle = empathy_contact_get_handle (contact);
-
- dispatcher_request_channel (request_data);
-}
-
-void
-empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcher *dispatcher;
- EmpathyDispatcherPriv *priv;
- McAccount *account;
- TpConnection *connection;
- ConnectionData *connection_data;
- DispatcherRequestData *request_data;
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- dispatcher = empathy_dispatcher_dup_singleton();
- priv = GET_PRIV (dispatcher);
-
- account = empathy_contact_get_account (contact);
- connection = g_hash_table_lookup (priv->accounts, account);
- connection_data = g_hash_table_lookup (priv->connections, connection);
-
- /* The contact handle might not be known yet */
- request_data = new_dispatcher_request_data (dispatcher, connection,
- TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_CONTACT, 0, NULL,
- contact, callback, user_data);
-
- connection_data->outstanding_requests = g_list_prepend
- (connection_data->outstanding_requests, request_data);
-
- empathy_contact_call_when_ready (contact,
- EMPATHY_CONTACT_READY_HANDLE, dispatcher_chat_with_contact_cb,
- request_data, NULL, G_OBJECT (dispatcher));
-
- g_object_unref (dispatcher);
-}
-
-void
-empathy_dispatcher_chat_with_contact_id (McAccount *account,
- const gchar *contact_id,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton ();
- EmpathyContactFactory *factory;
- EmpathyContact *contact;
-
- g_return_if_fail (MC_IS_ACCOUNT (account));
- g_return_if_fail (!EMP_STR_EMPTY (contact_id));
-
- factory = empathy_contact_factory_dup_singleton ();
- contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
-
- empathy_dispatcher_chat_with_contact (contact, callback, user_data);
-
- g_object_unref (contact);
- g_object_unref (factory);
- g_object_unref (dispatcher);
-}
-
-static void
-dispatcher_request_handles_cb (TpConnection *connection,
- const GArray *handles,
- const GError *error,
- gpointer user_data,
- GObject *object)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
-
- if (error != NULL)
- {
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- ConnectionData *cd;
-
- cd = g_hash_table_lookup (priv->connections, request_data->connection);
-
- if (request_data->cb)
- request_data->cb (NULL, error, request_data->user_data);
-
- cd->outstanding_requests = g_list_remove (cd->outstanding_requests,
- request_data);
-
- free_dispatcher_request_data (request_data);
-
- dispatcher_flush_outstanding_operations (dispatcher, cd);
- return;
- }
-
- request_data->handle = g_array_index (handles, guint, 0);
- dispatcher_request_channel (request_data);
-}
-
-void
-empathy_dispatcher_join_muc (McAccount *account,
- const gchar *roomname,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcher *dispatcher;
- EmpathyDispatcherPriv *priv;
- DispatcherRequestData *request_data;
- TpConnection *connection;
- ConnectionData *connection_data;
- const gchar *names[] = { roomname, NULL };
-
- g_return_if_fail (MC_IS_ACCOUNT (account));
- g_return_if_fail (!EMP_STR_EMPTY (roomname));
-
- dispatcher = empathy_dispatcher_dup_singleton();
- priv = GET_PRIV (dispatcher);
-
- connection = g_hash_table_lookup (priv->accounts, account);
- connection_data = g_hash_table_lookup (priv->connections, connection);
-
-
- /* Don't know the room handle yet */
- request_data = new_dispatcher_request_data (dispatcher, connection,
- TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_ROOM, 0, NULL,
- NULL, callback, user_data);
-
- connection_data->outstanding_requests = g_list_prepend
- (connection_data->outstanding_requests, request_data);
-
- tp_cli_connection_call_request_handles (connection, -1,
- TP_HANDLE_TYPE_ROOM, names,
- dispatcher_request_handles_cb, request_data, NULL,
- G_OBJECT (dispatcher));
-
- g_object_unref (dispatcher);
-}
-
-static void
-dispatcher_create_channel_cb (TpConnection *connect,
- const gchar *object_path,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (weak_object);
- DispatcherRequestData *request_data = (DispatcherRequestData*) user_data;
-
- dispatcher_connection_new_requested_channel (dispatcher,
- request_data, object_path, properties, error);
-}
-
-void
-empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
- McAccount *account,
- GHashTable *request,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- ConnectionData *connection_data;
- DispatcherRequestData *request_data;
- const gchar *channel_type;
- guint handle_type;
- guint handle;
- gboolean valid;
- TpConnection *connection;
-
- g_return_if_fail (EMPATHY_IS_DISPATCHER (dispatcher));
- g_return_if_fail (MC_IS_ACCOUNT (account));
- g_return_if_fail (request != NULL);
-
- connection = g_hash_table_lookup (priv->accounts, account);
- g_assert (connection != NULL);
-
- connection_data = g_hash_table_lookup (priv->connections, connection);
- g_assert (connection_data != NULL);
-
- channel_type = tp_asv_get_string (request, TP_IFACE_CHANNEL ".ChannelType");
-
- handle_type = tp_asv_get_uint32 (request,
- TP_IFACE_CHANNEL ".TargetHandleType", &valid);
- if (!valid)
- handle_type = TP_UNKNOWN_HANDLE_TYPE;
-
- handle = tp_asv_get_uint32 (request, TP_IFACE_CHANNEL ".TargetHandle", NULL);
-
- request_data = new_dispatcher_request_data (dispatcher, connection,
- channel_type, handle_type, handle, request,
- NULL, callback, user_data);
-
- connection_data->outstanding_requests = g_list_prepend
- (connection_data->outstanding_requests, request_data);
-
- tp_cli_connection_interface_requests_call_create_channel (
- request_data->connection, -1,
- request_data->request, dispatcher_create_channel_cb, request_data, NULL,
- G_OBJECT (request_data->dispatcher));
-}
-
-static void
-dispatcher_create_channel_with_contact_cb (EmpathyContact *contact,
- const GError *error,
- gpointer user_data,
- GObject *object)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
- GValue *target_handle;
-
- g_assert (request_data->request);
-
- if (error != NULL)
- {
- dispatcher_request_failed (request_data->dispatcher,
- request_data, error);
- return;
- }
-
- request_data->handle = empathy_contact_get_handle (contact);
-
- target_handle = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (target_handle, request_data->handle);
- g_hash_table_insert (request_data->request,
- TP_IFACE_CHANNEL ".TargetHandle", target_handle);
-
- tp_cli_connection_interface_requests_call_create_channel (
- request_data->connection, -1,
- request_data->request, dispatcher_create_channel_cb, request_data, NULL,
- G_OBJECT (request_data->dispatcher));
-}
-
-static void
-dispatcher_send_file_connection_ready_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
-
- if (error != NULL)
- {
- dispatcher_request_failed (request_data->dispatcher,
- request_data, error);
- return;
- }
-
- empathy_contact_call_when_ready (request_data->contact,
- EMPATHY_CONTACT_READY_HANDLE, dispatcher_create_channel_with_contact_cb,
- request_data, NULL, G_OBJECT (request_data->dispatcher));
-}
-
-void
-empathy_dispatcher_send_file_to_contact (EmpathyContact *contact,
- const gchar *filename,
- guint64 size,
- guint64 date,
- const gchar *content_type,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton();
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- McAccount *account = empathy_contact_get_account (contact);
- TpConnection *connection = g_hash_table_lookup (priv->accounts, account);
- ConnectionData *connection_data =
- g_hash_table_lookup (priv->connections, connection);
- DispatcherRequestData *request_data;
- GValue *value;
- GHashTable *request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (!EMP_STR_EMPTY (filename));
- g_return_if_fail (!EMP_STR_EMPTY (content_type));
-
- /* org.freedesktop.Telepathy.Channel.ChannelType */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value);
-
- /* org.freedesktop.Telepathy.Channel.TargetHandleType */
- value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value);
-
- /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.ContentType */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, content_type);
- g_hash_table_insert (request,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentType", value);
-
- /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Filename */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, filename);
- g_hash_table_insert (request,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Filename", value);
-
- /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Size */
- value = tp_g_value_slice_new (G_TYPE_UINT64);
- g_value_set_uint64 (value, size);
- g_hash_table_insert (request,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Size", value);
-
- /* org.freedesktop.Telepathy.Channel.Type.FileTransfer.Date */
- value = tp_g_value_slice_new (G_TYPE_UINT64);
- g_value_set_uint64 (value, date);
- g_hash_table_insert (request,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".Date", value);
-
-
- /* The contact handle might not be known yet */
- request_data = new_dispatcher_request_data (dispatcher, connection,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT, 0, request,
- contact, callback, user_data);
- connection_data->outstanding_requests = g_list_prepend
- (connection_data->outstanding_requests, request_data);
-
- tp_connection_call_when_ready (connection,
- dispatcher_send_file_connection_ready_cb, (gpointer) request_data);
-
- g_object_unref (dispatcher);
-}
-
-GStrv
-empathy_dispatcher_find_channel_class (EmpathyDispatcher *dispatcher,
- McAccount *account,
- const gchar *channel_type,
- guint handle_type)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- ConnectionData *cd;
- TpConnection *connection;
- int i;
- GPtrArray *classes;
-
- g_return_val_if_fail (channel_type != NULL, NULL);
- g_return_val_if_fail (handle_type != 0, NULL);
-
- connection = g_hash_table_lookup (priv->accounts, account);
-
- if (connection == NULL)
- return NULL;
-
- cd = g_hash_table_lookup (priv->connections, connection);
-
- if (cd == NULL)
- return NULL;
-
-
- classes = cd->requestable_channels;
- if (classes == NULL)
- return NULL;
-
- for (i = 0; i < classes->len; i++)
- {
- GValueArray *class;
- GValue *fixed;
- GValue *allowed;
- GHashTable *fprops;
- const gchar *c_type;
- guint32 h_type;
- gboolean valid;
-
- class = g_ptr_array_index (classes, i);
- fixed = g_value_array_get_nth (class, 0);
-
- fprops = g_value_get_boxed (fixed);
- c_type = tp_asv_get_string (fprops, TP_IFACE_CHANNEL ".ChannelType");
-
- if (tp_strdiff (channel_type, c_type))
- continue;
-
- h_type = tp_asv_get_uint32 (fprops,
- TP_IFACE_CHANNEL ".TargetHandleType", &valid);
-
- if (!valid || handle_type != h_type)
- continue;
-
- allowed = g_value_array_get_nth (class, 1);
-
- return g_value_get_boxed (allowed);
- }
-
- return NULL;
-}
-
diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h
deleted file mode 100644
index 13ef06afd..000000000
--- a/libempathy/empathy-dispatcher.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_DISPATCHER_H__
-#define __EMPATHY_DISPATCHER_H__
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <telepathy-glib/channel.h>
-
-#include "empathy-contact.h"
-#include "empathy-dispatch-operation.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_DISPATCHER (empathy_dispatcher_get_type ())
-#define EMPATHY_DISPATCHER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_DISPATCHER, EmpathyDispatcher))
-#define EMPATHY_DISPATCHER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_DISPATCHER, EmpathyDispatcherClass))
-#define EMPATHY_IS_DISPATCHER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_DISPATCHER))
-#define EMPATHY_IS_DISPATCHER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_DISPATCHER))
-#define EMPATHY_DISPATCHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_DISPATCHER, EmpathyDispatcherClass))
-
-typedef struct _EmpathyDispatcher EmpathyDispatcher;
-typedef struct _EmpathyDispatcherClass EmpathyDispatcherClass;
-
-struct _EmpathyDispatcher
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyDispatcherClass
-{
- GObjectClass parent_class;
-};
-
-/* Will be called when the channel is ready for dispatching. The requestor
- * handle the channel itself by calling empathy_dispatch_operation_handles */
-typedef void (EmpathyDispatcherRequestCb) (
- EmpathyDispatchOperation *dispatch, const GError *error,
- gpointer user_data);
-
-GType empathy_dispatcher_get_type (void) G_GNUC_CONST;
-
-void empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
- McAccount *account, GHashTable *request,
- EmpathyDispatcherRequestCb *callback, gpointer user_data);
-
-/* Requesting 1 to 1 stream media channels */
-void empathy_dispatcher_call_with_contact (EmpathyContact *contact,
- EmpathyDispatcherRequestCb *callback, gpointer user_data);
-
-/* Requesting 1 to 1 text channels */
-void empathy_dispatcher_chat_with_contact_id (McAccount *account,
- const gchar *contact_id, EmpathyDispatcherRequestCb *callback,
- gpointer user_data);
-void empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
- EmpathyDispatcherRequestCb *callback, gpointer user_data);
-
-/* Request a file channel to a specific contact */
-void empathy_dispatcher_send_file_to_contact (EmpathyContact *contact,
- const gchar *filename, guint64 size, guint64 date,
- const gchar *content_type, EmpathyDispatcherRequestCb *callback,
- gpointer user_data);
-
-/* Request a muc channel */
-void empathy_dispatcher_join_muc (McAccount *account,
- const gchar *roomname, EmpathyDispatcherRequestCb *callback,
- gpointer user_data);
-
-GStrv empathy_dispatcher_find_channel_class (EmpathyDispatcher *dispatcher,
- McAccount *account, const gchar *channel_type, guint handle_type);
-
-/* Get the dispatcher singleton */
-EmpathyDispatcher * empathy_dispatcher_dup_singleton (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_DISPATCHER_H__ */
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
deleted file mode 100644
index eeb183892..000000000
--- a/libempathy/empathy-idle.c
+++ /dev/null
@@ -1,680 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-#include <dbus/dbus-glib.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-enum-types.h>
-
-#include "empathy-idle.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-/* Number of seconds before entering extended autoaway. */
-#define EXT_AWAY_TIME (30*60)
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIdle)
-typedef struct {
- MissionControl *mc;
- DBusGProxy *gs_proxy;
- DBusGProxy *nm_proxy;
-
- McPresence state;
- gchar *status;
- McPresence flash_state;
- gboolean auto_away;
- gboolean use_nm;
-
- McPresence away_saved_state;
- McPresence nm_saved_state;
- gchar *nm_saved_status;
-
- gboolean is_idle;
- gboolean nm_connected;
- guint ext_away_timeout;
-} EmpathyIdlePriv;
-
-typedef enum {
- NM_STATE_UNKNOWN,
- NM_STATE_ASLEEP,
- NM_STATE_CONNECTING,
- NM_STATE_CONNECTED,
- NM_STATE_DISCONNECTED
-} NMState;
-
-enum {
- PROP_0,
- PROP_STATE,
- PROP_STATUS,
- PROP_FLASH_STATE,
- PROP_AUTO_AWAY,
- PROP_USE_NM
-};
-
-G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT);
-
-static EmpathyIdle * idle_singleton = NULL;
-
-static void
-idle_presence_changed_cb (MissionControl *mc,
- McPresence state,
- gchar *status,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Presence changed to '%s' (%d)", status, state);
-
- g_free (priv->status);
- priv->state = state;
- priv->status = NULL;
- if (!EMP_STR_EMPTY (status)) {
- priv->status = g_strdup (status);
- }
-
- g_object_notify (G_OBJECT (idle), "state");
- g_object_notify (G_OBJECT (idle), "status");
-}
-
-static gboolean
-idle_ext_away_cb (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Going to extended autoaway");
- empathy_idle_set_state (idle, MC_PRESENCE_EXTENDED_AWAY);
- priv->ext_away_timeout = 0;
-
- return FALSE;
-}
-
-static void
-idle_ext_away_stop (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- if (priv->ext_away_timeout) {
- g_source_remove (priv->ext_away_timeout);
- priv->ext_away_timeout = 0;
- }
-}
-
-static void
-idle_ext_away_start (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- if (priv->ext_away_timeout != 0) {
- return;
- }
- priv->ext_away_timeout = g_timeout_add_seconds (EXT_AWAY_TIME,
- (GSourceFunc) idle_ext_away_cb,
- idle);
-}
-
-static void
-idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
- gboolean is_idle,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Session idle state changed, %s -> %s",
- priv->is_idle ? "yes" : "no",
- is_idle ? "yes" : "no");
-
- if (!priv->auto_away ||
- (priv->nm_saved_state == MC_PRESENCE_UNSET &&
- (priv->state <= MC_PRESENCE_OFFLINE ||
- priv->state == MC_PRESENCE_HIDDEN))) {
- /* We don't want to go auto away OR we explicitely asked to be
- * offline, nothing to do here */
- priv->is_idle = is_idle;
- return;
- }
-
- if (is_idle && !priv->is_idle) {
- McPresence new_state;
- /* We are now idle */
-
- idle_ext_away_start (idle);
-
- if (priv->nm_saved_state != MC_PRESENCE_UNSET) {
- /* We are disconnected, when coming back from away
- * we want to restore the presence before the
- * disconnection. */
- priv->away_saved_state = priv->nm_saved_state;
- } else {
- priv->away_saved_state = priv->state;
- }
-
- new_state = MC_PRESENCE_AWAY;
- if (priv->state == MC_PRESENCE_EXTENDED_AWAY) {
- new_state = MC_PRESENCE_EXTENDED_AWAY;
- }
-
- DEBUG ("Going to autoaway. Saved state=%d, new state=%d",
- priv->away_saved_state, new_state);
- empathy_idle_set_state (idle, new_state);
- } else if (!is_idle && priv->is_idle) {
- const gchar *new_status;
- /* We are no more idle, restore state */
-
- idle_ext_away_stop (idle);
-
- if (priv->away_saved_state == MC_PRESENCE_AWAY ||
- priv->away_saved_state == MC_PRESENCE_EXTENDED_AWAY) {
- priv->away_saved_state = MC_PRESENCE_AVAILABLE;
- new_status = NULL;
- } else {
- new_status = priv->status;
- }
-
- DEBUG ("Restoring state to %d, reset status to %s",
- priv->away_saved_state, new_status);
-
- empathy_idle_set_presence (idle,
- priv->away_saved_state,
- new_status);
-
- priv->away_saved_state = MC_PRESENCE_UNSET;
- }
-
- priv->is_idle = is_idle;
-}
-
-static void
-idle_nm_state_change_cb (DBusGProxy *proxy,
- guint state,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
- gboolean old_nm_connected;
- gboolean new_nm_connected;
-
- priv = GET_PRIV (idle);
-
- if (!priv->use_nm) {
- return;
- }
-
- old_nm_connected = priv->nm_connected;
- new_nm_connected = !(state == NM_STATE_CONNECTING ||
- state == NM_STATE_DISCONNECTED);
- priv->nm_connected = TRUE; /* To be sure _set_state will work */
-
- DEBUG ("New network state %d", state);
-
- if (old_nm_connected && !new_nm_connected) {
- /* We are no more connected */
- DEBUG ("Disconnected: Save state %d (%s)",
- priv->state, priv->status);
- priv->nm_saved_state = priv->state;
- g_free (priv->nm_saved_status);
- priv->nm_saved_status = g_strdup (priv->status);
- empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);
- }
- else if (!old_nm_connected && new_nm_connected) {
- /* We are now connected */
- DEBUG ("Reconnected: Restore state %d (%s)",
- priv->nm_saved_state, priv->nm_saved_status);
- empathy_idle_set_presence (idle,
- priv->nm_saved_state,
- priv->nm_saved_status);
- priv->nm_saved_state = MC_PRESENCE_UNSET;
- g_free (priv->nm_saved_status);
- priv->nm_saved_status = NULL;
- }
-
- priv->nm_connected = new_nm_connected;
-}
-
-static void
-idle_finalize (GObject *object)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (object);
-
- g_free (priv->status);
- g_object_unref (priv->mc);
-
- if (priv->gs_proxy) {
- g_object_unref (priv->gs_proxy);
- }
-
- idle_ext_away_stop (EMPATHY_IDLE (object));
-}
-
-static GObject *
-idle_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *retval;
-
- if (idle_singleton) {
- retval = g_object_ref (idle_singleton);
- } else {
- retval = G_OBJECT_CLASS (empathy_idle_parent_class)->constructor
- (type, n_props, props);
-
- idle_singleton = EMPATHY_IDLE (retval);
- g_object_add_weak_pointer (retval, (gpointer) &idle_singleton);
- }
-
- return retval;
-}
-
-static void
-idle_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIdlePriv *priv;
- EmpathyIdle *idle;
-
- priv = GET_PRIV (object);
- idle = EMPATHY_IDLE (object);
-
- switch (param_id) {
- case PROP_STATE:
- g_value_set_enum (value, empathy_idle_get_state (idle));
- break;
- case PROP_STATUS:
- g_value_set_string (value, empathy_idle_get_status (idle));
- break;
- case PROP_FLASH_STATE:
- g_value_set_enum (value, empathy_idle_get_flash_state (idle));
- break;
- case PROP_AUTO_AWAY:
- g_value_set_boolean (value, empathy_idle_get_auto_away (idle));
- break;
- case PROP_USE_NM:
- g_value_set_boolean (value, empathy_idle_get_use_nm (idle));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-idle_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIdlePriv *priv;
- EmpathyIdle *idle;
-
- priv = GET_PRIV (object);
- idle = EMPATHY_IDLE (object);
-
- switch (param_id) {
- case PROP_STATE:
- empathy_idle_set_state (idle, g_value_get_enum (value));
- break;
- case PROP_STATUS:
- empathy_idle_set_status (idle, g_value_get_string (value));
- break;
- case PROP_FLASH_STATE:
- empathy_idle_set_flash_state (idle, g_value_get_enum (value));
- break;
- case PROP_AUTO_AWAY:
- empathy_idle_set_auto_away (idle, g_value_get_boolean (value));
- break;
- case PROP_USE_NM:
- empathy_idle_set_use_nm (idle, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-empathy_idle_class_init (EmpathyIdleClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = idle_finalize;
- object_class->constructor = idle_constructor;
- object_class->get_property = idle_get_property;
- object_class->set_property = idle_set_property;
-
- g_object_class_install_property (object_class,
- PROP_STATE,
- g_param_spec_enum ("state",
- "state",
- "state",
- MC_TYPE_PRESENCE,
- MC_PRESENCE_AVAILABLE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_STATUS,
- g_param_spec_string ("status",
- "status",
- "status",
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_FLASH_STATE,
- g_param_spec_enum ("flash-state",
- "flash-state",
- "flash-state",
- MC_TYPE_PRESENCE,
- MC_PRESENCE_UNSET,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_AUTO_AWAY,
- g_param_spec_boolean ("auto-away",
- "Automatic set presence to away",
- "Should it set presence to away if inactive",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_USE_NM,
- g_param_spec_boolean ("use-nm",
- "Use Network Manager",
- "Set presence according to Network Manager",
- FALSE,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
-}
-
-static void
-empathy_idle_init (EmpathyIdle *idle)
-{
- DBusGConnection *system_bus;
- GError *error = NULL;
- EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
- EMPATHY_TYPE_IDLE, EmpathyIdlePriv);
-
- idle->priv = priv;
- priv->is_idle = FALSE;
- priv->mc = empathy_mission_control_dup_singleton ();
- priv->state = mission_control_get_presence_actual (priv->mc, &error);
- if (error) {
- DEBUG ("Error getting actual presence: %s", error->message);
-
- priv->state = MC_PRESENCE_UNSET;
- g_clear_error (&error);
- }
- priv->status = mission_control_get_presence_message_actual (priv->mc, &error);
- if (error || EMP_STR_EMPTY (priv->status)) {
- g_free (priv->status);
- priv->status = NULL;
-
- if (error) {
- DEBUG ("Error getting actual presence message: %s", error->message);
- g_clear_error (&error);
- }
- }
-
- dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc),
- "PresenceChanged",
- G_CALLBACK (idle_presence_changed_cb),
- idle, NULL);
-
- priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
- "org.gnome.ScreenSaver",
- "/org/gnome/ScreenSaver",
- "org.gnome.ScreenSaver");
- if (priv->gs_proxy) {
- dbus_g_proxy_add_signal (priv->gs_proxy, "SessionIdleChanged",
- G_TYPE_BOOLEAN,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->gs_proxy, "SessionIdleChanged",
- G_CALLBACK (idle_session_idle_changed_cb),
- idle, NULL);
- } else {
- DEBUG ("Failed to get gs proxy");
- }
-
-
- system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (!system_bus) {
- DEBUG ("Failed to get system bus: %s",
- error ? error->message : "No error given");
- } else {
- priv->nm_proxy = dbus_g_proxy_new_for_name (system_bus,
- "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.NetworkManager");
- }
- if (priv->nm_proxy) {
- dbus_g_proxy_add_signal (priv->nm_proxy, "StateChange",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->nm_proxy, "StateChange",
- G_CALLBACK (idle_nm_state_change_cb),
- idle, NULL);
- } else {
- DEBUG ("Failed to get nm proxy");
- }
-
- priv->nm_connected = TRUE;
-}
-
-EmpathyIdle *
-empathy_idle_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_IDLE, NULL);
-}
-
-McPresence
-empathy_idle_get_state (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- return priv->state;
-}
-
-void
-empathy_idle_set_state (EmpathyIdle *idle,
- McPresence state)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- empathy_idle_set_presence (idle, state, priv->status);
-}
-
-const gchar *
-empathy_idle_get_status (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- if (!priv->status) {
- return empathy_presence_get_default_message (priv->state);
- }
-
- return priv->status;
-}
-
-void
-empathy_idle_set_status (EmpathyIdle *idle,
- const gchar *status)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- empathy_idle_set_presence (idle, priv->state, status);
-}
-
-McPresence
-empathy_idle_get_flash_state (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- return priv->flash_state;
-}
-
-void
-empathy_idle_set_flash_state (EmpathyIdle *idle,
- McPresence state)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- priv->flash_state = state;
-
- if (state == MC_PRESENCE_UNSET) {
- }
-
- g_object_notify (G_OBJECT (idle), "flash-state");
-}
-
-void
-empathy_idle_set_presence (EmpathyIdle *idle,
- McPresence state,
- const gchar *status)
-{
- EmpathyIdlePriv *priv;
- const gchar *default_status;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Changing presence to %s (%d)", status, state);
-
- /* Do not set translated default messages */
- default_status = empathy_presence_get_default_message (state);
- if (!tp_strdiff (status, default_status)) {
- status = NULL;
- }
-
- if (!priv->nm_connected) {
- DEBUG ("NM not connected");
-
- priv->nm_saved_state = state;
- if (tp_strdiff (priv->status, status)) {
- g_free (priv->status);
- priv->status = NULL;
- if (!EMP_STR_EMPTY (status)) {
- priv->status = g_strdup (status);
- }
- g_object_notify (G_OBJECT (idle), "status");
- }
-
- return;
- }
-
- mission_control_set_presence (priv->mc, state, status, NULL, NULL);
-}
-
-gboolean
-empathy_idle_get_auto_away (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv = GET_PRIV (idle);
-
- return priv->auto_away;
-}
-
-void
-empathy_idle_set_auto_away (EmpathyIdle *idle,
- gboolean auto_away)
-{
- EmpathyIdlePriv *priv = GET_PRIV (idle);
-
- priv->auto_away = auto_away;
-
- g_object_notify (G_OBJECT (idle), "auto-away");
-}
-
-gboolean
-empathy_idle_get_use_nm (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv = GET_PRIV (idle);
-
- return priv->use_nm;
-}
-
-void
-empathy_idle_set_use_nm (EmpathyIdle *idle,
- gboolean use_nm)
-{
- EmpathyIdlePriv *priv = GET_PRIV (idle);
-
- if (!priv->nm_proxy || use_nm == priv->use_nm) {
- return;
- }
-
- priv->use_nm = use_nm;
-
- if (use_nm) {
- guint nm_status;
- GError *error = NULL;
-
- dbus_g_proxy_call (priv->nm_proxy, "state",
- &error,
- G_TYPE_INVALID,
- G_TYPE_UINT, &nm_status,
- G_TYPE_INVALID);
-
- if (error) {
- DEBUG ("Couldn't get NM state: %s", error->message);
- g_clear_error (&error);
- nm_status = NM_STATE_ASLEEP;
- }
-
- idle_nm_state_change_cb (priv->nm_proxy, nm_status, idle);
- } else {
- priv->nm_connected = TRUE;
- if (priv->nm_saved_state != MC_PRESENCE_UNSET) {
- empathy_idle_set_state (idle, priv->nm_saved_state);
- }
- priv->nm_saved_state = MC_PRESENCE_UNSET;
- }
-
- g_object_notify (G_OBJECT (idle), "use-nm");
-}
-
diff --git a/libempathy/empathy-idle.h b/libempathy/empathy-idle.h
deleted file mode 100644
index 7296f7cd4..000000000
--- a/libempathy/empathy-idle.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_IDLE_H__
-#define __EMPATHY_IDLE_H__
-
-#include <glib.h>
-
-#include <libmissioncontrol/mission-control.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_IDLE (empathy_idle_get_type ())
-#define EMPATHY_IDLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_IDLE, EmpathyIdle))
-#define EMPATHY_IDLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_IDLE, EmpathyIdleClass))
-#define EMPATHY_IS_IDLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_IDLE))
-#define EMPATHY_IS_IDLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_IDLE))
-#define EMPATHY_IDLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_IDLE, EmpathyIdleClass))
-
-typedef struct _EmpathyIdle EmpathyIdle;
-typedef struct _EmpathyIdleClass EmpathyIdleClass;
-
-struct _EmpathyIdle {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyIdleClass {
- GObjectClass parent_class;
-};
-
-GType empathy_idle_get_type (void) G_GNUC_CONST;
-EmpathyIdle *empathy_idle_dup_singleton (void);
-McPresence empathy_idle_get_state (EmpathyIdle *idle);
-void empathy_idle_set_state (EmpathyIdle *idle,
- McPresence state);
-const gchar *empathy_idle_get_status (EmpathyIdle *idle);
-void empathy_idle_set_status (EmpathyIdle *idle,
- const gchar *status);
-McPresence empathy_idle_get_flash_state (EmpathyIdle *idle);
-void empathy_idle_set_flash_state (EmpathyIdle *idle,
- McPresence state);
-void empathy_idle_set_presence (EmpathyIdle *idle,
- McPresence state,
- const gchar *status);
-gboolean empathy_idle_get_auto_away (EmpathyIdle *idle);
-void empathy_idle_set_auto_away (EmpathyIdle *idle,
- gboolean auto_away);
-gboolean empathy_idle_get_use_nm (EmpathyIdle *idle);
-void empathy_idle_set_use_nm (EmpathyIdle *idle,
- gboolean use_nm);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_IDLE_H__ */
diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c
deleted file mode 100644
index ce1f90b23..000000000
--- a/libempathy/empathy-irc-network-manager.c
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Guillaume Desmottes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "empathy-utils.h"
-#include "empathy-irc-network-manager.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_IRC
-#include "empathy-debug.h"
-
-#define IRC_NETWORKS_DTD_FILENAME "empathy-irc-networks.dtd"
-#define SAVE_TIMER 4
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcNetworkManager)
-typedef struct {
- GHashTable *networks;
-
- gchar *global_file;
- gchar *user_file;
- guint last_id;
-
- /* Do we have to save modifications to the user file ? */
- gboolean have_to_save;
- /* Are we loading networks from XML files ? */
- gboolean loading;
- /* source id of the autosave timer */
- gint save_timer_id;
-} EmpathyIrcNetworkManagerPriv;
-
-/* properties */
-enum
-{
- PROP_GLOBAL_FILE = 1,
- PROP_USER_FILE,
- LAST_PROPERTY
-};
-
-G_DEFINE_TYPE (EmpathyIrcNetworkManager, empathy_irc_network_manager,
- G_TYPE_OBJECT);
-
-static void irc_network_manager_load_servers (
- EmpathyIrcNetworkManager *manager);
-static gboolean irc_network_manager_file_parse (
- EmpathyIrcNetworkManager *manager, const gchar *filename,
- gboolean user_defined);
-static gboolean irc_network_manager_file_save (
- EmpathyIrcNetworkManager *manager);
-
-static void
-empathy_irc_network_manager_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcNetworkManager *self = EMPATHY_IRC_NETWORK_MANAGER (object);
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_GLOBAL_FILE:
- g_value_set_string (value, priv->global_file);
- break;
- case PROP_USER_FILE:
- g_value_set_string (value, priv->user_file);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_irc_network_manager_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcNetworkManager *self = EMPATHY_IRC_NETWORK_MANAGER (object);
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_GLOBAL_FILE:
- g_free (priv->global_file);
- priv->global_file = g_value_dup_string (value);
- break;
- case PROP_USER_FILE:
- g_free (priv->user_file);
- priv->user_file = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static GObject *
-empathy_irc_network_manager_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *obj;
- EmpathyIrcNetworkManager *self;
-
- /* Parent constructor chain */
- obj = G_OBJECT_CLASS (empathy_irc_network_manager_parent_class)->
- constructor (type, n_props, props);
-
- self = EMPATHY_IRC_NETWORK_MANAGER (obj);
- irc_network_manager_load_servers (self);
-
- return obj;
-}
-
-static void
-empathy_irc_network_manager_finalize (GObject *object)
-{
- EmpathyIrcNetworkManager *self = EMPATHY_IRC_NETWORK_MANAGER (object);
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- if (priv->save_timer_id > 0)
- {
- g_source_remove (priv->save_timer_id);
- }
-
- if (priv->have_to_save)
- {
- irc_network_manager_file_save (self);
- }
-
- g_free (priv->global_file);
- g_free (priv->user_file);
-
- g_hash_table_destroy (priv->networks);
-
- G_OBJECT_CLASS (empathy_irc_network_manager_parent_class)->finalize (object);
-}
-
-static void
-empathy_irc_network_manager_init (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- EMPATHY_TYPE_IRC_NETWORK_MANAGER, EmpathyIrcNetworkManagerPriv);
-
- self->priv = priv;
-
- priv->networks = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
-
- priv->last_id = 0;
-
- priv->have_to_save = FALSE;
- priv->loading = FALSE;
- priv->save_timer_id = 0;
-}
-
-static void
-empathy_irc_network_manager_class_init (EmpathyIrcNetworkManagerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- object_class->constructor = empathy_irc_network_manager_constructor;
- object_class->get_property = empathy_irc_network_manager_get_property;
- object_class->set_property = empathy_irc_network_manager_set_property;
-
- g_type_class_add_private (object_class, sizeof (EmpathyIrcNetworkManagerPriv));
-
- object_class->finalize = empathy_irc_network_manager_finalize;
-
- param_spec = g_param_spec_string (
- "global-file",
- "path of the global networks file",
- "The path of the system-wide filename from which we have to load"
- " the networks list",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_GLOBAL_FILE, param_spec);
-
- param_spec = g_param_spec_string (
- "user-file",
- "path of the user networks file",
- "The path of user's filename from which we have to load"
- " the networks list and to which we'll save his modifications",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_USER_FILE, param_spec);
-}
-
-/**
- * empathy_irc_network_manager_new:
- * @global_file: the path of the global networks file, or %NULL
- * @user_file: the path of the user networks file, or %NULL
- *
- * Creates a new #EmpathyIrcNetworkManager
- *
- * Returns: a new #EmpathyIrcNetworkManager
- */
-EmpathyIrcNetworkManager *
-empathy_irc_network_manager_new (const gchar *global_file,
- const gchar *user_file)
-{
- EmpathyIrcNetworkManager *manager;
-
- manager = g_object_new (EMPATHY_TYPE_IRC_NETWORK_MANAGER,
- "global-file", global_file,
- "user-file", user_file,
- NULL);
-
- return manager;
-}
-
-static gboolean
-save_timeout (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- priv->save_timer_id = 0;
- irc_network_manager_file_save (self);
-
- return FALSE;
-}
-
-static void
-reset_save_timeout (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- if (priv->save_timer_id > 0)
- {
- g_source_remove (priv->save_timer_id);
- }
-
- priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER,
- (GSourceFunc) save_timeout, self);
-}
-
-static void
-network_modified (EmpathyIrcNetwork *network,
- EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- network->user_defined = TRUE;
-
- if (!priv->loading)
- {
- priv->have_to_save = TRUE;
- reset_save_timeout (self);
- }
-}
-
-static void
-add_network (EmpathyIrcNetworkManager *self,
- EmpathyIrcNetwork *network,
- const gchar *id)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- g_hash_table_insert (priv->networks, g_strdup (id), g_object_ref (network));
-
- g_signal_connect (network, "modified", G_CALLBACK (network_modified), self);
-}
-
-/**
- * empathy_irc_network_manager_add:
- * @manager: an #EmpathyIrcNetworkManager
- * @network: the #EmpathyIrcNetwork to add
- *
- * Add an #EmpathyIrcNetwork to the given #EmpathyIrcNetworkManager.
- *
- */
-void
-empathy_irc_network_manager_add (EmpathyIrcNetworkManager *self,
- EmpathyIrcNetwork *network)
-{
- EmpathyIrcNetworkManagerPriv *priv;
- gchar *id = NULL;
-
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self));
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK (network));
-
- priv = GET_PRIV (self);
-
- /* generate an id for this network */
- do
- {
- g_free (id);
- id = g_strdup_printf ("id%u", ++priv->last_id);
- } while (g_hash_table_lookup (priv->networks, id) != NULL &&
- priv->last_id < G_MAXUINT);
-
- if (priv->last_id == G_MAXUINT)
- {
- DEBUG ("Can't add network: too many networks using a similiar ID");
- return;
- }
-
- DEBUG ("add server with \"%s\" as ID", id);
-
- network->user_defined = TRUE;
- add_network (self, network, id);
-
- priv->have_to_save = TRUE;
- reset_save_timeout (self);
-
- g_free (id);
-}
-
-/**
- * empathy_irc_network_manager_remove:
- * @manager: an #EmpathyIrcNetworkManager
- * @network: the #EmpathyIrcNetwork to remove
- *
- * Remove an #EmpathyIrcNetwork from the given #EmpathyIrcNetworkManager.
- *
- */
-void
-empathy_irc_network_manager_remove (EmpathyIrcNetworkManager *self,
- EmpathyIrcNetwork *network)
-{
- EmpathyIrcNetworkManagerPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self));
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK (network));
-
- priv = GET_PRIV (self);
-
- network->user_defined = TRUE;
- network->dropped = TRUE;
-
- priv->have_to_save = TRUE;
- reset_save_timeout (self);
-}
-
-static void
-append_network_to_list (const gchar *id,
- EmpathyIrcNetwork *network,
- GSList **list)
-{
- if (network->dropped)
- return;
-
- *list = g_slist_prepend (*list, g_object_ref (network));
-}
-
-/**
- * empathy_irc_network_manager_get_networks:
- * @manager: an #EmpathyIrcNetworkManager
- *
- * Get the list of #EmpathyIrcNetwork associated with the given
- * manager.
- *
- * Returns: a new #GSList of refed #EmpathyIrcNetwork
- */
-GSList *
-empathy_irc_network_manager_get_networks (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv;
- GSList *irc_networks = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self), NULL);
-
- priv = GET_PRIV (self);
-
- g_hash_table_foreach (priv->networks, (GHFunc) append_network_to_list,
- &irc_networks);
-
- return irc_networks;
-}
-
-/*
- * API to save/load and parse the irc_networks file.
- */
-
-static void
-load_global_file (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- if (priv->global_file == NULL)
- return;
-
- if (!g_file_test (priv->global_file, G_FILE_TEST_EXISTS))
- {
- DEBUG ("Global networks file %s doesn't exist", priv->global_file);
- return;
- }
-
- irc_network_manager_file_parse (self, priv->global_file, FALSE);
-}
-
-static void
-load_user_file (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- if (priv->user_file == NULL)
- return;
-
- if (!g_file_test (priv->user_file, G_FILE_TEST_EXISTS))
- {
- DEBUG ("User networks file %s doesn't exist", priv->global_file);
- return;
- }
-
- irc_network_manager_file_parse (self, priv->user_file, TRUE);
-}
-
-static void
-irc_network_manager_load_servers (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
-
- priv->loading = TRUE;
-
- load_global_file (self);
- load_user_file (self);
-
- priv->loading = FALSE;
- priv->have_to_save = FALSE;
-}
-
-static void
-irc_network_manager_parse_irc_server (EmpathyIrcNetwork *network,
- xmlNodePtr node)
-{
- xmlNodePtr server_node;
-
- for (server_node = node->children; server_node;
- server_node = server_node->next)
- {
- gchar *address = NULL, *port = NULL, *ssl = NULL;
-
- if (strcmp (server_node->name, "server") != 0)
- continue;
-
- address = xmlGetProp (server_node, "address");
- port = xmlGetProp (server_node, "port");
- ssl = xmlGetProp (server_node, "ssl");
-
- if (address != NULL)
- {
- gint port_nb = 0;
- gboolean have_ssl = FALSE;
- EmpathyIrcServer *server;
-
- if (port != NULL)
- port_nb = strtol (port, NULL, 10);
-
- if (port_nb <= 0 || port_nb > G_MAXUINT16)
- port_nb = 6667;
-
- if (ssl == NULL || strcmp (ssl, "TRUE") == 0)
- have_ssl = TRUE;
-
- DEBUG ("parsed server %s port %d ssl %d", address, port_nb, have_ssl);
-
- server = empathy_irc_server_new (address, port_nb, have_ssl);
- empathy_irc_network_append_server (network, server);
- }
-
- if (address)
- xmlFree (address);
- if (port)
- xmlFree (port);
- if (ssl)
- xmlFree (ssl);
- }
-}
-
-static void
-irc_network_manager_parse_irc_network (EmpathyIrcNetworkManager *self,
- xmlNodePtr node,
- gboolean user_defined)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
- EmpathyIrcNetwork *network;
- xmlNodePtr child;
- gchar *str;
- gchar *id, *name;
-
- id = xmlGetProp (node, "id");
- if (xmlHasProp (node, "dropped"))
- {
- if (!user_defined)
- {
- DEBUG ("the 'dropped' attribute shouldn't be used in the global file");
- }
-
- network = g_hash_table_lookup (priv->networks, id);
- if (network != NULL)
- {
- network->dropped = TRUE;
- network->user_defined = TRUE;
- }
- xmlFree (id);
- return;
- }
-
- if (!xmlHasProp (node, "name"))
- return;
-
- name = xmlGetProp (node, "name");
- network = empathy_irc_network_new (name);
-
- if (xmlHasProp (node, "network_charset"))
- {
- gchar *charset;
- charset = xmlGetProp (node, "network_charset");
- g_object_set (network, "charset", charset, NULL);
- xmlFree (charset);
- }
-
- add_network (self, network, id);
- DEBUG ("add network %s (id %s)", name, id);
-
- for (child = node->children; child; child = child->next)
- {
- gchar *tag;
-
- tag = (gchar *) child->name;
- str = (gchar *) xmlNodeGetContent (child);
-
- if (!str)
- continue;
-
- if (strcmp (tag, "servers") == 0)
- {
- irc_network_manager_parse_irc_server (network, child);
- }
-
- xmlFree (str);
- }
-
- network->user_defined = user_defined;
- g_object_unref (network);
- xmlFree (name);
- xmlFree (id);
-}
-
-static gboolean
-irc_network_manager_file_parse (EmpathyIrcNetworkManager *self,
- const gchar *filename,
- gboolean user_defined)
-{
- EmpathyIrcNetworkManagerPriv *priv;
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr networks;
- xmlNodePtr node;
-
- priv = GET_PRIV (self);
-
- DEBUG ("Attempting to parse file:'%s'...", filename);
-
- ctxt = xmlNewParserCtxt ();
-
- /* Parse and validate the file. */
- doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
- if (!doc)
- {
- g_warning ("Failed to parse file:'%s'", filename);
- xmlFreeParserCtxt (ctxt);
- return FALSE;
- }
-
- if (!empathy_xml_validate (doc, IRC_NETWORKS_DTD_FILENAME)) {
- g_warning ("Failed to validate file:'%s'", filename);
- xmlFreeDoc (doc);
- xmlFreeParserCtxt (ctxt);
- return FALSE;
- }
-
- /* The root node, networks. */
- networks = xmlDocGetRootElement (doc);
-
- for (node = networks->children; node; node = node->next)
- {
- irc_network_manager_parse_irc_network (self, node, user_defined);
- }
-
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
-
- return TRUE;
-}
-
-static void
-write_network_to_xml (const gchar *id,
- EmpathyIrcNetwork *network,
- xmlNodePtr root)
-{
- xmlNodePtr network_node, servers_node;
- GSList *servers, *l;
- gchar *name, *charset;
-
- if (!network->user_defined)
- /* no need to write this network to the XML */
- return;
-
- network_node = xmlNewChild (root, NULL, "network", NULL);
- xmlNewProp (network_node, "id", id);
-
- if (network->dropped)
- {
- xmlNewProp (network_node, "dropped", "1");
- return;
- }
-
- g_object_get (network,
- "name", &name,
- "charset", &charset,
- NULL);
- xmlNewProp (network_node, "name", name);
- xmlNewProp (network_node, "network_charset", charset);
- g_free (name);
- g_free (charset);
-
- servers = empathy_irc_network_get_servers (network);
-
- servers_node = xmlNewChild (network_node, NULL, "servers", NULL);
- for (l = servers; l != NULL; l = g_slist_next (l))
- {
- EmpathyIrcServer *server;
- xmlNodePtr server_node;
- gchar *address, *tmp;
- guint port;
- gboolean ssl;
-
- server = l->data;
-
- server_node = xmlNewChild (servers_node, NULL, "server", NULL);
-
- g_object_get (server,
- "address", &address,
- "port", &port,
- "ssl", &ssl,
- NULL);
-
- xmlNewProp (server_node, "address", address);
-
- tmp = g_strdup_printf ("%u", port);
- xmlNewProp (server_node, "port", tmp);
- g_free (tmp);
-
- xmlNewProp (server_node, "ssl", ssl ? "TRUE": "FALSE");
-
- g_free (address);
- }
-
- /* free the list */
- g_slist_foreach (servers, (GFunc) g_object_unref, NULL);
- g_slist_free (servers);
-}
-
-static gboolean
-irc_network_manager_file_save (EmpathyIrcNetworkManager *self)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
- xmlDocPtr doc;
- xmlNodePtr root;
-
- if (priv->user_file == NULL)
- {
- DEBUG ("can't save: no user file defined");
- return FALSE;
- }
-
- DEBUG ("Saving IRC networks");
-
- doc = xmlNewDoc ("1.0");
- root = xmlNewNode (NULL, "networks");
- xmlDocSetRootElement (doc, root);
-
- g_hash_table_foreach (priv->networks, (GHFunc) write_network_to_xml, root);
-
- /* Make sure the XML is indented properly */
- xmlIndentTreeOutput = 1;
-
- xmlSaveFormatFileEnc (priv->user_file, doc, "utf-8", 1);
- xmlFreeDoc (doc);
-
- xmlCleanupParser ();
- xmlMemoryDump ();
-
- priv->have_to_save = FALSE;
-
- return TRUE;
-}
-
-static gboolean
-find_network_by_address (const gchar *id,
- EmpathyIrcNetwork *network,
- const gchar *address)
-{
- GSList *servers, *l;
- gboolean found = FALSE;
-
- if (network->dropped)
- return FALSE;
-
- servers = empathy_irc_network_get_servers (network);
-
- for (l = servers; l != NULL && !found; l = g_slist_next (l))
- {
- EmpathyIrcServer *server = l->data;
- gchar *_address;
-
- g_object_get (server, "address", &_address, NULL);
- found = (_address != NULL && strcmp (address, _address) == 0);
-
- g_free (_address);
- }
-
- g_slist_foreach (servers, (GFunc) g_object_unref, NULL);
- g_slist_free (servers);
-
- return found;
-}
-
-/**
- * empathy_irc_network_manager_find_network_by_address:
- * @manager: an #EmpathyIrcNetworkManager
- * @address: the server address to look for
- *
- * Find the #EmpathyIrcNetwork which owns an #EmpathyIrcServer
- * that has the given address.
- *
- * Returns: the found #EmpathyIrcNetwork, or %NULL if not found.
- */
-EmpathyIrcNetwork *
-empathy_irc_network_manager_find_network_by_address (
- EmpathyIrcNetworkManager *self,
- const gchar *address)
-{
- EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);
- EmpathyIrcNetwork *network;
-
- g_return_val_if_fail (address != NULL, NULL);
-
- network = g_hash_table_find (priv->networks,
- (GHRFunc) find_network_by_address, (gchar *) address);
-
- return network;
-}
diff --git a/libempathy/empathy-irc-network-manager.h b/libempathy/empathy-irc-network-manager.h
deleted file mode 100644
index a050f4723..000000000
--- a/libempathy/empathy-irc-network-manager.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Guillaume Desmottes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#ifndef __EMPATHY_IRC_NETWORK_MANAGER_H__
-#define __EMPATHY_IRC_NETWORK_MANAGER_H__
-
-#include <glib-object.h>
-
-#include "empathy-irc-network.h"
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyIrcNetworkManager EmpathyIrcNetworkManager;
-typedef struct _EmpathyIrcNetworkManagerClass EmpathyIrcNetworkManagerClass;
-
-struct _EmpathyIrcNetworkManager
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyIrcNetworkManagerClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_irc_network_manager_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_IRC_NETWORK_MANAGER \
- (empathy_irc_network_manager_get_type ())
-#define EMPATHY_IRC_NETWORK_MANAGER(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_IRC_NETWORK_MANAGER, \
- EmpathyIrcNetworkManager))
-#define EMPATHY_IRC_NETWORK_MANAGER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_IRC_NETWORK_MANAGER, \
- EmpathyIrcNetworkManagerClass))
-#define EMPATHY_IS_IRC_NETWORK_MANAGER(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_IRC_NETWORK_MANAGER))
-#define EMPATHY_IS_IRC_NETWORK_MANAGER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_IRC_NETWORK_MANAGER))
-#define EMPATHY_IRC_NETWORK_MANAGER_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_IRC_NETWORK_MANAGER, \
- EmpathyIrcNetworkManagerClass))
-
-EmpathyIrcNetworkManager * empathy_irc_network_manager_new (
- const gchar *global_file, const gchar *user_file);
-
-void empathy_irc_network_manager_add (EmpathyIrcNetworkManager *manager,
- EmpathyIrcNetwork *network);
-
-void empathy_irc_network_manager_remove (EmpathyIrcNetworkManager *manager,
- EmpathyIrcNetwork *network);
-
-GSList * empathy_irc_network_manager_get_networks (
- EmpathyIrcNetworkManager *manager);
-
-EmpathyIrcNetwork * empathy_irc_network_manager_find_network_by_address (
- EmpathyIrcNetworkManager *manager, const gchar *address);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_IRC_NETWORK_MANAGER_H__ */
diff --git a/libempathy/empathy-irc-network.c b/libempathy/empathy-irc-network.c
deleted file mode 100644
index 2f433e4ef..000000000
--- a/libempathy/empathy-irc-network.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2007 Guillaume Desmottes
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-marshal.h"
-#include "empathy-irc-network.h"
-#include "empathy-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcNetwork)
-typedef struct
-{
- gchar *name;
- gchar *charset;
- GSList *servers;
-} EmpathyIrcNetworkPriv;
-
-/* properties */
-enum
-{
- PROP_NAME = 1,
- PROP_CHARSET,
- LAST_PROPERTY
-};
-
-/* signals */
-enum
-{
- MODIFIED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE (EmpathyIrcNetwork, empathy_irc_network, G_TYPE_OBJECT);
-
-static void
-server_modified_cb (EmpathyIrcServer *server,
- EmpathyIrcNetwork *self)
-{
- g_signal_emit (self, signals[MODIFIED], 0);
-}
-
-static void
-empathy_irc_network_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcNetwork *self = EMPATHY_IRC_NETWORK (object);
- EmpathyIrcNetworkPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_NAME:
- g_value_set_string (value, priv->name);
- break;
- case PROP_CHARSET:
- g_value_set_string (value, priv->charset);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_irc_network_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcNetwork *self = EMPATHY_IRC_NETWORK (object);
- EmpathyIrcNetworkPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_NAME:
- if (tp_strdiff (priv->name, g_value_get_string (value)))
- {
- g_free (priv->name);
- priv->name = g_value_dup_string (value);
- g_signal_emit (object, signals[MODIFIED], 0);
- }
- break;
- case PROP_CHARSET:
- if (tp_strdiff (priv->charset, g_value_get_string (value)))
- {
- g_free (priv->charset);
- priv->charset = g_value_dup_string (value);
- g_signal_emit (object, signals[MODIFIED], 0);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_irc_network_dispose (GObject *object)
-{
- EmpathyIrcNetwork *self = EMPATHY_IRC_NETWORK (object);
- EmpathyIrcNetworkPriv *priv = GET_PRIV (self);
- GSList *l;
-
- for (l = priv->servers; l != NULL; l = g_slist_next (l))
- {
- g_signal_handlers_disconnect_by_func (l->data,
- G_CALLBACK (server_modified_cb), self);
- g_object_unref (l->data);
- }
-
- G_OBJECT_CLASS (empathy_irc_network_parent_class)->dispose (object);
-}
-
-static void
-empathy_irc_network_finalize (GObject *object)
-{
- EmpathyIrcNetwork *self = EMPATHY_IRC_NETWORK (object);
- EmpathyIrcNetworkPriv *priv = GET_PRIV (self);
-
- g_slist_free (priv->servers);
- g_free (priv->name);
- g_free (priv->charset);
-
- G_OBJECT_CLASS (empathy_irc_network_parent_class)->finalize (object);
-}
-
-static void
-empathy_irc_network_init (EmpathyIrcNetwork *self)
-{
- EmpathyIrcNetworkPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- EMPATHY_TYPE_IRC_NETWORK, EmpathyIrcNetworkPriv);
-
- self->priv = priv;
-
- priv->servers = NULL;
-
- self->user_defined = TRUE;
- self->dropped = FALSE;
-}
-
-static void
-empathy_irc_network_class_init (EmpathyIrcNetworkClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- object_class->get_property = empathy_irc_network_get_property;
- object_class->set_property = empathy_irc_network_set_property;
-
- g_type_class_add_private (object_class, sizeof (EmpathyIrcNetworkPriv));
-
- object_class->dispose = empathy_irc_network_dispose;
- object_class->finalize = empathy_irc_network_finalize;
-
- param_spec = g_param_spec_string (
- "name",
- "Network name",
- "The displayed name of this network",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_NAME, param_spec);
-
- param_spec = g_param_spec_string (
- "charset",
- "Charset",
- "The charset to use on this network",
- "UTF-8",
- G_PARAM_CONSTRUCT |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_CHARSET, param_spec);
-
- /**
- * EmpathyIrcNetwork::modified:
- * @network: the object that received the signal
- *
- * Emitted when either a property or a server of the network is modified.
- *
- */
- signals[MODIFIED] = g_signal_new (
- "modified",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-/**
- * empathy_irc_network_new:
- * @name: the name of the network
- *
- * Creates a new #EmpathyIrcNetwork.
- *
- * Returns: a new #EmpathyIrcNetwork
- */
-EmpathyIrcNetwork *
-empathy_irc_network_new (const gchar *name)
-{
- return g_object_new (EMPATHY_TYPE_IRC_NETWORK,
- "name", name,
- NULL);
-}
-
-/**
- * empathy_irc_network_get_servers:
- * @network: an #EmpathyIrcNetwork
- *
- * Get the list of #EmpathyIrcServer that belongs to this network.
- * These servers are sorted according their priority.
- * So the first one will be the first used when trying to connect to
- * the network.
- *
- * Returns: a new #GSList of refed #EmpathyIrcServer.
- */
-GSList *
-empathy_irc_network_get_servers (EmpathyIrcNetwork *self)
-{
- EmpathyIrcNetworkPriv *priv;
- GSList *servers = NULL, *l;
-
- g_return_val_if_fail (EMPATHY_IS_IRC_NETWORK (self), NULL);
- priv = GET_PRIV (self);
-
- for (l = priv->servers; l != NULL; l = g_slist_next (l))
- {
- servers = g_slist_prepend (servers, g_object_ref (l->data));
- }
-
- return g_slist_reverse (servers);
-}
-
-/**
- * empathy_irc_network_append_server:
- * @network: an #EmpathyIrcNetwork
- * @server: the #EmpathyIrcServer to add
- *
- * Add an #EmpathyIrcServer to the given #EmpathyIrcNetwork. The server
- * is added at the last position in network's servers list.
- *
- */
-void
-empathy_irc_network_append_server (EmpathyIrcNetwork *self,
- EmpathyIrcServer *server)
-{
- EmpathyIrcNetworkPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK (self));
- g_return_if_fail (server != NULL && EMPATHY_IS_IRC_SERVER (server));
-
- priv = GET_PRIV (self);
-
- g_return_if_fail (g_slist_find (priv->servers, server) == NULL);
-
- priv->servers = g_slist_append (priv->servers, g_object_ref (server));
-
- g_signal_connect (server, "modified", G_CALLBACK (server_modified_cb), self);
-
- g_signal_emit (self, signals[MODIFIED], 0);
-}
-
-/**
- * empathy_irc_network_remove_server:
- * @network: an #EmpathyIrcNetwork
- * @server: the #EmpathyIrcServer to remove
- *
- * Remove an #EmpathyIrcServer from the servers list of the
- * given #EmpathyIrcNetwork.
- *
- */
-void
-empathy_irc_network_remove_server (EmpathyIrcNetwork *self,
- EmpathyIrcServer *server)
-{
- EmpathyIrcNetworkPriv *priv;
- GSList *l;
-
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK (self));
- g_return_if_fail (server != NULL && EMPATHY_IS_IRC_SERVER (server));
-
- priv = GET_PRIV (self);
-
- l = g_slist_find (priv->servers, server);
- if (l == NULL)
- return;
-
- g_object_unref (l->data);
- priv->servers = g_slist_delete_link (priv->servers, l);
- g_signal_handlers_disconnect_by_func (server, G_CALLBACK (server_modified_cb),
- self);
-
- g_signal_emit (self, signals[MODIFIED], 0);
-}
-
-/**
- * empathy_irc_network_set_server_position:
- * @network: an #EmpathyIrcNetwork
- * @server: the #EmpathyIrcServer to move
- * @pos: the position to move the server. If this is negative, or is larger than
- * the number of servers in the list, the server is moved to the end of the
- * list.
- *
- * Move an #EmpathyIrcServer in the servers list of the given
- * #EmpathyIrcNetwork.
- *
- */
-void
-empathy_irc_network_set_server_position (EmpathyIrcNetwork *self,
- EmpathyIrcServer *server,
- gint pos)
-{
- EmpathyIrcNetworkPriv *priv;
- GSList *l;
-
- g_return_if_fail (EMPATHY_IS_IRC_NETWORK (self));
- g_return_if_fail (server != NULL && EMPATHY_IS_IRC_SERVER (server));
-
- priv = GET_PRIV (self);
-
- l = g_slist_find (priv->servers, server);
- if (l == NULL)
- return;
-
- priv->servers = g_slist_delete_link (priv->servers, l);
- priv->servers = g_slist_insert (priv->servers, server, pos);
-
- g_signal_emit (self, signals[MODIFIED], 0);
-}
diff --git a/libempathy/empathy-irc-network.h b/libempathy/empathy-irc-network.h
deleted file mode 100644
index b10b2769e..000000000
--- a/libempathy/empathy-irc-network.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Guillaume Desmottes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#ifndef __EMPATHY_IRC_NETWORK_H__
-#define __EMPATHY_IRC_NETWORK_H__
-
-#include <glib-object.h>
-
-#include "empathy-irc-server.h"
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyIrcNetwork EmpathyIrcNetwork;
-typedef struct _EmpathyIrcNetworkClass EmpathyIrcNetworkClass;
-
-struct _EmpathyIrcNetwork
-{
- GObject parent;
- gpointer priv;
-
- gboolean user_defined;
- gboolean dropped;
-};
-
-struct _EmpathyIrcNetworkClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_irc_network_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_IRC_NETWORK (empathy_irc_network_get_type ())
-#define EMPATHY_IRC_NETWORK(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_IRC_NETWORK, \
- EmpathyIrcNetwork))
-#define EMPATHY_IRC_NETWORK_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_IRC_NETWORK,\
- EmpathyIrcNetworkClass))
-#define EMPATHY_IS_IRC_NETWORK(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_IRC_NETWORK))
-#define EMPATHY_IS_IRC_NETWORK_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_IRC_NETWORK))
-#define EMPATHY_IRC_NETWORK_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_IRC_NETWORK, \
- EmpathyIrcNetworkClass))
-
-EmpathyIrcNetwork * empathy_irc_network_new (const gchar *name);
-
-GSList * empathy_irc_network_get_servers (EmpathyIrcNetwork *network);
-
-void empathy_irc_network_append_server (EmpathyIrcNetwork *network,
- EmpathyIrcServer *server);
-
-void empathy_irc_network_remove_server (EmpathyIrcNetwork *network,
- EmpathyIrcServer *server);
-
-void empathy_irc_network_set_server_position (EmpathyIrcNetwork *network,
- EmpathyIrcServer *server, gint pos);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_IRC_NETWORK_H__ */
diff --git a/libempathy/empathy-irc-networks.dtd b/libempathy/empathy-irc-networks.dtd
deleted file mode 100644
index 692e613c1..000000000
--- a/libempathy/empathy-irc-networks.dtd
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
- DTD for Empathys irc networks.
- by Xavier Claessens <xclaesse@gmail.com>
--->
-
-
-<!ELEMENT networks (network*)>
-<!ELEMENT network (servers*)>
-<!ATTLIST network id ID #REQUIRED>
-<!ATTLIST network name CDATA #IMPLIED>
-<!ATTLIST network network_charset CDATA #IMPLIED>
-<!ATTLIST network dropped CDATA #IMPLIED>
-
-<!ELEMENT servers (server*)>
-<!ELEMENT server EMPTY>
-<!ATTLIST server address CDATA #REQUIRED>
-<!ATTLIST server port CDATA #REQUIRED>
-<!ATTLIST server ssl CDATA #REQUIRED>
diff --git a/libempathy/empathy-irc-server.c b/libempathy/empathy-irc-server.c
deleted file mode 100644
index 2ef8dc59c..000000000
--- a/libempathy/empathy-irc-server.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Guillaume Desmottes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-marshal.h"
-#include "empathy-irc-server.h"
-#include "empathy-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcServer)
-typedef struct
-{
- gchar *address;
- gint port;
- gboolean ssl;
-} EmpathyIrcServerPriv;
-
-/* properties */
-enum
-{
- PROP_ADDRESS = 1,
- PROP_PORT,
- PROP_SSL,
- LAST_PROPERTY
-};
-
-/* signals */
-enum
-{
- MODIFIED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE (EmpathyIrcServer, empathy_irc_server, G_TYPE_OBJECT);
-
-static void
-empathy_irc_server_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
- EmpathyIrcServerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_ADDRESS:
- g_value_set_string (value, priv->address);
- break;
- case PROP_PORT:
- g_value_set_uint (value, priv->port);
- break;
- case PROP_SSL:
- g_value_set_boolean (value, priv->ssl);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_irc_server_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
- EmpathyIrcServerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_ADDRESS:
- if (tp_strdiff (priv->address, g_value_get_string (value)))
- {
- g_free (priv->address);
- priv->address = g_value_dup_string (value);
- g_signal_emit (object, signals[MODIFIED], 0);
- }
- break;
- case PROP_PORT:
- if (priv->port != g_value_get_uint (value))
- {
- priv->port = g_value_get_uint (value);
- g_signal_emit (object, signals[MODIFIED], 0);
- }
- break;
- case PROP_SSL:
- if (priv->ssl != g_value_get_boolean (value))
- {
- priv->ssl = g_value_get_boolean (value);
- g_signal_emit (object, signals[MODIFIED], 0);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_irc_server_finalize (GObject *object)
-{
- EmpathyIrcServer *self = EMPATHY_IRC_SERVER (object);
- EmpathyIrcServerPriv *priv = GET_PRIV (self);
-
- g_free (priv->address);
-
- G_OBJECT_CLASS (empathy_irc_server_parent_class)->finalize (object);
-}
-
-static void
-empathy_irc_server_init (EmpathyIrcServer *self)
-{
- EmpathyIrcServerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- EMPATHY_TYPE_IRC_SERVER, EmpathyIrcServerPriv);
-
- self->priv = priv;
-}
-
-static void
-empathy_irc_server_class_init (EmpathyIrcServerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- object_class->get_property = empathy_irc_server_get_property;
- object_class->set_property = empathy_irc_server_set_property;
-
- g_type_class_add_private (object_class, sizeof (EmpathyIrcServerPriv));
-
- object_class->finalize = empathy_irc_server_finalize;
-
- param_spec = g_param_spec_string (
- "address",
- "Server address",
- "The address of this server",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_ADDRESS, param_spec);
-
- param_spec = g_param_spec_uint (
- "port",
- "Server port",
- "The port to use to connect on this server",
- 1, G_MAXUINT16, 6667,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_PORT, param_spec);
-
- param_spec = g_param_spec_boolean (
- "ssl",
- "SSL",
- "If this server needs SSL connection",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB);
- g_object_class_install_property (object_class, PROP_SSL, param_spec);
-
- /**
- * EmpathyIrcServer::modified:
- * @server: the object that received the signal
- *
- * Emitted when a property of the server is modified.
- *
- */
- signals[MODIFIED] = g_signal_new (
- "modified",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-/**
- * empathy_irc_server_new:
- * @address: the address
- * @port: the port
- * @ssl: %TRUE if the server needs a SSL connection
- *
- * Creates a new #EmpathyIrcServer
- *
- * Returns: a new #EmpathyIrcServer
- */
-EmpathyIrcServer *
-empathy_irc_server_new (const gchar *address,
- guint port,
- gboolean ssl)
-{
- return g_object_new (EMPATHY_TYPE_IRC_SERVER,
- "address", address,
- "port", port,
- "ssl", ssl,
- NULL);
-}
diff --git a/libempathy/empathy-irc-server.h b/libempathy/empathy-irc-server.h
deleted file mode 100644
index d72af64ac..000000000
--- a/libempathy/empathy-irc-server.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Guillaume Desmottes
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <gdesmott@gnome.org>
- */
-
-#ifndef __EMPATHY_IRC_SERVER_H__
-#define __EMPATHY_IRC_SERVER_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyIrcServer EmpathyIrcServer;
-typedef struct _EmpathyIrcServerClass EmpathyIrcServerClass;
-
-struct _EmpathyIrcServer
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyIrcServerClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_irc_server_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_IRC_SERVER (empathy_irc_server_get_type ())
-#define EMPATHY_IRC_SERVER(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_IRC_SERVER, EmpathyIrcServer))
-#define EMPATHY_IRC_SERVER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_IRC_SERVER, \
- EmpathyIrcServerClass))
-#define EMPATHY_IS_IRC_SERVER(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_IRC_SERVER))
-#define EMPATHY_IS_IRC_SERVER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_IRC_SERVER))
-#define EMPATHY_IRC_SERVER_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_IRC_SERVER,\
- EmpathyIrcServerClass))
-
-EmpathyIrcServer * empathy_irc_server_new (const gchar *address, guint port,
- gboolean ssl);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_IRC_SERVER_H__ */
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c
deleted file mode 100644
index e2423ebf2..000000000
--- a/libempathy/empathy-log-manager.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib/gstdio.h>
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-log-manager.h"
-#include "empathy-log-store-empathy.h"
-#include "empathy-log-store.h"
-#include "empathy-tp-chat.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLogManager)
-typedef struct
-{
- GList *stores;
-} EmpathyLogManagerPriv;
-
-G_DEFINE_TYPE (EmpathyLogManager, empathy_log_manager, G_TYPE_OBJECT);
-
-static EmpathyLogManager * manager_singleton = NULL;
-
-static void
-log_manager_finalize (GObject *object)
-{
- EmpathyLogManagerPriv *priv;
-
- priv = GET_PRIV (object);
-
- g_list_foreach (priv->stores, (GFunc) g_object_unref, NULL);
- g_list_free (priv->stores);
-}
-
-static GObject *
-log_manager_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *retval;
- EmpathyLogManagerPriv *priv;
-
- if (manager_singleton)
- {
- retval = g_object_ref (manager_singleton);
- }
- else
- {
- retval = G_OBJECT_CLASS (empathy_log_manager_parent_class)->constructor
- (type, n_props, props);
-
- manager_singleton = EMPATHY_LOG_MANAGER (retval);
- g_object_add_weak_pointer (retval, (gpointer *) &manager_singleton);
-
- priv = GET_PRIV (manager_singleton);
-
- priv->stores = g_list_append (priv->stores,
- g_object_new (EMPATHY_TYPE_LOG_STORE_EMPATHY, NULL));
- }
-
- return retval;
-}
-
-static void
-empathy_log_manager_class_init (EmpathyLogManagerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = log_manager_constructor;
- object_class->finalize = log_manager_finalize;
-
- g_type_class_add_private (object_class, sizeof (EmpathyLogManagerPriv));
-}
-
-static void
-empathy_log_manager_init (EmpathyLogManager *manager)
-{
- EmpathyLogManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_LOG_MANAGER, EmpathyLogManagerPriv);
-
- manager->priv = priv;
-}
-
-EmpathyLogManager *
-empathy_log_manager_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_LOG_MANAGER, NULL);
-}
-
-gboolean
-empathy_log_manager_add_message (EmpathyLogManager *manager,
- const gchar *chat_id,
- gboolean chatroom,
- EmpathyMessage *message,
- GError **error)
-{
- EmpathyLogManagerPriv *priv;
- GList *l;
- gboolean out = FALSE;
- gboolean found = FALSE;
-
- /* TODO: When multiple log stores appear with add_message implementations
- * make this customisable. */
- const gchar *add_store = "Empathy";
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), FALSE);
- g_return_val_if_fail (chat_id != NULL, FALSE);
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- if (!tp_strdiff (empathy_log_store_get_name (
- EMPATHY_LOG_STORE (l->data)), add_store))
- {
- out = empathy_log_store_add_message (EMPATHY_LOG_STORE (l->data),
- chat_id, chatroom, message, error);
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- DEBUG ("Failed to find chosen log store to write to.");
-
- return out;
-}
-
-gboolean
-empathy_log_manager_exists (EmpathyLogManager *manager,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- GList *l;
- EmpathyLogManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), FALSE);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE);
- g_return_val_if_fail (chat_id != NULL, FALSE);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- if (empathy_log_store_exists (EMPATHY_LOG_STORE (l->data),
- account, chat_id, chatroom))
- return TRUE;
- }
-
- return FALSE;
-}
-
-GList *
-empathy_log_manager_get_dates (EmpathyLogManager *manager,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- GList *l, *out = NULL;
- EmpathyLogManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- EmpathyLogStore *store = EMPATHY_LOG_STORE (l->data);
- GList *new;
-
- /* Insert dates of each store in the out list. Keep the out list sorted
- * and avoid to insert dups. */
- new = empathy_log_store_get_dates (store, account, chat_id, chatroom);
- while (new)
- {
- if (g_list_find_custom (out, new->data, (GCompareFunc) strcmp))
- g_free (new->data);
- else
- out = g_list_insert_sorted (out, new->data, (GCompareFunc) strcmp);
-
- new = g_list_delete_link (new, new);
- }
- }
-
- return out;
-}
-
-GList *
-empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- const gchar *date)
-{
- GList *l, *out = NULL;
- EmpathyLogManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- EmpathyLogStore *store = EMPATHY_LOG_STORE (l->data);
-
- out = g_list_concat (out, empathy_log_store_get_messages_for_date (
- store, account, chat_id, chatroom, date));
- }
-
- return out;
-}
-
-static gint
-log_manager_message_date_cmp (gconstpointer a,
- gconstpointer b)
-{
- EmpathyMessage *one = (EmpathyMessage *) a;
- EmpathyMessage *two = (EmpathyMessage *) b;
- time_t one_time, two_time;
-
- one_time = empathy_message_get_timestamp (one);
- two_time = empathy_message_get_timestamp (two);
-
- /* Return -1 of message1 is older than message2 */
- return one_time < two_time ? -1 : one_time - two_time;
-}
-
-GList *
-empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- guint num_messages,
- EmpathyLogMessageFilter filter,
- gpointer user_data)
-{
- EmpathyLogManagerPriv *priv;
- GList *out = NULL;
- GList *l;
- guint i = 0;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- priv = GET_PRIV (manager);
-
- /* Get num_messages from each log store and keep only the
- * newest ones in the out list. Keep that list sorted: Older first. */
- for (l = priv->stores; l; l = g_list_next (l))
- {
- EmpathyLogStore *store = EMPATHY_LOG_STORE (l->data);
- GList *new;
-
- new = empathy_log_store_get_filtered_messages (store, account, chat_id,
- chatroom, num_messages, filter, user_data);
- while (new)
- {
- if (i < num_messages)
- {
- /* We have less message than needed so far. Keep this message */
- out = g_list_insert_sorted (out, new->data,
- (GCompareFunc) log_manager_message_date_cmp);
- i++;
- }
- else if (log_manager_message_date_cmp (new->data, out->data) > 0)
- {
- /* This message is newer than the oldest message we have in out
- * list. Remove the head of out list and insert this message */
- g_object_unref (out->data);
- out = g_list_delete_link (out, out);
- out = g_list_insert_sorted (out, new->data,
- (GCompareFunc) log_manager_message_date_cmp);
- }
- else
- {
- /* This message is older than the oldest message we have in out
- * list. Drop it. */
- g_object_unref (new->data);
- }
-
- new = g_list_delete_link (new, new);
- }
- }
-
- return out;
-}
-
-GList *
-empathy_log_manager_get_chats (EmpathyLogManager *manager,
- McAccount *account)
-{
- GList *l, *out = NULL;
- EmpathyLogManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- EmpathyLogStore *store = EMPATHY_LOG_STORE (l->data);
-
- out = g_list_concat (out,
- empathy_log_store_get_chats (store, account));
- }
-
- return out;
-}
-
-GList *
-empathy_log_manager_search_new (EmpathyLogManager *manager,
- const gchar *text)
-{
- GList *l, *out = NULL;
- EmpathyLogManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (!EMP_STR_EMPTY (text), NULL);
-
- priv = GET_PRIV (manager);
-
- for (l = priv->stores; l; l = g_list_next (l))
- {
- EmpathyLogStore *store = EMPATHY_LOG_STORE (l->data);
-
- out = g_list_concat (out,
- empathy_log_store_search_new (store, text));
- }
-
- return out;
-}
-
-void
-empathy_log_manager_search_hit_free (EmpathyLogSearchHit *hit)
-{
- if (hit->account != NULL)
- g_object_unref (hit->account);
-
- g_free (hit->date);
- g_free (hit->filename);
- g_free (hit->chat_id);
-
- g_slice_free (EmpathyLogSearchHit, hit);
-}
-
-void
-empathy_log_manager_search_free (GList *hits)
-{
- GList *l;
-
- for (l = hits; l; l = g_list_next (l))
- {
- empathy_log_manager_search_hit_free (l->data);
- }
-
- g_list_free (hits);
-}
-
-/* Format is just date, 20061201. */
-gchar *
-empathy_log_manager_get_date_readable (const gchar *date)
-{
- time_t t;
-
- t = empathy_time_parse (date);
-
- return empathy_time_to_string_local (t, "%a %d %b %Y");
-}
-
-static void
-log_manager_chat_received_message_cb (EmpathyTpChat *tp_chat,
- EmpathyMessage *message,
- EmpathyLogManager *log_manager)
-{
- GError *error = NULL;
- TpHandleType handle_type;
- TpChannel *channel;
-
- channel = empathy_tp_chat_get_channel (tp_chat);
- tp_channel_get_handle (channel, &handle_type);
-
- if (!empathy_log_manager_add_message (log_manager,
- tp_channel_get_identifier (channel),
- handle_type == TP_HANDLE_TYPE_ROOM,
- message, &error))
- {
- DEBUG ("Failed to write message: %s",
- error ? error->message : "No error message");
-
- if (error != NULL)
- g_error_free (error);
- }
-}
-
-static void
-log_manager_dispatcher_observe_cb (EmpathyDispatcher *dispatcher,
- EmpathyDispatchOperation *operation,
- EmpathyLogManager *log_manager)
-{
- GQuark channel_type;
-
- channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
-
- if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
- {
- EmpathyTpChat *tp_chat;
-
- tp_chat = EMPATHY_TP_CHAT (
- empathy_dispatch_operation_get_channel_wrapper (operation));
-
- g_signal_connect (tp_chat, "message-received",
- G_CALLBACK (log_manager_chat_received_message_cb), log_manager);
- }
-}
-
-
-void
-empathy_log_manager_observe (EmpathyLogManager *log_manager,
- EmpathyDispatcher *dispatcher)
-{
- g_signal_connect (dispatcher, "observe",
- G_CALLBACK (log_manager_dispatcher_observe_cb), log_manager);
-}
diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h
deleted file mode 100644
index f6a9290bd..000000000
--- a/libempathy/empathy-log-manager.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_LOG_MANAGER_H__
-#define __EMPATHY_LOG_MANAGER_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-message.h"
-#include "empathy-dispatcher.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_LOG_MANAGER (empathy_log_manager_get_type ())
-#define EMPATHY_LOG_MANAGER(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_LOG_MANAGER, \
- EmpathyLogManager))
-#define EMPATHY_LOG_MANAGER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_LOG_MANAGER, \
- EmpathyLogManagerClass))
-#define EMPATHY_IS_LOG_MANAGER(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_LOG_MANAGER))
-#define EMPATHY_IS_LOG_MANAGER_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_LOG_MANAGER))
-#define EMPATHY_LOG_MANAGER_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_LOG_MANAGER, \
- EmpathyLogManagerClass))
-
-typedef struct _EmpathyLogManager EmpathyLogManager;
-typedef struct _EmpathyLogManagerClass EmpathyLogManagerClass;
-typedef struct _EmpathyLogSearchHit EmpathyLogSearchHit;
-
-struct _EmpathyLogManager
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyLogManagerClass
-{
- GObjectClass parent_class;
-};
-
-struct _EmpathyLogSearchHit
-{
- McAccount *account;
- gchar *chat_id;
- gboolean is_chatroom;
- gchar *filename;
- gchar *date;
-};
-
-typedef gboolean (*EmpathyLogMessageFilter) (EmpathyMessage *message,
- gpointer user_data);
-
-GType empathy_log_manager_get_type (void) G_GNUC_CONST;
-EmpathyLogManager *empathy_log_manager_dup_singleton (void);
-gboolean empathy_log_manager_add_message (EmpathyLogManager *manager,
- const gchar *chat_id, gboolean chatroom, EmpathyMessage *message,
- GError **error);
-gboolean empathy_log_manager_exists (EmpathyLogManager *manager,
- McAccount *account, const gchar *chat_id, gboolean chatroom);
-GList *empathy_log_manager_get_dates (EmpathyLogManager *manager,
- McAccount *account, const gchar *chat_id, gboolean chatroom);
-GList *empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
- McAccount *account, const gchar *chat_id, gboolean chatroom,
- const gchar *date);
-GList *empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager,
- McAccount *account, const gchar *chat_id, gboolean chatroom,
- guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data);
-GList *empathy_log_manager_get_chats (EmpathyLogManager *manager,
- McAccount *account);
-GList *empathy_log_manager_search_new (EmpathyLogManager *manager,
- const gchar *text);
-void empathy_log_manager_search_free (GList *hits);
-gchar *empathy_log_manager_get_date_readable (const gchar *date);
-void empathy_log_manager_search_hit_free (EmpathyLogSearchHit *hit);
-void empathy_log_manager_observe (EmpathyLogManager *log_manager,
- EmpathyDispatcher *dispatcher);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_LOG_MANAGER_H__ */
diff --git a/libempathy/empathy-log-manager.xsl b/libempathy/empathy-log-manager.xsl
deleted file mode 100644
index a934f3ab3..000000000
--- a/libempathy/empathy-log-manager.xsl
+++ /dev/null
@@ -1,148 +0,0 @@
-<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
-
- <xsl:output method="html" encoding="utf-8" indent="yes"/>
-
- <xsl:template match="/">
- <html>
- <head>
- <style type="text/css">
- <xsl:text>
- body {
- background: #fff;
- font-family: Verdana, "Bitstream Vera Sans", Sans-Serif;
- font-size: 10pt;
- }
- .stamp {
- color: #999;
- }
- .top-day-stamp {
- color: #999;
- text-align: center;
- margin-bottom: 1em;
- }
- .new-day-stamp {
- color: #999;
- text-align: center;
- margin-bottom: 1em;
- margin-top: 1em;
- }
- .nick {
- color: rgb(54,100, 139);
- }
- .nick-self {
- color: rgb(46,139,87);
- }
- .nick-highlight {
- color: rgb(205,92,92);
- }
- </xsl:text>
- </style>
- <title><xsl:value-of select="$title"/></title>
- </head>
- <body>
- <xsl:apply-templates/>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="get-day">
- <xsl:param name="stamp"/>
- <xsl:value-of select="substring ($stamp, 1, 8)"/>
- </xsl:template>
-
- <xsl:template name="format-stamp">
- <xsl:param name="stamp"/>
- <xsl:variable name="hour" select="substring ($stamp, 10, 2)"/>
- <xsl:variable name="min" select="substring ($stamp, 13, 2)"/>
-
- <xsl:value-of select="$hour"/>:<xsl:value-of select="$min"/>
- </xsl:template>
-
- <xsl:template name="format-day-stamp">
- <xsl:param name="stamp"/>
- <xsl:variable name="year" select="substring ($stamp, 1, 4)"/>
- <xsl:variable name="month" select="substring ($stamp, 5, 2)"/>
- <xsl:variable name="day" select="substring ($stamp, 7, 2)"/>
-
- <xsl:value-of select="$year"/>-<xsl:value-of select="$month"/>-<xsl:value-of select="$day"/>
- </xsl:template>
-
- <xsl:template name="header">
- <xsl:param name="stamp"/>
- <div class="top-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </div>
- </xsl:template>
-
- <xsl:template match="a">
- <xsl:text disable-output-escaping="yes">&lt;a href="</xsl:text>
-
- <xsl:value-of disable-output-escaping="yes" select="@href"/>
-
- <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
-
- <xsl:value-of select="@href"/>
- <xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
- </xsl:template>
-
- <xsl:template match="log">
-
- <div class="top-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="//message[1]/@time"/>
- </xsl:call-template>
- </div>
-
- <xsl:for-each select="*">
-
- <xsl:variable name="prev-time">
- <xsl:call-template name="get-day">
- <xsl:with-param name="stamp" select="preceding-sibling::*[1]/@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="this-time">
- <xsl:call-template name="get-day">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:if test="$prev-time &lt; $this-time">
- <div class="new-day-stamp">
- <xsl:call-template name="format-day-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </div>
- </xsl:if>
-
- <xsl:variable name="stamp">
- <xsl:call-template name="format-stamp">
- <xsl:with-param name="stamp" select="@time"/>
- </xsl:call-template>
- </xsl:variable>
-
- <span class="stamp">
- <xsl:value-of select="$stamp"/>
- </span>
-
- <xsl:variable name="nick-class">
- <xsl:choose>
- <xsl:when test="not(string(@id))">nick-self</xsl:when>
- <xsl:otherwise>nick</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <span class="{$nick-class}">
- &lt;<xsl:value-of select="@name"/>&gt;
- </span>
-
- <xsl:apply-templates/>
- <br/>
-
- </xsl:for-each>
-
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c
deleted file mode 100644
index 3414d666f..000000000
--- a/libempathy/empathy-log-store-empathy.c
+++ /dev/null
@@ -1,779 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib/gstdio.h>
-
-#include "empathy-log-store.h"
-#include "empathy-log-store-empathy.h"
-#include "empathy-log-manager.h"
-#include "empathy-contact.h"
-#include "empathy-time.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-#define LOG_DIR_CREATE_MODE (S_IRUSR | S_IWUSR | S_IXUSR)
-#define LOG_FILE_CREATE_MODE (S_IRUSR | S_IWUSR)
-#define LOG_DIR_CHATROOMS "chatrooms"
-#define LOG_FILENAME_SUFFIX ".log"
-#define LOG_TIME_FORMAT_FULL "%Y%m%dT%H:%M:%S"
-#define LOG_TIME_FORMAT "%Y%m%d"
-#define LOG_HEADER \
- "<?xml version='1.0' encoding='utf-8'?>\n" \
- "<?xml-stylesheet type=\"text/xsl\" href=\"empathy-log.xsl\"?>\n" \
- "<log>\n"
-
-#define LOG_FOOTER \
- "</log>\n"
-
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLogStoreEmpathy)
-typedef struct
-{
- gchar *basedir;
- gchar *name;
-} EmpathyLogStoreEmpathyPriv;
-
-static void log_store_iface_init (gpointer g_iface,gpointer iface_data);
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyLogStoreEmpathy, empathy_log_store_empathy,
- G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_LOG_STORE,
- log_store_iface_init));
-
-static void
-log_store_empathy_finalize (GObject *object)
-{
- EmpathyLogStoreEmpathy *self = EMPATHY_LOG_STORE_EMPATHY (object);
- EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self);
-
- g_free (priv->basedir);
- g_free (priv->name);
-}
-
-static void
-empathy_log_store_empathy_class_init (EmpathyLogStoreEmpathyClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = log_store_empathy_finalize;
-
- g_type_class_add_private (object_class, sizeof (EmpathyLogStoreEmpathyPriv));
-}
-
-static void
-empathy_log_store_empathy_init (EmpathyLogStoreEmpathy *self)
-{
- EmpathyLogStoreEmpathyPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- EMPATHY_TYPE_LOG_STORE_EMPATHY, EmpathyLogStoreEmpathyPriv);
-
- self->priv = priv;
-
- priv->basedir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (),
- ".gnome2", PACKAGE_NAME, "logs", NULL);
-
- priv->name = g_strdup ("Empathy");
-}
-
-static gchar *
-log_store_empathy_get_dir (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- const gchar *account_id;
- gchar *basedir;
- EmpathyLogStoreEmpathyPriv *priv;
-
- priv = GET_PRIV (self);
-
- account_id = mc_account_get_unique_name (account);
-
- if (chatroom)
- basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir, account_id,
- LOG_DIR_CHATROOMS, chat_id, NULL);
- else
- basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir,
- account_id, chat_id, NULL);
-
- return basedir;
-}
-
-static gchar *
-log_store_empathy_get_timestamp_filename (void)
-{
- time_t t;
- gchar *time_str;
- gchar *filename;
-
- t = empathy_time_get_current ();
- time_str = empathy_time_to_string_local (t, LOG_TIME_FORMAT);
- filename = g_strconcat (time_str, LOG_FILENAME_SUFFIX, NULL);
-
- g_free (time_str);
-
- return filename;
-}
-
-static gchar *
-log_store_empathy_get_timestamp_from_message (EmpathyMessage *message)
-{
- time_t t;
-
- t = empathy_message_get_timestamp (message);
-
- /* We keep the timestamps in the messages as UTC. */
- return empathy_time_to_string_utc (t, LOG_TIME_FORMAT_FULL);
-}
-
-static gchar *
-log_store_empathy_get_filename (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- gchar *basedir;
- gchar *timestamp;
- gchar *filename;
-
- basedir = log_store_empathy_get_dir (self, account, chat_id, chatroom);
- timestamp = log_store_empathy_get_timestamp_filename ();
- filename = g_build_filename (basedir, timestamp, NULL);
-
- g_free (basedir);
- g_free (timestamp);
-
- return filename;
-}
-
-static gboolean
-log_store_empathy_add_message (EmpathyLogStore *self,
- const gchar *chat_id,
- gboolean chatroom,
- EmpathyMessage *message,
- GError **error)
-{
- FILE *file;
- McAccount *account;
- EmpathyContact *sender;
- const gchar *body_str;
- const gchar *str;
- EmpathyAvatar *avatar;
- gchar *avatar_token = NULL;
- gchar *filename;
- gchar *basedir;
- gchar *body;
- gchar *timestamp;
- gchar *contact_name;
- gchar *contact_id;
- TpChannelTextMessageType msg_type;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), FALSE);
- g_return_val_if_fail (chat_id != NULL, FALSE);
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
-
- sender = empathy_message_get_sender (message);
- account = empathy_contact_get_account (sender);
- body_str = empathy_message_get_body (message);
- msg_type = empathy_message_get_tptype (message);
-
- if (EMP_STR_EMPTY (body_str))
- return FALSE;
-
- filename = log_store_empathy_get_filename (self, account, chat_id, chatroom);
- basedir = g_path_get_dirname (filename);
- if (!g_file_test (basedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- {
- DEBUG ("Creating directory:'%s'", basedir);
- g_mkdir_with_parents (basedir, LOG_DIR_CREATE_MODE);
- }
- g_free (basedir);
-
- DEBUG ("Adding message: '%s' to file: '%s'", body_str, filename);
-
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- file = g_fopen (filename, "w+");
- if (file != NULL)
- g_fprintf (file, LOG_HEADER);
-
- g_chmod (filename, LOG_FILE_CREATE_MODE);
- }
- else
- {
- file = g_fopen (filename, "r+");
- if (file != NULL)
- fseek (file, - strlen (LOG_FOOTER), SEEK_END);
- }
-
- body = g_markup_escape_text (body_str, -1);
- timestamp = log_store_empathy_get_timestamp_from_message (message);
-
- str = empathy_contact_get_name (sender);
- contact_name = g_markup_escape_text (str, -1);
-
- str = empathy_contact_get_id (sender);
- contact_id = g_markup_escape_text (str, -1);
-
- avatar = empathy_contact_get_avatar (sender);
- if (avatar != NULL)
- avatar_token = g_markup_escape_text (avatar->token, -1);
-
- g_fprintf (file,
- "<message time='%s' cm_id='%d' id='%s' name='%s' token='%s' isuser='%s' type='%s'>"
- "%s</message>\n" LOG_FOOTER, timestamp,
- empathy_message_get_id (message),
- contact_id, contact_name,
- avatar_token ? avatar_token : "",
- empathy_contact_is_user (sender) ? "true" : "false",
- empathy_message_type_to_str (msg_type), body);
-
- fclose (file);
- g_free (filename);
- g_free (contact_id);
- g_free (contact_name);
- g_free (timestamp);
- g_free (body);
- g_free (avatar_token);
-
- return TRUE;
-}
-
-static gboolean
-log_store_empathy_exists (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- gchar *dir;
- gboolean exists;
-
- dir = log_store_empathy_get_dir (self, account, chat_id, chatroom);
- exists = g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
- g_free (dir);
-
- return exists;
-}
-
-static GList *
-log_store_empathy_get_dates (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- GList *dates = NULL;
- gchar *date;
- gchar *directory;
- GDir *dir;
- const gchar *filename;
- const gchar *p;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- directory = log_store_empathy_get_dir (self, account, chat_id, chatroom);
- dir = g_dir_open (directory, 0, NULL);
- if (!dir)
- {
- DEBUG ("Could not open directory:'%s'", directory);
- g_free (directory);
- return NULL;
- }
-
- DEBUG ("Collating a list of dates in:'%s'", directory);
-
- while ((filename = g_dir_read_name (dir)) != NULL)
- {
- if (!g_str_has_suffix (filename, LOG_FILENAME_SUFFIX))
- continue;
-
- p = strstr (filename, LOG_FILENAME_SUFFIX);
- date = g_strndup (filename, p - filename);
-
- if (!date)
- continue;
-
- if (!g_regex_match_simple ("\\d{8}", date, 0, 0))
- continue;
-
- dates = g_list_insert_sorted (dates, date, (GCompareFunc) strcmp);
- }
-
- g_free (directory);
- g_dir_close (dir);
-
- DEBUG ("Parsed %d dates", g_list_length (dates));
-
- return dates;
-}
-
-static gchar *
-log_store_empathy_get_filename_for_date (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- const gchar *date)
-{
- gchar *basedir;
- gchar *timestamp;
- gchar *filename;
-
- basedir = log_store_empathy_get_dir (self, account, chat_id, chatroom);
- timestamp = g_strconcat (date, LOG_FILENAME_SUFFIX, NULL);
- filename = g_build_filename (basedir, timestamp, NULL);
-
- g_free (basedir);
- g_free (timestamp);
-
- return filename;
-}
-
-static EmpathyLogSearchHit *
-log_store_empathy_search_hit_new (EmpathyLogStore *self,
- const gchar *filename)
-{
- EmpathyLogSearchHit *hit;
- const gchar *account_name;
- const gchar *end;
- gchar **strv;
- guint len;
-
- if (!g_str_has_suffix (filename, LOG_FILENAME_SUFFIX))
- return NULL;
-
- strv = g_strsplit (filename, G_DIR_SEPARATOR_S, -1);
- len = g_strv_length (strv);
-
- hit = g_slice_new0 (EmpathyLogSearchHit);
-
- end = strstr (strv[len-1], LOG_FILENAME_SUFFIX);
- hit->date = g_strndup (strv[len-1], end - strv[len-1]);
- hit->chat_id = g_strdup (strv[len-2]);
- hit->is_chatroom = (strcmp (strv[len-3], LOG_DIR_CHATROOMS) == 0);
-
- if (hit->is_chatroom)
- account_name = strv[len-4];
- else
- account_name = strv[len-3];
-
- hit->account = mc_account_lookup (account_name);
- hit->filename = g_strdup (filename);
-
- g_strfreev (strv);
-
- return hit;
-}
-
-static GList *
-log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
- const gchar *filename)
-{
- GList *messages = NULL;
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr log_node;
- xmlNodePtr node;
- EmpathyLogSearchHit *hit;
- McAccount *account;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL);
- g_return_val_if_fail (filename != NULL, NULL);
-
- DEBUG ("Attempting to parse filename:'%s'...", filename);
-
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- DEBUG ("Filename:'%s' does not exist", filename);
- return NULL;
- }
-
- /* Get the account from the filename */
- hit = log_store_empathy_search_hit_new (self, filename);
- account = g_object_ref (hit->account);
- empathy_log_manager_search_hit_free (hit);
-
- /* Create parser. */
- ctxt = xmlNewParserCtxt ();
-
- /* Parse and validate the file. */
- doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
- if (!doc)
- {
- g_warning ("Failed to parse file:'%s'", filename);
- xmlFreeParserCtxt (ctxt);
- return NULL;
- }
-
- /* The root node, presets. */
- log_node = xmlDocGetRootElement (doc);
- if (!log_node)
- {
- xmlFreeDoc (doc);
- xmlFreeParserCtxt (ctxt);
- return NULL;
- }
-
- /* Now get the messages. */
- for (node = log_node->children; node; node = node->next)
- {
- EmpathyMessage *message;
- EmpathyContact *sender;
- gchar *time;
- time_t t;
- gchar *sender_id;
- gchar *sender_name;
- gchar *sender_avatar_token;
- gchar *body;
- gchar *is_user_str;
- gboolean is_user = FALSE;
- gchar *msg_type_str;
- gchar *cm_id_str;
- guint cm_id;
- TpChannelTextMessageType msg_type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
-
- if (strcmp (node->name, "message") != 0)
- continue;
-
- body = xmlNodeGetContent (node);
- time = xmlGetProp (node, "time");
- sender_id = xmlGetProp (node, "id");
- sender_name = xmlGetProp (node, "name");
- sender_avatar_token = xmlGetProp (node, "token");
- is_user_str = xmlGetProp (node, "isuser");
- msg_type_str = xmlGetProp (node, "type");
- cm_id_str = xmlGetProp (node, "cm_id");
-
- if (is_user_str)
- is_user = strcmp (is_user_str, "true") == 0;
-
- if (msg_type_str)
- msg_type = empathy_message_type_from_str (msg_type_str);
-
- if (cm_id_str)
- cm_id = atoi (cm_id_str);
-
- t = empathy_time_parse (time);
-
- sender = empathy_contact_new_full (account, sender_id, sender_name);
- empathy_contact_set_is_user (sender, is_user);
- if (!EMP_STR_EMPTY (sender_avatar_token))
- empathy_contact_load_avatar_cache (sender,
- sender_avatar_token);
-
- message = empathy_message_new (body);
- empathy_message_set_sender (message, sender);
- empathy_message_set_timestamp (message, t);
- empathy_message_set_tptype (message, msg_type);
-
- if (cm_id_str)
- empathy_message_set_id (message, cm_id);
-
- messages = g_list_append (messages, message);
-
- g_object_unref (sender);
- xmlFree (time);
- xmlFree (sender_id);
- xmlFree (sender_name);
- xmlFree (body);
- xmlFree (is_user_str);
- xmlFree (msg_type_str);
- xmlFree (cm_id_str);
- }
-
- DEBUG ("Parsed %d messages", g_list_length (messages));
-
- xmlFreeDoc (doc);
- xmlFreeParserCtxt (ctxt);
-
- return messages;
-}
-
-static GList *
-log_store_empathy_get_all_files (EmpathyLogStore *self,
- const gchar *dir)
-{
- GDir *gdir;
- GList *files = NULL;
- const gchar *name;
- const gchar *basedir;
- EmpathyLogStoreEmpathyPriv *priv;
-
- priv = GET_PRIV (self);
-
- basedir = dir ? dir : priv->basedir;
-
- gdir = g_dir_open (basedir, 0, NULL);
- if (!gdir)
- return NULL;
-
- while ((name = g_dir_read_name (gdir)) != NULL)
- {
- gchar *filename;
-
- filename = g_build_filename (basedir, name, NULL);
- if (g_str_has_suffix (filename, LOG_FILENAME_SUFFIX))
- {
- files = g_list_prepend (files, filename);
- continue;
- }
-
- if (g_file_test (filename, G_FILE_TEST_IS_DIR))
- {
- /* Recursively get all log files */
- files = g_list_concat (files,
- log_store_empathy_get_all_files (self, filename));
- }
-
- g_free (filename);
- }
-
- g_dir_close (gdir);
-
- return files;
-}
-
-static GList *
-log_store_empathy_search_new (EmpathyLogStore *self,
- const gchar *text)
-{
- GList *files, *l;
- GList *hits = NULL;
- gchar *text_casefold;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL);
- g_return_val_if_fail (!EMP_STR_EMPTY (text), NULL);
-
- text_casefold = g_utf8_casefold (text, -1);
-
- files = log_store_empathy_get_all_files (self, NULL);
- DEBUG ("Found %d log files in total", g_list_length (files));
-
- for (l = files; l; l = g_list_next (l))
- {
- gchar *filename;
- GMappedFile *file;
- gsize length;
- gchar *contents;
- gchar *contents_casefold;
-
- filename = l->data;
-
- file = g_mapped_file_new (filename, FALSE, NULL);
- if (!file)
- continue;
-
- length = g_mapped_file_get_length (file);
- contents = g_mapped_file_get_contents (file);
- contents_casefold = g_utf8_casefold (contents, length);
-
- g_mapped_file_free (file);
-
- if (strstr (contents_casefold, text_casefold))
- {
- EmpathyLogSearchHit *hit;
-
- hit = log_store_empathy_search_hit_new (self, filename);
-
- if (hit)
- {
- hits = g_list_prepend (hits, hit);
- DEBUG ("Found text:'%s' in file:'%s' on date:'%s'",
- text, hit->filename, hit->date);
- }
- }
-
- g_free (contents_casefold);
- g_free (filename);
- }
-
- g_list_free (files);
- g_free (text_casefold);
-
- return hits;
-}
-
-static GList *
-log_store_empathy_get_chats_for_dir (EmpathyLogStore *self,
- const gchar *dir,
- gboolean is_chatroom)
-{
- GDir *gdir;
- GList *hits = NULL;
- const gchar *name;
- GError *error = NULL;
-
- gdir = g_dir_open (dir, 0, &error);
- if (!gdir)
- {
- DEBUG ("Failed to open directory: %s, error: %s", dir, error->message);
- g_error_free (error);
- return NULL;
- }
-
- while ((name = g_dir_read_name (gdir)) != NULL)
- {
- EmpathyLogSearchHit *hit;
- gchar *filename;
-
- filename = g_build_filename (dir, name, NULL);
- if (!is_chatroom && strcmp (name, LOG_DIR_CHATROOMS) == 0)
- {
- hits = g_list_concat (hits, log_store_empathy_get_chats_for_dir (
- self, filename, TRUE));
- g_free (filename);
- continue;
- }
-
- hit = g_slice_new0 (EmpathyLogSearchHit);
- hit->chat_id = g_strdup (name);
- hit->is_chatroom = is_chatroom;
-
- hits = g_list_prepend (hits, hit);
- }
-
- g_dir_close (gdir);
-
- return hits;
-}
-
-
-static GList *
-log_store_empathy_get_messages_for_date (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- const gchar *date)
-{
- gchar *filename;
- GList *messages;
-
- g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- filename = log_store_empathy_get_filename_for_date (self, account,
- chat_id, chatroom, date);
- messages = log_store_empathy_get_messages_for_file (self, filename);
- g_free (filename);
-
- return messages;
-}
-
-static GList *
-log_store_empathy_get_chats (EmpathyLogStore *self,
- McAccount *account)
-{
- gchar *dir;
- GList *hits;
- EmpathyLogStoreEmpathyPriv *priv;
-
- priv = GET_PRIV (self);
-
- dir = g_build_filename (priv->basedir,
- mc_account_get_unique_name (account), NULL);
-
- hits = log_store_empathy_get_chats_for_dir (self, dir, FALSE);
-
- g_free (dir);
-
- return hits;
-}
-
-static const gchar *
-log_store_empathy_get_name (EmpathyLogStore *self)
-{
- EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self);
-
- return priv->name;
-}
-
-static GList *
-log_store_empathy_get_filtered_messages (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- guint num_messages,
- EmpathyLogMessageFilter filter,
- gpointer user_data)
-{
- GList *dates, *l, *messages = NULL;
- guint i = 0;
-
- dates = log_store_empathy_get_dates (self, account, chat_id, chatroom);
-
- for (l = g_list_last (dates); l && i < num_messages; l = g_list_previous (l))
- {
- GList *new_messages, *n, *next;
-
- /* FIXME: We should really restrict the message parsing to get only
- * the newest num_messages. */
- new_messages = log_store_empathy_get_messages_for_date (self, account,
- chat_id, chatroom, l->data);
-
- n = new_messages;
- while (n != NULL)
- {
- next = g_list_next (n);
- if (!filter (n->data, user_data))
- {
- g_object_unref (n->data);
- new_messages = g_list_delete_link (new_messages, n);
- }
- else
- {
- i++;
- }
- n = next;
- }
- messages = g_list_concat (messages, new_messages);
- }
-
- g_list_foreach (dates, (GFunc) g_free, NULL);
- g_list_free (dates);
-
- return messages;
-}
-
-static void
-log_store_iface_init (gpointer g_iface,
- gpointer iface_data)
-{
- EmpathyLogStoreInterface *iface = (EmpathyLogStoreInterface *) g_iface;
-
- iface->get_name = log_store_empathy_get_name;
- iface->exists = log_store_empathy_exists;
- iface->add_message = log_store_empathy_add_message;
- iface->get_dates = log_store_empathy_get_dates;
- iface->get_messages_for_date = log_store_empathy_get_messages_for_date;
- iface->get_chats = log_store_empathy_get_chats;
- iface->search_new = log_store_empathy_search_new;
- iface->ack_message = NULL;
- iface->get_filtered_messages = log_store_empathy_get_filtered_messages;
-}
diff --git a/libempathy/empathy-log-store-empathy.h b/libempathy/empathy-log-store-empathy.h
deleted file mode 100644
index 3bc9997c0..000000000
--- a/libempathy/empathy-log-store-empathy.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_LOG_STORE_EMPATHY_H__
-#define __EMPATHY_LOG_STORE_EMPATHY_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_LOG_STORE_EMPATHY \
- (empathy_log_store_empathy_get_type ())
-#define EMPATHY_LOG_STORE_EMPATHY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_LOG_STORE_EMPATHY, \
- EmpathyLogStoreEmpathy))
-#define EMPATHY_LOG_STORE_EMPATHY_CLASS(vtable) \
- (G_TYPE_CHECK_CLASS_CAST ((vtable), EMPATHY_TYPE_LOG_STORE_EMPATHY, \
- EmpathyLogStoreEmpathyClass))
-#define EMPATHY_IS_LOG_STORE_EMPATHY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_LOG_STORE_EMPATHY))
-#define EMPATHY_IS_LOG_STORE_EMPATHY_CLASS(vtable) \
- (G_TYPE_CHECK_CLASS_TYPE ((vtable), EMPATHY_TYPE_LOG_STORE_EMPATHY))
-#define EMPATHY_LOG_STORE_EMPATHY_GET_CLASS(inst) \
- (G_TYPE_INSTANCE_GET_CLASS ((inst), EMPATHY_TYPE_LOG_STORE_EMPATHY, \
- EmpathyLogStoreEmpathyClass))
-
-typedef struct _EmpathyLogStoreEmpathy EmpathyLogStoreEmpathy;
-typedef struct _EmpathyLogStoreEmpathyClass EmpathyLogStoreEmpathyClass;
-
-struct _EmpathyLogStoreEmpathy
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyLogStoreEmpathyClass
-{
- GObjectClass parent;
-};
-
-GType empathy_log_store_empathy_get_type (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_LOG_STORE_EMPATHY_H__ */
diff --git a/libempathy/empathy-log-store.c b/libempathy/empathy-log-store.c
deleted file mode 100644
index ba5a9a09d..000000000
--- a/libempathy/empathy-log-store.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#include "empathy-log-store.h"
-
-GType
-empathy_log_store_get_type (void)
-{
- static GType type = 0;
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof (EmpathyLogStoreInterface),
- NULL, /* 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, "EmpathyLogStore",
- &info, 0);
- }
- return type;
-}
-
-const gchar *
-empathy_log_store_get_name (EmpathyLogStore *self)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_name)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_name (self);
-}
-
-gboolean
-empathy_log_store_exists (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->exists)
- return FALSE;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->exists (
- self, account, chat_id, chatroom);
-}
-
-
-
-gboolean
-empathy_log_store_add_message (EmpathyLogStore *self,
- const gchar *chat_id,
- gboolean chatroom,
- EmpathyMessage *message,
- GError **error)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->add_message)
- return FALSE;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->add_message (
- self, chat_id, chatroom, message, error);
-}
-
-GList *
-empathy_log_store_get_dates (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_dates)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_dates (
- self, account, chat_id, chatroom);
-}
-
-GList *
-empathy_log_store_get_messages_for_date (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- const gchar *date)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_messages_for_date (
- self, account, chat_id, chatroom, date);
-}
-
-GList *
-empathy_log_store_get_last_messages (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_last_messages)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_last_messages (
- self, account, chat_id, chatroom);
-}
-
-GList *
-empathy_log_store_get_chats (EmpathyLogStore *self,
- McAccount *account)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats (self, account);
-}
-
-GList *
-empathy_log_store_search_new (EmpathyLogStore *self,
- const gchar *text)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->search_new)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->search_new (self, text);
-}
-
-void
-empathy_log_store_ack_message (EmpathyLogStore *self,
- const gchar *chat_id,
- gboolean chatroom,
- EmpathyMessage *message)
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->ack_message)
- return;
-
- EMPATHY_LOG_STORE_GET_INTERFACE (self)->ack_message (
- self, chat_id, chatroom, message);
-}
-
-GList *
-empathy_log_store_get_filtered_messages (EmpathyLogStore *self,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- guint num_messages,
- EmpathyLogMessageFilter filter,
- gpointer user_data)
-
-{
- if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages)
- return NULL;
-
- return EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_filtered_messages (
- self, account, chat_id, chatroom, num_messages, filter, user_data);
-}
diff --git a/libempathy/empathy-log-store.h b/libempathy/empathy-log-store.h
deleted file mode 100644
index 6a253b21b..000000000
--- a/libempathy/empathy-log-store.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_LOG_STORE_H__
-#define __EMPATHY_LOG_STORE_H__
-
-#include <glib-object.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-message.h"
-#include "empathy-log-manager.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_LOG_STORE (empathy_log_store_get_type ())
-#define EMPATHY_LOG_STORE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_LOG_STORE, \
- EmpathyLogStore))
-#define EMPATHY_IS_LOG_STORE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_LOG_STORE))
-#define EMPATHY_LOG_STORE_GET_INTERFACE(inst) \
- (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EMPATHY_TYPE_LOG_STORE, \
- EmpathyLogStoreInterface))
-
-typedef struct _EmpathyLogStore EmpathyLogStore; /* dummy object */
-typedef struct _EmpathyLogStoreInterface EmpathyLogStoreInterface;
-
-struct _EmpathyLogStoreInterface
-{
- GTypeInterface parent;
-
- const gchar * (*get_name) (EmpathyLogStore *self);
- gboolean (*exists) (EmpathyLogStore *self, McAccount *account,
- const gchar *chat_id, gboolean chatroom);
- gboolean (*add_message) (EmpathyLogStore *self, const gchar *chat_id,
- gboolean chatroom, EmpathyMessage *message, GError **error);
- GList * (*get_dates) (EmpathyLogStore *self, McAccount *account,
- const gchar *chat_id, gboolean chatroom);
- GList * (*get_messages_for_date) (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom,
- const gchar *date);
- GList * (*get_last_messages) (EmpathyLogStore *self, McAccount *account,
- const gchar *chat_id, gboolean chatroom);
- GList * (*get_chats) (EmpathyLogStore *self,
- McAccount *account);
- GList * (*search_new) (EmpathyLogStore *self, const gchar *text);
- void (*ack_message) (EmpathyLogStore *self, const gchar *chat_id,
- gboolean chatroom, EmpathyMessage *message);
- GList * (*get_filtered_messages) (EmpathyLogStore *self, McAccount *account,
- const gchar *chat_id, gboolean chatroom, guint num_messages,
- EmpathyLogMessageFilter filter, gpointer user_data);
-};
-
-GType empathy_log_store_get_type (void) G_GNUC_CONST;
-
-const gchar *empathy_log_store_get_name (EmpathyLogStore *self);
-gboolean empathy_log_store_exists (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom);
-gboolean empathy_log_store_add_message (EmpathyLogStore *self,
- const gchar *chat_id, gboolean chatroom, EmpathyMessage *message,
- GError **error);
-GList *empathy_log_store_get_dates (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom);
-GList *empathy_log_store_get_messages_for_date (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom,
- const gchar *date);
-GList *empathy_log_store_get_last_messages (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom);
-GList *empathy_log_store_get_chats (EmpathyLogStore *self,
- McAccount *account);
-GList *empathy_log_store_search_new (EmpathyLogStore *self,
- const gchar *text);
-void empathy_log_store_ack_message (EmpathyLogStore *self,
- const gchar *chat_id, gboolean chatroom, EmpathyMessage *message);
-GList *empathy_log_store_get_filtered_messages (EmpathyLogStore *self,
- McAccount *account, const gchar *chat_id, gboolean chatroom,
- guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_LOG_STORE_H__ */
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
deleted file mode 100644
index 6d74c0722..000000000
--- a/libempathy/empathy-message.c
+++ /dev/null
@@ -1,520 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Mikael Hallendal <micke@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-message.h"
-#include "empathy-utils.h"
-#include "empathy-enum-types.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyMessage)
-typedef struct {
- TpChannelTextMessageType type;
- EmpathyContact *sender;
- EmpathyContact *receiver;
- gchar *body;
- time_t timestamp;
- guint id;
-} EmpathyMessagePriv;
-
-static void empathy_message_finalize (GObject *object);
-static void message_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void message_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-
-G_DEFINE_TYPE (EmpathyMessage, empathy_message, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
- PROP_TYPE,
- PROP_SENDER,
- PROP_RECEIVER,
- PROP_BODY,
- PROP_TIMESTAMP,
-};
-
-static void
-empathy_message_class_init (EmpathyMessageClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = empathy_message_finalize;
- object_class->get_property = message_get_property;
- object_class->set_property = message_set_property;
-
- g_object_class_install_property (object_class,
- PROP_TYPE,
- g_param_spec_uint ("type",
- "Message Type",
- "The type of message",
- TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
- TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY,
- TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SENDER,
- g_param_spec_object ("sender",
- "Message Sender",
- "The sender of the message",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_RECEIVER,
- g_param_spec_object ("receiver",
- "Message Receiver",
- "The receiver of the message",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_BODY,
- g_param_spec_string ("body",
- "Message Body",
- "The content of the message",
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_TIMESTAMP,
- g_param_spec_long ("timestamp",
- "timestamp",
- "timestamp",
- -1,
- G_MAXLONG,
- -1,
- G_PARAM_READWRITE));
-
-
- g_type_class_add_private (object_class, sizeof (EmpathyMessagePriv));
-
-}
-
-static void
-empathy_message_init (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (message,
- EMPATHY_TYPE_MESSAGE, EmpathyMessagePriv);
-
- message->priv = priv;
- priv->timestamp = empathy_time_get_current ();
-}
-
-static void
-empathy_message_finalize (GObject *object)
-{
- EmpathyMessagePriv *priv;
-
- priv = GET_PRIV (object);
-
- if (priv->sender) {
- g_object_unref (priv->sender);
- }
- if (priv->receiver) {
- g_object_unref (priv->receiver);
- }
-
- g_free (priv->body);
-
- G_OBJECT_CLASS (empathy_message_parent_class)->finalize (object);
-}
-
-static void
-message_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyMessagePriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_TYPE:
- g_value_set_uint (value, priv->type);
- break;
- case PROP_SENDER:
- g_value_set_object (value, priv->sender);
- break;
- case PROP_RECEIVER:
- g_value_set_object (value, priv->receiver);
- break;
- case PROP_BODY:
- g_value_set_string (value, priv->body);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-message_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyMessagePriv *priv;
-
- priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_TYPE:
- empathy_message_set_tptype (EMPATHY_MESSAGE (object),
- g_value_get_uint (value));
- break;
- case PROP_SENDER:
- empathy_message_set_sender (EMPATHY_MESSAGE (object),
- EMPATHY_CONTACT (g_value_get_object (value)));
- break;
- case PROP_RECEIVER:
- empathy_message_set_receiver (EMPATHY_MESSAGE (object),
- EMPATHY_CONTACT (g_value_get_object (value)));
- break;
- case PROP_BODY:
- empathy_message_set_body (EMPATHY_MESSAGE (object),
- g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-EmpathyMessage *
-empathy_message_new (const gchar *body)
-{
- return g_object_new (EMPATHY_TYPE_MESSAGE,
- "body", body,
- NULL);
-}
-
-TpChannelTextMessageType
-empathy_message_get_tptype (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message),
- TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL);
-
- priv = GET_PRIV (message);
-
- return priv->type;
-}
-
-void
-empathy_message_set_tptype (EmpathyMessage *message,
- TpChannelTextMessageType type)
-{
- EmpathyMessagePriv *priv;
-
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
- priv = GET_PRIV (message);
-
- priv->type = type;
-
- g_object_notify (G_OBJECT (message), "type");
-}
-
-EmpathyContact *
-empathy_message_get_sender (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), NULL);
-
- priv = GET_PRIV (message);
-
- return priv->sender;
-}
-
-void
-empathy_message_set_sender (EmpathyMessage *message, EmpathyContact *contact)
-{
- EmpathyMessagePriv *priv;
- EmpathyContact *old_sender;
-
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (message);
-
- old_sender = priv->sender;
- priv->sender = g_object_ref (contact);
-
- if (old_sender) {
- g_object_unref (old_sender);
- }
-
- g_object_notify (G_OBJECT (message), "sender");
-}
-
-EmpathyContact *
-empathy_message_get_receiver (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), NULL);
-
- priv = GET_PRIV (message);
-
- return priv->receiver;
-}
-
-void
-empathy_message_set_receiver (EmpathyMessage *message, EmpathyContact *contact)
-{
- EmpathyMessagePriv *priv;
- EmpathyContact *old_receiver;
-
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (message);
-
- old_receiver = priv->receiver;
- priv->receiver = g_object_ref (contact);
-
- if (old_receiver) {
- g_object_unref (old_receiver);
- }
-
- g_object_notify (G_OBJECT (message), "receiver");
-}
-
-const gchar *
-empathy_message_get_body (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), NULL);
-
- priv = GET_PRIV (message);
-
- return priv->body;
-}
-
-void
-empathy_message_set_body (EmpathyMessage *message,
- const gchar *body)
-{
- EmpathyMessagePriv *priv = GET_PRIV (message);
- TpChannelTextMessageType type;
-
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
- g_free (priv->body);
- priv->body = NULL;
-
- type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
- if (g_str_has_prefix (body, "/me")) {
- type = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
- body += 4;
- }
- else if (g_str_has_prefix (body, "/say")) {
- body += 5;
- }
-
- if (body) {
- priv->body = g_strdup (body);
- }
-
- if (type != priv->type) {
- empathy_message_set_tptype (message, type);
- }
-
- g_object_notify (G_OBJECT (message), "body");
-}
-
-time_t
-empathy_message_get_timestamp (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), -1);
-
- priv = GET_PRIV (message);
-
- return priv->timestamp;
-}
-
-void
-empathy_message_set_timestamp (EmpathyMessage *message,
- time_t timestamp)
-{
- EmpathyMessagePriv *priv;
-
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
- g_return_if_fail (timestamp >= -1);
-
- priv = GET_PRIV (message);
-
- if (timestamp <= 0) {
- priv->timestamp = empathy_time_get_current ();
- } else {
- priv->timestamp = timestamp;
- }
-
- g_object_notify (G_OBJECT (message), "timestamp");
-}
-
-#define IS_SEPARATOR(ch) (ch == ' ' || ch == ',' || ch == '.' || ch == ':')
-gboolean
-empathy_message_should_highlight (EmpathyMessage *message)
-{
- EmpathyContact *contact;
- const gchar *msg, *to;
- gchar *cf_msg, *cf_to;
- gchar *ch;
- gboolean ret_val;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
-
- ret_val = FALSE;
-
- msg = empathy_message_get_body (message);
- if (!msg) {
- return FALSE;
- }
-
- contact = empathy_message_get_receiver (message);
- if (!contact || !empathy_contact_is_user (contact)) {
- return FALSE;
- }
-
- to = empathy_contact_get_name (contact);
- if (!to) {
- return FALSE;
- }
-
- cf_msg = g_utf8_casefold (msg, -1);
- cf_to = g_utf8_casefold (to, -1);
-
- ch = strstr (cf_msg, cf_to);
- if (ch == NULL) {
- goto finished;
- }
- if (ch != cf_msg) {
- /* Not first in the message */
- if (!IS_SEPARATOR (*(ch - 1))) {
- goto finished;
- }
- }
-
- ch = ch + strlen (cf_to);
- if (ch >= cf_msg + strlen (cf_msg)) {
- ret_val = TRUE;
- goto finished;
- }
-
- if (IS_SEPARATOR (*ch)) {
- ret_val = TRUE;
- goto finished;
- }
-
-finished:
- g_free (cf_msg);
- g_free (cf_to);
-
- return ret_val;
-}
-
-TpChannelTextMessageType
-empathy_message_type_from_str (const gchar *type_str)
-{
- if (strcmp (type_str, "normal") == 0) {
- return TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
- }
- if (strcmp (type_str, "action") == 0) {
- return TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
- }
- else if (strcmp (type_str, "notice") == 0) {
- return TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE;
- }
- else if (strcmp (type_str, "auto-reply") == 0) {
- return TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY;
- }
-
- return TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
-}
-
-const gchar *
-empathy_message_type_to_str (TpChannelTextMessageType type)
-{
- switch (type) {
- case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION:
- return "action";
- case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE:
- return "notice";
- case TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY:
- return "auto-reply";
- default:
- return "normal";
- }
-}
-
-guint
-empathy_message_get_id (EmpathyMessage *message)
-{
- EmpathyMessagePriv *priv = GET_PRIV (message);
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), 0);
-
- return priv->id;
-}
-
-void
-empathy_message_set_id (EmpathyMessage *message, guint id)
-{
- EmpathyMessagePriv *priv = GET_PRIV (message);
-
- priv->id = id;
-}
-
-gboolean
-empathy_message_equal (EmpathyMessage *message1, EmpathyMessage *message2)
-{
- EmpathyMessagePriv *priv1;
- EmpathyMessagePriv *priv2;
-
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message1), FALSE);
- g_return_val_if_fail (EMPATHY_IS_MESSAGE (message2), FALSE);
-
- priv1 = GET_PRIV (message1);
- priv2 = GET_PRIV (message2);
-
- if (priv1->id == priv2->id && !tp_strdiff (priv1->body, priv2->body)) {
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
deleted file mode 100644
index 280150923..000000000
--- a/libempathy/empathy-message.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Mikael Hallendal <micke@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_MESSAGE_H__
-#define __EMPATHY_MESSAGE_H__
-
-#include <glib-object.h>
-
-#include "empathy-contact.h"
-#include "empathy-time.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_MESSAGE (empathy_message_get_type ())
-#define EMPATHY_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_MESSAGE, EmpathyMessage))
-#define EMPATHY_MESSAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_MESSAGE, EmpathyMessageClass))
-#define EMPATHY_IS_MESSAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_MESSAGE))
-#define EMPATHY_IS_MESSAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_MESSAGE))
-#define EMPATHY_MESSAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_MESSAGE, EmpathyMessageClass))
-
-typedef struct _EmpathyMessage EmpathyMessage;
-typedef struct _EmpathyMessageClass EmpathyMessageClass;
-
-struct _EmpathyMessage {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyMessageClass {
- GObjectClass parent_class;
-};
-
-GType empathy_message_get_type (void) G_GNUC_CONST;
-EmpathyMessage * empathy_message_new (const gchar *body);
-TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message);
-void empathy_message_set_tptype (EmpathyMessage *message,
- TpChannelTextMessageType type);
-EmpathyContact * empathy_message_get_sender (EmpathyMessage *message);
-void empathy_message_set_sender (EmpathyMessage *message,
- EmpathyContact *contact);
-EmpathyContact * empathy_message_get_receiver (EmpathyMessage *message);
-void empathy_message_set_receiver (EmpathyMessage *message,
- EmpathyContact *contact);
-const gchar * empathy_message_get_body (EmpathyMessage *message);
-void empathy_message_set_body (EmpathyMessage *message,
- const gchar *body);
-time_t empathy_message_get_timestamp (EmpathyMessage *message);
-void empathy_message_set_timestamp (EmpathyMessage *message,
- time_t timestamp);
-gboolean empathy_message_should_highlight (EmpathyMessage *message);
-TpChannelTextMessageType empathy_message_type_from_str (const gchar *type_str);
-const gchar * empathy_message_type_to_str (TpChannelTextMessageType type);
-
-guint empathy_message_get_id (EmpathyMessage *message);
-void empathy_message_set_id (EmpathyMessage *message, guint id);
-
-gboolean empathy_message_equal (EmpathyMessage *message1, EmpathyMessage *message2);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_MESSAGE_H__ */
diff --git a/libempathy/empathy-status-presets.c b/libempathy/empathy-status-presets.c
deleted file mode 100644
index e7b8804ad..000000000
--- a/libempathy/empathy-status-presets.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2005-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Martyn Russell <martyn@imendio.com>
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <telepathy-glib/util.h>
-
-#include "empathy-utils.h"
-#include "empathy-status-presets.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-#define STATUS_PRESETS_XML_FILENAME "status-presets.xml"
-#define STATUS_PRESETS_DTD_FILENAME "empathy-status-presets.dtd"
-#define STATUS_PRESETS_MAX_EACH 15
-
-typedef struct {
- gchar *status;
- McPresence state;
-} StatusPreset;
-
-static StatusPreset *status_preset_new (McPresence state,
- const gchar *status);
-static void status_preset_free (StatusPreset *status);
-static void status_presets_file_parse (const gchar *filename);
-const gchar * status_presets_get_state_as_str (McPresence state);
-static gboolean status_presets_file_save (void);
-static void status_presets_set_default (McPresence state,
- const gchar *status);
-
-static GList *presets = NULL;
-static StatusPreset *default_preset = NULL;
-
-static StatusPreset *
-status_preset_new (McPresence state,
- const gchar *status)
-{
- StatusPreset *preset;
-
- preset = g_new0 (StatusPreset, 1);
-
- preset->status = g_strdup (status);
- preset->state = state;
-
- return preset;
-}
-
-static void
-status_preset_free (StatusPreset *preset)
-{
- g_free (preset->status);
- g_free (preset);
-}
-
-static void
-status_presets_file_parse (const gchar *filename)
-{
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr presets_node;
- xmlNodePtr node;
-
- DEBUG ("Attempting to parse file:'%s'...", filename);
-
- ctxt = xmlNewParserCtxt ();
-
- /* Parse and validate the file. */
- doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
- if (!doc) {
- g_warning ("Failed to parse file:'%s'", filename);
- xmlFreeParserCtxt (ctxt);
- return;
- }
-
- if (!empathy_xml_validate (doc, STATUS_PRESETS_DTD_FILENAME)) {
- g_warning ("Failed to validate file:'%s'", filename);
- xmlFreeDoc(doc);
- xmlFreeParserCtxt (ctxt);
- return;
- }
-
- /* The root node, presets. */
- presets_node = xmlDocGetRootElement (doc);
-
- node = presets_node->children;
- while (node) {
- if (strcmp ((gchar *) node->name, "status") == 0 ||
- strcmp ((gchar *) node->name, "default") == 0) {
- McPresence state;
- gchar *status;
- gchar *state_str;
- StatusPreset *preset;
- gboolean is_default = FALSE;
-
- if (strcmp ((gchar *) node->name, "default") == 0) {
- is_default = TRUE;
- }
-
- status = (gchar *) xmlNodeGetContent (node);
- state_str = (gchar *) xmlGetProp (node, "presence");
-
- if (state_str) {
- state = empathy_presence_from_str (state_str);
-
- if (is_default) {
- DEBUG ("Default status preset state is:"
- " '%s', status:'%s'", state_str,
- status);
-
- status_presets_set_default (state, status);
- } else {
- preset = status_preset_new (state, status);
- presets = g_list_append (presets, preset);
- }
- }
-
- xmlFree (status);
- xmlFree (state_str);
- }
-
- node = node->next;
- }
-
- /* Use the default if not set */
- if (!default_preset) {
- status_presets_set_default (MC_PRESENCE_OFFLINE, NULL);
- }
-
- DEBUG ("Parsed %d status presets", g_list_length (presets));
-
- xmlFreeDoc (doc);
- xmlFreeParserCtxt (ctxt);
-}
-
-void
-empathy_status_presets_get_all (void)
-{
- gchar *dir;
- gchar *file_with_path;
-
- /* If already set up clean up first. */
- if (presets) {
- g_list_foreach (presets, (GFunc) status_preset_free, NULL);
- g_list_free (presets);
- presets = NULL;
- }
-
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
- g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
- file_with_path = g_build_filename (dir, STATUS_PRESETS_XML_FILENAME, NULL);
- g_free (dir);
-
- if (g_file_test (file_with_path, G_FILE_TEST_EXISTS)) {
- status_presets_file_parse (file_with_path);
- }
-
- g_free (file_with_path);
-}
-
-static gboolean
-status_presets_file_save (void)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
- GList *l;
- gchar *dir;
- gchar *file;
- gint count[LAST_MC_PRESENCE];
- gint i;
-
- for (i = 0; i < LAST_MC_PRESENCE; i++) {
- count[i] = 0;
- }
-
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
- g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
- file = g_build_filename (dir, STATUS_PRESETS_XML_FILENAME, NULL);
- g_free (dir);
-
- doc = xmlNewDoc ("1.0");
- root = xmlNewNode (NULL, "presets");
- xmlDocSetRootElement (doc, root);
-
- if (default_preset) {
- xmlNodePtr subnode;
- xmlChar *state;
-
- state = (gchar*) empathy_presence_to_str (default_preset->state);
-
- subnode = xmlNewTextChild (root, NULL, "default",
- default_preset->status);
- xmlNewProp (subnode, "presence", state);
- }
-
- for (l = presets; l; l = l->next) {
- StatusPreset *sp;
- xmlNodePtr subnode;
- xmlChar *state;
-
- sp = l->data;
- state = (gchar*) empathy_presence_to_str (sp->state);
-
- count[sp->state]++;
- if (count[sp->state] > STATUS_PRESETS_MAX_EACH) {
- continue;
- }
-
- subnode = xmlNewTextChild (root, NULL,
- "status", sp->status);
- xmlNewProp (subnode, "presence", state);
- }
-
- /* Make sure the XML is indented properly */
- xmlIndentTreeOutput = 1;
-
- DEBUG ("Saving file:'%s'", file);
- xmlSaveFormatFileEnc (file, doc, "utf-8", 1);
- xmlFreeDoc (doc);
-
- g_free (file);
-
- return TRUE;
-}
-
-GList *
-empathy_status_presets_get (McPresence state,
- gint max_number)
-{
- GList *list = NULL;
- GList *l;
- gint i;
-
- i = 0;
- for (l = presets; l; l = l->next) {
- StatusPreset *sp;
-
- sp = l->data;
-
- if (sp->state != state) {
- continue;
- }
-
- list = g_list_append (list, sp->status);
- i++;
-
- if (max_number != -1 && i >= max_number) {
- break;
- }
- }
-
- return list;
-}
-
-void
-empathy_status_presets_set_last (McPresence state,
- const gchar *status)
-{
- GList *l;
- StatusPreset *preset;
- gint num;
-
- /* Check if duplicate */
- for (l = presets; l; l = l->next) {
- preset = l->data;
-
- if (state == preset->state &&
- !tp_strdiff (status, preset->status)) {
- return;
- }
- }
-
- preset = status_preset_new (state, status);
- presets = g_list_prepend (presets, preset);
-
- num = 0;
- for (l = presets; l; l = l->next) {
- preset = l->data;
-
- if (state != preset->state) {
- continue;
- }
-
- num++;
-
- if (num > STATUS_PRESETS_MAX_EACH) {
- status_preset_free (preset);
- presets = g_list_delete_link (presets, l);
- break;
- }
- }
-
- status_presets_file_save ();
-}
-
-void
-empathy_status_presets_remove (McPresence state,
- const gchar *status)
-{
- StatusPreset *preset;
- GList *l;
-
- for (l = presets; l; l = l->next) {
- preset = l->data;
-
- if (state == preset->state &&
- !tp_strdiff (status, preset->status)) {
- status_preset_free (preset);
- presets = g_list_delete_link (presets, l);
- status_presets_file_save ();
- break;
- }
- }
-}
-
-void
-empathy_status_presets_reset (void)
-{
- g_list_foreach (presets, (GFunc) status_preset_free, NULL);
- g_list_free (presets);
-
- presets = NULL;
-
- status_presets_set_default (MC_PRESENCE_AVAILABLE, NULL);
-
- status_presets_file_save ();
-}
-
-McPresence
-empathy_status_presets_get_default_state (void)
-{
- if (!default_preset) {
- return MC_PRESENCE_OFFLINE;
- }
-
- return default_preset->state;
-}
-
-const gchar *
-empathy_status_presets_get_default_status (void)
-{
- if (!default_preset ||
- !default_preset->status) {
- return NULL;
- }
-
- return default_preset->status;
-}
-
-static void
-status_presets_set_default (McPresence state,
- const gchar *status)
-{
- if (default_preset) {
- status_preset_free (default_preset);
- }
-
- default_preset = status_preset_new (state, status);
-}
-
-void
-empathy_status_presets_set_default (McPresence state,
- const gchar *status)
-{
- status_presets_set_default (state, status);
- status_presets_file_save ();
-}
-
-void
-empathy_status_presets_clear_default (void)
-{
- if (default_preset) {
- status_preset_free (default_preset);
- default_preset = NULL;
- }
-
- status_presets_file_save ();
-}
diff --git a/libempathy/empathy-status-presets.dtd b/libempathy/empathy-status-presets.dtd
deleted file mode 100644
index 872be6b4e..000000000
--- a/libempathy/empathy-status-presets.dtd
+++ /dev/null
@@ -1,14 +0,0 @@
-<!--
- DTD for Empathys status presets.
- by Martyn Russell <martyn@imendio.com>
--->
-
-<!-- Root element. -->
-<!ELEMENT presets ((default?),status*)>
-
-<!ELEMENT default (#PCDATA)>
-<!ATTLIST default presence CDATA #REQUIRED>
-
-<!ELEMENT status (#PCDATA)>
-<!ATTLIST status presence CDATA #REQUIRED>
-
diff --git a/libempathy/empathy-status-presets.h b/libempathy/empathy-status-presets.h
deleted file mode 100644
index 06b6c7912..000000000
--- a/libempathy/empathy-status-presets.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2005-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Martyn Russell <martyn@imendio.com>
- */
-
-#ifndef __EMPATHY_STATUS_PRESETS_H__
-#define __EMPATHY_STATUS_PRESETS_H__
-
-#include <libmissioncontrol/mission-control.h>
-
-G_BEGIN_DECLS
-
-void empathy_status_presets_get_all (void);
-GList * empathy_status_presets_get (McPresence state,
- gint max_number);
-void empathy_status_presets_set_last (McPresence state,
- const gchar *status);
-void empathy_status_presets_remove (McPresence state,
- const gchar *status);
-void empathy_status_presets_reset (void);
-McPresence empathy_status_presets_get_default_state (void);
-const gchar * empathy_status_presets_get_default_status (void);
-void empathy_status_presets_set_default (McPresence state,
- const gchar *status);
-void empathy_status_presets_clear_default (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_STATUS_PRESETS_H__ */
diff --git a/libempathy/empathy-time.c b/libempathy/empathy-time.c
deleted file mode 100644
index 9eec8adc0..000000000
--- a/libempathy/empathy-time.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Richard Hult <richard@imendio.com>
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "empathy-time.h"
-
-/* Note: EmpathyTime is always in UTC. */
-
-time_t
-empathy_time_get_current (void)
-{
- return time (NULL);
-}
-
-time_t
-empathy_time_get_local_time (struct tm *tm)
-{
- const gchar *timezone;
- time_t t;
-
- timezone = g_getenv ("TZ");
- g_setenv ("TZ", "", TRUE);
-
- tzset ();
-
- t = mktime (tm);
-
- if (timezone) {
- g_setenv ("TZ", timezone, TRUE);
- } else {
- g_unsetenv ("TZ");
- }
-
- tzset ();
-
- return t;
-}
-
-/* The format is: "20021209T23:51:30" and is in UTC. 0 is returned on
- * failure. The alternative format "20021209" is also accepted.
- */
-time_t
-empathy_time_parse (const gchar *str)
-{
- struct tm tm;
- gint year, month;
- gint n_parsed;
-
- memset (&tm, 0, sizeof (struct tm));
-
- n_parsed = sscanf (str, "%4d%2d%2dT%2d:%2d:%2d",
- &year, &month, &tm.tm_mday, &tm.tm_hour,
- &tm.tm_min, &tm.tm_sec);
- if (n_parsed != 3 && n_parsed != 6) {
- return 0;
- }
-
- tm.tm_year = year - 1900;
- tm.tm_mon = month - 1;
- tm.tm_isdst = -1;
-
- return empathy_time_get_local_time (&tm);
-}
-
-/* Converts the UTC timestamp to a string, also in UTC. Returns NULL on failure. */
-gchar *
-empathy_time_to_string_utc (time_t t,
- const gchar *format)
-{
- gchar stamp[128];
- struct tm *tm;
-
- g_return_val_if_fail (format != NULL, NULL);
-
- tm = gmtime (&t);
- if (strftime (stamp, sizeof (stamp), format, tm) == 0) {
- return NULL;
- }
-
- return g_strdup (stamp);
-}
-
-/* Converts the UTC timestamp to a string, in local time. Returns NULL on failure. */
-gchar *
-empathy_time_to_string_local (time_t t,
- const gchar *format)
-{
- gchar stamp[128];
- struct tm *tm;
-
- g_return_val_if_fail (format != NULL, NULL);
-
- tm = localtime (&t);
- if (strftime (stamp, sizeof (stamp), format, tm) == 0) {
- return NULL;
- }
-
- return g_strdup (stamp);
-}
-
diff --git a/libempathy/empathy-time.h b/libempathy/empathy-time.h
deleted file mode 100644
index ce520cdf9..000000000
--- a/libempathy/empathy-time.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EMPATHY_TIME_H__
-#define __EMPATHY_TIME_H__
-
-#ifndef __USE_XOPEN
-#define __USE_XOPEN
-#endif
-#include <time.h>
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TIME_FORMAT_DISPLAY_SHORT "%H:%M"
-#define EMPATHY_TIME_FORMAT_DISPLAY_LONG "%a %d %b %Y"
-
-time_t empathy_time_get_current (void);
-time_t empathy_time_get_local_time (struct tm *tm);
-time_t empathy_time_parse (const gchar *str);
-gchar *empathy_time_to_string_utc (time_t t,
- const gchar *format);
-gchar *empathy_time_to_string_local (time_t t,
- const gchar *format);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TIME_H__ */
-
diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c
deleted file mode 100644
index 42bf7a063..000000000
--- a/libempathy/empathy-tp-call.c
+++ /dev/null
@@ -1,671 +0,0 @@
-/*
- * Copyright (C) 2007 Elliot Fairweather
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <string.h>
-
-#include <telepathy-glib/proxy-subclass.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/interfaces.h>
-
-#include "empathy-tp-call.h"
-#include "empathy-contact-factory.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpCall)
-typedef struct
-{
- gboolean dispose_has_run;
- TpChannel *channel;
- EmpathyContact *contact;
- gboolean is_incoming;
- guint status;
-
- EmpathyTpCallStream *audio;
- EmpathyTpCallStream *video;
-} EmpathyTpCallPriv;
-
-enum
-{
- PROP_0,
- PROP_CHANNEL,
- PROP_CONTACT,
- PROP_IS_INCOMING,
- PROP_STATUS,
- PROP_AUDIO_STREAM,
- PROP_VIDEO_STREAM
-};
-
-G_DEFINE_TYPE (EmpathyTpCall, empathy_tp_call, G_TYPE_OBJECT)
-
-static void
-tp_call_add_stream (EmpathyTpCall *call,
- guint stream_id,
- guint contact_handle,
- guint stream_type,
- guint stream_state,
- guint stream_direction)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- switch (stream_type)
- {
- case TP_MEDIA_STREAM_TYPE_AUDIO:
- DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
- stream_id, stream_state, stream_direction);
- priv->audio->exists = TRUE;
- priv->audio->id = stream_id;
- priv->audio->state = stream_state;
- priv->audio->direction = stream_direction;
- g_object_notify (G_OBJECT (call), "audio-stream");
- break;
- case TP_MEDIA_STREAM_TYPE_VIDEO:
- DEBUG ("Video stream - id: %d, state: %d, direction: %d",
- stream_id, stream_state, stream_direction);
- priv->video->exists = TRUE;
- priv->video->id = stream_id;
- priv->video->state = stream_state;
- priv->video->direction = stream_direction;
- g_object_notify (G_OBJECT (call), "video-stream");
- break;
- default:
- DEBUG ("Unknown stream type: %d", stream_type);
- }
-}
-
-static void
-tp_call_stream_added_cb (TpChannel *channel,
- guint stream_id,
- guint contact_handle,
- guint stream_type,
- gpointer user_data,
- GObject *call)
-{
- DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
- stream_id, contact_handle, stream_type);
-
- tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
- stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
- TP_MEDIA_STREAM_DIRECTION_NONE);
-}
-
-static void
-tp_call_stream_removed_cb (TpChannel *channel,
- guint stream_id,
- gpointer user_data,
- GObject *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- DEBUG ("Stream removed - stream id: %d", stream_id);
-
- if (stream_id == priv->audio->id)
- {
- priv->audio->exists = FALSE;
- g_object_notify (call, "audio-stream");
- }
- else if (stream_id == priv->video->id)
- {
- priv->video->exists = FALSE;
- g_object_notify (call, "video-stream");
- }
-}
-
-static void
-tp_call_stream_state_changed_cb (TpChannel *proxy,
- guint stream_id,
- guint stream_state,
- gpointer user_data,
- GObject *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- DEBUG ("Stream state changed - stream id: %d, state state: %d",
- stream_id, stream_state);
-
- if (stream_id == priv->audio->id)
- {
- priv->audio->state = stream_state;
- g_object_notify (call, "audio-stream");
- }
- else if (stream_id == priv->video->id)
- {
- priv->video->state = stream_state;
- g_object_notify (call, "video-stream");
- }
-}
-
-static void
-tp_call_stream_direction_changed_cb (TpChannel *channel,
- guint stream_id,
- guint stream_direction,
- guint pending_flags,
- gpointer user_data,
- GObject *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- DEBUG ("Stream direction changed - stream: %d, direction: %d",
- stream_id, stream_direction);
-
- if (stream_id == priv->audio->id)
- {
- priv->audio->direction = stream_direction;
- g_object_notify (call, "audio-stream");
- }
- else if (stream_id == priv->video->id)
- {
- priv->video->direction = stream_direction;
- g_object_notify (call, "video-stream");
- }
-}
-
-static void
-tp_call_request_streams_cb (TpChannel *channel,
- const GPtrArray *streams,
- const GError *error,
- gpointer user_data,
- GObject *call)
-{
- guint i;
-
- if (error)
- {
- DEBUG ("Error requesting streams: %s", error->message);
- return;
- }
-
- for (i = 0; i < streams->len; i++)
- {
- GValueArray *values;
- guint stream_id;
- guint contact_handle;
- guint stream_type;
- guint stream_state;
- guint stream_direction;
-
- values = g_ptr_array_index (streams, i);
- stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
- contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
- stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
- stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
- stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
-
- tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
- stream_type, stream_state, stream_direction);
- }
-}
-
-static void
-tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
- EmpathyCapabilities capabilities)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
- GArray *stream_types;
- guint handle;
- guint stream_type;
-
- if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
- capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
-
- DEBUG ("Requesting new stream for capabilities %d",
- capabilities);
-
- stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
- handle = empathy_contact_get_handle (priv->contact);
-
- if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
- {
- stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
- g_array_append_val (stream_types, stream_type);
- }
- if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
- {
- stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
- g_array_append_val (stream_types, stream_type);
- }
-
- tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
- handle, stream_types, tp_call_request_streams_cb, NULL, NULL,
- G_OBJECT (call));
-
- g_array_free (stream_types, TRUE);
-}
-
-static EmpathyContact *
-tp_call_dup_contact_from_handle (EmpathyTpCall *call, TpHandle handle)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
- EmpathyContactFactory *factory;
- McAccount *account;
- EmpathyContact *contact;
-
- factory = empathy_contact_factory_dup_singleton ();
- account = empathy_channel_get_account (priv->channel);
- contact = empathy_contact_factory_get_from_handle (factory, account, handle);
-
- g_object_unref (factory);
- g_object_unref (account);
-
- return contact;
-}
-
-static void
-tp_call_update_status (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
- TpHandle self_handle;
- const TpIntSet *set;
- TpIntSetIter iter;
-
- g_object_ref (call);
-
- self_handle = tp_channel_group_get_self_handle (priv->channel);
- set = tp_channel_group_get_members (priv->channel);
- tp_intset_iter_init (&iter, set);
- while (tp_intset_iter_next (&iter))
- {
- if (priv->contact == NULL && iter.element != self_handle)
- {
- /* We found the remote contact */
- priv->contact = tp_call_dup_contact_from_handle (call, iter.element);
- priv->is_incoming = TRUE;
- priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
- g_object_notify (G_OBJECT (call), "is-incoming");
- g_object_notify (G_OBJECT (call), "contact");
- g_object_notify (G_OBJECT (call), "status");
- }
-
- if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
- ((priv->is_incoming && iter.element == self_handle) ||
- (!priv->is_incoming && iter.element != self_handle)))
- {
- priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
- g_object_notify (G_OBJECT (call), "status");
- }
- }
-
- g_object_unref (call);
-}
-
-static void
-tp_call_members_changed_cb (TpChannel *channel,
- gchar *message,
- GArray *added,
- GArray *removed,
- GArray *local_pending,
- GArray *remote_pending,
- guint actor,
- guint reason,
- EmpathyTpCall *call)
-{
- tp_call_update_status (call);
-}
-
-void
-empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- priv->contact = g_object_ref (contact);
- priv->is_incoming = FALSE;
- priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
- g_object_notify (G_OBJECT (call), "is-incoming");
- g_object_notify (G_OBJECT (call), "contact");
- g_object_notify (G_OBJECT (call), "status");
- tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_AUDIO);
-}
-
-static void
-tp_call_channel_invalidated_cb (TpChannel *channel,
- GQuark domain,
- gint code,
- gchar *message,
- EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- DEBUG ("Channel invalidated: %s", message);
- priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
- g_object_notify (G_OBJECT (call), "status");
-}
-
-static void
-tp_call_async_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *call)
-{
- if (error)
- DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
-}
-
-static GObject *
-tp_call_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- EmpathyTpCall *call;
- EmpathyTpCallPriv *priv;
-
- object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
- n_construct_params, construct_params);
-
- call = EMPATHY_TP_CALL (object);
- priv = GET_PRIV (call);
-
- /* Setup streamed media channel */
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (tp_call_channel_invalidated_cb), call);
- tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
- tp_call_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
- tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
- tp_call_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
- tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
- tp_call_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
- tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
- tp_call_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
- tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
- tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call));
-
- /* Update status when members changes */
- tp_call_update_status (call);
- g_signal_connect (priv->channel, "group-members-changed",
- G_CALLBACK (tp_call_members_changed_cb), call);
-
- return object;
-}
-static void
-tp_call_dispose (GObject *object)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (object);
-
- DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- if (priv->channel != NULL)
- {
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_call_channel_invalidated_cb, object);
-
- g_object_unref (priv->channel);
- priv->channel = NULL;
- }
-
- if (priv->contact != NULL)
- g_object_unref (priv->contact);
-
- if (G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose)
- G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose (object);
-}
-
-static void
-tp_call_finalize (GObject *object)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (object);
-
- DEBUG ("Finalizing: %p", object);
-
- g_slice_free (EmpathyTpCallStream, priv->audio);
- g_slice_free (EmpathyTpCallStream, priv->video);
-
- (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
-}
-
-static void
-tp_call_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (object);
-
- switch (prop_id)
- {
- case PROP_CHANNEL:
- priv->channel = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tp_call_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (object);
-
- switch (prop_id)
- {
- case PROP_CHANNEL:
- g_value_set_object (value, priv->channel);
- break;
- case PROP_CONTACT:
- g_value_set_object (value, priv->contact);
- break;
- case PROP_IS_INCOMING:
- g_value_set_boolean (value, priv->is_incoming);
- break;
- case PROP_STATUS:
- g_value_set_uint (value, priv->status);
- break;
- case PROP_AUDIO_STREAM:
- g_value_set_pointer (value, priv->audio);
- break;
- case PROP_VIDEO_STREAM:
- g_value_set_pointer (value, priv->video);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_tp_call_class_init (EmpathyTpCallClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = tp_call_constructor;
- object_class->dispose = tp_call_dispose;
- object_class->finalize = tp_call_finalize;
- object_class->set_property = tp_call_set_property;
- object_class->get_property = tp_call_get_property;
-
- g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
-
- g_object_class_install_property (object_class, PROP_CHANNEL,
- g_param_spec_object ("channel", "channel", "channel",
- TP_TYPE_CHANNEL,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_CONTACT,
- g_param_spec_object ("contact", "Call contact", "Call contact",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_IS_INCOMING,
- g_param_spec_boolean ("is-incoming", "Is media stream incoming",
- "Is media stream incoming", FALSE, G_PARAM_READABLE |
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_STATUS,
- g_param_spec_uint ("status", "Call status",
- "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
- g_param_spec_pointer ("audio-stream", "Audio stream data",
- "Audio stream data",
- G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
- g_param_spec_pointer ("video-stream", "Video stream data",
- "Video stream data",
- G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-}
-
-static void
-empathy_tp_call_init (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
- EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
-
- call->priv = priv;
- priv->status = EMPATHY_TP_CALL_STATUS_READYING;
- priv->contact = NULL;
- priv->audio = g_slice_new0 (EmpathyTpCallStream);
- priv->video = g_slice_new0 (EmpathyTpCallStream);
- priv->audio->exists = FALSE;
- priv->video->exists = FALSE;
-}
-
-EmpathyTpCall *
-empathy_tp_call_new (TpChannel *channel)
-{
- g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
-
- return g_object_new (EMPATHY_TYPE_TP_CALL,
- "channel", channel,
- NULL);
-}
-
-void
-empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
- TpHandle self_handle;
- GArray handles = {(gchar *) &self_handle, 1};
-
- g_return_if_fail (EMPATHY_IS_TP_CALL (call));
- g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING);
- g_return_if_fail (priv->is_incoming);
-
- DEBUG ("Accepting incoming call");
-
- self_handle = tp_channel_group_get_self_handle (priv->channel);
- tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
- &handles, NULL, NULL, NULL, NULL, NULL);
-}
-
-void
-empathy_tp_call_close (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
- if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
- return;
-
- DEBUG ("Closing channel");
-
- tp_cli_channel_call_close (priv->channel, -1,
- NULL, NULL, NULL, NULL);
-
- priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
- g_object_notify (G_OBJECT (call), "status");
-}
-
-void
-empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
- gboolean is_sending)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
- guint new_direction;
-
- g_return_if_fail (EMPATHY_IS_TP_CALL (call));
- g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
-
- DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
-
- if (!priv->video->exists)
- {
- if (is_sending)
- tp_call_request_streams_for_capabilities (call,
- EMPATHY_CAPABILITIES_VIDEO);
- return;
- }
-
- if (is_sending)
- new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
- else
- new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
-
- tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
- -1, priv->video->id, new_direction,
- (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
- tp_call_async_cb, NULL, NULL, G_OBJECT (call));
-}
-
-void
-empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- g_return_if_fail (EMPATHY_IS_TP_CALL (call));
- g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
-
- if (!priv->audio->exists)
- return;
-
- tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
- priv->audio->id, event,
- (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
- "starting tone", NULL, G_OBJECT (call));
-}
-
-void
-empathy_tp_call_stop_tone (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- g_return_if_fail (EMPATHY_IS_TP_CALL (call));
- g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
-
- if (!priv->audio->exists)
- return;
-
- tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
- priv->audio->id,
- (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
- "stoping tone", NULL, G_OBJECT (call));
-}
-
-gboolean
-empathy_tp_call_has_dtmf (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
-
- return tp_proxy_has_interface_by_id (priv->channel,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
-}
-
diff --git a/libempathy/empathy-tp-call.h b/libempathy/empathy-tp-call.h
deleted file mode 100644
index 081773423..000000000
--- a/libempathy/empathy-tp-call.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Elliot Fairweather
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_CALL_H__
-#define __EMPATHY_TP_CALL_H__
-
-#include <glib.h>
-#include <telepathy-glib/channel.h>
-
-#include "empathy-contact.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_CALL (empathy_tp_call_get_type ())
-#define EMPATHY_TP_CALL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), \
- EMPATHY_TYPE_TP_CALL, EmpathyTpCall))
-#define EMPATHY_TP_CALL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
- EMPATHY_TYPE_TP_CALL, EmpathyTpCallClass))
-#define EMPATHY_IS_TP_CALL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), \
- EMPATHY_TYPE_TP_CALL))
-#define EMPATHY_IS_TP_CALL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- EMPATHY_TYPE_TP_CALL))
-#define EMPATHY_TP_CALL_GET_CLASS(object) \
- (G_TYPE_INSTANCE_GET_CLASS ((object), \
- EMPATHY_TYPE_TP_CALL, EmpathyTpCallClass))
-
-typedef struct _EmpathyTpCall EmpathyTpCall;
-typedef struct _EmpathyTpCallClass EmpathyTpCallClass;
-
-struct _EmpathyTpCall {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpCallClass {
- GObjectClass parent_class;
-};
-
-typedef enum
-{
- EMPATHY_TP_CALL_STATUS_READYING,
- EMPATHY_TP_CALL_STATUS_PENDING,
- EMPATHY_TP_CALL_STATUS_ACCEPTED,
- EMPATHY_TP_CALL_STATUS_CLOSED
-} EmpathyTpCallStatus;
-
-typedef struct
-{
- gboolean exists;
- guint id;
- guint state;
- guint direction;
-} EmpathyTpCallStream;
-
-GType empathy_tp_call_get_type (void) G_GNUC_CONST;
-EmpathyTpCall *empathy_tp_call_new (TpChannel *channel);
-void empathy_tp_call_close (EmpathyTpCall *call);
-
-void empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact);
-
-void empathy_tp_call_accept_incoming_call (EmpathyTpCall *call);
-void empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
- gboolean is_sending);
-void empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event);
-void empathy_tp_call_stop_tone (EmpathyTpCall *call);
-gboolean empathy_tp_call_has_dtmf (EmpathyTpCall *call);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_CALL_H__ */
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
deleted file mode 100644
index 49870b41b..000000000
--- a/libempathy/empathy-tp-chat.c
+++ /dev/null
@@ -1,1421 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/util.h>
-
-#include "empathy-tp-chat.h"
-#include "empathy-tp-group.h"
-#include "empathy-contact-factory.h"
-#include "empathy-contact-monitor.h"
-#include "empathy-contact-list.h"
-#include "empathy-marshal.h"
-#include "empathy-time.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CHAT
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpChat)
-typedef struct {
- gboolean dispose_has_run;
- EmpathyContactFactory *factory;
- EmpathyContactMonitor *contact_monitor;
- EmpathyContact *user;
- EmpathyContact *remote_contact;
- EmpathyTpGroup *group;
- McAccount *account;
- TpChannel *channel;
- gchar *id;
- gboolean listing_pending_messages;
- /* Queue of messages not signalled yet */
- GQueue *messages_queue;
- /* Queue of messages signalled but not acked yet */
- GQueue *pending_messages_queue;
- gboolean had_properties_list;
- GPtrArray *properties;
- gboolean ready;
- guint members_count;
-} EmpathyTpChatPriv;
-
-typedef struct {
- gchar *name;
- guint id;
- TpPropertyFlags flags;
- GValue *value;
-} TpChatProperty;
-
-static void tp_chat_iface_init (EmpathyContactListIface *iface);
-
-enum {
- PROP_0,
- PROP_CHANNEL,
- PROP_REMOTE_CONTACT,
- PROP_READY,
-};
-
-enum {
- MESSAGE_RECEIVED,
- SEND_ERROR,
- CHAT_STATE_CHANGED,
- PROPERTY_CHANGED,
- DESTROY,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyTpChat, empathy_tp_chat, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
- tp_chat_iface_init));
-
-static void acknowledge_messages (EmpathyTpChat *chat, GArray *ids);
-
-static void
-tp_chat_invalidated_cb (TpProxy *proxy,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_object_unref (priv->channel);
- priv->channel = NULL;
-
- DEBUG ("Channel invalidated: %s", message);
- g_signal_emit (chat, signals[DESTROY], 0);
-
-}
-
-static void
-tp_chat_async_cb (TpChannel *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error) {
- DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
- }
-}
-
-static void
-tp_chat_member_added_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- guint handle_type = 0;
-
- if (priv->channel == NULL)
- return;
-
- priv->members_count++;
- g_signal_emit_by_name (chat, "members-changed",
- contact, actor, reason, message,
- TRUE);
-
- g_object_get (priv->channel, "handle-type", &handle_type, NULL);
- if (handle_type == TP_HANDLE_TYPE_ROOM) {
- return;
- }
-
- if (priv->members_count > 2 && priv->remote_contact) {
- /* We now have more than 2 members, this is not a p2p chat
- * anymore. Remove the remote-contact as it makes no sense, the
- * EmpathyContactList interface must be used now. */
- g_object_unref (priv->remote_contact);
- priv->remote_contact = NULL;
- g_object_notify (G_OBJECT (chat), "remote-contact");
- }
- if (priv->members_count <= 2 && !priv->remote_contact &&
- !empathy_contact_is_user (contact)) {
- /* This is a p2p chat, if it's not ourself that means this is
- * the remote contact with who we are chatting. This is to
- * avoid forcing the usage of the EmpathyContactList interface
- * for p2p chats. */
- priv->remote_contact = g_object_ref (contact);
- g_object_notify (G_OBJECT (chat), "remote-contact");
- }
-}
-
-static void
-tp_chat_member_removed_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- guint handle_type = 0;
-
- if (priv->channel == NULL)
- return;
-
- priv->members_count--;
- g_signal_emit_by_name (chat, "members-changed",
- contact, actor, reason, message,
- FALSE);
-
- g_object_get (priv->channel, "handle-type", &handle_type, NULL);
- if (handle_type == TP_HANDLE_TYPE_ROOM) {
- return;
- }
-
- if (priv->members_count <= 2 && !priv->remote_contact) {
- GList *members, *l;
-
- /* We are not a MUC anymore, get the remote contact back */
- members = empathy_tp_group_get_members (group);
- for (l = members; l; l = l->next) {
- if (!empathy_contact_is_user (l->data)) {
- priv->remote_contact = g_object_ref (l->data);
- g_object_notify (G_OBJECT (chat), "remote-contact");
- break;
- }
- }
- g_list_foreach (members, (GFunc) g_object_unref, NULL);
- g_list_free (members);
- }
-}
-
-static void
-tp_chat_local_pending_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- if (priv->channel == NULL)
- return;
-
- g_signal_emit_by_name (chat, "pendings-changed",
- contact, actor, reason, message,
- TRUE);
-}
-
-static void
-tp_chat_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (list);
- TpHandle handle;
- GArray handles = {(gchar *) &handle, 1};
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- handle = empathy_contact_get_handle (contact);
- tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
- &handles, NULL,
- NULL, NULL, NULL,
- NULL);
-}
-
-static void
-tp_chat_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (list);
- TpHandle handle;
- GArray handles = {(gchar *) &handle, 1};
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- handle = empathy_contact_get_handle (contact);
- tp_cli_channel_interface_group_call_remove_members (priv->channel, -1,
- &handles, NULL,
- NULL, NULL, NULL,
- NULL);
-}
-
-static GList *
-tp_chat_get_members (EmpathyContactList *list)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (list);
- GList *members = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (list), NULL);
-
- if (priv->group) {
- members = empathy_tp_group_get_members (priv->group);
- } else {
- members = g_list_prepend (members, g_object_ref (priv->user));
- members = g_list_prepend (members, g_object_ref (priv->remote_contact));
- }
-
- return members;
-}
-
-static EmpathyContactMonitor *
-tp_chat_get_monitor (EmpathyContactList *list)
-{
- EmpathyTpChatPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (list), NULL);
-
- priv = GET_PRIV (list);
-
- if (priv->contact_monitor == NULL) {
- priv->contact_monitor = empathy_contact_monitor_new_for_iface (list);
- }
-
- return priv->contact_monitor;
-}
-
-static EmpathyMessage *
-tp_chat_build_message (EmpathyTpChat *chat,
- guint id,
- guint type,
- guint timestamp,
- guint from_handle,
- const gchar *message_body)
-{
- EmpathyTpChatPriv *priv;
- EmpathyMessage *message;
- EmpathyContact *sender;
-
- priv = GET_PRIV (chat);
-
- if (from_handle == 0) {
- sender = g_object_ref (priv->user);
- } else {
- sender = empathy_contact_factory_get_from_handle (priv->factory,
- priv->account,
- from_handle);
- }
-
- message = empathy_message_new (message_body);
- empathy_message_set_tptype (message, type);
- empathy_message_set_sender (message, sender);
- empathy_message_set_receiver (message, priv->user);
- empathy_message_set_timestamp (message, timestamp);
- empathy_message_set_id (message, id);
-
- g_object_unref (sender);
-
- return message;
-}
-
-static void
-tp_chat_sender_ready_notify_cb (EmpathyContact *contact,
- GParamSpec *param_spec,
- EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- EmpathyMessage *message;
- EmpathyContactReady ready;
- EmpathyContact *sender = NULL;
- gboolean removed = FALSE;
-
- /* Emit all messages queued until we find a message with not
- * ready sender (in case of a MUC we could have more than one sender).
- * When leaving this loop, sender is the first not ready contact queued
- * and removed tells if at least one message got removed
- * from the queue. */
- while ((message = g_queue_peek_head (priv->messages_queue)) != NULL) {
- sender = empathy_message_get_sender (message);
- ready = empathy_contact_get_ready (sender);
-
- if ((ready & EMPATHY_CONTACT_READY_NAME) == 0 ||
- (ready & EMPATHY_CONTACT_READY_ID) == 0) {
- break;
- }
-
- DEBUG ("Queued message ready");
- message = g_queue_pop_head (priv->messages_queue);
- g_queue_push_tail (priv->pending_messages_queue, message);
- g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
- removed = TRUE;
- }
-
- if (removed) {
- /* We removed at least one message from the queue, disconnect
- * the ready signal from the previous contact */
- g_signal_handlers_disconnect_by_func (contact,
- tp_chat_sender_ready_notify_cb,
- chat);
-
- if (g_queue_get_length (priv->messages_queue) > 0) {
- /* We still have queued message, connect the ready
- * signal on the new first message sender. */
- g_signal_connect (sender, "notify::ready",
- G_CALLBACK (tp_chat_sender_ready_notify_cb),
- chat);
- }
- }
-}
-
-static void
-tp_chat_emit_or_queue_message (EmpathyTpChat *chat,
- EmpathyMessage *message)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- EmpathyContact *sender;
- EmpathyContactReady ready;
-
- if (g_queue_get_length (priv->messages_queue) > 0) {
- DEBUG ("Message queue not empty");
- g_queue_push_tail (priv->messages_queue, g_object_ref (message));
- return;
- }
-
-
- sender = empathy_message_get_sender (message);
- ready = empathy_contact_get_ready (sender);
- if ((ready & EMPATHY_CONTACT_READY_NAME) &&
- (ready & EMPATHY_CONTACT_READY_ID)) {
- DEBUG ("Message queue empty and sender ready");
- g_queue_push_tail (priv->pending_messages_queue, g_object_ref (message));
- g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
- return;
- }
-
- DEBUG ("Sender not ready");
- g_queue_push_tail (priv->messages_queue, g_object_ref (message));
- g_signal_connect (sender, "notify::ready",
- G_CALLBACK (tp_chat_sender_ready_notify_cb),
- chat);
-}
-
-static void
-tp_chat_received_cb (TpChannel *channel,
- guint message_id,
- guint timestamp,
- guint from_handle,
- guint message_type,
- guint message_flags,
- const gchar *message_body,
- gpointer user_data,
- GObject *chat_)
-{
- EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- EmpathyMessage *message;
-
- if (priv->channel == NULL)
- return;
-
- if (priv->listing_pending_messages) {
- return;
- }
-
- DEBUG ("Message received: %s", message_body);
-
- if (message_flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT &&
- !tp_strdiff (message_body, "")) {
- GArray *ids;
-
- DEBUG ("Empty message with NonTextContent, ignoring and acking.");
-
- ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
- g_array_append_val (ids, message_id);
- acknowledge_messages (chat, ids);
- g_array_free (ids, TRUE);
-
- return;
- }
-
- message = tp_chat_build_message (chat,
- message_id,
- message_type,
- timestamp,
- from_handle,
- message_body);
-
- tp_chat_emit_or_queue_message (chat, message);
- g_object_unref (message);
-}
-
-static void
-tp_chat_sent_cb (TpChannel *channel,
- guint timestamp,
- guint message_type,
- const gchar *message_body,
- gpointer user_data,
- GObject *chat_)
-{
- EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- EmpathyMessage *message;
-
- if (priv->channel == NULL)
- return;
-
- DEBUG ("Message sent: %s", message_body);
-
- message = tp_chat_build_message (chat,
- 0,
- message_type,
- timestamp,
- 0,
- message_body);
-
- tp_chat_emit_or_queue_message (chat, message);
- g_object_unref (message);
-}
-
-static void
-tp_chat_send_error_cb (TpChannel *channel,
- guint error_code,
- guint timestamp,
- guint message_type,
- const gchar *message_body,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyMessage *message;
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- if (priv->channel == NULL)
- return;
-
- DEBUG ("Message sent error: %s (%d)", message_body, error_code);
-
- message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
- 0,
- message_type,
- timestamp,
- 0,
- message_body);
-
- g_signal_emit (chat, signals[SEND_ERROR], 0, message, error_code);
- g_object_unref (message);
-}
-
-static void
-tp_chat_send_cb (TpChannel *proxy,
- const GError *error,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyMessage *message = EMPATHY_MESSAGE (user_data);
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- g_signal_emit (chat, signals[SEND_ERROR], 0, message,
- TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN);
- }
-}
-
-static void
-tp_chat_state_changed_cb (TpChannel *channel,
- guint handle,
- guint state,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- EmpathyContact *contact;
-
- if (priv->channel == NULL)
- return;
-
- contact = empathy_contact_factory_get_from_handle (priv->factory,
- priv->account,
- handle);
-
- DEBUG ("Chat state changed for %s (%d): %d",
- empathy_contact_get_name (contact), handle, state);
-
- g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state);
- g_object_unref (contact);
-}
-
-static void
-tp_chat_list_pending_messages_cb (TpChannel *channel,
- const GPtrArray *messages_list,
- const GError *error,
- gpointer user_data,
- GObject *chat_)
-{
- EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- guint i;
- GArray *empty_non_text_content_ids = NULL;
-
- priv->listing_pending_messages = FALSE;
-
- if (priv->channel == NULL)
- return;
-
- if (error) {
- DEBUG ("Error listing pending messages: %s", error->message);
- return;
- }
-
- for (i = 0; i < messages_list->len; i++) {
- EmpathyMessage *message;
- GValueArray *message_struct;
- const gchar *message_body;
- guint message_id;
- guint timestamp;
- guint from_handle;
- guint message_type;
- guint message_flags;
-
- message_struct = g_ptr_array_index (messages_list, i);
-
- message_id = g_value_get_uint (g_value_array_get_nth (message_struct, 0));
- timestamp = g_value_get_uint (g_value_array_get_nth (message_struct, 1));
- from_handle = g_value_get_uint (g_value_array_get_nth (message_struct, 2));
- message_type = g_value_get_uint (g_value_array_get_nth (message_struct, 3));
- message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4));
- message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5));
-
- DEBUG ("Message pending: %s", message_body);
-
- if (message_flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT &&
- !tp_strdiff (message_body, "")) {
- DEBUG ("Empty message with NonTextContent, ignoring and acking.");
-
- if (empty_non_text_content_ids == NULL) {
- empty_non_text_content_ids = g_array_new (FALSE, FALSE, sizeof (guint));
- }
-
- g_array_append_val (empty_non_text_content_ids, message_id);
- continue;
- }
-
- message = tp_chat_build_message (chat,
- message_id,
- message_type,
- timestamp,
- from_handle,
- message_body);
-
- tp_chat_emit_or_queue_message (chat, message);
- g_object_unref (message);
- }
-
- if (empty_non_text_content_ids != NULL) {
- acknowledge_messages (chat, empty_non_text_content_ids);
- g_array_free (empty_non_text_content_ids, TRUE);
- }
-}
-
-static void
-tp_chat_property_flags_changed_cb (TpProxy *proxy,
- const GPtrArray *properties,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- guint i, j;
-
- if (priv->channel == NULL)
- return;
-
- if (!priv->had_properties_list || !properties) {
- return;
- }
-
- for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
- guint id;
- guint flags;
-
- prop_struct = g_ptr_array_index (properties, i);
- id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
- flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 1));
-
- for (j = 0; j < priv->properties->len; j++) {
- property = g_ptr_array_index (priv->properties, j);
- if (property->id == id) {
- property->flags = flags;
- DEBUG ("property %s flags changed: %d",
- property->name, property->flags);
- break;
- }
- }
- }
-}
-
-static void
-tp_chat_properties_changed_cb (TpProxy *proxy,
- const GPtrArray *properties,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- guint i, j;
-
- if (priv->channel == NULL)
- return;
-
- if (!priv->had_properties_list || !properties) {
- return;
- }
-
- for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
- guint id;
- GValue *src_value;
-
- prop_struct = g_ptr_array_index (properties, i);
- id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
- src_value = g_value_get_boxed (g_value_array_get_nth (prop_struct, 1));
-
- for (j = 0; j < priv->properties->len; j++) {
- property = g_ptr_array_index (priv->properties, j);
- if (property->id == id) {
- if (property->value) {
- g_value_copy (src_value, property->value);
- } else {
- property->value = tp_g_value_slice_dup (src_value);
- }
-
- DEBUG ("property %s changed", property->name);
- g_signal_emit (chat, signals[PROPERTY_CHANGED], 0,
- property->name, property->value);
- break;
- }
- }
- }
-}
-
-static void
-tp_chat_get_properties_cb (TpProxy *proxy,
- const GPtrArray *properties,
- const GError *error,
- gpointer user_data,
- GObject *chat)
-{
- if (error) {
- DEBUG ("Error getting properties: %s", error->message);
- return;
- }
-
- tp_chat_properties_changed_cb (proxy, properties, user_data, chat);
-}
-
-static void
-tp_chat_list_properties_cb (TpProxy *proxy,
- const GPtrArray *properties,
- const GError *error,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- GArray *ids;
- guint i;
-
- if (priv->channel == NULL)
- return;
-
- priv->had_properties_list = TRUE;
-
- if (error) {
- DEBUG ("Error listing properties: %s", error->message);
- return;
- }
-
- ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len);
- priv->properties = g_ptr_array_sized_new (properties->len);
- for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
-
- prop_struct = g_ptr_array_index (properties, i);
- property = g_slice_new0 (TpChatProperty);
- property->id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
- property->name = g_value_dup_string (g_value_array_get_nth (prop_struct, 1));
- property->flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 3));
-
- DEBUG ("Adding property name=%s id=%d flags=%d",
- property->name, property->id, property->flags);
- g_ptr_array_add (priv->properties, property);
- if (property->flags & TP_PROPERTY_FLAG_READ) {
- g_array_append_val (ids, property->id);
- }
- }
-
- tp_cli_properties_interface_call_get_properties (proxy, -1,
- ids,
- tp_chat_get_properties_cb,
- NULL, NULL,
- chat);
-
- g_array_free (ids, TRUE);
-}
-
-void
-empathy_tp_chat_set_property (EmpathyTpChat *chat,
- const gchar *name,
- const GValue *value)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- TpChatProperty *property;
- guint i;
-
- g_return_if_fail (priv->ready);
-
- for (i = 0; i < priv->properties->len; i++) {
- property = g_ptr_array_index (priv->properties, i);
- if (!tp_strdiff (property->name, name)) {
- GPtrArray *properties;
- GValueArray *prop;
- GValue id = {0, };
- GValue dest_value = {0, };
-
- if (!(property->flags & TP_PROPERTY_FLAG_WRITE)) {
- break;
- }
-
- g_value_init (&id, G_TYPE_UINT);
- g_value_init (&dest_value, G_TYPE_VALUE);
- g_value_set_uint (&id, property->id);
- g_value_set_boxed (&dest_value, value);
-
- prop = g_value_array_new (2);
- g_value_array_append (prop, &id);
- g_value_array_append (prop, &dest_value);
-
- properties = g_ptr_array_sized_new (1);
- g_ptr_array_add (properties, prop);
-
- DEBUG ("Set property %s", name);
- tp_cli_properties_interface_call_set_properties (priv->channel, -1,
- properties,
- (tp_cli_properties_interface_callback_for_set_properties)
- tp_chat_async_cb,
- "Seting property", NULL,
- G_OBJECT (chat));
-
- g_ptr_array_free (properties, TRUE);
- g_value_array_free (prop);
-
- break;
- }
- }
-}
-
-static void
-tp_chat_channel_ready_cb (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- TpConnection *connection;
- guint handle, handle_type;
-
- if (priv->channel == NULL)
- return;
-
- DEBUG ("Channel ready");
-
- g_object_get (priv->channel,
- "connection", &connection,
- "handle", &handle,
- "handle_type", &handle_type,
- NULL);
-
- if (handle_type != TP_HANDLE_TYPE_NONE && handle != 0) {
- GArray *handles;
- gchar **names;
-
- handles = g_array_new (FALSE, FALSE, sizeof (guint));
- g_array_append_val (handles, handle);
- tp_cli_connection_run_inspect_handles (connection, -1,
- handle_type, handles,
- &names, NULL, NULL);
- priv->id = *names;
- g_array_free (handles, TRUE);
- g_free (names);
- }
-
- if (handle_type == TP_HANDLE_TYPE_CONTACT && handle != 0) {
- priv->remote_contact = empathy_contact_factory_get_from_handle (priv->factory,
- priv->account,
- handle);
- g_object_notify (G_OBJECT (chat), "remote-contact");
- }
-
- if (tp_proxy_has_interface_by_id (priv->channel,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) {
- priv->group = empathy_tp_group_new (priv->channel);
-
- g_signal_connect (priv->group, "member-added",
- G_CALLBACK (tp_chat_member_added_cb),
- chat);
- g_signal_connect (priv->group, "member-removed",
- G_CALLBACK (tp_chat_member_removed_cb),
- chat);
- g_signal_connect (priv->group, "local-pending",
- G_CALLBACK (tp_chat_local_pending_cb),
- chat);
- empathy_run_until_ready (priv->group);
- } else {
- priv->members_count = 2;
- }
-
- if (tp_proxy_has_interface_by_id (priv->channel,
- TP_IFACE_QUARK_PROPERTIES_INTERFACE)) {
- tp_cli_properties_interface_call_list_properties (priv->channel, -1,
- tp_chat_list_properties_cb,
- NULL, NULL,
- G_OBJECT (chat));
- tp_cli_properties_interface_connect_to_properties_changed (priv->channel,
- tp_chat_properties_changed_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- tp_cli_properties_interface_connect_to_property_flags_changed (priv->channel,
- tp_chat_property_flags_changed_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- }
-
- priv->listing_pending_messages = TRUE;
- tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
- FALSE,
- tp_chat_list_pending_messages_cb,
- NULL, NULL,
- G_OBJECT (chat));
-
- tp_cli_channel_type_text_connect_to_received (priv->channel,
- tp_chat_received_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- tp_cli_channel_type_text_connect_to_sent (priv->channel,
- tp_chat_sent_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- tp_cli_channel_type_text_connect_to_send_error (priv->channel,
- tp_chat_send_error_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
- tp_chat_state_changed_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
- tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
- tp_chat_state_changed_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
-
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (chat), "ready");
-}
-
-static void
-tp_chat_dispose (GObject *object)
-{
- EmpathyTpChat *self = EMPATHY_TP_CHAT (object);
- EmpathyTpChatPriv *priv = GET_PRIV (self);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- if (priv->channel != NULL)
- {
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_chat_invalidated_cb, self);
- g_object_unref (priv->channel);
- priv->channel = NULL;
- }
-
- if (priv->remote_contact != NULL)
- g_object_unref (priv->remote_contact);
-
- priv->remote_contact = NULL;
-
- if (priv->group != NULL)
- g_object_unref (priv->group);
- priv->group = NULL;
-
- if (priv->factory != NULL)
- g_object_unref (priv->factory);
- priv->factory = NULL;
-
- if (priv->user != NULL);
- g_object_unref (priv->user);
- priv->user = NULL;
-
- if (priv->account != NULL);
- g_object_unref (priv->account);
- priv->account = NULL;
-
- if (priv->contact_monitor)
- g_object_unref (priv->contact_monitor);
- priv->contact_monitor = NULL;
-
- if (!g_queue_is_empty (priv->messages_queue)) {
- EmpathyMessage *message;
- EmpathyContact *contact;
-
- message = g_queue_peek_head (priv->messages_queue);
- contact = empathy_message_get_sender (message);
- g_signal_handlers_disconnect_by_func (contact,
- tp_chat_sender_ready_notify_cb, object);
- }
-
- g_list_foreach (priv->messages_queue->head,
- (GFunc) g_object_unref, NULL);
-
- g_list_foreach (priv->pending_messages_queue->head,
- (GFunc) g_object_unref, NULL);
-
- if (G_OBJECT_CLASS (empathy_tp_chat_parent_class)->dispose)
- G_OBJECT_CLASS (empathy_tp_chat_parent_class)->dispose (object);
-}
-
-static void
-tp_chat_finalize (GObject *object)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (object);
- guint i;
-
- DEBUG ("Finalize: %p", object);
-
- if (priv->properties) {
- for (i = 0; i < priv->properties->len; i++) {
- TpChatProperty *property;
-
- property = g_ptr_array_index (priv->properties, i);
- g_free (property->name);
- if (property->value) {
- tp_g_value_slice_free (property->value);
- }
- g_slice_free (TpChatProperty, property);
- }
- g_ptr_array_free (priv->properties, TRUE);
- }
-
-
- g_free (priv->id);
- g_queue_free (priv->messages_queue);
- g_queue_free (priv->pending_messages_queue);
-
- G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object);
-}
-
-static GObject *
-tp_chat_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *chat;
- EmpathyTpChatPriv *priv;
- gboolean channel_ready;
-
- chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);
-
- priv = GET_PRIV (chat);
- priv->account = empathy_channel_get_account (priv->channel);
- priv->factory = empathy_contact_factory_dup_singleton ();
- priv->user = empathy_contact_factory_get_user (priv->factory, priv->account);
-
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (tp_chat_invalidated_cb),
- chat);
-
- g_object_get (priv->channel, "channel-ready", &channel_ready, NULL);
- if (channel_ready) {
- tp_chat_channel_ready_cb (EMPATHY_TP_CHAT (chat));
- } else {
- g_signal_connect_swapped (priv->channel, "notify::channel-ready",
- G_CALLBACK (tp_chat_channel_ready_cb),
- chat);
- }
-
- return chat;
-}
-
-static void
-tp_chat_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CHANNEL:
- g_value_set_object (value, priv->channel);
- break;
- case PROP_REMOTE_CONTACT:
- g_value_set_object (value, priv->remote_contact);
- break;
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_chat_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CHANNEL:
- priv->channel = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = tp_chat_dispose;
- object_class->finalize = tp_chat_finalize;
- object_class->constructor = tp_chat_constructor;
- object_class->get_property = tp_chat_get_property;
- object_class->set_property = tp_chat_set_property;
-
- g_object_class_install_property (object_class,
- PROP_CHANNEL,
- g_param_spec_object ("channel",
- "telepathy channel",
- "The text channel for the chat",
- TP_TYPE_CHANNEL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_REMOTE_CONTACT,
- g_param_spec_object ("remote-contact",
- "The remote contact",
- "The remote contact if there is no group iface on the channel",
- EMPATHY_TYPE_CONTACT,
- G_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_READY,
- g_param_spec_boolean ("ready",
- "Is the object ready",
- "This object can't be used until this becomes true",
- FALSE,
- G_PARAM_READABLE));
-
- /* Signals */
- signals[MESSAGE_RECEIVED] =
- g_signal_new ("message-received",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_MESSAGE);
-
- signals[SEND_ERROR] =
- g_signal_new ("send-error",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE,
- 2, EMPATHY_TYPE_MESSAGE, G_TYPE_UINT);
-
- signals[CHAT_STATE_CHANGED] =
- g_signal_new ("chat-state-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE,
- 2, EMPATHY_TYPE_CONTACT, G_TYPE_UINT);
-
- signals[PROPERTY_CHANGED] =
- g_signal_new ("property-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_VALUE);
-
- signals[DESTROY] =
- g_signal_new ("destroy",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpChatPriv));
-}
-
-static void
-empathy_tp_chat_init (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chat,
- EMPATHY_TYPE_TP_CHAT, EmpathyTpChatPriv);
-
- chat->priv = priv;
- priv->contact_monitor = NULL;
- priv->messages_queue = g_queue_new ();
- priv->pending_messages_queue = g_queue_new ();
-}
-
-static void
-tp_chat_iface_init (EmpathyContactListIface *iface)
-{
- iface->add = tp_chat_add;
- iface->remove = tp_chat_remove;
- iface->get_members = tp_chat_get_members;
- iface->get_monitor = tp_chat_get_monitor;
-}
-
-EmpathyTpChat *
-empathy_tp_chat_new (TpChannel *channel)
-{
- return g_object_new (EMPATHY_TYPE_TP_CHAT,
- "channel", channel,
- NULL);
-}
-
-void
-empathy_tp_chat_close (EmpathyTpChat *chat) {
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- /* If there are still messages left, it'll come back..
- We loose the ordering of sent messages though */
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_chat_invalidated_cb, chat);
-
- tp_cli_channel_call_close (priv->channel, -1, tp_chat_async_cb,
- "closing channel", NULL, NULL);
-
- g_object_unref (priv->channel);
- priv->channel = NULL;
-
- g_signal_emit (chat, signals[DESTROY], 0);
-}
-
-const gchar *
-empathy_tp_chat_get_id (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
- g_return_val_if_fail (priv->ready, NULL);
-
- return priv->id;
-}
-
-EmpathyContact *
-empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
-
- return priv->remote_contact;
-}
-
-McAccount *
-empathy_tp_chat_get_account (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE);
-
- return priv->account;
-}
-
-TpChannel *
-empathy_tp_chat_get_channel (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
-
- return priv->channel;
-}
-
-gboolean
-empathy_tp_chat_is_ready (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE);
-
- return priv->ready;
-}
-
-guint
-empathy_tp_chat_get_members_count (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), 0);
-
- return priv->members_count;
-}
-
-void
-empathy_tp_chat_send (EmpathyTpChat *chat,
- EmpathyMessage *message)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- const gchar *message_body;
- TpChannelTextMessageType message_type;
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
- g_return_if_fail (EMPATHY_IS_MESSAGE (message));
- g_return_if_fail (priv->ready);
-
- message_body = empathy_message_get_body (message);
- message_type = empathy_message_get_tptype (message);
-
- DEBUG ("Sending message: %s", message_body);
- tp_cli_channel_type_text_call_send (priv->channel, -1,
- message_type,
- message_body,
- tp_chat_send_cb,
- g_object_ref (message),
- (GDestroyNotify) g_object_unref,
- G_OBJECT (chat));
-}
-
-void
-empathy_tp_chat_set_state (EmpathyTpChat *chat,
- TpChannelChatState state)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
- g_return_if_fail (priv->ready);
-
- DEBUG ("Set state: %d", state);
- tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
- state,
- tp_chat_async_cb,
- "setting chat state",
- NULL,
- G_OBJECT (chat));
-}
-
-
-const GList *
-empathy_tp_chat_get_pending_messages (EmpathyTpChat *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- return priv->pending_messages_queue->head;
-}
-
-static void
-acknowledge_messages (EmpathyTpChat *chat, GArray *ids) {
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- tp_cli_channel_type_text_call_acknowledge_pending_messages (
- priv->channel, -1, ids, tp_chat_async_cb,
- "acknowledging received message", NULL, G_OBJECT (chat));
-}
-
-void
-empathy_tp_chat_acknowledge_message (EmpathyTpChat *chat,
- EmpathyMessage *message) {
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- GArray *message_ids;
- GList *m;
- guint id;
-
- if (empathy_message_get_sender (message) == priv->user)
- goto out;
-
- message_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
-
- id = empathy_message_get_id (message);
- g_array_append_val (message_ids, id);
- acknowledge_messages (chat, message_ids);
- g_array_free (message_ids, TRUE);
-
-out:
- m = g_queue_find (priv->pending_messages_queue, message);
- g_assert (m != NULL);
- g_queue_delete_link (priv->pending_messages_queue, m);
- g_object_unref (message);
-}
-
-void
-empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat,
- const GList *messages) {
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- /* Copy messages as the messges list (probably is) our own */
- GList *msgs = g_list_copy ((GList *) messages);
- GList *l;
- guint length;
- GArray *message_ids;
-
- length = g_list_length ((GList *)messages);
-
- if (length == 0)
- return;
-
- message_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), length);
-
- for (l = msgs; l != NULL; l = g_list_next (l)) {
- GList *m;
-
- EmpathyMessage *message = EMPATHY_MESSAGE (l->data);
-
- m = g_queue_find (priv->pending_messages_queue, message);
- g_assert (m != NULL);
- g_queue_delete_link (priv->pending_messages_queue, m);
-
- if (empathy_message_get_sender (message) != priv->user) {
- guint id = empathy_message_get_id (message);
- g_array_append_val (message_ids, id);
- }
- }
-
- if (message_ids->len > 0)
- acknowledge_messages (chat, message_ids);
-
- g_array_free (message_ids, TRUE);
- g_list_free (msgs);
-}
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
deleted file mode 100644
index 353052923..000000000
--- a/libempathy/empathy-tp-chat.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_CHAT_H__
-#define __EMPATHY_TP_CHAT_H__
-
-#include <glib.h>
-
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/enums.h>
-
-#include "empathy-message.h"
-#include "empathy-contact.h"
-
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_CHAT (empathy_tp_chat_get_type ())
-#define EMPATHY_TP_CHAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_CHAT, EmpathyTpChat))
-#define EMPATHY_TP_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_CHAT, EmpathyTpChatClass))
-#define EMPATHY_IS_TP_CHAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_CHAT))
-#define EMPATHY_IS_TP_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_CHAT))
-#define EMPATHY_TP_CHAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_CHAT, EmpathyTpChatClass))
-
-typedef struct _EmpathyTpChat EmpathyTpChat;
-typedef struct _EmpathyTpChatClass EmpathyTpChatClass;
-
-struct _EmpathyTpChat {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpChatClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tp_chat_get_type (void) G_GNUC_CONST;
-EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel);
-void empathy_tp_chat_close (EmpathyTpChat *chat);
-const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat);
-EmpathyContact*empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat);
-McAccount * empathy_tp_chat_get_account (EmpathyTpChat *chat);
-TpChannel * empathy_tp_chat_get_channel (EmpathyTpChat *chat);
-gboolean empathy_tp_chat_is_ready (EmpathyTpChat *chat);
-guint empathy_tp_chat_get_members_count (EmpathyTpChat *chat);
-void empathy_tp_chat_send (EmpathyTpChat *chat,
- EmpathyMessage *message);
-void empathy_tp_chat_set_state (EmpathyTpChat *chat,
- TpChannelChatState state);
-void empathy_tp_chat_set_property (EmpathyTpChat *chat,
- const gchar *name,
- const GValue *value);
-
-/* Returns a read-only list of pending messages (should be a copy maybe ?) */
-const GList * empathy_tp_chat_get_pending_messages (EmpathyTpChat *chat);
-void empathy_tp_chat_acknowledge_message (EmpathyTpChat *chat,
- EmpathyMessage *message);
-void empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat,
- const GList *messages);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_CHAT_H__ */
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
deleted file mode 100644
index d83ba12a8..000000000
--- a/libempathy/empathy-tp-contact-factory.c
+++ /dev/null
@@ -1,1540 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/gtypes.h>
-#include <libmissioncontrol/mission-control.h>
-
-#include <extensions/extensions.h>
-
-#include "empathy-tp-contact-factory.h"
-#include "empathy-utils.h"
-#include "empathy-account-manager.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CONTACT
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpContactFactory)
-typedef struct {
- EmpathyAccountManager *account_manager;
- McAccount *account;
- TpConnection *connection;
- gboolean ready;
-
- GList *contacts;
- EmpathyContact *user;
-
- gchar **avatar_mime_types;
- guint avatar_min_width;
- guint avatar_min_height;
- guint avatar_max_width;
- guint avatar_max_height;
- guint avatar_max_size;
- gboolean can_request_ft;
-} EmpathyTpContactFactoryPriv;
-
-G_DEFINE_TYPE (EmpathyTpContactFactory, empathy_tp_contact_factory, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
- PROP_ACCOUNT,
- PROP_READY,
-
- PROP_MIME_TYPES,
- PROP_MIN_WIDTH,
- PROP_MIN_HEIGHT,
- PROP_MAX_WIDTH,
- PROP_MAX_HEIGHT,
- PROP_MAX_SIZE
-};
-
-static EmpathyContact *
-tp_contact_factory_find_by_handle (EmpathyTpContactFactory *tp_factory,
- guint handle)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- GList *l;
-
- for (l = priv->contacts; l; l = l->next) {
- if (empathy_contact_get_handle (l->data) == handle) {
- return l->data;
- }
- }
-
- return NULL;
-}
-
-static EmpathyContact *
-tp_contact_factory_find_by_id (EmpathyTpContactFactory *tp_factory,
- const gchar *id)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- GList *l;
-
- for (l = priv->contacts; l; l = l->next) {
- if (!tp_strdiff (empathy_contact_get_id (l->data), id)) {
- return l->data;
- }
- }
-
- return NULL;
-}
-
-static void
-tp_contact_factory_weak_notify (gpointer data,
- GObject *where_the_object_was)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (data);
-
- DEBUG ("Remove finalized contact %p", where_the_object_was);
-
- priv->contacts = g_list_remove (priv->contacts, where_the_object_was);
-}
-
-static void
-tp_contact_factory_presences_table_foreach (const gchar *state_str,
- GHashTable *presences_table,
- EmpathyContact *contact)
-{
- const GValue *message;
- const gchar *message_str = NULL;
-
- empathy_contact_set_presence (contact,
- empathy_presence_from_str (state_str));
-
- message = g_hash_table_lookup (presences_table, "message");
- if (message) {
- message_str = g_value_get_string (message);
- }
-
- if (!EMP_STR_EMPTY (message_str)) {
- empathy_contact_set_presence_message (contact, message_str);
- } else {
- empathy_contact_set_presence_message (contact, NULL);
- }
-}
-
-static void
-tp_contact_factory_parse_presence_foreach (guint handle,
- GValueArray *presence_struct,
- EmpathyTpContactFactory *tp_factory)
-{
- GHashTable *presences_table;
- EmpathyContact *contact;
-
- contact = tp_contact_factory_find_by_handle (tp_factory, handle);
- if (!contact) {
- return;
- }
-
- presences_table = g_value_get_boxed (g_value_array_get_nth (presence_struct, 1));
-
- g_hash_table_foreach (presences_table,
- (GHFunc) tp_contact_factory_presences_table_foreach,
- contact);
-
- DEBUG ("Changing presence for contact %s (%d) to '%s' (%d)",
- empathy_contact_get_id (contact),
- handle,
- empathy_contact_get_presence_message (contact),
- empathy_contact_get_presence (contact));
-}
-
-static void
-tp_contact_factory_get_presence_cb (TpConnection *connection,
- GHashTable *handle_table,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Error getting presence: %s", error->message);
- if (error->domain == TP_DBUS_ERRORS &&
- error->code == TP_DBUS_ERROR_NO_INTERFACE) {
- guint *handles = user_data;
-
- /* We have no presence iface, set default presence
- * to available */
- while (*handles != 0) {
- EmpathyContact *contact;
-
- contact = tp_contact_factory_find_by_handle (
- (EmpathyTpContactFactory*) tp_factory,
- *handles);
- if (contact) {
- empathy_contact_set_presence (contact,
- MC_PRESENCE_AVAILABLE);
- }
-
- handles++;
- }
- }
-
- return;
- }
-
- g_hash_table_foreach (handle_table,
- (GHFunc) tp_contact_factory_parse_presence_foreach,
- EMPATHY_TP_CONTACT_FACTORY (tp_factory));
-}
-
-static void
-tp_contact_factory_presence_update_cb (TpConnection *connection,
- GHashTable *handle_table,
- gpointer user_data,
- GObject *tp_factory)
-{
- g_hash_table_foreach (handle_table,
- (GHFunc) tp_contact_factory_parse_presence_foreach,
- EMPATHY_TP_CONTACT_FACTORY (tp_factory));
-}
-
-static void
-tp_contact_factory_set_aliases_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Error setting alias: %s", error->message);
- }
-}
-
-static void
-tp_contact_factory_request_aliases_cb (TpConnection *connection,
- const gchar **contact_names,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- guint *handles = user_data;
- guint i = 0;
- const gchar **name;
-
- if (error) {
- DEBUG ("Error requesting aliases: %s", error->message);
-
- /* If we failed to get alias set it to NULL, like that if
- * someone is waiting for the name to be ready it won't wait
- * infinitely */
- while (*handles != 0) {
- EmpathyContact *contact;
-
- contact = tp_contact_factory_find_by_handle (
- (EmpathyTpContactFactory*) tp_factory,
- *handles);
- if (contact) {
- empathy_contact_set_name (contact, NULL);
- }
-
- handles++;
- }
- return;
- }
-
- for (name = contact_names; *name; name++) {
- EmpathyContact *contact;
-
- contact = tp_contact_factory_find_by_handle (EMPATHY_TP_CONTACT_FACTORY (tp_factory),
- handles[i]);
- if (!contact) {
- continue;
- }
-
- DEBUG ("Renaming contact %s (%d) to %s (request cb)",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- *name);
-
- empathy_contact_set_name (contact, *name);
-
- i++;
- }
-}
-
-static void
-tp_contact_factory_aliases_changed_cb (TpConnection *connection,
- const GPtrArray *renamed_handlers,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object);
- guint i;
-
- for (i = 0; renamed_handlers->len > i; i++) {
- guint handle;
- const gchar *alias;
- GValueArray *renamed_struct;
- EmpathyContact *contact;
-
- renamed_struct = g_ptr_array_index (renamed_handlers, i);
- handle = g_value_get_uint (g_value_array_get_nth (renamed_struct, 0));
- alias = g_value_get_string (g_value_array_get_nth (renamed_struct, 1));
- contact = tp_contact_factory_find_by_handle (tp_factory, handle);
-
- if (!contact) {
- /* We don't know this contact, skip */
- continue;
- }
-
- DEBUG ("Renaming contact %s (%d) to %s (changed cb)",
- empathy_contact_get_id (contact),
- handle, alias);
-
- empathy_contact_set_name (contact, alias);
- }
-}
-
-static void
-tp_contact_factory_set_avatar_cb (TpConnection *connection,
- const gchar *token,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Error setting avatar: %s", error->message);
- }
-}
-
-static void
-tp_contact_factory_clear_avatar_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Error clearing avatar: %s", error->message);
- }
-}
-
-static void
-tp_contact_factory_avatar_retrieved_cb (TpConnection *connection,
- guint handle,
- const gchar *token,
- const GArray *avatar_data,
- const gchar *mime_type,
- gpointer user_data,
- GObject *tp_factory)
-{
- EmpathyContact *contact;
-
- contact = tp_contact_factory_find_by_handle (EMPATHY_TP_CONTACT_FACTORY (tp_factory),
- handle);
- if (!contact) {
- return;
- }
-
- DEBUG ("Avatar retrieved for contact %s (%d)",
- empathy_contact_get_id (contact),
- handle);
-
- empathy_contact_load_avatar_data (contact,
- avatar_data->data,
- avatar_data->len,
- mime_type,
- token);
-}
-
-static void
-tp_contact_factory_request_avatars_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Error requesting avatars: %s", error->message);
- }
-}
-
-static gboolean
-tp_contact_factory_avatar_maybe_update (EmpathyTpContactFactory *tp_factory,
- guint handle,
- const gchar *token)
-{
- EmpathyContact *contact;
- EmpathyAvatar *avatar;
-
- contact = tp_contact_factory_find_by_handle (tp_factory, handle);
- if (!contact) {
- return TRUE;
- }
-
- /* Check if we have an avatar */
- if (EMP_STR_EMPTY (token)) {
- empathy_contact_set_avatar (contact, NULL);
- return TRUE;
- }
-
- /* Check if the avatar changed */
- avatar = empathy_contact_get_avatar (contact);
- if (avatar && !tp_strdiff (avatar->token, token)) {
- return TRUE;
- }
-
- /* The avatar changed, search the new one in the cache */
- if (empathy_contact_load_avatar_cache (contact, token)) {
- /* Got from cache, use it */
- return TRUE;
- }
-
- /* Avatar is not up-to-date, we have to request it. */
- return FALSE;
-}
-
-typedef struct {
- EmpathyTpContactFactory *tp_factory;
- GArray *handles;
-} TokensData;
-
-static void
-tp_contact_factory_avatar_tokens_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- TokensData *data = user_data;
- const gchar *token = value;
- guint handle = GPOINTER_TO_UINT (key);
-
- if (!tp_contact_factory_avatar_maybe_update (data->tp_factory,
- handle, token)) {
- g_array_append_val (data->handles, handle);
- }
-}
-
-static void
-tp_contact_factory_get_known_avatar_tokens_cb (TpConnection *connection,
- GHashTable *tokens,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- TokensData data;
-
- if (error) {
- DEBUG ("Error getting known avatars tokens: %s", error->message);
- return;
- }
-
- data.tp_factory = EMPATHY_TP_CONTACT_FACTORY (tp_factory);
- data.handles = g_array_new (FALSE, FALSE, sizeof (guint));
- g_hash_table_foreach (tokens,
- tp_contact_factory_avatar_tokens_foreach,
- &data);
-
- DEBUG ("Got %d tokens, need to request %d avatars",
- g_hash_table_size (tokens), data.handles->len);
-
- /* Request needed avatars */
- if (data.handles->len > 0) {
- tp_cli_connection_interface_avatars_call_request_avatars (connection,
- -1,
- data.handles,
- tp_contact_factory_request_avatars_cb,
- NULL, NULL,
- tp_factory);
- }
-
- g_array_free (data.handles, TRUE);
-}
-
-static void
-tp_contact_factory_avatar_updated_cb (TpConnection *connection,
- guint handle,
- const gchar *new_token,
- gpointer user_data,
- GObject *tp_factory)
-{
- GArray *handles;
-
- if (tp_contact_factory_avatar_maybe_update (EMPATHY_TP_CONTACT_FACTORY (tp_factory),
- handle, new_token)) {
- /* Avatar was cached, nothing to do */
- return;
- }
-
- DEBUG ("Need to request avatar for token %s", new_token);
-
- handles = g_array_new (FALSE, FALSE, sizeof (guint));
- g_array_append_val (handles, handle);
-
- tp_cli_connection_interface_avatars_call_request_avatars (connection,
- -1,
- handles,
- tp_contact_factory_request_avatars_cb,
- NULL, NULL,
- tp_factory);
- g_array_free (handles, TRUE);
-}
-
-static void
-tp_contact_factory_update_capabilities (EmpathyTpContactFactory *tp_factory,
- guint handle,
- const gchar *channel_type,
- guint generic,
- guint specific)
-{
- EmpathyContact *contact;
- EmpathyCapabilities capabilities;
-
- contact = tp_contact_factory_find_by_handle (tp_factory, handle);
- if (!contact) {
- return;
- }
-
- capabilities = empathy_contact_get_capabilities (contact);
- capabilities &= ~EMPATHY_CAPABILITIES_UNKNOWN;
-
- if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA) == 0) {
- capabilities &= ~EMPATHY_CAPABILITIES_AUDIO;
- capabilities &= ~EMPATHY_CAPABILITIES_VIDEO;
- if (specific & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO) {
- capabilities |= EMPATHY_CAPABILITIES_AUDIO;
- }
- if (specific & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO) {
- capabilities |= EMPATHY_CAPABILITIES_VIDEO;
- }
- }
-
- DEBUG ("Changing capabilities for contact %s (%d) to %d",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- capabilities);
-
- empathy_contact_set_capabilities (contact, capabilities);
-}
-
-static void
-tp_contact_factory_get_capabilities_cb (TpConnection *connection,
- const GPtrArray *capabilities,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object);
- guint i;
-
- if (error) {
- DEBUG ("Error getting capabilities: %s", error->message);
- /* FIXME Should set the capabilities of the contacts for which this request
- * originated to NONE */
- return;
- }
-
- for (i = 0; i < capabilities->len; i++) {
- GValueArray *values;
- guint handle;
- const gchar *channel_type;
- guint generic;
- guint specific;
-
- values = g_ptr_array_index (capabilities, i);
- handle = g_value_get_uint (g_value_array_get_nth (values, 0));
- channel_type = g_value_get_string (g_value_array_get_nth (values, 1));
- generic = g_value_get_uint (g_value_array_get_nth (values, 2));
- specific = g_value_get_uint (g_value_array_get_nth (values, 3));
-
- tp_contact_factory_update_capabilities (tp_factory,
- handle,
- channel_type,
- generic,
- specific);
- }
-}
-
-static void
-tp_contact_factory_capabilities_changed_cb (TpConnection *connection,
- const GPtrArray *capabilities,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object);
- guint i;
-
- for (i = 0; i < capabilities->len; i++) {
- GValueArray *values;
- guint handle;
- const gchar *channel_type;
- guint generic;
- guint specific;
-
- values = g_ptr_array_index (capabilities, i);
- handle = g_value_get_uint (g_value_array_get_nth (values, 0));
- channel_type = g_value_get_string (g_value_array_get_nth (values, 1));
- generic = g_value_get_uint (g_value_array_get_nth (values, 3));
- specific = g_value_get_uint (g_value_array_get_nth (values, 5));
-
- tp_contact_factory_update_capabilities (tp_factory,
- handle,
- channel_type,
- generic,
- specific);
- }
-}
-
-static void
-tp_contact_factory_request_everything (EmpathyTpContactFactory *tp_factory,
- const GArray *handles)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- guint *dup_handles;
-
- g_return_if_fail (priv->ready);
-
- dup_handles = g_malloc0 ((handles->len + 1) * sizeof (guint));
- g_memmove (dup_handles, handles->data, handles->len * sizeof (guint));
- tp_cli_connection_interface_presence_call_get_presence (priv->connection,
- -1,
- handles,
- tp_contact_factory_get_presence_cb,
- dup_handles, g_free,
- G_OBJECT (tp_factory));
-
- /* FIXME: Sometimes the dbus call timesout because CM takes
- * too much time to request all aliases from the server,
- * that's why we increase the timeout here. See fd.o bug #14795 */
- dup_handles = g_malloc0 ((handles->len + 1) * sizeof (guint));
- g_memmove (dup_handles, handles->data, handles->len * sizeof (guint));
- tp_cli_connection_interface_aliasing_call_request_aliases (priv->connection,
- 5*60*1000,
- handles,
- tp_contact_factory_request_aliases_cb,
- dup_handles, g_free,
- G_OBJECT (tp_factory));
-
- tp_cli_connection_interface_avatars_call_get_known_avatar_tokens (priv->connection,
- -1,
- handles,
- tp_contact_factory_get_known_avatar_tokens_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
-
- tp_cli_connection_interface_capabilities_call_get_capabilities (priv->connection,
- -1,
- handles,
- tp_contact_factory_get_capabilities_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
-}
-
-static void
-tp_contact_factory_list_free (gpointer data)
-{
- GList *l = data;
-
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
-}
-
-static void
-tp_contact_factory_request_handles_cb (TpConnection *connection,
- const GArray *handles,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- GList *contacts = user_data;
- GList *l;
- guint i = 0;
-
- if (error) {
- DEBUG ("Failed to request handles: %s", error->message);
- return;
- }
-
- for (l = contacts; l; l = l->next) {
- guint handle;
-
- handle = g_array_index (handles, guint, i);
- empathy_contact_set_handle (l->data, handle);
-
- i++;
- }
-
- tp_contact_factory_request_everything (EMPATHY_TP_CONTACT_FACTORY (tp_factory),
- handles);
-}
-
-static void
-tp_contact_factory_inspect_handles_cb (TpConnection *connection,
- const gchar **ids,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- const gchar **id;
- GList *contacts = user_data;
- GList *l;
-
- if (error) {
- DEBUG ("Failed to inspect handles: %s", error->message);
- return;
- }
-
- id = ids;
- for (l = contacts; l; l = l->next) {
- empathy_contact_set_id (l->data, *id);
- id++;
- }
-}
-
-static void
-tp_contact_factory_disconnect_contact_foreach (gpointer data,
- gpointer user_data)
-{
- EmpathyContact *contact = data;
-
- empathy_contact_set_presence (contact, MC_PRESENCE_UNSET);
- empathy_contact_set_handle (contact, 0);
-}
-
-static void
-tp_contact_factory_connection_invalidated_cb (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- DEBUG ("Connection invalidated");
-
- g_object_unref (priv->connection);
- priv->connection = NULL;
- priv->ready = FALSE;
- g_object_notify (G_OBJECT (tp_factory), "ready");
-
-
- g_list_foreach (priv->contacts,
- tp_contact_factory_disconnect_contact_foreach,
- tp_factory);
-}
-
-static void
-tp_contact_factory_ready (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- GList *l;
- GArray *handle_needed;
- GArray *id_needed;
- GList *handle_needed_contacts = NULL;
- GList *id_needed_contacts = NULL;
-
- DEBUG ("Connection ready");
-
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (tp_factory), "ready");
-
- /* Connect signals */
- tp_cli_connection_interface_aliasing_connect_to_aliases_changed (priv->connection,
- tp_contact_factory_aliases_changed_cb,
- NULL, NULL,
- G_OBJECT (tp_factory),
- NULL);
- tp_cli_connection_interface_avatars_connect_to_avatar_updated (priv->connection,
- tp_contact_factory_avatar_updated_cb,
- NULL, NULL,
- G_OBJECT (tp_factory),
- NULL);
- tp_cli_connection_interface_avatars_connect_to_avatar_retrieved (priv->connection,
- tp_contact_factory_avatar_retrieved_cb,
- NULL, NULL,
- G_OBJECT (tp_factory),
- NULL);
- tp_cli_connection_interface_presence_connect_to_presence_update (priv->connection,
- tp_contact_factory_presence_update_cb,
- NULL, NULL,
- G_OBJECT (tp_factory),
- NULL);
- tp_cli_connection_interface_capabilities_connect_to_capabilities_changed (priv->connection,
- tp_contact_factory_capabilities_changed_cb,
- NULL, NULL,
- G_OBJECT (tp_factory),
- NULL);
-
- /* Request needed info for all existing contacts */
- handle_needed = g_array_new (TRUE, FALSE, sizeof (gchar*));
- id_needed = g_array_new (FALSE, FALSE, sizeof (guint));
- for (l = priv->contacts; l; l = l->next) {
- EmpathyContact *contact;
- guint handle;
- const gchar *id;
-
- contact = l->data;
- handle = empathy_contact_get_handle (contact);
- id = empathy_contact_get_id (contact);
- if (handle == 0) {
- g_assert (!EMP_STR_EMPTY (id));
- g_array_append_val (handle_needed, id);
- handle_needed_contacts = g_list_prepend (handle_needed_contacts,
- g_object_ref (contact));
- }
- if (EMP_STR_EMPTY (id)) {
- g_array_append_val (id_needed, handle);
- id_needed_contacts = g_list_prepend (id_needed_contacts,
- g_object_ref (contact));
- }
- }
- handle_needed_contacts = g_list_reverse (handle_needed_contacts);
- id_needed_contacts = g_list_reverse (id_needed_contacts);
-
- tp_cli_connection_call_request_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_CONTACT,
- (const gchar**) handle_needed->data,
- tp_contact_factory_request_handles_cb,
- handle_needed_contacts, tp_contact_factory_list_free,
- G_OBJECT (tp_factory));
-
- tp_cli_connection_call_inspect_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_CONTACT,
- id_needed,
- tp_contact_factory_inspect_handles_cb,
- id_needed_contacts, tp_contact_factory_list_free,
- G_OBJECT (tp_factory));
-
- tp_contact_factory_request_everything ((EmpathyTpContactFactory*) tp_factory,
- id_needed);
-
- g_array_free (handle_needed, TRUE);
- g_array_free (id_needed, TRUE);
-}
-
-static void
-get_requestable_channel_classes_cb (TpProxy *connection,
- const GValue *value,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpContactFactory *self = EMPATHY_TP_CONTACT_FACTORY (weak_object);
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (self);
- GPtrArray *classes;
- guint i;
-
- if (error != NULL) {
- DEBUG ("Error: %s", error->message);
- tp_contact_factory_ready (self);
- return;
- }
-
- classes = g_value_get_boxed (value);
- for (i = 0; i < classes->len; i++) {
- GValue class = {0,};
- GValue *chan_type, *handle_type;
- GHashTable *fixed_prop;
- GList *l;
-
- g_value_init (&class, TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS);
- g_value_set_static_boxed (&class, g_ptr_array_index (classes, i));
-
- dbus_g_type_struct_get (&class,
- 0, &fixed_prop,
- G_MAXUINT);
-
- chan_type = g_hash_table_lookup (fixed_prop,
- TP_IFACE_CHANNEL ".ChannelType");
- if (chan_type == NULL ||
- tp_strdiff (g_value_get_string (chan_type),
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER)) {
- continue;
- }
-
- handle_type = g_hash_table_lookup (fixed_prop,
- TP_IFACE_CHANNEL ".TargetHandleType");
- if (handle_type == NULL ||
- g_value_get_uint (handle_type) != TP_HANDLE_TYPE_CONTACT) {
- continue;
- }
-
- /* We can request file transfer channel to contacts. */
- priv->can_request_ft = TRUE;
-
- /* Update the capabilities of all contacts */
- for (l = priv->contacts; l != NULL; l = g_list_next (l)) {
- EmpathyContact *contact = l->data;
- EmpathyCapabilities caps;
-
- caps = empathy_contact_get_capabilities (contact);
- empathy_contact_set_capabilities (contact, caps |
- EMPATHY_CAPABILITIES_FT);
- }
- break;
- }
-
- tp_contact_factory_ready (self);
-}
-
-static void
-tp_contact_factory_got_avatar_requirements_cb (TpConnection *proxy,
- const gchar **mime_types,
- guint min_width,
- guint min_height,
- guint max_width,
- guint max_height,
- guint max_size,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- if (error) {
- DEBUG ("Failed to get avatar requirements: %s", error->message);
- /* We'll just leave avatar_mime_types as NULL; the
- * avatar-setting code can use this as a signal that you can't
- * set avatars.
- */
- } else {
- priv->avatar_mime_types = g_strdupv ((gchar **) mime_types);
- priv->avatar_min_width = min_width;
- priv->avatar_min_height = min_height;
- priv->avatar_max_width = max_width;
- priv->avatar_max_height = max_height;
- priv->avatar_max_size = max_size;
- }
-
- /* Can we request file transfer channels? */
- tp_cli_dbus_properties_call_get (priv->connection, -1,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
- "RequestableChannelClasses",
- get_requestable_channel_classes_cb, NULL, NULL,
- G_OBJECT (tp_factory));
-}
-
-static void
-tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
- guint handle,
- const GError *error,
- gpointer user_data,
- GObject *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- if (error) {
- DEBUG ("Failed to get self handles: %s", error->message);
- return;
- }
-
- empathy_contact_set_handle (priv->user, handle);
-
- /* Get avatar requirements for this connection */
- tp_cli_connection_interface_avatars_call_get_avatar_requirements (
- priv->connection,
- -1,
- tp_contact_factory_got_avatar_requirements_cb,
- NULL, NULL,
- tp_factory);
-}
-
-static void
-tp_contact_factory_connection_ready_cb (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- /* Get our own handle */
- tp_cli_connection_call_get_self_handle (priv->connection,
- -1,
- tp_contact_factory_got_self_handle_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
-}
-
-static void
-tp_contact_factory_status_updated (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- gboolean connection_ready;
- MissionControl *mc;
-
- if (priv->connection) {
- /* We already have our connection object */
- return;
- }
-
- mc = empathy_mission_control_dup_singleton ();
- priv->connection = mission_control_get_tpconnection (mc, priv->account, NULL);
- if (!priv->connection) {
- return;
- }
-
- /* We got a new connection, wait for it to be ready */
- g_signal_connect_swapped (priv->connection, "invalidated",
- G_CALLBACK (tp_contact_factory_connection_invalidated_cb),
- tp_factory);
-
- g_object_get (priv->connection, "connection-ready", &connection_ready, NULL);
- if (connection_ready) {
- tp_contact_factory_connection_ready_cb (tp_factory);
- } else {
- g_signal_connect_swapped (priv->connection, "notify::connection-ready",
- G_CALLBACK (tp_contact_factory_connection_ready_cb),
- tp_factory);
- }
-
- g_object_unref (mc);
-}
-
-static void
-tp_contact_factory_account_connection_cb (EmpathyAccountManager *account_manager,
- McAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
- EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- if (account && empathy_account_equal (account, priv->account)) {
- tp_contact_factory_status_updated (tp_factory);
- }
-}
-
-static void
-tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
- EmpathyContact *contact)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- g_object_weak_ref (G_OBJECT (contact),
- tp_contact_factory_weak_notify,
- tp_factory);
- priv->contacts = g_list_prepend (priv->contacts, contact);
-
- DEBUG ("Contact added: %s (%d)",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact));
-}
-
-static void
-tp_contact_factory_hold_handles_cb (TpConnection *connection,
- const GError *error,
- gpointer userdata,
- GObject *tp_factory)
-{
- if (error) {
- DEBUG ("Failed to hold handles: %s", error->message);
- }
-}
-
-EmpathyContact *
-empathy_tp_contact_factory_get_user (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory), NULL);
-
- return g_object_ref (priv->user);
-}
-
-static void
-contact_created (EmpathyTpContactFactory *self,
- EmpathyContact *contact)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (self);
-
- if (priv->can_request_ft)
- {
- /* Set the FT capability */
- /* FIXME: We should use the futur ContactCapabilities interface */
- EmpathyCapabilities caps;
-
- caps = empathy_contact_get_capabilities (contact);
- caps |= EMPATHY_CAPABILITIES_FT;
-
- empathy_contact_set_capabilities (contact, caps);
- }
-
- tp_contact_factory_add_contact (self, contact);
-}
-
-EmpathyContact *
-empathy_tp_contact_factory_get_from_id (EmpathyTpContactFactory *tp_factory,
- const gchar *id)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- EmpathyContact *contact;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory), NULL);
- g_return_val_if_fail (id != NULL, NULL);
-
- /* Check if the contact already exists */
- contact = tp_contact_factory_find_by_id (tp_factory, id);
- if (contact) {
- return g_object_ref (contact);
- }
-
- /* Create new contact */
- contact = g_object_new (EMPATHY_TYPE_CONTACT,
- "account", priv->account,
- "id", id,
- NULL);
- contact_created (tp_factory, contact);
-
- if (priv->ready) {
- const gchar *contact_ids[] = {id, NULL};
- GList *contacts;
-
- contacts = g_list_prepend (NULL, g_object_ref (contact));
- tp_cli_connection_call_request_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_CONTACT,
- contact_ids,
- tp_contact_factory_request_handles_cb,
- contacts, tp_contact_factory_list_free,
- G_OBJECT (tp_factory));
- }
-
- return contact;
-}
-
-EmpathyContact *
-empathy_tp_contact_factory_get_from_handle (EmpathyTpContactFactory *tp_factory,
- guint handle)
-{
- EmpathyContact *contact;
- GArray *handles;
- GList *contacts;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory), NULL);
-
- handles = g_array_new (FALSE, FALSE, sizeof (guint));
- g_array_append_val (handles, handle);
-
- contacts = empathy_tp_contact_factory_get_from_handles (tp_factory, handles);
- g_array_free (handles, TRUE);
-
- contact = contacts ? contacts->data : NULL;
- g_list_free (contacts);
-
- return contact;
-}
-
-GList *
-empathy_tp_contact_factory_get_from_handles (EmpathyTpContactFactory *tp_factory,
- const GArray *handles)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- GList *contacts = NULL;
- GArray *new_handles;
- GList *new_contacts = NULL;
- guint i;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory), NULL);
- g_return_val_if_fail (handles != NULL, NULL);
-
- /* Search all contacts we already have */
- new_handles = g_array_new (FALSE, FALSE, sizeof (guint));
- for (i = 0; i < handles->len; i++) {
- EmpathyContact *contact;
- guint handle;
-
- handle = g_array_index (handles, guint, i);
- if (handle == 0) {
- continue;
- }
-
- contact = tp_contact_factory_find_by_handle (tp_factory, handle);
- if (contact) {
- contacts = g_list_prepend (contacts, g_object_ref (contact));
- } else {
- g_array_append_val (new_handles, handle);
- }
- }
-
- if (new_handles->len == 0) {
- g_array_free (new_handles, TRUE);
- return contacts;
- }
-
- /* Create new contacts */
- for (i = 0; i < new_handles->len; i++) {
- EmpathyContact *contact;
- guint handle;
-
- handle = g_array_index (new_handles, guint, i);
-
- contact = g_object_new (EMPATHY_TYPE_CONTACT,
- "account", priv->account,
- "handle", handle,
- NULL);
- contact_created (tp_factory, contact);
- contacts = g_list_prepend (contacts, contact);
- new_contacts = g_list_prepend (new_contacts, g_object_ref (contact));
- }
- new_contacts = g_list_reverse (new_contacts);
-
- if (priv->ready) {
- /* Get the IDs of all new handles */
- tp_cli_connection_call_inspect_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_CONTACT,
- new_handles,
- tp_contact_factory_inspect_handles_cb,
- new_contacts, tp_contact_factory_list_free,
- G_OBJECT (tp_factory));
-
- /* Hold all new handles. */
- /* FIXME: Should be unholded when removed from the factory */
- tp_cli_connection_call_hold_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_CONTACT,
- new_handles,
- tp_contact_factory_hold_handles_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
-
- tp_contact_factory_request_everything (tp_factory, new_handles);
- }
-
- g_array_free (new_handles, TRUE);
-
- return contacts;
-}
-
-void
-empathy_tp_contact_factory_set_alias (EmpathyTpContactFactory *tp_factory,
- EmpathyContact *contact,
- const gchar *alias)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- GHashTable *new_alias;
- guint handle;
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- g_return_if_fail (priv->ready);
- g_return_if_fail (empathy_account_equal (empathy_contact_get_account (contact),
- priv->account));
-
- handle = empathy_contact_get_handle (contact);
-
- DEBUG ("Setting alias for contact %s (%d) to %s",
- empathy_contact_get_id (contact),
- handle, alias);
-
- new_alias = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- g_free);
-
- g_hash_table_insert (new_alias,
- GUINT_TO_POINTER (handle),
- g_strdup (alias));
-
- tp_cli_connection_interface_aliasing_call_set_aliases (priv->connection,
- -1,
- new_alias,
- tp_contact_factory_set_aliases_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
-
- g_hash_table_destroy (new_alias);
-}
-
-void
-empathy_tp_contact_factory_set_avatar (EmpathyTpContactFactory *tp_factory,
- const gchar *data,
- gsize size,
- const gchar *mime_type)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory));
- g_return_if_fail (priv->ready);
-
- if (data && size > 0 && size < G_MAXUINT) {
- GArray avatar;
-
- avatar.data = (gchar*) data;
- avatar.len = size;
-
- DEBUG ("Setting avatar on account %s",
- mc_account_get_unique_name (priv->account));
-
- tp_cli_connection_interface_avatars_call_set_avatar (priv->connection,
- -1,
- &avatar,
- mime_type,
- tp_contact_factory_set_avatar_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
- } else {
- DEBUG ("Clearing avatar on account %s",
- mc_account_get_unique_name (priv->account));
-
- tp_cli_connection_interface_avatars_call_clear_avatar (priv->connection,
- -1,
- tp_contact_factory_clear_avatar_cb,
- NULL, NULL,
- G_OBJECT (tp_factory));
- }
-}
-
-gboolean
-empathy_tp_contact_factory_is_ready (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory), FALSE);
-
- return priv->ready;
-}
-
-static void
-tp_contact_factory_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- g_value_set_object (value, priv->account);
- break;
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- case PROP_MIME_TYPES:
- g_value_set_boxed (value, priv->avatar_mime_types);
- break;
- case PROP_MIN_WIDTH:
- g_value_set_uint (value, priv->avatar_min_width);
- break;
- case PROP_MIN_HEIGHT:
- g_value_set_uint (value, priv->avatar_min_height);
- break;
- case PROP_MAX_WIDTH:
- g_value_set_uint (value, priv->avatar_max_width);
- break;
- case PROP_MAX_HEIGHT:
- g_value_set_uint (value, priv->avatar_max_height);
- break;
- case PROP_MAX_SIZE:
- g_value_set_uint (value, priv->avatar_max_size);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_contact_factory_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- priv->account = g_object_ref (g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_contact_factory_finalize (GObject *object)
-{
- EmpathyTpContactFactoryPriv *priv = GET_PRIV (object);
- GList *l;
-
- DEBUG ("Finalized: %p (%s)", object,
- mc_account_get_normalized_name (priv->account));
-
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- tp_contact_factory_account_connection_cb,
- object);
-
- for (l = priv->contacts; l; l = l->next) {
- g_object_weak_unref (G_OBJECT (l->data),
- tp_contact_factory_weak_notify,
- object);
- }
-
- g_list_free (priv->contacts);
- g_object_unref (priv->account_manager);
- g_object_unref (priv->account);
- g_object_unref (priv->user);
-
- if (priv->connection) {
- g_signal_handlers_disconnect_by_func (priv->connection,
- tp_contact_factory_connection_invalidated_cb,
- object);
- g_object_unref (priv->connection);
- }
-
- g_strfreev (priv->avatar_mime_types);
-
- G_OBJECT_CLASS (empathy_tp_contact_factory_parent_class)->finalize (object);
-}
-
-static GObject *
-tp_contact_factory_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *tp_factory;
- EmpathyTpContactFactoryPriv *priv;
-
- tp_factory = G_OBJECT_CLASS (empathy_tp_contact_factory_parent_class)->constructor (type, n_props, props);
- priv = GET_PRIV (tp_factory);
-
- priv->ready = FALSE;
- priv->user = empathy_contact_new (priv->account);
- empathy_contact_set_is_user (priv->user, TRUE);
- tp_contact_factory_add_contact ((EmpathyTpContactFactory*) tp_factory, priv->user);
- tp_contact_factory_status_updated (EMPATHY_TP_CONTACT_FACTORY (tp_factory));
-
- return tp_factory;
-}
-
-static void
-empathy_tp_contact_factory_class_init (EmpathyTpContactFactoryClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_contact_factory_finalize;
- object_class->constructor = tp_contact_factory_constructor;
- object_class->get_property = tp_contact_factory_get_property;
- object_class->set_property = tp_contact_factory_set_property;
-
- g_object_class_install_property (object_class,
- PROP_ACCOUNT,
- g_param_spec_object ("account",
- "Factory's Account",
- "The account associated with the factory",
- MC_TYPE_ACCOUNT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_READY,
- g_param_spec_boolean ("ready",
- "Whether the factory is ready",
- "TRUE once the factory is ready to be used",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MIME_TYPES,
- g_param_spec_boxed ("avatar-mime-types",
- "Supported MIME types for avatars",
- "Types of images that may be set as "
- "avatars on this connection. Only valid "
- "once 'ready' becomes TRUE.",
- G_TYPE_STRV,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MIN_WIDTH,
- g_param_spec_uint ("avatar-min-width",
- "Minimum width for avatars",
- "Minimum width of avatar that may be set. "
- "Only valid once 'ready' becomes TRUE.",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MIN_HEIGHT,
- g_param_spec_uint ("avatar-min-height",
- "Minimum height for avatars",
- "Minimum height of avatar that may be set. "
- "Only valid once 'ready' becomes TRUE.",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MAX_WIDTH,
- g_param_spec_uint ("avatar-max-width",
- "Maximum width for avatars",
- "Maximum width of avatar that may be set "
- "or 0 if there is no maximum. "
- "Only valid once 'ready' becomes TRUE.",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MAX_HEIGHT,
- g_param_spec_uint ("avatar-max-height",
- "Maximum height for avatars",
- "Maximum height of avatar that may be set "
- "or 0 if there is no maximum. "
- "Only valid once 'ready' becomes TRUE.",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class,
- PROP_MAX_SIZE,
- g_param_spec_uint ("avatar-max-size",
- "Maximum size for avatars in bytes",
- "Maximum file size of avatar that may be "
- "set or 0 if there is no maximum. "
- "Only valid once 'ready' becomes TRUE.",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpContactFactoryPriv));
-}
-
-static void
-empathy_tp_contact_factory_init (EmpathyTpContactFactory *tp_factory)
-{
- EmpathyTpContactFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (tp_factory,
- EMPATHY_TYPE_TP_CONTACT_FACTORY, EmpathyTpContactFactoryPriv);
-
- tp_factory->priv = priv;
- priv->account_manager = empathy_account_manager_dup_singleton ();
-
- g_signal_connect (priv->account_manager, "account-connection-changed",
- G_CALLBACK (tp_contact_factory_account_connection_cb),
- tp_factory);
-
- priv->can_request_ft = FALSE;
-}
-
-EmpathyTpContactFactory *
-empathy_tp_contact_factory_new (McAccount *account)
-{
- return g_object_new (EMPATHY_TYPE_TP_CONTACT_FACTORY,
- "account", account,
- NULL);
-}
-
diff --git a/libempathy/empathy-tp-contact-factory.h b/libempathy/empathy-tp-contact-factory.h
deleted file mode 100644
index 92e7c2980..000000000
--- a/libempathy/empathy-tp-contact-factory.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_CONTACT_FACTORY_H__
-#define __EMPATHY_TP_CONTACT_FACTORY_H__
-
-#include <glib.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include "empathy-contact.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_CONTACT_FACTORY (empathy_tp_contact_factory_get_type ())
-#define EMPATHY_TP_CONTACT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_CONTACT_FACTORY, EmpathyTpContactFactory))
-#define EMPATHY_TP_CONTACT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_CONTACT_FACTORY, EmpathyTpContactFactoryClass))
-#define EMPATHY_IS_TP_CONTACT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_CONTACT_FACTORY))
-#define EMPATHY_IS_TP_CONTACT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_CONTACT_FACTORY))
-#define EMPATHY_TP_CONTACT_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_CONTACT_FACTORY, EmpathyTpContactFactoryClass))
-
-typedef struct _EmpathyTpContactFactory EmpathyTpContactFactory;
-typedef struct _EmpathyTpContactFactoryClass EmpathyTpContactFactoryClass;
-
-struct _EmpathyTpContactFactory {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpContactFactoryClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tp_contact_factory_get_type (void) G_GNUC_CONST;
-EmpathyTpContactFactory *empathy_tp_contact_factory_new (McAccount *account);
-EmpathyContact * empathy_tp_contact_factory_get_user (EmpathyTpContactFactory *tp_factory);
-EmpathyContact * empathy_tp_contact_factory_get_from_id (EmpathyTpContactFactory *tp_factory,
- const gchar *id);
-EmpathyContact * empathy_tp_contact_factory_get_from_handle (EmpathyTpContactFactory *tp_factory,
- guint handle);
-GList * empathy_tp_contact_factory_get_from_handles (EmpathyTpContactFactory *tp_factory,
- const GArray *handles);
-void empathy_tp_contact_factory_set_alias (EmpathyTpContactFactory *tp_factory,
- EmpathyContact *contact,
- const gchar *alias);
-void empathy_tp_contact_factory_set_avatar (EmpathyTpContactFactory *tp_factory,
- const gchar *data,
- gsize size,
- const gchar *mime_type);
-gboolean empathy_tp_contact_factory_is_ready (EmpathyTpContactFactory *tp_factory);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_CONTACT_FACTORY_H__ */
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
deleted file mode 100644
index ef11587ad..000000000
--- a/libempathy/empathy-tp-contact-list.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/dbus.h>
-
-#include "empathy-tp-contact-list.h"
-#include "empathy-contact-list.h"
-#include "empathy-tp-group.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CONTACT
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpContactList)
-typedef struct {
- McAccount *account;
- TpConnection *connection;
- const gchar *protocol_group;
- gboolean ready;
-
- EmpathyTpGroup *publish;
- EmpathyTpGroup *subscribe;
- GList *members;
- GList *pendings;
-
- GList *groups;
- GHashTable *contacts_groups;
-} EmpathyTpContactListPriv;
-
-typedef enum {
- TP_CONTACT_LIST_TYPE_PUBLISH,
- TP_CONTACT_LIST_TYPE_SUBSCRIBE,
- TP_CONTACT_LIST_TYPE_UNKNOWN
-} TpContactListType;
-
-static void tp_contact_list_iface_init (EmpathyContactListIface *iface);
-
-enum {
- DESTROY,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_ACCOUNT,
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyTpContactList, empathy_tp_contact_list, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
- tp_contact_list_iface_init));
-
-static void
-tp_contact_list_group_destroy_cb (EmpathyTpGroup *group,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- DEBUG ("Group destroyed: %s", empathy_tp_group_get_name (group));
-
- priv->groups = g_list_remove (priv->groups, group);
- g_object_unref (group);
-}
-
-static void
-tp_contact_list_group_member_added_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- const gchar *group_name;
- GList **groups;
-
- if (!g_list_find (priv->members, contact)) {
- return;
- }
-
- groups = g_hash_table_lookup (priv->contacts_groups, contact);
- if (!groups) {
- groups = g_slice_new0 (GList*);
- g_hash_table_insert (priv->contacts_groups,
- g_object_ref (contact),
- groups);
- }
-
- group_name = empathy_tp_group_get_name (group);
- if (!g_list_find_custom (*groups, group_name, (GCompareFunc) strcmp)) {
- DEBUG ("Contact %s (%d) added to group %s",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- group_name);
- *groups = g_list_prepend (*groups, g_strdup (group_name));
- g_signal_emit_by_name (list, "groups-changed", contact,
- group_name,
- TRUE);
- }
-}
-
-static void
-tp_contact_list_group_member_removed_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- const gchar *group_name;
- GList **groups, *l;
-
- if (!g_list_find (priv->members, contact)) {
- return;
- }
-
- groups = g_hash_table_lookup (priv->contacts_groups, contact);
- if (!groups) {
- return;
- }
-
- group_name = empathy_tp_group_get_name (group);
- if ((l = g_list_find_custom (*groups, group_name, (GCompareFunc) strcmp))) {
- DEBUG ("Contact %s (%d) removed from group %s",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- group_name);
- *groups = g_list_delete_link (*groups, l);
- g_signal_emit_by_name (list, "groups-changed", contact,
- group_name,
- FALSE);
- }
-}
-
-static EmpathyTpGroup *
-tp_contact_list_find_group (EmpathyTpContactList *list,
- const gchar *group)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- GList *l;
-
- for (l = priv->groups; l; l = l->next) {
- if (!tp_strdiff (group, empathy_tp_group_get_name (l->data))) {
- return l->data;
- }
- }
- return NULL;
-}
-
-static TpContactListType
-tp_contact_list_get_type (EmpathyTpContactList *list,
- EmpathyTpGroup *group)
-{
- const gchar *name;
-
- name = empathy_tp_group_get_name (group);
- if (!tp_strdiff (name, "subscribe")) {
- return TP_CONTACT_LIST_TYPE_SUBSCRIBE;
- } else if (!tp_strdiff (name, "publish")) {
- return TP_CONTACT_LIST_TYPE_PUBLISH;
- }
-
- return TP_CONTACT_LIST_TYPE_UNKNOWN;
-}
-
-static void
-tp_contact_list_add_member (EmpathyTpContactList *list,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- GList *l;
-
- /* Add to the list and emit signal */
- priv->members = g_list_prepend (priv->members, g_object_ref (contact));
- g_signal_emit_by_name (list, "members-changed",
- contact, actor, reason, message,
- TRUE);
-
- /* This contact is now member, implicitly accept pending. */
- if (g_list_find (priv->pendings, contact)) {
- empathy_tp_group_add_member (priv->publish, contact, "");
- }
-
- /* Update groups of the contact */
- for (l = priv->groups; l; l = l->next) {
- if (empathy_tp_group_is_member (l->data, contact)) {
- tp_contact_list_group_member_added_cb (l->data, contact,
- NULL, 0, NULL,
- list);
- }
- }
-}
-
-static void
-tp_contact_list_added_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- TpContactListType list_type;
-
- list_type = tp_contact_list_get_type (list, group);
- DEBUG ("Contact %s (%d) added to list type %d",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- list_type);
-
- /* We now get the presence of that contact, add it to members */
- if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE &&
- !g_list_find (priv->members, contact)) {
- tp_contact_list_add_member (list, contact, actor, reason, message);
- }
-
- /* We now send our presence to that contact, remove it from pendings */
- if (list_type == TP_CONTACT_LIST_TYPE_PUBLISH &&
- g_list_find (priv->pendings, contact)) {
- g_signal_emit_by_name (list, "pendings-changed",
- contact, actor, reason, message,
- FALSE);
- priv->pendings = g_list_remove (priv->pendings, contact);
- g_object_unref (contact);
- }
-}
-
-static void
-tp_contact_list_removed_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- TpContactListType list_type;
-
- list_type = tp_contact_list_get_type (list, group);
- DEBUG ("Contact %s (%d) removed from list type %d",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- list_type);
-
- /* This contact refuses to send us his presence, remove from members. */
- if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE &&
- g_list_find (priv->members, contact)) {
- g_signal_emit_by_name (list, "members-changed",
- contact, actor, reason, message,
- FALSE);
- priv->members = g_list_remove (priv->members, contact);
- g_object_unref (contact);
- }
-
- /* We refuse to send our presence to that contact, remove from pendings */
- if (list_type == TP_CONTACT_LIST_TYPE_PUBLISH &&
- g_list_find (priv->pendings, contact)) {
- g_signal_emit_by_name (list, "pendings-changed",
- contact, actor, reason, message,
- FALSE);
- priv->pendings = g_list_remove (priv->pendings, contact);
- g_object_unref (contact);
- }
-}
-
-static void
-tp_contact_list_pending_cb (EmpathyTpGroup *group,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- TpContactListType list_type;
-
- list_type = tp_contact_list_get_type (list, group);
- DEBUG ("Contact %s (%d) pending in list type %d",
- empathy_contact_get_id (contact),
- empathy_contact_get_handle (contact),
- list_type);
-
- /* We want this contact in our contact list but we don't get its
- * presence yet. Add to members anyway. */
- if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE &&
- !g_list_find (priv->members, contact)) {
- tp_contact_list_add_member (list, contact, actor, reason, message);
- }
-
- /* This contact wants our presence, auto accept if he is member,
- * otherwise he is pending. */
- if (list_type == TP_CONTACT_LIST_TYPE_PUBLISH &&
- !g_list_find (priv->pendings, contact)) {
- if (g_list_find (priv->members, contact)) {
- empathy_tp_group_add_member (priv->publish, contact, "");
- } else {
- priv->pendings = g_list_prepend (priv->pendings,
- g_object_ref (contact));
- g_signal_emit_by_name (list, "pendings-changed",
- contact, actor, reason, message,
- TRUE);
- }
- }
-}
-
-static void
-tp_contact_list_invalidated_cb (TpConnection *connection,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- GList *l;
-
- DEBUG ("Connection invalidated");
-
- /* Remove all contacts */
- for (l = priv->members; l; l = l->next) {
- g_signal_emit_by_name (list, "members-changed", l->data,
- NULL, 0, NULL,
- FALSE);
- g_object_unref (l->data);
- }
- for (l = priv->pendings; l; l = l->next) {
- g_signal_emit_by_name (list, "pendings-changed", l->data,
- NULL, 0, NULL,
- FALSE);
- g_object_unref (l->data);
- }
- g_list_free (priv->members);
- g_list_free (priv->pendings);
- priv->members = NULL;
- priv->pendings = NULL;
-
- /* Tell the world to not use us anymore */
- g_signal_emit (list, signals[DESTROY], 0);
-}
-
-static void
-tp_contact_list_group_list_free (GList **groups)
-{
- g_list_foreach (*groups, (GFunc) g_free, NULL);
- g_list_free (*groups);
- g_slice_free (GList*, groups);
-}
-
-static void
-tp_contact_list_add_channel (EmpathyTpContactList *list,
- const gchar *object_path,
- const gchar *channel_type,
- TpHandleType handle_type,
- guint handle)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- TpChannel *channel;
- EmpathyTpGroup *group;
- const gchar *group_name;
- GList *contacts, *l;
-
- if (strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) != 0 ||
- handle_type != TP_HANDLE_TYPE_GROUP) {
- return;
- }
-
- channel = tp_channel_new (priv->connection,
- object_path, channel_type,
- handle_type, handle, NULL);
-
- group = empathy_tp_group_new (channel);
- empathy_run_until_ready (group);
- g_object_unref (channel);
-
- /* Check if already exists */
- group_name = empathy_tp_group_get_name (group);
- if (tp_contact_list_find_group (list, group_name)) {
- g_object_unref (group);
- return;
- }
-
- /* Add the group */
- DEBUG ("New server-side group: %s", group_name);
- priv->groups = g_list_prepend (priv->groups, group);
- g_signal_connect (group, "member-added",
- G_CALLBACK (tp_contact_list_group_member_added_cb),
- list);
- g_signal_connect (group, "member-removed",
- G_CALLBACK (tp_contact_list_group_member_removed_cb),
- list);
- g_signal_connect (group, "destroy",
- G_CALLBACK (tp_contact_list_group_destroy_cb),
- list);
-
- /* Get initial members */
- contacts = empathy_tp_group_get_members (group);
- for (l = contacts; l; l = l->next) {
- tp_contact_list_group_member_added_cb (group, l->data,
- NULL, 0, NULL,
- list);
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-}
-
-static void
-tp_contact_list_new_channel_cb (TpConnection *proxy,
- const gchar *object_path,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- gboolean suppress_handler,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- if (!suppress_handler && priv->ready) {
- tp_contact_list_add_channel (EMPATHY_TP_CONTACT_LIST (list),
- object_path, channel_type,
- handle_type, handle);
- }
-}
-
-static void
-tp_contact_list_list_channels_cb (TpConnection *connection,
- const GPtrArray *channels,
- const GError *error,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- guint i;
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- for (i = 0; i < channels->len; i++) {
- GValueArray *chan_struct;
- const gchar *object_path;
- const gchar *channel_type;
- TpHandleType handle_type;
- guint handle;
-
- chan_struct = g_ptr_array_index (channels, i);
- object_path = g_value_get_boxed (g_value_array_get_nth (chan_struct, 0));
- channel_type = g_value_get_string (g_value_array_get_nth (chan_struct, 1));
- handle_type = g_value_get_uint (g_value_array_get_nth (chan_struct, 2));
- handle = g_value_get_uint (g_value_array_get_nth (chan_struct, 3));
-
- tp_contact_list_add_channel (EMPATHY_TP_CONTACT_LIST (list),
- object_path, channel_type,
- handle_type, handle);
- }
-
- priv->ready = TRUE;
-}
-
-static void
-tp_contact_list_request_channel_cb (TpConnection *connection,
- const gchar *object_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpContactList *list = EMPATHY_TP_CONTACT_LIST (weak_object);
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- EmpathyTpGroup *group;
- TpChannel *channel;
- TpContactListType list_type;
- GList *contacts, *l;
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- channel = tp_channel_new (connection, object_path,
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_HANDLE_TYPE_LIST,
- GPOINTER_TO_UINT (user_data),
- NULL);
- group = empathy_tp_group_new (channel);
- empathy_run_until_ready (group);
-
- list_type = tp_contact_list_get_type (list, group);
- if (list_type == TP_CONTACT_LIST_TYPE_PUBLISH && !priv->publish) {
- DEBUG ("Got publish list");
- priv->publish = group;
-
- /* Publish is the list of contacts to who we send our
- * presence. Makes no sense to be in remote-pending */
- g_signal_connect (group, "local-pending",
- G_CALLBACK (tp_contact_list_pending_cb),
- list);
-
- contacts = empathy_tp_group_get_local_pendings (group);
- for (l = contacts; l; l = l->next) {
- EmpathyPendingInfo *info = l->data;
- tp_contact_list_pending_cb (group,
- info->member,
- info->actor,
- 0,
- info->message,
- list);
- empathy_pending_info_free (info);
- }
- g_list_free (contacts);
- }
- else if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE && !priv->subscribe) {
- DEBUG ("Got subscribe list");
- priv->subscribe = group;
-
- /* Subscribe is the list of contacts from who we
- * receive presence. Makes no sense to be in
- * local-pending */
- g_signal_connect (group, "remote-pending",
- G_CALLBACK (tp_contact_list_pending_cb),
- list);
-
- contacts = empathy_tp_group_get_remote_pendings (group);
- for (l = contacts; l; l = l->next) {
- tp_contact_list_pending_cb (group,
- l->data,
- NULL, 0,
- NULL, list);
- g_object_unref (l->data);
- }
- g_list_free (contacts);
- } else {
- DEBUG ("Type of contact list channel unknown or aleady "
- "have that list: %s",
- empathy_tp_group_get_name (group));
- g_object_unref (group);
- return;
- }
-
- /* For all list types when need to get members */
- g_signal_connect (group, "member-added",
- G_CALLBACK (tp_contact_list_added_cb),
- list);
- g_signal_connect (group, "member-removed",
- G_CALLBACK (tp_contact_list_removed_cb),
- list);
-
- contacts = empathy_tp_group_get_members (group);
- for (l = contacts; l; l = l->next) {
- tp_contact_list_added_cb (group,
- l->data,
- NULL, 0, NULL,
- list);
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-}
-
-static void
-tp_contact_list_request_handle_cb (TpConnection *connection,
- const GArray *handles,
- const GError *error,
- gpointer user_data,
- GObject *list)
-{
- guint handle;
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- handle = g_array_index (handles, guint, 0);
- tp_cli_connection_call_request_channel (connection, -1,
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_HANDLE_TYPE_LIST,
- handle,
- TRUE,
- tp_contact_list_request_channel_cb,
- GUINT_TO_POINTER (handle), NULL,
- list);
-}
-
-static void
-tp_contact_list_request_list (EmpathyTpContactList *list,
- const gchar *type)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- const gchar *names[] = {type, NULL};
-
- tp_cli_connection_call_request_handles (priv->connection,
- -1,
- TP_HANDLE_TYPE_LIST,
- names,
- tp_contact_list_request_handle_cb,
- NULL, NULL,
- G_OBJECT (list));
-}
-
-static void
-tp_contact_list_finalize (GObject *object)
-{
- EmpathyTpContactListPriv *priv;
- EmpathyTpContactList *list;
-
- list = EMPATHY_TP_CONTACT_LIST (object);
- priv = GET_PRIV (list);
-
- DEBUG ("finalize: %p", object);
-
- if (priv->subscribe) {
- g_object_unref (priv->subscribe);
- }
- if (priv->publish) {
- g_object_unref (priv->publish);
- }
- if (priv->account) {
- g_object_unref (priv->account);
- }
- if (priv->connection) {
- g_signal_handlers_disconnect_by_func (priv->connection,
- tp_contact_list_invalidated_cb,
- object);
- g_object_unref (priv->connection);
- }
-
- g_hash_table_destroy (priv->contacts_groups);
- g_list_foreach (priv->groups, (GFunc) g_object_unref, NULL);
- g_list_free (priv->groups);
- g_list_foreach (priv->members, (GFunc) g_object_unref, NULL);
- g_list_free (priv->members);
- g_list_foreach (priv->pendings, (GFunc) g_object_unref, NULL);
- g_list_free (priv->pendings);
-
- G_OBJECT_CLASS (empathy_tp_contact_list_parent_class)->finalize (object);
-}
-
-static void
-tp_contact_list_connection_ready (TpConnection *connection,
- const GError *error,
- gpointer list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- if (error) {
- tp_contact_list_invalidated_cb (connection,
- error->domain,
- error->code,
- error->message,
- EMPATHY_TP_CONTACT_LIST (list));
- return;
- }
-
- g_signal_connect (priv->connection, "invalidated",
- G_CALLBACK (tp_contact_list_invalidated_cb),
- list);
-
- tp_contact_list_request_list (list, "publish");
- tp_contact_list_request_list (list, "subscribe");
-
- tp_cli_connection_call_list_channels (priv->connection, -1,
- tp_contact_list_list_channels_cb,
- NULL, NULL,
- list);
-
- tp_cli_connection_connect_to_new_channel (priv->connection,
- tp_contact_list_new_channel_cb,
- NULL, NULL,
- list, NULL);
-}
-
-static void
-tp_contact_list_constructed (GObject *list)
-{
-
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- MissionControl *mc;
- guint status;
- McProfile *profile;
- const gchar *protocol_name;
-
- /* Get the connection. status==0 means CONNECTED */
- mc = empathy_mission_control_dup_singleton ();
- status = mission_control_get_connection_status (mc, priv->account, NULL);
- g_return_if_fail (status == 0);
- priv->connection = mission_control_get_tpconnection (mc, priv->account, NULL);
- g_return_if_fail (priv->connection != NULL);
- g_object_unref (mc);
-
- tp_connection_call_when_ready (priv->connection,
- tp_contact_list_connection_ready,
- list);
-
- /* Check for protocols that does not support contact groups. We can
- * put all contacts into a special group in that case.
- * FIXME: Default group should be an information in the profile */
- profile = mc_account_get_profile (priv->account);
- protocol_name = mc_profile_get_protocol_name (profile);
- if (strcmp (protocol_name, "local-xmpp") == 0) {
- priv->protocol_group = _("People nearby");
- }
- g_object_unref (profile);
-}
-
-static void
-tp_contact_list_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- g_value_set_object (value, priv->account);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_contact_list_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_ACCOUNT:
- priv->account = g_object_ref (g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-empathy_tp_contact_list_class_init (EmpathyTpContactListClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_contact_list_finalize;
- object_class->constructed = tp_contact_list_constructed;
- object_class->get_property = tp_contact_list_get_property;
- object_class->set_property = tp_contact_list_set_property;
-
- g_object_class_install_property (object_class,
- PROP_ACCOUNT,
- g_param_spec_object ("account",
- "The Account",
- "The account associated with the contact list",
- MC_TYPE_ACCOUNT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- signals[DESTROY] =
- g_signal_new ("destroy",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpContactListPriv));
-}
-
-static void
-empathy_tp_contact_list_init (EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (list,
- EMPATHY_TYPE_TP_CONTACT_LIST, EmpathyTpContactListPriv);
-
- list->priv = priv;
- priv->contacts_groups = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- (GDestroyNotify) g_object_unref,
- (GDestroyNotify) tp_contact_list_group_list_free);
-}
-
-EmpathyTpContactList *
-empathy_tp_contact_list_new (McAccount *account)
-{
- return g_object_new (EMPATHY_TYPE_TP_CONTACT_LIST,
- "account", account,
- NULL);
-}
-
-McAccount *
-empathy_tp_contact_list_get_account (EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), NULL);
-
- priv = GET_PRIV (list);
-
- return priv->account;
-}
-
-static void
-tp_contact_list_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- if (priv->subscribe) {
- empathy_tp_group_add_member (priv->subscribe, contact, message);
- }
-
- if (priv->publish && g_list_find (priv->pendings, contact)) {
- empathy_tp_group_add_member (priv->publish, contact, message);
- }
-}
-
-static void
-tp_contact_list_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- if (priv->subscribe) {
- empathy_tp_group_remove_member (priv->subscribe, contact, message);
- }
- if (priv->publish) {
- empathy_tp_group_remove_member (priv->publish, contact, message);
- }
-}
-
-static GList *
-tp_contact_list_get_members (EmpathyContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), NULL);
-
- g_list_foreach (priv->members, (GFunc) g_object_ref, NULL);
- return g_list_copy (priv->members);
-}
-
-static GList *
-tp_contact_list_get_pendings (EmpathyContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), NULL);
-
- g_list_foreach (priv->pendings, (GFunc) g_object_ref, NULL);
- return g_list_copy (priv->pendings);
-}
-
-static GList *
-tp_contact_list_get_all_groups (EmpathyContactList *list)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- GList *groups = NULL, *l;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), NULL);
-
- if (priv->protocol_group) {
- groups = g_list_prepend (groups, g_strdup (priv->protocol_group));
- }
-
- for (l = priv->groups; l; l = l->next) {
- const gchar *name;
-
- name = empathy_tp_group_get_name (l->data);
- groups = g_list_prepend (groups, g_strdup (name));
- }
-
- return groups;
-}
-
-static GList *
-tp_contact_list_get_groups (EmpathyContactList *list,
- EmpathyContact *contact)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- GList **groups;
- GList *ret = NULL, *l;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), NULL);
-
- if (priv->protocol_group) {
- ret = g_list_prepend (ret, g_strdup (priv->protocol_group));
- }
-
- groups = g_hash_table_lookup (priv->contacts_groups, contact);
- if (!groups) {
- return ret;
- }
-
- for (l = *groups; l; l = l->next) {
- ret = g_list_prepend (ret, g_strdup (l->data));
- }
-
-
- return ret;
-}
-
-static EmpathyTpGroup *
-tp_contact_list_get_group (EmpathyTpContactList *list,
- const gchar *group)
-{
- EmpathyTpContactListPriv *priv = GET_PRIV (list);
- EmpathyTpGroup *tp_group;
- gchar *object_path;
- guint handle;
- GArray *handles;
- const char *names[2] = {group, NULL};
- GError *error = NULL;
-
- tp_group = tp_contact_list_find_group (list, group);
- if (tp_group) {
- return tp_group;
- }
-
- DEBUG ("creating new group: %s", group);
-
- if (!tp_cli_connection_run_request_handles (priv->connection, -1,
- TP_HANDLE_TYPE_GROUP,
- names,
- &handles,
- &error, NULL)) {
- DEBUG ("Failed to RequestHandles: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- return NULL;
- }
- handle = g_array_index (handles, guint, 0);
- g_array_free (handles, TRUE);
-
- if (!tp_cli_connection_run_request_channel (priv->connection, -1,
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_HANDLE_TYPE_GROUP,
- handle,
- TRUE,
- &object_path,
- &error, NULL)) {
- DEBUG ("Failed to RequestChannel: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- return NULL;
- }
-
- tp_contact_list_add_channel (EMPATHY_TP_CONTACT_LIST (list),
- object_path,
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_HANDLE_TYPE_GROUP, handle);
-
- g_free (object_path);
-
- return tp_contact_list_find_group (list, group);
-}
-
-static void
-tp_contact_list_add_to_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group)
-{
- EmpathyTpGroup *tp_group;
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- tp_group = tp_contact_list_get_group (EMPATHY_TP_CONTACT_LIST (list),
- group);
-
- if (tp_group) {
- empathy_tp_group_add_member (tp_group, contact, "");
- }
-}
-
-static void
-tp_contact_list_remove_from_group (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *group)
-{
- EmpathyTpGroup *tp_group;
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- tp_group = tp_contact_list_find_group (EMPATHY_TP_CONTACT_LIST (list),
- group);
-
- if (tp_group) {
- empathy_tp_group_remove_member (tp_group, contact, "");
- }
-}
-
-static void
-tp_contact_list_rename_group (EmpathyContactList *list,
- const gchar *old_group,
- const gchar *new_group)
-{
- EmpathyTpGroup *tp_group;
- GList *members;
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- tp_group = tp_contact_list_find_group (EMPATHY_TP_CONTACT_LIST (list),
- old_group);
- if (!tp_group) {
- return;
- }
-
- DEBUG ("rename group %s to %s", old_group, new_group);
-
- /* Remove all members from the old group */
- members = empathy_tp_group_get_members (tp_group);
- empathy_tp_group_remove_members (tp_group, members, "");
- empathy_tp_group_close (tp_group);
-
- /* Add all members to the new group */
- tp_group = tp_contact_list_get_group (EMPATHY_TP_CONTACT_LIST (list),
- new_group);
- empathy_tp_group_add_members (tp_group, members, "");
-
- g_list_foreach (members, (GFunc) g_object_unref, NULL);
- g_list_free (members);
-}
-
-static void
-tp_contact_list_remove_group (EmpathyContactList *list,
- const gchar *group)
-{
- EmpathyTpGroup *tp_group;
- GList *members;
-
- g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
-
- tp_group = tp_contact_list_find_group (EMPATHY_TP_CONTACT_LIST (list),
- group);
-
- if (!tp_group) {
- return;
- }
-
- DEBUG ("remove group %s", group);
-
- /* Remove all members of the group */
- members = empathy_tp_group_get_members (tp_group);
- empathy_tp_group_remove_members (tp_group, members, "");
- empathy_tp_group_close (tp_group);
-
- g_list_foreach (members, (GFunc) g_object_unref, NULL);
- g_list_free (members);
-}
-
-static void
-tp_contact_list_iface_init (EmpathyContactListIface *iface)
-{
- iface->add = tp_contact_list_add;
- iface->remove = tp_contact_list_remove;
- iface->get_members = tp_contact_list_get_members;
- iface->get_pendings = tp_contact_list_get_pendings;
- iface->get_all_groups = tp_contact_list_get_all_groups;
- iface->get_groups = tp_contact_list_get_groups;
- iface->add_to_group = tp_contact_list_add_to_group;
- iface->remove_from_group = tp_contact_list_remove_from_group;
- iface->rename_group = tp_contact_list_rename_group;
- iface->remove_group = tp_contact_list_remove_group;
-}
-
-gboolean
-empathy_tp_contact_list_can_add (EmpathyTpContactList *list)
-{
- EmpathyTpContactListPriv *priv;
- TpChannelGroupFlags flags;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE);
-
- priv = GET_PRIV (list);
-
- if (priv->subscribe == NULL)
- return FALSE;
-
- flags = empathy_tp_group_get_flags (priv->subscribe);
- return (flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) != 0;
-}
diff --git a/libempathy/empathy-tp-contact-list.h b/libempathy/empathy-tp-contact-list.h
deleted file mode 100644
index e8edcface..000000000
--- a/libempathy/empathy-tp-contact-list.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_CONTACT_LIST_H__
-#define __EMPATHY_TP_CONTACT_LIST_H__
-
-#include <glib.h>
-#include <libmissioncontrol/mc-account.h>
-
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_CONTACT_LIST (empathy_tp_contact_list_get_type ())
-#define EMPATHY_TP_CONTACT_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyTpContactList))
-#define EMPATHY_TP_CONTACT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CONTACT_LIST, EmpathyTpContactListClass))
-#define EMPATHY_IS_TP_CONTACT_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST))
-#define EMPATHY_IS_TP_CONTACT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_LIST))
-#define EMPATHY_TP_CONTACT_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyTpContactListClass))
-
-typedef struct _EmpathyTpContactList EmpathyTpContactList;
-typedef struct _EmpathyTpContactListClass EmpathyTpContactListClass;
-
-struct _EmpathyTpContactList {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpContactListClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tp_contact_list_get_type (void) G_GNUC_CONST;
-EmpathyTpContactList * empathy_tp_contact_list_new (McAccount *account);
-McAccount * empathy_tp_contact_list_get_account (EmpathyTpContactList *list);
-gboolean empathy_tp_contact_list_can_add (EmpathyTpContactList *list);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_CONTACT_LIST_H__ */
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
deleted file mode 100644
index 2d43cbba6..000000000
--- a/libempathy/empathy-tp-file.c
+++ /dev/null
@@ -1,1024 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Marco Barisione <marco@barisione.org>
- * Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <gio/gio.h>
-#include <gio/gunixinputstream.h>
-#include <gio/gunixoutputstream.h>
-
-#include <telepathy-glib/proxy-subclass.h>
-
-#include "empathy-tp-file.h"
-#include "empathy-contact-factory.h"
-#include "empathy-marshal.h"
-#include "empathy-time.h"
-#include "empathy-utils.h"
-
-#include "extensions/extensions.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_FT
-#include "empathy-debug.h"
-
-/**
- * SECTION:empathy-tp-file
- * @short_description: File channel
- * @see_also: #EmpathyTpFile, #EmpathyContact, empathy_dispatcher_send_file()
- * @include: libempthy/empathy-tp-file.h
- *
- * The #EmpathyTpFile object represents a Telepathy file channel.
- */
-
-/**
- * EMPATHY_TP_FILE_UNKNOWN_SIZE:
- *
- * Value used for the "size" or "estimated-size" properties when the size of
- * the transferred file is unknown.
- */
-
-/* Functions to copy the content of a GInputStream to a GOutputStream */
-
-#define N_BUFFERS 2
-#define BUFFER_SIZE 4096
-
-typedef struct {
- GInputStream *in;
- GOutputStream *out;
- GCancellable *cancellable;
- char *buff[N_BUFFERS]; /* the temporary buffers */
- gsize count[N_BUFFERS]; /* how many bytes are used in the buffers */
- gboolean is_full[N_BUFFERS]; /* whether the buffers contain data */
- gint curr_read; /* index of the buffer used for reading */
- gint curr_write; /* index of the buffer used for writing */
- gboolean is_reading; /* we are reading */
- gboolean is_writing; /* we are writing */
- guint n_closed; /* number of streams that have been closed */
- gint ref_count;
-} CopyData;
-
-static void schedule_next (CopyData *copy);
-
-static void
-copy_data_unref (CopyData *copy)
-{
- if (--copy->ref_count == 0)
- {
- gint i;
-
- /* Free the data only if both the input and output streams have
- * been closed. */
- copy->n_closed++;
- if (copy->n_closed < 2)
- return;
-
- if (copy->in != NULL)
- g_object_unref (copy->in);
-
- if (copy->out != NULL)
- g_object_unref (copy->out);
-
- for (i = 0; i < N_BUFFERS; i++)
- g_free (copy->buff[i]);
-
- g_object_unref (copy->cancellable);
- g_free (copy);
- }
-}
-
-static void
-io_error (CopyData *copy,
- GError *error)
-{
- g_cancellable_cancel (copy->cancellable);
-
- if (error == NULL)
- g_warning ("I/O error");
- else if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)
- ; /* Ignore cancellations */
- else
- g_warning ("I/O error: %d: %s\n", error->code, error->message);
-
- if (copy->in != NULL)
- g_input_stream_close (copy->in, NULL, NULL);
-
- if (copy->out != NULL)
- g_output_stream_close (copy->out, NULL, NULL);
-
- copy_data_unref (copy);
-}
-
-static void
-close_done (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CopyData *copy = user_data;
-
- g_object_unref (source_object);
- copy_data_unref (copy);
-}
-
-static void
-write_done_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CopyData *copy = user_data;
- gssize count_write;
- GError *error = NULL;
-
- count_write = g_output_stream_write_finish (copy->out, res, &error);
-
- if (count_write <= 0)
- {
- io_error (copy, error);
- g_error_free (error);
- return;
- }
-
- copy->is_full[copy->curr_write] = FALSE;
- copy->curr_write = (copy->curr_write + 1) % N_BUFFERS;
- copy->is_writing = FALSE;
-
- schedule_next (copy);
-}
-
-static void
-read_done_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CopyData *copy = user_data;
- gssize count_read;
- GError *error = NULL;
-
- count_read = g_input_stream_read_finish (copy->in, res, &error);
-
- if (count_read == 0)
- {
- g_input_stream_close_async (copy->in, 0, copy->cancellable,
- close_done, copy);
- copy->in = NULL;
- }
- else if (count_read < 0)
- {
- io_error (copy, error);
- g_error_free (error);
- return;
- }
-
- copy->count[copy->curr_read] = count_read;
- copy->is_full[copy->curr_read] = TRUE;
- copy->curr_read = (copy->curr_read + 1) % N_BUFFERS;
- copy->is_reading = FALSE;
-
- schedule_next (copy);
-}
-
-static void
-schedule_next (CopyData *copy)
-{
- if (copy->in != NULL &&
- !copy->is_reading &&
- !copy->is_full[copy->curr_read])
- {
- /* We are not reading and the current buffer is empty, so
- * start an async read. */
- copy->is_reading = TRUE;
- g_input_stream_read_async (copy->in,
- copy->buff[copy->curr_read],
- BUFFER_SIZE, 0, copy->cancellable,
- read_done_cb, copy);
- }
-
- if (!copy->is_writing &&
- copy->is_full[copy->curr_write])
- {
- if (copy->count[copy->curr_write] == 0)
- {
- /* The last read on the buffer read 0 bytes, this
- * means that we got an EOF, so we can close
- * the output channel. */
- g_output_stream_close_async (copy->out, 0,
- copy->cancellable,
- close_done, copy);
- copy->out = NULL;
- }
- else
- {
- /* We are not writing and the current buffer contains
- * data, so start an async write. */
- copy->is_writing = TRUE;
- g_output_stream_write_async (copy->out,
- copy->buff[copy->curr_write],
- copy->count[copy->curr_write],
- 0, copy->cancellable,
- write_done_cb, copy);
- }
- }
-}
-
-static void
-copy_stream (GInputStream *in,
- GOutputStream *out,
- GCancellable *cancellable)
-{
- CopyData *copy;
- gint i;
-
- g_return_if_fail (in != NULL);
- g_return_if_fail (out != NULL);
-
- copy = g_new0 (CopyData, 1);
- copy->in = g_object_ref (in);
- copy->out = g_object_ref (out);
- copy->ref_count = 1;
-
- if (cancellable != NULL)
- copy->cancellable = g_object_ref (cancellable);
- else
- copy->cancellable = g_cancellable_new ();
-
- for (i = 0; i < N_BUFFERS; i++)
- copy->buff[i] = g_malloc (BUFFER_SIZE);
-
- schedule_next (copy);
-}
-
-/* EmpathyTpFile object */
-
-struct _EmpathyTpFilePriv {
- EmpathyContactFactory *factory;
- MissionControl *mc;
- TpChannel *channel;
-
- EmpathyContact *contact;
- GInputStream *in_stream;
- GOutputStream *out_stream;
-
- /* org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties */
- TpFileTransferState state;
- gchar *content_type;
- gchar *filename;
- guint64 size;
- TpFileHashType content_hash_type;
- gchar *content_hash;
- gchar *description;
- guint64 transferred_bytes;
-
- gboolean incoming;
- TpFileTransferStateChangeReason state_change_reason;
- time_t start_time;
- gchar *unix_socket_path;
- GCancellable *cancellable;
-};
-
-enum {
- PROP_0,
- PROP_CHANNEL,
- PROP_STATE,
- PROP_INCOMING,
- PROP_FILENAME,
- PROP_SIZE,
- PROP_CONTENT_TYPE,
- PROP_TRANSFERRED_BYTES,
- PROP_CONTENT_HASH_TYPE,
- PROP_CONTENT_HASH,
-};
-
-G_DEFINE_TYPE (EmpathyTpFile, empathy_tp_file, G_TYPE_OBJECT);
-
-static void
-empathy_tp_file_init (EmpathyTpFile *tp_file)
-{
- EmpathyTpFilePriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE ((tp_file),
- EMPATHY_TYPE_TP_FILE, EmpathyTpFilePriv);
-
- tp_file->priv = priv;
-}
-
-static void
-tp_file_invalidated_cb (TpProxy *proxy,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpFile *tp_file)
-{
- DEBUG ("Channel invalidated: %s", message);
-
- if (tp_file->priv->state != TP_FILE_TRANSFER_STATE_COMPLETED &&
- tp_file->priv->state != TP_FILE_TRANSFER_STATE_CANCELLED)
- {
- /* The channel is not in a finished state, an error occured */
- tp_file->priv->state = TP_FILE_TRANSFER_STATE_CANCELLED;
- tp_file->priv->state_change_reason =
- TP_FILE_TRANSFER_STATE_CHANGE_REASON_LOCAL_ERROR;
- g_object_notify (G_OBJECT (tp_file), "state");
- }
-}
-
-static void
-tp_file_finalize (GObject *object)
-{
- EmpathyTpFile *tp_file = EMPATHY_TP_FILE (object);
-
- if (tp_file->priv->channel)
- {
- g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
- tp_file_invalidated_cb, object);
- g_object_unref (tp_file->priv->channel);
- tp_file->priv->channel = NULL;
- }
-
- if (tp_file->priv->factory)
- {
- g_object_unref (tp_file->priv->factory);
- }
- if (tp_file->priv->mc)
- {
- g_object_unref (tp_file->priv->mc);
- }
-
- g_free (tp_file->priv->filename);
- g_free (tp_file->priv->unix_socket_path);
- g_free (tp_file->priv->description);
- g_free (tp_file->priv->content_hash);
- g_free (tp_file->priv->content_type);
-
- if (tp_file->priv->in_stream)
- g_object_unref (tp_file->priv->in_stream);
-
- if (tp_file->priv->out_stream)
- g_object_unref (tp_file->priv->out_stream);
-
- if (tp_file->priv->contact)
- g_object_unref (tp_file->priv->contact);
-
- if (tp_file->priv->cancellable)
- g_object_unref (tp_file->priv->cancellable);
-
- G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object);
-}
-
-static void
-tp_file_start_transfer (EmpathyTpFile *tp_file)
-{
- gint fd;
- size_t path_len;
- struct sockaddr_un addr;
-
- fd = socket (PF_UNIX, SOCK_STREAM, 0);
- if (fd < 0)
- {
- DEBUG ("Failed to create socket, closing channel");
- empathy_tp_file_cancel (tp_file);
- return;
- }
-
- memset (&addr, 0, sizeof (addr));
- addr.sun_family = AF_UNIX;
- path_len = strlen (tp_file->priv->unix_socket_path);
- strncpy (addr.sun_path, tp_file->priv->unix_socket_path, path_len);
-
- if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
- {
- DEBUG ("Failed to connect socket, closing channel");
- empathy_tp_file_cancel (tp_file);
- close (fd);
- return;
- }
-
- DEBUG ("Start the transfer");
-
- tp_file->priv->start_time = empathy_time_get_current ();
- tp_file->priv->cancellable = g_cancellable_new ();
- if (tp_file->priv->incoming)
- {
- GInputStream *socket_stream;
-
- socket_stream = g_unix_input_stream_new (fd, TRUE);
- copy_stream (socket_stream, tp_file->priv->out_stream,
- tp_file->priv->cancellable);
- g_object_unref (socket_stream);
- }
- else
- {
- GOutputStream *socket_stream;
-
- socket_stream = g_unix_output_stream_new (fd, TRUE);
- copy_stream (tp_file->priv->in_stream, socket_stream,
- tp_file->priv->cancellable);
- g_object_unref (socket_stream);
- }
-}
-
-static void
-tp_file_state_changed_cb (TpChannel *channel,
- guint state,
- guint reason,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpFile *tp_file = EMPATHY_TP_FILE (weak_object);
-
- if (state == tp_file->priv->state)
- return;
-
- DEBUG ("File transfer state changed:\n"
- "\tfilename = %s, old state = %u, state = %u, reason = %u\n"
- "\tincoming = %s, in_stream = %s, out_stream = %s",
- tp_file->priv->filename, tp_file->priv->state, state, reason,
- tp_file->priv->incoming ? "yes" : "no",
- tp_file->priv->in_stream ? "present" : "not present",
- tp_file->priv->out_stream ? "present" : "not present");
-
- /* If the channel is open AND we have the socket path, we can start the
- * transfer. The socket path could be NULL if we are not doing the actual
- * data transfer but are just an observer for the channel. */
- if (state == TP_FILE_TRANSFER_STATE_OPEN &&
- tp_file->priv->unix_socket_path != NULL)
- tp_file_start_transfer (tp_file);
-
- tp_file->priv->state = state;
- tp_file->priv->state_change_reason = reason;
-
- g_object_notify (G_OBJECT (tp_file), "state");
-}
-
-static void
-tp_file_transferred_bytes_changed_cb (TpChannel *channel,
- guint64 count,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpFile *tp_file = EMPATHY_TP_FILE (weak_object);
-
- if (tp_file->priv->transferred_bytes == count)
- return;
-
- tp_file->priv->transferred_bytes = count;
- g_object_notify (G_OBJECT (tp_file), "transferred-bytes");
-}
-
-static GObject *
-tp_file_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *file_obj;
- EmpathyTpFile *tp_file;
- TpHandle handle;
- GHashTable *properties;
- McAccount *account;
- GValue *requested;
-
- file_obj = G_OBJECT_CLASS (empathy_tp_file_parent_class)->constructor (type,
- n_props, props);
-
- tp_file = EMPATHY_TP_FILE (file_obj);
-
- tp_file->priv->factory = empathy_contact_factory_dup_singleton ();
- tp_file->priv->mc = empathy_mission_control_dup_singleton ();
-
- g_signal_connect (tp_file->priv->channel, "invalidated",
- G_CALLBACK (tp_file_invalidated_cb), tp_file);
-
- tp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
- tp_file->priv->channel, tp_file_state_changed_cb, NULL, NULL,
- G_OBJECT (tp_file), NULL);
-
- tp_cli_channel_type_file_transfer_connect_to_transferred_bytes_changed (
- tp_file->priv->channel, tp_file_transferred_bytes_changed_cb,
- NULL, NULL, G_OBJECT (tp_file), NULL);
-
- account = empathy_channel_get_account (tp_file->priv->channel);
-
- handle = tp_channel_get_handle (tp_file->priv->channel, NULL);
- tp_file->priv->contact = empathy_contact_factory_get_from_handle (
- tp_file->priv->factory, account, (guint) handle);
-
- tp_cli_dbus_properties_run_get_all (tp_file->priv->channel,
- -1, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, &properties, NULL, NULL);
-
- tp_cli_dbus_properties_run_get (tp_file->priv->channel,
- -1, TP_IFACE_CHANNEL, "Requested", &requested, NULL, NULL);
-
- tp_file->priv->size = g_value_get_uint64 (
- g_hash_table_lookup (properties, "Size"));
-
- tp_file->priv->state = g_value_get_uint (
- g_hash_table_lookup (properties, "State"));
-
- tp_file->priv->state_change_reason =
- TP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE;
-
- tp_file->priv->transferred_bytes = g_value_get_uint64 (
- g_hash_table_lookup (properties, "TransferredBytes"));
-
- tp_file->priv->filename = g_value_dup_string (
- g_hash_table_lookup (properties, "Filename"));
-
- tp_file->priv->content_hash = g_value_dup_string (
- g_hash_table_lookup (properties, "ContentHash"));
-
- tp_file->priv->content_hash_type = g_value_get_uint (
- g_hash_table_lookup (properties, "ContentHashType"));
-
- tp_file->priv->content_type = g_value_dup_string (
- g_hash_table_lookup (properties, "ContentType"));
-
- tp_file->priv->description = g_value_dup_string (
- g_hash_table_lookup (properties, "Description"));
-
- tp_file->priv->incoming = !g_value_get_boolean (requested);
-
- g_hash_table_destroy (properties);
- g_object_unref (account);
- g_value_unset (requested);
-
- return file_obj;
-}
-
-static void
-tp_file_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpFile *tp_file;
-
- tp_file = EMPATHY_TP_FILE (object);
-
- switch (param_id)
- {
- case PROP_CHANNEL:
- g_value_set_object (value, tp_file->priv->channel);
- break;
- case PROP_INCOMING:
- g_value_set_boolean (value, tp_file->priv->incoming);
- break;
- case PROP_STATE:
- g_value_set_uint (value, tp_file->priv->state);
- break;
- case PROP_CONTENT_TYPE:
- g_value_set_string (value, tp_file->priv->content_type);
- break;
- case PROP_FILENAME:
- g_value_set_string (value, tp_file->priv->filename);
- break;
- case PROP_SIZE:
- g_value_set_uint64 (value, tp_file->priv->size);
- break;
- case PROP_CONTENT_HASH_TYPE:
- g_value_set_uint (value, tp_file->priv->content_hash_type);
- break;
- case PROP_CONTENT_HASH:
- g_value_set_string (value, tp_file->priv->content_hash);
- break;
- case PROP_TRANSFERRED_BYTES:
- g_value_set_uint64 (value, tp_file->priv->transferred_bytes);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_file_channel_set_dbus_property (gpointer proxy,
- const gchar *property,
- const GValue *value)
-{
- DEBUG ("Setting %s property", property);
- tp_cli_dbus_properties_call_set (TP_PROXY (proxy), -1,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, property, value,
- NULL, NULL, NULL, NULL);
-}
-
-static void
-tp_file_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpFile *tp_file = (EmpathyTpFile *) object;
- switch (param_id)
- {
- case PROP_CHANNEL:
- tp_file->priv->channel = g_object_ref (g_value_get_object (value));
- break;
- case PROP_STATE:
- tp_file->priv->state = g_value_get_uint (value);
- break;
- case PROP_INCOMING:
- tp_file->priv->incoming = g_value_get_boolean (value);
- break;
- case PROP_FILENAME:
- g_free (tp_file->priv->filename);
- tp_file->priv->filename = g_value_dup_string (value);
- tp_file_channel_set_dbus_property (tp_file->priv->channel,
- "Filename", value);
- break;
- case PROP_SIZE:
- tp_file->priv->size = g_value_get_uint64 (value);
- tp_file_channel_set_dbus_property (tp_file->priv->channel,
- "Size", value);
- break;
- case PROP_CONTENT_TYPE:
- tp_file_channel_set_dbus_property (tp_file->priv->channel,
- "ContentType", value);
- g_free (tp_file->priv->content_type);
- tp_file->priv->content_type = g_value_dup_string (value);
- break;
- case PROP_CONTENT_HASH:
- tp_file_channel_set_dbus_property (tp_file->priv->channel,
- "ContentHash", value);
- g_free (tp_file->priv->content_hash);
- tp_file->priv->content_hash = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static GHashTable *ft_table = NULL;
-
-static void
-tp_file_weak_notify_cb (gpointer channel,
- GObject *tp_file)
-{
- g_hash_table_remove (ft_table, channel);
-}
-
-/**
- * empathy_tp_file_new:
- * @channel: a Telepathy channel
- *
- * Creates a new #EmpathyTpFile wrapping @channel, or return a new ref to an
- * existing #EmpathyTpFile for that channel.
- *
- * Returns: a new #EmpathyTpFile
- */
-EmpathyTpFile *
-empathy_tp_file_new (TpChannel *channel)
-{
- EmpathyTpFile *tp_file;
-
- g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
-
- if (ft_table != NULL)
- {
- tp_file = g_hash_table_lookup (ft_table, channel);
- if (tp_file != NULL) {
- return g_object_ref (tp_file);
- }
- }
- else
- ft_table = g_hash_table_new_full (empathy_proxy_hash,
- empathy_proxy_equal, (GDestroyNotify) g_object_unref, NULL);
-
- tp_file = g_object_new (EMPATHY_TYPE_TP_FILE,
- "channel", channel,
- NULL);
-
- g_hash_table_insert (ft_table, g_object_ref (channel), tp_file);
- g_object_weak_ref (G_OBJECT (tp_file), tp_file_weak_notify_cb, channel);
-
- return tp_file;
-}
-
-/**
- * empathy_tp_file_get_channel
- * @tp_file: an #EmpathyTpFile
- *
- * Returns the Telepathy file transfer channel
- *
- * Returns: the #TpChannel
- */
-TpChannel *
-empathy_tp_file_get_channel (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
-
- return tp_file->priv->channel;
-}
-
-static void
-tp_file_method_cb (TpChannel *channel,
- const GValue *address,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpFile *tp_file = (EmpathyTpFile *) weak_object;
-
- if (error)
- {
- DEBUG ("Error: %s", error->message);
- empathy_tp_file_cancel (tp_file);
- return;
- }
-
- tp_file->priv->unix_socket_path = g_value_dup_string (address);
-
- DEBUG ("Got unix socket path: %s", tp_file->priv->unix_socket_path);
-
- if (tp_file->priv->state == TP_FILE_TRANSFER_STATE_OPEN)
- tp_file_start_transfer (tp_file);
-}
-
-/**
- * empathy_tp_file_accept:
- * @tp_file: an #EmpathyTpFile
- * @offset: position where to start the transfer
- * @gfile: a #GFile where to write transfered data
- * @error: a #GError set if there is an error when opening @gfile
- *
- * Accepts a file transfer that's in the "local pending" state (i.e.
- * TP_FILE_TRANSFER_STATE_LOCAL_PENDING).
- */
-void
-empathy_tp_file_accept (EmpathyTpFile *tp_file,
- guint64 offset,
- GFile *gfile,
- GError **error)
-{
- GValue nothing = { 0 };
-
- g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
- g_return_if_fail (G_IS_FILE (gfile));
-
- tp_file->priv->out_stream = G_OUTPUT_STREAM (g_file_replace (gfile, NULL,
- FALSE, 0, NULL, error));
- if (error && *error)
- return;
-
- tp_file->priv->filename = g_file_get_basename (gfile);
- g_object_notify (G_OBJECT (tp_file), "filename");
-
- DEBUG ("Accepting file: filename=%s", tp_file->priv->filename);
-
- g_value_init (&nothing, G_TYPE_STRING);
- g_value_set_static_string (&nothing, "");
-
- tp_cli_channel_type_file_transfer_call_accept_file (tp_file->priv->channel,
- -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
- &nothing, offset, tp_file_method_cb, NULL, NULL, G_OBJECT (tp_file));
-}
-
-/**
- * empathy_tp_file_offer:
- * @tp_file: an #EmpathyTpFile
- * @gfile: a #GFile where to read the data to transfer
- * @error: a #GError set if there is an error when opening @gfile
- *
- * Offers a file transfer that's in the "not offered" state (i.e.
- * TP_FILE_TRANSFER_STATE_NOT_OFFERED).
- */
-void
-empathy_tp_file_offer (EmpathyTpFile *tp_file, GFile *gfile, GError **error)
-{
- GValue nothing = { 0 };
-
- g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
-
- tp_file->priv->in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, error));
- if (error && *error)
- return;
-
- g_value_init (&nothing, G_TYPE_STRING);
- g_value_set_static_string (&nothing, "");
-
- tp_cli_channel_type_file_transfer_call_provide_file (tp_file->priv->channel,
- -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
- &nothing, tp_file_method_cb, NULL, NULL, G_OBJECT (tp_file));
-}
-
-EmpathyContact *
-empathy_tp_file_get_contact (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
- return tp_file->priv->contact;
-}
-
-const gchar *
-empathy_tp_file_get_filename (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
- return tp_file->priv->filename;
-}
-
-gboolean
-empathy_tp_file_is_incoming (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), FALSE);
- return tp_file->priv->incoming;
-}
-
-TpFileTransferState
-empathy_tp_file_get_state (EmpathyTpFile *tp_file,
- TpFileTransferStateChangeReason *reason)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
- TP_FILE_TRANSFER_STATE_NONE);
-
- if (reason != NULL)
- *reason = tp_file->priv->state_change_reason;
-
- return tp_file->priv->state;
-}
-
-guint64
-empathy_tp_file_get_size (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
- EMPATHY_TP_FILE_UNKNOWN_SIZE);
- return tp_file->priv->size;
-}
-
-guint64
-empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), 0);
- return tp_file->priv->transferred_bytes;
-}
-
-gint
-empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file)
-{
- time_t curr_time, elapsed_time;
- gdouble time_per_byte;
- gdouble remaining_time;
-
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), -1);
-
- if (tp_file->priv->size == EMPATHY_TP_FILE_UNKNOWN_SIZE)
- return -1;
-
- if (tp_file->priv->transferred_bytes == tp_file->priv->size)
- return 0;
-
- curr_time = empathy_time_get_current ();
- elapsed_time = curr_time - tp_file->priv->start_time;
- time_per_byte = (gdouble) elapsed_time /
- (gdouble) tp_file->priv->transferred_bytes;
- remaining_time = time_per_byte * (tp_file->priv->size -
- tp_file->priv->transferred_bytes);
-
- return (gint) remaining_time;
-}
-
-const gchar *
-empathy_tp_file_get_content_type (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file), NULL);
- return tp_file->priv->content_type;
-}
-
-void
-empathy_tp_file_cancel (EmpathyTpFile *tp_file)
-{
- g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
-
- DEBUG ("Closing channel..");
- tp_cli_channel_call_close (tp_file->priv->channel, -1,
- NULL, NULL, NULL, NULL);
-
- if (tp_file->priv->cancellable != NULL)
- g_cancellable_cancel (tp_file->priv->cancellable);
-}
-
-void
-empathy_tp_file_close (EmpathyTpFile *tp_file)
-{
- empathy_tp_file_cancel (tp_file);
-}
-
-static void
-empathy_tp_file_class_init (EmpathyTpFileClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_file_finalize;
- object_class->constructor = tp_file_constructor;
- object_class->get_property = tp_file_get_property;
- object_class->set_property = tp_file_set_property;
-
- /* Construct-only properties */
- g_object_class_install_property (object_class,
- PROP_CHANNEL,
- g_param_spec_object ("channel",
- "telepathy channel",
- "The file transfer channel",
- TP_TYPE_CHANNEL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_STATE,
- g_param_spec_uint ("state",
- "state of the transfer",
- "The file transfer state",
- 0,
- G_MAXUINT,
- G_MAXUINT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_INCOMING,
- g_param_spec_boolean ("incoming",
- "incoming",
- "Whether the transfer is incoming",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_FILENAME,
- g_param_spec_string ("filename",
- "name of the transfer",
- "The file transfer filename",
- "",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_SIZE,
- g_param_spec_uint64 ("size",
- "size of the file",
- "The file transfer size",
- 0,
- G_MAXUINT64,
- G_MAXUINT64,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_CONTENT_TYPE,
- g_param_spec_string ("content-type",
- "file transfer content-type",
- "The file transfer content-type",
- "",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_CONTENT_HASH_TYPE,
- g_param_spec_uint ("content-hash-type",
- "file transfer hash type",
- "The type of the file transfer hash",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_CONTENT_HASH,
- g_param_spec_string ("content-hash",
- "file transfer hash",
- "The hash of the transfer's contents",
- "",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_TRANSFERRED_BYTES,
- g_param_spec_uint64 ("transferred-bytes",
- "bytes transferred",
- "The number of bytes transferred",
- 0,
- G_MAXUINT64,
- 0,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpFilePriv));
-}
-
diff --git a/libempathy/empathy-tp-file.h b/libempathy/empathy-tp-file.h
deleted file mode 100644
index 42c54e4f0..000000000
--- a/libempathy/empathy-tp-file.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Marco Barisione <marco@barisione.org>
- * Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_TP_FILE_H__
-#define __EMPATHY_TP_FILE_H__
-
-#include <gio/gio.h>
-#include <glib.h>
-
-#include <telepathy-glib/channel.h>
-
-#include "empathy-contact.h"
-
-#include <libmissioncontrol/mc-account.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TP_FILE_UNKNOWN_SIZE G_MAXUINT64
-
-#define EMPATHY_TYPE_TP_FILE (empathy_tp_file_get_type ())
-#define EMPATHY_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFile))
-#define EMPATHY_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
-#define EMPATHY_IS_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_FILE))
-#define EMPATHY_IS_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_FILE))
-#define EMPATHY_TP_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
-
-typedef struct _EmpathyTpFile EmpathyTpFile;
-typedef struct _EmpathyTpFilePriv EmpathyTpFilePriv;
-typedef struct _EmpathyTpFileClass EmpathyTpFileClass;
-
-struct _EmpathyTpFile
-{
- GObject parent;
-
- EmpathyTpFilePriv *priv;
-};
-
-struct _EmpathyTpFileClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_tp_file_get_type (void) G_GNUC_CONST;
-
-EmpathyTpFile *empathy_tp_file_new (TpChannel *channel);
-
-TpChannel *empathy_tp_file_get_channel (EmpathyTpFile *tp_file);
-void empathy_tp_file_accept (EmpathyTpFile *tp_file, guint64 offset,
- GFile *gfile, GError **error);
-void empathy_tp_file_cancel (EmpathyTpFile *tp_file);
-void empathy_tp_file_close (EmpathyTpFile *tp_file);
-void empathy_tp_file_offer (EmpathyTpFile *tp_file, GFile *gfile,
- GError **error);
-
-EmpathyContact *empathy_tp_file_get_contact (EmpathyTpFile *tp_file);
-const gchar *empathy_tp_file_get_filename (EmpathyTpFile *tp_file);
-gboolean empathy_tp_file_is_incoming (EmpathyTpFile *tp_file);
-TpFileTransferState empathy_tp_file_get_state (
- EmpathyTpFile *tp_file, TpFileTransferStateChangeReason *reason);
-guint64 empathy_tp_file_get_size (EmpathyTpFile *tp_file);
-guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
-gint empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file);
-const gchar *empathy_tp_file_get_content_type (EmpathyTpFile *tp_file);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_FILE_H__ */
diff --git a/libempathy/empathy-tp-group.c b/libempathy/empathy-tp-group.c
deleted file mode 100644
index c3471c157..000000000
--- a/libempathy/empathy-tp-group.c
+++ /dev/null
@@ -1,981 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <libmissioncontrol/mc-account.h>
-
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
-
-#include "empathy-tp-group.h"
-#include "empathy-contact-factory.h"
-#include "empathy-utils.h"
-#include "empathy-marshal.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpGroup)
-typedef struct {
- TpChannel *channel;
- gboolean ready;
-
- EmpathyContactFactory *factory;
- McAccount *account;
- gchar *group_name;
- guint self_handle;
- GList *members;
- GList *local_pendings;
- GList *remote_pendings;
-} EmpathyTpGroupPriv;
-
-enum {
- MEMBER_ADDED,
- MEMBER_REMOVED,
- LOCAL_PENDING,
- REMOTE_PENDING,
- DESTROY,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_CHANNEL,
- PROP_READY
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (EmpathyTpGroup, empathy_tp_group, G_TYPE_OBJECT);
-
-static EmpathyContact *
-tp_group_get_contact (EmpathyTpGroup *group,
- guint handle)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- EmpathyContact *contact = NULL;
-
- if (handle != 0) {
- contact = empathy_contact_factory_get_from_handle (priv->factory,
- priv->account,
- handle);
- }
-
- if (contact && handle == priv->self_handle) {
- empathy_contact_set_is_user (contact, TRUE);
- }
-
- return contact;
-}
-
-static GList *
-tp_group_get_contacts (EmpathyTpGroup *group,
- const GArray *handles)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- GList *contacts, *l;
-
- if (!handles) {
- return NULL;
- }
-
- contacts = empathy_contact_factory_get_from_handles (priv->factory,
- priv->account,
- handles);
-
- /* FIXME: Only useful if the group has a different self handle than
- * the connection, otherwise the contact factory already set that
- * property. That can be known using group flags. */
- for (l = contacts; l; l = l->next) {
- if (empathy_contact_get_handle (l->data) == priv->self_handle) {
- empathy_contact_set_is_user (l->data, TRUE);
- }
- }
-
- return contacts;
-}
-
-EmpathyPendingInfo *
-empathy_pending_info_new (EmpathyContact *member,
- EmpathyContact *actor,
- const gchar *message)
-{
- EmpathyPendingInfo *info;
-
- info = g_slice_new0 (EmpathyPendingInfo);
-
- if (member) {
- info->member = g_object_ref (member);
- }
- if (actor) {
- info->actor = g_object_ref (actor);
- }
- if (message) {
- info->message = g_strdup (message);
- }
-
- return info;
-}
-
-void
-empathy_pending_info_free (EmpathyPendingInfo *info)
-{
- if (!info) {
- return;
- }
-
- if (info->member) {
- g_object_unref (info->member);
- }
- if (info->actor) {
- g_object_unref (info->actor);
- }
- g_free (info->message);
-
- g_slice_free (EmpathyPendingInfo, info);
-}
-
-static gint
-tp_group_local_pending_find (gconstpointer a,
- gconstpointer b)
-{
- const EmpathyPendingInfo *info = a;
-
- return (info->member != b);
-}
-
-static void
-tp_group_remove_from_pendings (EmpathyTpGroup *group,
- EmpathyContact *contact)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- GList *l;
-
- /* local pending */
- l = g_list_find_custom (priv->local_pendings,
- contact,
- tp_group_local_pending_find);
- if (l) {
- empathy_pending_info_free (l->data);
- priv->local_pendings = g_list_delete_link (priv->local_pendings, l);
- }
-
- /* remote pending */
- l = g_list_find (priv->remote_pendings, contact);
- if (l) {
- g_object_unref (l->data);
- priv->remote_pendings = g_list_delete_link (priv->remote_pendings, l);
- }
-}
-
-static void
-tp_group_update_members (EmpathyTpGroup *group,
- const gchar *message,
- const GArray *added,
- const GArray *removed,
- const GArray *local_pending,
- const GArray *remote_pending,
- guint actor,
- guint reason)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- EmpathyContact *actor_contact = NULL;
- GList *contacts, *l, *ll;
-
- actor_contact = tp_group_get_contact (group, actor);
-
- DEBUG ("Members changed for list %s:\n"
- " added-len=%d, current-len=%d\n"
- " removed-len=%d\n"
- " local-pending-len=%d, current-len=%d\n"
- " remote-pending-len=%d, current-len=%d",
- priv->group_name, added ? added->len : 0,
- g_list_length (priv->members), removed ? removed->len : 0,
- local_pending ? local_pending->len : 0,
- g_list_length (priv->local_pendings),
- remote_pending ? remote_pending->len : 0,
- g_list_length (priv->remote_pendings));
-
- /* Contacts added */
- contacts = tp_group_get_contacts (group, added);
- for (l = contacts; l; l = l->next) {
- tp_group_remove_from_pendings (group, l->data);
-
- /* If the contact is not yet member, add it and emit signal */
- if (!g_list_find (priv->members, l->data)) {
- priv->members = g_list_prepend (priv->members,
- g_object_ref (l->data));
- g_signal_emit (group, signals[MEMBER_ADDED], 0,
- l->data, actor_contact, reason, message);
- }
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-
- /* Contacts removed */
- contacts = tp_group_get_contacts (group, removed);
- for (l = contacts; l; l = l->next) {
- tp_group_remove_from_pendings (group, l->data);
-
- /* If the contact is member, remove it and emit signal */
- if ((ll = g_list_find (priv->members, l->data))) {
- g_object_unref (ll->data);
- priv->members = g_list_delete_link (priv->members, ll);
- g_signal_emit (group, signals[MEMBER_REMOVED], 0,
- l->data, actor_contact, reason, message);
- }
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-
- /* Contacts local pending */
- contacts = tp_group_get_contacts (group, local_pending);
- for (l = contacts; l; l = l->next) {
- /* If the contact is not yet local-pending, add it and emit signal */
- if (!g_list_find_custom (priv->local_pendings, l->data,
- tp_group_local_pending_find)) {
- EmpathyPendingInfo *info;
-
- info = empathy_pending_info_new (l->data,
- actor_contact,
- message);
-
- priv->local_pendings = g_list_prepend (priv->local_pendings, info);
- g_signal_emit (group, signals[LOCAL_PENDING], 0,
- l->data, actor_contact, reason, message);
- }
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-
- /* Contacts remote pending */
- contacts = tp_group_get_contacts (group, remote_pending);
- for (l = contacts; l; l = l->next) {
- /* If the contact is not yet remote-pending, add it and emit signal */
- if (!g_list_find (priv->remote_pendings, l->data)) {
- priv->remote_pendings = g_list_prepend (priv->remote_pendings,
- g_object_ref (l->data));
- g_signal_emit (group, signals[REMOTE_PENDING], 0,
- l->data, actor_contact, reason, message);
- }
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-
- if (actor_contact) {
- g_object_unref (actor_contact);
- }
-
- DEBUG ("Members changed done for list %s:\n"
- " members-len=%d\n"
- " local-pendings-len=%d\n"
- " remote-pendings-len=%d",
- priv->group_name, g_list_length (priv->members),
- g_list_length (priv->local_pendings),
- g_list_length (priv->remote_pendings));
-}
-
-static void
-tp_group_members_changed_cb (TpChannel *channel,
- const gchar *message,
- const GArray *added,
- const GArray *removed,
- const GArray *local_pending,
- const GArray *remote_pending,
- guint actor,
- guint reason,
- gpointer user_data,
- GObject *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- if (priv->ready) {
- tp_group_update_members (EMPATHY_TP_GROUP (group), message,
- added, removed,
- local_pending, remote_pending,
- actor, reason);
- }
-}
-
-static void
-tp_group_get_members_cb (TpChannel *channel,
- const GArray *handles,
- const GError *error,
- gpointer user_data,
- GObject *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- if (error) {
- DEBUG ("Failed to get members: %s", error->message);
- return;
- }
-
- tp_group_update_members (EMPATHY_TP_GROUP (group),
- NULL, /* message */
- handles, /* added */
- NULL, /* removed */
- NULL, /* local_pending */
- NULL, /* remote_pending */
- 0, /* actor */
- 0); /* reason */
-
- DEBUG ("Ready");
- priv->ready = TRUE;
- g_object_notify (group, "ready");
-}
-
-static void
-tp_group_get_local_pending_cb (TpChannel *channel,
- const GPtrArray *array,
- const GError *error,
- gpointer user_data,
- GObject *group)
-{
- GArray *handles;
- guint i = 0;
-
- if (error) {
- DEBUG ("Failed to get local pendings: %s", error->message);
- return;
- }
-
- handles = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
- g_array_append_val (handles, i);
- for (i = 0; array->len > i; i++) {
- GValueArray *pending_struct;
- const gchar *message;
- guint member_handle;
- guint actor_handle;
- guint reason;
-
- pending_struct = g_ptr_array_index (array, i);
- member_handle = g_value_get_uint (g_value_array_get_nth (pending_struct, 0));
- actor_handle = g_value_get_uint (g_value_array_get_nth (pending_struct, 1));
- reason = g_value_get_uint (g_value_array_get_nth (pending_struct, 2));
- message = g_value_get_string (g_value_array_get_nth (pending_struct, 3));
-
- g_array_index (handles, guint, 0) = member_handle;
-
- tp_group_update_members (EMPATHY_TP_GROUP (group),
- message, /* message */
- NULL, /* added */
- NULL, /* removed */
- handles, /* local_pending */
- NULL, /* remote_pending */
- actor_handle, /* actor */
- reason); /* reason */
- }
- g_array_free (handles, TRUE);
-}
-
-static void
-tp_group_get_remote_pending_cb (TpChannel *channel,
- const GArray *handles,
- const GError *error,
- gpointer user_data,
- GObject *group)
-{
- if (error) {
- DEBUG ("Failed to get remote pendings: %s", error->message);
- return;
- }
-
- tp_group_update_members (EMPATHY_TP_GROUP (group),
- NULL, /* message */
- NULL, /* added */
- NULL, /* removed */
- NULL, /* local_pending */
- handles, /* remote_pending */
- 0, /* actor */
- 0); /* reason */
-}
-
-static void
-tp_group_inspect_handles_cb (TpConnection *connection,
- const gchar **names,
- const GError *error,
- gpointer user_data,
- GObject *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- if (error) {
- DEBUG ("Failed to inspect channel handle: %s", error->message);
- return;
- }
-
- priv->group_name = g_strdup (*names);
-}
-
-static void
-tp_group_invalidated_cb (TpProxy *proxy,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpGroup *group)
-{
- DEBUG ("Channel invalidated: %s", message);
- g_signal_emit (group, signals[DESTROY], 0);
-}
-
-static void
-tp_group_get_self_handle_cb (TpChannel *proxy,
- guint handle,
- const GError *error,
- gpointer user_data,
- GObject *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- TpConnection *connection;
- guint channel_handle;
- guint channel_handle_type;
- GArray *handles;
-
- if (error) {
- DEBUG ("Failed to get self handle: %s", error->message);
- return;
- }
-
- priv->self_handle = handle;
- tp_cli_channel_interface_group_connect_to_members_changed (priv->channel,
- tp_group_members_changed_cb,
- NULL, NULL,
- group, NULL);
-
- /* GetMembers is called last, so it will be the last to get the reply,
- * so we'll be ready once that call return. */
- g_object_get (priv->channel,
- "connection", &connection,
- "handle-type", &channel_handle_type,
- "handle", &channel_handle,
- NULL);
- handles = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
- g_array_prepend_val (handles, channel_handle);
- tp_cli_connection_call_inspect_handles (connection, -1,
- channel_handle_type,
- handles,
- tp_group_inspect_handles_cb,
- NULL, NULL,
- group);
- g_array_free (handles, TRUE);
-
- tp_cli_channel_interface_group_call_get_local_pending_members_with_info
- (priv->channel, -1,
- tp_group_get_local_pending_cb,
- NULL, NULL,
- group);
- tp_cli_channel_interface_group_call_get_remote_pending_members
- (priv->channel, -1,
- tp_group_get_remote_pending_cb,
- NULL, NULL,
- group);
- tp_cli_channel_interface_group_call_get_members (priv->channel, -1,
- tp_group_get_members_cb,
- NULL, NULL,
- group);
-}
-
-static void
-tp_group_factory_ready_cb (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (priv->factory, priv->account);
- g_signal_handlers_disconnect_by_func (tp_factory, tp_group_factory_ready_cb, group);
- tp_cli_channel_interface_group_call_get_self_handle (priv->channel, -1,
- tp_group_get_self_handle_cb,
- NULL, NULL,
- G_OBJECT (group));
-}
-
-static void
-tp_group_channel_ready_cb (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- EmpathyTpContactFactory *tp_factory;
-
- tp_factory = empathy_contact_factory_get_tp_factory (priv->factory,
- priv->account);
- if (empathy_tp_contact_factory_is_ready (tp_factory)) {
- tp_group_factory_ready_cb (group);
- } else {
- g_signal_connect_swapped (tp_factory, "notify::ready",
- G_CALLBACK (tp_group_factory_ready_cb),
- group);
- }
-}
-
-static void
-tp_group_finalize (GObject *object)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (object);
- EmpathyTpContactFactory *tp_factory;
-
- DEBUG ("finalize: %p", object);
-
- tp_factory = empathy_contact_factory_get_tp_factory (priv->factory, priv->account);
- g_signal_handlers_disconnect_by_func (tp_factory, tp_group_factory_ready_cb, object);
-
- if (priv->channel) {
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_group_invalidated_cb,
- object);
- g_object_unref (priv->channel);
- }
- if (priv->account) {
- g_object_unref (priv->account);
- }
- if (priv->factory) {
- g_object_unref (priv->factory);
- }
- g_free (priv->group_name);
-
- g_list_foreach (priv->members, (GFunc) g_object_unref, NULL);
- g_list_free (priv->members);
-
- g_list_foreach (priv->local_pendings, (GFunc) empathy_pending_info_free, NULL);
- g_list_free (priv->local_pendings);
-
- g_list_foreach (priv->remote_pendings, (GFunc) g_object_unref, NULL);
- g_list_free (priv->remote_pendings);
-
- G_OBJECT_CLASS (empathy_tp_group_parent_class)->finalize (object);
-}
-
-static void
-tp_group_constructed (GObject *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- gboolean channel_ready;
-
- priv->factory = empathy_contact_factory_dup_singleton ();
- priv->account = empathy_channel_get_account (priv->channel);
-
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (tp_group_invalidated_cb),
- group);
-
- g_object_get (priv->channel, "channel-ready", &channel_ready, NULL);
- if (channel_ready) {
- tp_group_channel_ready_cb (EMPATHY_TP_GROUP (group));
- } else {
- g_signal_connect_swapped (priv->channel, "notify::channel-ready",
- G_CALLBACK (tp_group_channel_ready_cb),
- group);
- }
-}
-
-static void
-tp_group_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CHANNEL:
- g_value_set_object (value, priv->channel);
- break;
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_group_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CHANNEL:
- priv->channel = g_object_ref (g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-empathy_tp_group_class_init (EmpathyTpGroupClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_group_finalize;
- object_class->constructed = tp_group_constructed;
- object_class->get_property = tp_group_get_property;
- object_class->set_property = tp_group_set_property;
-
- g_object_class_install_property (object_class,
- PROP_CHANNEL,
- g_param_spec_object ("channel",
- "telepathy channel",
- "The channel for the group",
- TP_TYPE_CHANNEL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_READY,
- g_param_spec_boolean ("ready",
- "Is the object ready",
- "This object can't be used until this becomes true",
- FALSE,
- G_PARAM_READABLE));
-
- signals[MEMBER_ADDED] =
- g_signal_new ("member-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
-
- signals[MEMBER_REMOVED] =
- g_signal_new ("member-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
-
- signals[LOCAL_PENDING] =
- g_signal_new ("local-pending",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
-
- signals[REMOTE_PENDING] =
- g_signal_new ("remote-pending",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
-
- signals[DESTROY] =
- g_signal_new ("destroy",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpGroupPriv));
-}
-
-static void
-empathy_tp_group_init (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
- EMPATHY_TYPE_TP_GROUP, EmpathyTpGroupPriv);
-
- group->priv = priv;
-}
-
-EmpathyTpGroup *
-empathy_tp_group_new (TpChannel *channel)
-{
- g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
-
- return g_object_new (EMPATHY_TYPE_TP_GROUP,
- "channel", channel,
- NULL);
-}
-
-static void
-tp_group_async_cb (TpChannel *channel,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error) {
- DEBUG ("%s: %s", (gchar*) user_data, error->message);
- }
-}
-
-void
-empathy_tp_group_close (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_if_fail (EMPATHY_IS_TP_GROUP (group));
- g_return_if_fail (priv->ready);
-
- tp_cli_channel_call_close (priv->channel, -1,
- tp_group_async_cb,
- "Failed to close", NULL,
- G_OBJECT (group));
-}
-
-static GArray *
-tp_group_get_handles (GList *contacts)
-{
- GArray *handles;
- guint length;
- GList *l;
-
- length = g_list_length (contacts);
- handles = g_array_sized_new (FALSE, FALSE, sizeof (guint), length);
-
- for (l = contacts; l; l = l->next) {
- guint handle;
-
- handle = empathy_contact_get_handle (l->data);
- g_array_append_val (handles, handle);
- }
-
- return handles;
-}
-
-void
-empathy_tp_group_add_members (EmpathyTpGroup *group,
- GList *contacts,
- const gchar *message)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- GArray *handles;
-
- g_return_if_fail (EMPATHY_IS_TP_GROUP (group));
- g_return_if_fail (contacts != NULL);
- g_return_if_fail (priv->ready);
-
- handles = tp_group_get_handles (contacts);
- tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
- handles,
- message,
- tp_group_async_cb,
- "Failed to add members", NULL,
- G_OBJECT (group));
- g_array_free (handles, TRUE);
-}
-
-void
-empathy_tp_group_remove_members (EmpathyTpGroup *group,
- GList *contacts,
- const gchar *message)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- GArray *handles;
-
- g_return_if_fail (EMPATHY_IS_TP_GROUP (group));
- g_return_if_fail (contacts != NULL);
- g_return_if_fail (priv->ready);
-
- handles = tp_group_get_handles (contacts);
- tp_cli_channel_interface_group_call_remove_members (priv->channel, -1,
- handles,
- message,
- tp_group_async_cb,
- "Failed to remove members", NULL,
- G_OBJECT (group));
- g_array_free (handles, TRUE);
-}
-
-void
-empathy_tp_group_add_member (EmpathyTpGroup *group,
- EmpathyContact *contact,
- const gchar *message)
-{
- GList *contacts;
-
- contacts = g_list_prepend (NULL, contact);
- empathy_tp_group_add_members (group, contacts, message);
- g_list_free (contacts);
-}
-
-void
-empathy_tp_group_remove_member (EmpathyTpGroup *group,
- EmpathyContact *contact,
- const gchar *message)
-{
- GList *contacts;
-
- contacts = g_list_prepend (NULL, contact);
- empathy_tp_group_remove_members (group, contacts, message);
- g_list_free (contacts);
-}
-
-GList *
-empathy_tp_group_get_members (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
-
- g_list_foreach (priv->members, (GFunc) g_object_ref, NULL);
-
- return g_list_copy (priv->members);
-}
-
-GList *
-empathy_tp_group_get_local_pendings (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- GList *pendings = NULL, *l;
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
-
- for (l = priv->local_pendings; l; l = l->next) {
- EmpathyPendingInfo *info;
- EmpathyPendingInfo *new_info;
-
- info = l->data;
- new_info = empathy_pending_info_new (info->member,
- info->actor,
- info->message);
- pendings = g_list_prepend (pendings, new_info);
- }
-
- return pendings;
-}
-
-GList *
-empathy_tp_group_get_remote_pendings (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
-
- g_list_foreach (priv->remote_pendings, (GFunc) g_object_ref, NULL);
-
- return g_list_copy (priv->remote_pendings);
-}
-
-const gchar *
-empathy_tp_group_get_name (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
- g_return_val_if_fail (priv->ready, NULL);
-
- return priv->group_name;
-}
-
-EmpathyContact *
-empathy_tp_group_get_self_contact (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
- g_return_val_if_fail (priv->ready, NULL);
-
- return tp_group_get_contact (group, priv->self_handle);
-}
-
-gboolean
-empathy_tp_group_is_member (EmpathyTpGroup *group,
- EmpathyContact *contact)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), FALSE);
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
-
- return g_list_find (priv->members, contact) != NULL;
-}
-
-gboolean
-empathy_tp_group_is_ready (EmpathyTpGroup *group)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), FALSE);
-
- return priv->ready;
-}
-
-EmpathyPendingInfo *
-empathy_tp_group_get_invitation (EmpathyTpGroup *group,
- EmpathyContact **remote_contact)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (group);
- EmpathyContact *contact = NULL;
- EmpathyPendingInfo *invitation = NULL;
- GList *l;
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), FALSE);
- g_return_val_if_fail (priv->ready, NULL);
-
- for (l = priv->local_pendings; l; l = l->next) {
- EmpathyPendingInfo *info = l->data;
-
- if (empathy_contact_is_user (info->member)) {
- invitation = info;
- break;
- }
- }
-
- if (invitation) {
- contact = invitation->actor;
- }
- if (!invitation) {
- if (priv->remote_pendings) {
- contact = priv->remote_pendings->data;
- }
- else if (priv->members) {
- contact = priv->members->data;
- }
- }
-
- if (remote_contact && contact) {
- *remote_contact = g_object_ref (contact);
- }
-
- return invitation;
-}
-
-TpChannelGroupFlags
-empathy_tp_group_get_flags (EmpathyTpGroup *self)
-{
- EmpathyTpGroupPriv *priv = GET_PRIV (self);
-
- g_return_val_if_fail (EMPATHY_IS_TP_GROUP (self), 0);
-
- if (priv->channel == NULL)
- return 0;
-
- return tp_channel_group_get_flags (priv->channel);
-}
diff --git a/libempathy/empathy-tp-group.h b/libempathy/empathy-tp-group.h
deleted file mode 100644
index 9e0dd53ef..000000000
--- a/libempathy/empathy-tp-group.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Xavier Claessens <xclaesse@gmail.com>
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_GROUP_H__
-#define __EMPATHY_TP_GROUP_H__
-
-#include <glib.h>
-
-#include <telepathy-glib/channel.h>
-
-#include "empathy-contact.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_GROUP (empathy_tp_group_get_type ())
-#define EMPATHY_TP_GROUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_GROUP, EmpathyTpGroup))
-#define EMPATHY_TP_GROUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_GROUP, EmpathyTpGroupClass))
-#define EMPATHY_IS_TP_GROUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_GROUP))
-#define EMPATHY_IS_TP_GROUP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_GROUP))
-#define EMPATHY_TP_GROUP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_GROUP, EmpathyTpGroupClass))
-
-typedef struct _EmpathyTpGroup EmpathyTpGroup;
-typedef struct _EmpathyTpGroupClass EmpathyTpGroupClass;
-
-struct _EmpathyTpGroup {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpGroupClass {
- GObjectClass parent_class;
-};
-
-typedef struct {
- EmpathyContact *member;
- EmpathyContact *actor;
- gchar *message;
- guint reason;
-} EmpathyPendingInfo;
-
-GType empathy_tp_group_get_type (void) G_GNUC_CONST;
-EmpathyTpGroup * empathy_tp_group_new (TpChannel *channel);
-void empathy_tp_group_close (EmpathyTpGroup *group);
-void empathy_tp_group_add_members (EmpathyTpGroup *group,
- GList *contacts,
- const gchar *message);
-void empathy_tp_group_add_member (EmpathyTpGroup *group,
- EmpathyContact *contact,
- const gchar *message);
-void empathy_tp_group_remove_members (EmpathyTpGroup *group,
- GList *contacts,
- const gchar *message);
-void empathy_tp_group_remove_member (EmpathyTpGroup *group,
- EmpathyContact *contact,
- const gchar *message);
-GList * empathy_tp_group_get_members (EmpathyTpGroup *group);
-GList * empathy_tp_group_get_local_pendings (EmpathyTpGroup *group);
-GList * empathy_tp_group_get_remote_pendings (EmpathyTpGroup *group);
-const gchar * empathy_tp_group_get_name (EmpathyTpGroup *group);
-EmpathyContact * empathy_tp_group_get_self_contact (EmpathyTpGroup *group);
-gboolean empathy_tp_group_is_member (EmpathyTpGroup *group,
- EmpathyContact *contact);
-gboolean empathy_tp_group_is_ready (EmpathyTpGroup *group);
-EmpathyPendingInfo *empathy_tp_group_get_invitation (EmpathyTpGroup *group,
- EmpathyContact **remote_contact);
-EmpathyPendingInfo *empathy_pending_info_new (EmpathyContact *member,
- EmpathyContact *actor,
- const gchar *message);
-void empathy_pending_info_free (EmpathyPendingInfo *info);
-TpChannelGroupFlags empathy_tp_group_get_flags (EmpathyTpGroup *group);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_GROUP_H__ */
diff --git a/libempathy/empathy-tp-roomlist.c b/libempathy/empathy-tp-roomlist.c
deleted file mode 100644
index a1583c083..000000000
--- a/libempathy/empathy-tp-roomlist.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/util.h>
-
-#include <libmissioncontrol/mission-control.h>
-
-#include "empathy-tp-roomlist.h"
-#include "empathy-chatroom.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP
-#include "empathy-debug.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpRoomlist)
-typedef struct {
- TpConnection *connection;
- TpChannel *channel;
- McAccount *account;
- gboolean is_listing;
-} EmpathyTpRoomlistPriv;
-
-enum {
- NEW_ROOM,
- DESTROY,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_CONNECTION,
- PROP_IS_LISTING,
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (EmpathyTpRoomlist, empathy_tp_roomlist, G_TYPE_OBJECT);
-
-static void
-tp_roomlist_listing_cb (TpChannel *channel,
- gboolean listing,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- DEBUG ("Listing: %s", listing ? "Yes" : "No");
- priv->is_listing = listing;
- g_object_notify (list, "is-listing");
-}
-
-static void
-tp_roomlist_chatrooms_free (gpointer data)
-{
- GSList *chatrooms = data;
-
- g_slist_foreach (chatrooms, (GFunc) g_object_unref, NULL);
- g_slist_free (chatrooms);
-}
-
-static void
-tp_roomlist_inspect_handles_cb (TpConnection *connection,
- const gchar **names,
- const GError *error,
- gpointer user_data,
- GObject *list)
-{
- GSList *chatrooms = user_data;
-
- if (error != NULL) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- while (*names != NULL) {
- EmpathyChatroom *chatroom = chatrooms->data;
-
- empathy_chatroom_set_room (chatroom, *names);
- g_signal_emit (list, signals[NEW_ROOM], 0, chatroom);
-
- names++;
- chatrooms = chatrooms->next;
- }
-}
-
-static void
-tp_roomlist_got_rooms_cb (TpChannel *channel,
- const GPtrArray *rooms,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
- EmpathyChatroom *chatroom;
- guint i;
- GArray *handles = NULL;
- GSList *chatrooms = NULL;
-
- for (i = 0; i < rooms->len; i++) {
- const GValue *room_name_value;
- const GValue *handle_name_value;
- GValueArray *room_struct;
- guint handle;
- const gchar *channel_type;
- GHashTable *info;
-
- /* Get information */
- room_struct = g_ptr_array_index (rooms, i);
- handle = g_value_get_uint (g_value_array_get_nth (room_struct, 0));
- channel_type = g_value_get_string (g_value_array_get_nth (room_struct, 1));
- info = g_value_get_boxed (g_value_array_get_nth (room_struct, 2));
- room_name_value = g_hash_table_lookup (info, "name");
- handle_name_value = g_hash_table_lookup (info, "handle-name");
-
- if (tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)) {
- continue;
- }
-
- chatroom = empathy_chatroom_new (priv->account);
-
- if (room_name_value != NULL) {
- empathy_chatroom_set_name (chatroom,
- g_value_get_string (room_name_value));
- }
-
- if (handle_name_value != NULL) {
- empathy_chatroom_set_room (chatroom,
- g_value_get_string (handle_name_value));
-
- /* We have the room ID, we can directly emit it */
- g_signal_emit (list, signals[NEW_ROOM], 0, chatroom);
- g_object_unref (chatroom);
- } else {
- /* We don't have the room ID, we'll inspect all handles
- * at once and then emit rooms */
- if (handles == NULL) {
- handles = g_array_new (FALSE, FALSE, sizeof (guint));
- }
-
- g_array_append_val (handles, handle);
- chatrooms = g_slist_prepend (chatrooms, chatroom);
- }
- }
-
- if (handles != NULL) {
- chatrooms = g_slist_reverse (chatrooms);
- tp_cli_connection_call_inspect_handles (priv->connection, -1,
- TP_HANDLE_TYPE_ROOM,
- handles,
- tp_roomlist_inspect_handles_cb,
- chatrooms,
- tp_roomlist_chatrooms_free,
- list);
- g_array_free (handles, TRUE);
- }
-}
-
-static void
-tp_roomlist_get_listing_rooms_cb (TpChannel *channel,
- gboolean is_listing,
- const GError *error,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- if (error) {
- DEBUG ("Error geting listing rooms: %s", error->message);
- return;
- }
-
- priv->is_listing = is_listing;
- g_object_notify (list, "is-listing");
-}
-
-static void
-tp_roomlist_invalidated_cb (TpChannel *channel,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpRoomlist *list)
-{
- DEBUG ("Channel invalidated: %s", message);
- g_signal_emit (list, signals[DESTROY], 0);
-}
-
-static void
-tp_roomlist_request_channel_cb (TpConnection *connection,
- const gchar *object_path,
- const GError *error,
- gpointer user_data,
- GObject *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- if (error) {
- DEBUG ("Error requesting channel: %s", error->message);
- return;
- }
-
- priv->channel = tp_channel_new (priv->connection, object_path,
- TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
- TP_HANDLE_TYPE_NONE,
- 0, NULL);
- tp_channel_run_until_ready (priv->channel, NULL, NULL);
-
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (tp_roomlist_invalidated_cb),
- list);
-
- tp_cli_channel_type_room_list_connect_to_listing_rooms (priv->channel,
- tp_roomlist_listing_cb,
- NULL, NULL,
- G_OBJECT (list),
- NULL);
- tp_cli_channel_type_room_list_connect_to_got_rooms (priv->channel,
- tp_roomlist_got_rooms_cb,
- NULL, NULL,
- G_OBJECT (list),
- NULL);
-
- tp_cli_channel_type_room_list_call_get_listing_rooms (priv->channel, -1,
- tp_roomlist_get_listing_rooms_cb,
- NULL, NULL,
- G_OBJECT (list));
-}
-
-static void
-tp_roomlist_finalize (GObject *object)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (object);
-
- if (priv->channel) {
- DEBUG ("Closing channel...");
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_roomlist_invalidated_cb,
- object);
- tp_cli_channel_call_close (priv->channel, -1,
- NULL, NULL, NULL, NULL);
- g_object_unref (priv->channel);
- }
-
- if (priv->account) {
- g_object_unref (priv->account);
- }
- if (priv->connection) {
- g_object_unref (priv->connection);
- }
-
- G_OBJECT_CLASS (empathy_tp_roomlist_parent_class)->finalize (object);
-}
-
-static void
-tp_roomlist_constructed (GObject *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
- MissionControl *mc;
-
- mc = empathy_mission_control_dup_singleton ();
- priv->account = mission_control_get_account_for_tpconnection (mc,
- priv->connection,
- NULL);
- g_object_unref (mc);
-
- tp_cli_connection_call_request_channel (priv->connection, -1,
- TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
- TP_HANDLE_TYPE_NONE,
- 0,
- TRUE,
- tp_roomlist_request_channel_cb,
- NULL, NULL,
- list);
-}
-
-static void
-tp_roomlist_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CONNECTION:
- g_value_set_object (value, priv->connection);
- break;
- case PROP_IS_LISTING:
- g_value_set_boolean (value, priv->is_listing);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-tp_roomlist_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (object);
-
- switch (param_id) {
- case PROP_CONNECTION:
- priv->connection = g_object_ref (g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-empathy_tp_roomlist_class_init (EmpathyTpRoomlistClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_roomlist_finalize;
- object_class->constructed = tp_roomlist_constructed;
- object_class->get_property = tp_roomlist_get_property;
- object_class->set_property = tp_roomlist_set_property;
-
- g_object_class_install_property (object_class,
- PROP_CONNECTION,
- g_param_spec_object ("connection",
- "The Connection",
- "The connection on which it lists rooms",
- TP_TYPE_CONNECTION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_IS_LISTING,
- g_param_spec_boolean ("is-listing",
- "Is listing",
- "Are we listing rooms",
- FALSE,
- G_PARAM_READABLE));
-
- signals[NEW_ROOM] =
- g_signal_new ("new-room",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_CHATROOM);
-
- signals[DESTROY] =
- g_signal_new ("destroy",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpRoomlistPriv));
-}
-
-static void
-empathy_tp_roomlist_init (EmpathyTpRoomlist *list)
-{
- EmpathyTpRoomlistPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (list,
- EMPATHY_TYPE_TP_ROOMLIST, EmpathyTpRoomlistPriv);
-
- list->priv = priv;
-}
-
-EmpathyTpRoomlist *
-empathy_tp_roomlist_new (McAccount *account)
-{
- EmpathyTpRoomlist *list;
- MissionControl *mc;
- TpConnection *connection;
-
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
-
- mc = empathy_mission_control_dup_singleton ();
- connection = mission_control_get_tpconnection (mc, account, NULL);
-
- list = g_object_new (EMPATHY_TYPE_TP_ROOMLIST,
- "connection", connection,
- NULL);
-
- g_object_unref (mc);
- g_object_unref (connection);
-
- return list;
-}
-
-gboolean
-empathy_tp_roomlist_is_listing (EmpathyTpRoomlist *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- g_return_val_if_fail (EMPATHY_IS_TP_ROOMLIST (list), FALSE);
-
- return priv->is_listing;
-}
-
-void
-empathy_tp_roomlist_start (EmpathyTpRoomlist *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- g_return_if_fail (EMPATHY_IS_TP_ROOMLIST (list));
- g_return_if_fail (TP_IS_CHANNEL (priv->channel));
-
- tp_cli_channel_type_room_list_call_list_rooms (priv->channel, -1,
- NULL, NULL, NULL, NULL);
-}
-
-void
-empathy_tp_roomlist_stop (EmpathyTpRoomlist *list)
-{
- EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
-
- g_return_if_fail (EMPATHY_IS_TP_ROOMLIST (list));
- g_return_if_fail (TP_IS_CHANNEL (priv->channel));
-
- tp_cli_channel_type_room_list_call_stop_listing (priv->channel, -1,
- NULL, NULL, NULL, NULL);
-}
-
diff --git a/libempathy/empathy-tp-roomlist.h b/libempathy/empathy-tp-roomlist.h
deleted file mode 100644
index 9f45b7f5c..000000000
--- a/libempathy/empathy-tp-roomlist.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_TP_ROOMLIST_H__
-#define __EMPATHY_TP_ROOMLIST_H__
-
-#include <glib.h>
-
-#include <telepathy-glib/connection.h>
-#include <libmissioncontrol/mc-account.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_ROOMLIST (empathy_tp_roomlist_get_type ())
-#define EMPATHY_TP_ROOMLIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_ROOMLIST, EmpathyTpRoomlist))
-#define EMPATHY_TP_ROOMLIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_ROOMLIST, EmpathyTpRoomlistClass))
-#define EMPATHY_IS_TP_ROOMLIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_ROOMLIST))
-#define EMPATHY_IS_TP_ROOMLIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_ROOMLIST))
-#define EMPATHY_TP_ROOMLIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_ROOMLIST, EmpathyTpRoomlistClass))
-
-typedef struct _EmpathyTpRoomlist EmpathyTpRoomlist;
-typedef struct _EmpathyTpRoomlistClass EmpathyTpRoomlistClass;
-
-struct _EmpathyTpRoomlist {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpRoomlistClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tp_roomlist_get_type (void) G_GNUC_CONST;
-EmpathyTpRoomlist *empathy_tp_roomlist_new (McAccount *account);
-gboolean empathy_tp_roomlist_is_listing (EmpathyTpRoomlist *list);
-void empathy_tp_roomlist_start (EmpathyTpRoomlist *list);
-void empathy_tp_roomlist_stop (EmpathyTpRoomlist *list);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_ROOMLIST_H__ */
diff --git a/libempathy/empathy-tp-tube.c b/libempathy/empathy-tp-tube.c
deleted file mode 100644
index 793b6ff7a..000000000
--- a/libempathy/empathy-tp-tube.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
- * Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/util.h>
-#include <extensions/extensions.h>
-
-#include "empathy-contact-factory.h"
-#include "empathy-enum-types.h"
-#include "empathy-tp-tube.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_TP
-#include "empathy-debug.h"
-
-typedef struct {
- TpSocketAddressType type;
- EmpatyTpTubeAcceptStreamTubeCb *callback;
- gpointer user_data;
-} EmpathyTpTubeAcceptData;
-
-static EmpathyTpTubeAcceptData *
-new_empathy_tp_tube_accept_data (TpSocketAddressType type,
- EmpatyTpTubeAcceptStreamTubeCb *callback, gpointer user_data)
-{
- EmpathyTpTubeAcceptData *r;
-
- r = g_slice_new0 (EmpathyTpTubeAcceptData);
- r->type = type;
- r->callback = callback;
- r->user_data = user_data;
-
- return r;
-}
-
-static void
-free_empathy_tp_tube_accept_data (gpointer data)
-{
- g_slice_free (EmpathyTpTubeAcceptData, data);
-}
-
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpTube)
-typedef struct
-{
- TpChannel *channel;
- guint initiator;
- guint type;
- gchar *service;
- /* FIXME readd support for parameters.. */
- GHashTable *parameters;
- guint state;
- EmpathyContact *initiator_contact;
- EmpathyContactFactory *factory;
-} EmpathyTpTubePriv;
-
-enum
-{
- PROP_0,
- PROP_CHANNEL,
- PROP_STATE,
-};
-
-enum
-{
- DESTROY,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (EmpathyTpTube, empathy_tp_tube, G_TYPE_OBJECT)
-
-static void
-tp_tube_state_changed_cb (TpProxy *proxy,
- guint state,
- gpointer user_data,
- GObject *tube)
-{
- EmpathyTpTubePriv *priv = GET_PRIV (tube);
-
- DEBUG ("Tube state changed");
-
- priv->state = state;
- g_object_notify (tube, "state");
-}
-
-static void
-tp_tube_invalidated_cb (TpChannel *channel,
- GQuark domain,
- gint code,
- gchar *message,
- EmpathyTpTube *tube)
-{
- DEBUG ("Channel invalidated: %s", message);
- g_signal_emit (tube, signals[DESTROY], 0);
-}
-
-static void
-tp_tube_async_cb (TpChannel *channel,
- const GError *error,
- gpointer user_data,
- GObject *tube)
-{
- if (error)
- DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
-}
-
-static void
-tp_tube_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpTubePriv *priv = GET_PRIV (object);
-
- switch (prop_id)
- {
- case PROP_CHANNEL:
- priv->channel = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tp_tube_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpTubePriv *priv = GET_PRIV (object);
-
- switch (prop_id)
- {
- case PROP_CHANNEL:
- g_value_set_object (value, priv->channel);
- break;
- case PROP_STATE:
- g_value_set_uint (value, priv->state);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GObject *
-tp_tube_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
-{
- GObject *self;
- EmpathyTpTubePriv *priv;
-
- self = G_OBJECT_CLASS (empathy_tp_tube_parent_class)->constructor (
- type, n_props, props);
- priv = GET_PRIV (self);
-
- g_signal_connect (priv->channel, "invalidated",
- G_CALLBACK (tp_tube_invalidated_cb), self);
-
- emp_cli_channel_interface_tube_connect_to_tube_channel_state_changed (
- TP_PROXY (priv->channel), tp_tube_state_changed_cb, NULL, NULL,
- self, NULL);
-
- return self;
-}
-
-static void
-tp_tube_finalize (GObject *object)
-{
- EmpathyTpTubePriv *priv = GET_PRIV (object);
-
- DEBUG ("Finalizing: %p", object);
-
- if (priv->channel)
- {
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_tube_invalidated_cb, object);
- tp_cli_channel_call_close (priv->channel, -1, tp_tube_async_cb,
- "closing tube", NULL, NULL);
- g_object_unref (priv->channel);
- }
- if (priv->initiator_contact)
- g_object_unref (priv->initiator_contact);
- if (priv->factory)
- g_object_unref (priv->factory);
-
- g_free (priv->service);
-
- if (priv->parameters != NULL)
- g_hash_table_destroy (priv->parameters);
-
- G_OBJECT_CLASS (empathy_tp_tube_parent_class)->finalize (object);
-}
-
-static void
-empathy_tp_tube_class_init (EmpathyTpTubeClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = tp_tube_constructor;
- object_class->finalize = tp_tube_finalize;
- object_class->set_property = tp_tube_set_property;
- object_class->get_property = tp_tube_get_property;
-
- g_object_class_install_property (object_class, PROP_CHANNEL,
- g_param_spec_object ("channel", "channel", "channel", TP_TYPE_CHANNEL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property (object_class, PROP_STATE,
- g_param_spec_uint ("state", "state", "state", 0, G_MAXUINT, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
-
- signals[DESTROY] = g_signal_new ("destroy",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (EmpathyTpTubePriv));
-}
-
-static void
-empathy_tp_tube_init (EmpathyTpTube *tube)
-{
- EmpathyTpTubePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (tube,
- EMPATHY_TYPE_TP_TUBE, EmpathyTpTubePriv);
-
- tube->priv = priv;
-
- priv->factory = empathy_contact_factory_dup_singleton ();
-}
-
-EmpathyTpTube *
-empathy_tp_tube_new (TpChannel *channel)
-{
- g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
-
- return g_object_new (EMPATHY_TYPE_TP_TUBE, "channel", channel, NULL);
-}
-
-EmpathyTpTube *
-empathy_tp_tube_new_stream_tube (EmpathyContact *contact,
- TpSocketAddressType type,
- const gchar *hostname,
- guint port,
- const gchar *service,
- GHashTable *parameters)
-{
- MissionControl *mc;
- McAccount *account;
- TpConnection *connection;
- TpChannel *channel;
- gchar *object_path;
- GHashTable *params;
- GValue *address;
- GValue *control_param;
- EmpathyTpTube *tube = NULL;
- GError *error = NULL;
- GHashTable *request;
- GHashTable *channel_properties;
- GValue *value;
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
- g_return_val_if_fail (hostname != NULL, NULL);
- g_return_val_if_fail (service != NULL, NULL);
-
- mc = empathy_mission_control_dup_singleton ();
- account = empathy_contact_get_account (contact);
- connection = mission_control_get_tpconnection (mc, account, NULL);
- g_object_unref (mc);
-
- tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
-
- request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- /* org.freedesktop.Telepathy.Channel.ChannelType */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value);
-
- /* org.freedesktop.Telepathy.Channel.TargetHandleType */
- value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value);
-
- /* org.freedesktop.Telepathy.Channel.TargetHandleType */
- value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (value, empathy_contact_get_handle (contact));
- g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value);
-
- /* org.freedesktop.Telepathy.Channel.Type.StreamTube.Service */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_string (value, service);
- g_hash_table_insert (request,
- EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service", value);
-
- if (!tp_cli_connection_interface_requests_run_create_channel (connection, -1,
- request, &object_path, &channel_properties, &error, NULL))
- {
- DEBUG ("Error requesting channel: %s", error->message);
- g_clear_error (&error);
- g_object_unref (connection);
- return NULL;
- }
-
- DEBUG ("Offering a new stream tube");
-
- channel = tp_channel_new_from_properties (connection, object_path,
- channel_properties, NULL);
-
- tp_channel_run_until_ready (channel, NULL, NULL);
-
- #define ADDRESS_TYPE dbus_g_type_get_struct ("GValueArray",\
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)
- params = g_hash_table_new (g_str_hash, g_str_equal);
- address = tp_g_value_slice_new (ADDRESS_TYPE);
- g_value_take_boxed (address, dbus_g_type_specialized_construct (ADDRESS_TYPE));
- dbus_g_type_struct_set (address, 0, hostname, 1, port, G_MAXUINT);
- control_param = tp_g_value_slice_new (G_TYPE_STRING);
-
- if (!emp_cli_channel_type_stream_tube_run_offer_stream_tube (
- TP_PROXY(channel), -1, type, address,
- TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, parameters,
- &error, NULL))
- {
- DEBUG ("Couldn't offer tube: %s", error->message);
- g_clear_error (&error);
- goto OUT;
- }
-
- DEBUG ("Stream tube offered");
-
- tube = empathy_tp_tube_new (channel);
-
-OUT:
- g_object_unref (channel);
- g_free (object_path);
- g_hash_table_destroy (request);
- g_hash_table_destroy (channel_properties);
- tp_g_value_slice_free (address);
- tp_g_value_slice_free (control_param);
- g_object_unref (connection);
-
- return tube;
-}
-
-static void
-tp_tube_accept_stream_cb (TpProxy *proxy,
- const GValue *address,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpTube *tube = EMPATHY_TP_TUBE (weak_object);
- EmpathyTpTubeAcceptData *data = (EmpathyTpTubeAcceptData *)user_data;
- EmpathyTpTubeAddress eaddress;
-
- eaddress.type = data->type;
-
- if (error)
- {
- DEBUG ("Error accepting tube: %s", error->message);
- data->callback (tube, NULL, error, data->user_data);
- return;
- }
-
- switch (eaddress.type)
- {
- case TP_SOCKET_ADDRESS_TYPE_UNIX:
- case TP_SOCKET_ADDRESS_TYPE_ABSTRACT_UNIX:
- eaddress.a.socket.path = g_value_get_boxed (address);
- break;
- case TP_SOCKET_ADDRESS_TYPE_IPV4:
- case TP_SOCKET_ADDRESS_TYPE_IPV6:
- dbus_g_type_struct_get (address,
- 0, &eaddress.a.inet.hostname,
- 1, &eaddress.a.inet.port, G_MAXUINT);
- break;
- }
-
- data->callback (tube, &eaddress, NULL, data->user_data);
-}
-
-void
-empathy_tp_tube_accept_stream_tube (EmpathyTpTube *tube,
- TpSocketAddressType type, EmpatyTpTubeAcceptStreamTubeCb *callback,
- gpointer user_data)
-{
- EmpathyTpTubePriv *priv = GET_PRIV (tube);
- GValue *control_param;
- EmpathyTpTubeAcceptData *data;
-
- g_return_if_fail (EMPATHY_IS_TP_TUBE (tube));
-
- DEBUG ("Accepting stream tube");
- /* FIXME allow other acls */
- control_param = tp_g_value_slice_new (G_TYPE_STRING);
-
- data = new_empathy_tp_tube_accept_data (type, callback, user_data);
-
- emp_cli_channel_type_stream_tube_call_accept_stream_tube (
- TP_PROXY (priv->channel), -1, type, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
- control_param, tp_tube_accept_stream_cb, data,
- free_empathy_tp_tube_accept_data, G_OBJECT (tube));
-
- tp_g_value_slice_free (control_param);
-}
diff --git a/libempathy/empathy-tp-tube.h b/libempathy/empathy-tp-tube.h
deleted file mode 100644
index 8e63945e5..000000000
--- a/libempathy/empathy-tp-tube.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
- * Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_TP_TUBE_H__
-#define __EMPATHY_TP_TUBE_H__
-
-#include <glib-object.h>
-
-#include <telepathy-glib/channel.h>
-
-#include "empathy-contact.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TP_TUBE (empathy_tp_tube_get_type ())
-#define EMPATHY_TP_TUBE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), \
- EMPATHY_TYPE_TP_TUBE, EmpathyTpTube))
-#define EMPATHY_TP_TUBE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
- EMPATHY_TYPE_TP_TUBE, EmpathyTpTubeClass))
-#define EMPATHY_IS_TP_TUBE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), \
- EMPATHY_TYPE_TP_TUBE))
-#define EMPATHY_IS_TP_TUBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- EMPATHY_TYPE_TP_TUBE))
-#define EMPATHY_TP_TUBE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), \
- EMPATHY_TYPE_TP_TUBE, EmpathyTpTubeClass))
-
-typedef struct _EmpathyTpTube EmpathyTpTube;
-typedef struct _EmpathyTpTubeClass EmpathyTpTubeClass;
-
-typedef struct {
- TpSocketAddressType type;
- union {
- struct socket_address_t {
- GArray *path;
- } socket;
- struct inet_address_t {
- gchar *hostname;
- guint port;
- } inet;
- } a;
-} EmpathyTpTubeAddress;
-
-struct _EmpathyTpTube {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyTpTubeClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tp_tube_get_type (void) G_GNUC_CONST;
-EmpathyTpTube *empathy_tp_tube_new (TpChannel *channel);
-EmpathyTpTube *empathy_tp_tube_new_stream_tube (EmpathyContact *contact,
- TpSocketAddressType type, const gchar *hostname, guint port,
- const gchar *service, GHashTable *parameters);
-
-typedef void (EmpatyTpTubeAcceptStreamTubeCb) (EmpathyTpTube *tube,
- const EmpathyTpTubeAddress *address, const GError *error,
- gpointer user_data);
-
-void empathy_tp_tube_accept_stream_tube (EmpathyTpTube *tube,
- TpSocketAddressType type, EmpatyTpTubeAcceptStreamTubeCb *callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TP_TUBE_H__ */
diff --git a/libempathy/empathy-tube-handler.c b/libempathy/empathy-tube-handler.c
deleted file mode 100644
index 4fb82177d..000000000
--- a/libempathy/empathy-tube-handler.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/util.h>
-
-#include <extensions/extensions.h>
-
-#include "empathy-tp-tube.h"
-#include "empathy-tube-handler.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-static void empathy_tube_handler_iface_init (EmpSvcTubeHandlerClass *klass);
-
-enum
-{
- NEW_TUBE,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyTubeHandler, empathy_tube_handler,
- G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_TUBE_HANDLER,
- empathy_tube_handler_iface_init))
-
-typedef struct
-{
- EmpathyTubeHandler *thandler;
- gchar *bus_name;
- gchar *connection;
- gchar *channel;
- guint handle_type;
- guint handle;
-} IdleData;
-
-static gboolean
-tube_handler_handle_tube_idle_cb (gpointer data)
-{
- IdleData *idle_data = data;
- TpConnection *connection;
- TpChannel *channel;
- EmpathyTpTube *tube;
- static TpDBusDaemon *daemon = NULL;
-
- DEBUG ("New tube to be handled");
-
- if (!daemon)
- daemon = tp_dbus_daemon_new (tp_get_bus ());
-
- connection = tp_connection_new (daemon, idle_data->bus_name,
- idle_data->connection, NULL);
- channel = tp_channel_new (connection, idle_data->channel,
- TP_IFACE_CHANNEL_TYPE_TUBES, idle_data->handle_type,
- idle_data->handle, NULL);
- tp_channel_run_until_ready (channel, NULL, NULL);
-
- tube = empathy_tp_tube_new (channel);
- g_signal_emit (idle_data->thandler, signals[NEW_TUBE], 0, tube);
-
- g_object_unref (tube);
- g_object_unref (channel);
- g_object_unref (connection);
- g_free (idle_data->bus_name);
- g_free (idle_data->connection);
- g_free (idle_data->channel);
- g_slice_free (IdleData, idle_data);
-
- return FALSE;
-}
-
-static void
-tube_handler_handle_tube (EmpSvcTubeHandler *self,
- const gchar *bus_name,
- const gchar *connection,
- const gchar *channel,
- guint handle_type,
- guint handle,
- DBusGMethodInvocation *context)
-{
- EmpathyTubeHandler *thandler = EMPATHY_TUBE_HANDLER (self);
- IdleData *data;
-
- data = g_slice_new (IdleData);
- data->thandler = thandler;
- data->bus_name = g_strdup (bus_name);
- data->connection = g_strdup (connection);
- data->channel = g_strdup (channel);
- data->handle_type = handle_type;
- data->handle = handle;
-
- g_idle_add_full (G_PRIORITY_HIGH, tube_handler_handle_tube_idle_cb,
- data, NULL);
-
- emp_svc_tube_handler_return_from_handle_tube (context);
-}
-
-static void
-empathy_tube_handler_class_init (EmpathyTubeHandlerClass *klass)
-{
- signals[NEW_TUBE] =
- g_signal_new ("new-tube", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, EMPATHY_TYPE_TP_TUBE);
-}
-
-static void
-empathy_tube_handler_iface_init (EmpSvcTubeHandlerClass *klass)
-{
- emp_svc_tube_handler_implement_handle_tube (klass,
- tube_handler_handle_tube);
-}
-
-static void
-empathy_tube_handler_init (EmpathyTubeHandler *thandler)
-{
-}
-
-EmpathyTubeHandler *
-empathy_tube_handler_new (TpTubeType type, const gchar *service)
-{
- EmpathyTubeHandler *thandler = NULL;
- DBusGProxy *proxy;
- guint result;
- gchar *bus_name;
- gchar *object_path;
- GError *error = NULL;
-
- g_return_val_if_fail (type < NUM_TP_TUBE_TYPES, NULL);
- g_return_val_if_fail (service != NULL, NULL);
-
- bus_name = empathy_tube_handler_build_bus_name (type, service);
- object_path = empathy_tube_handler_build_object_path (type, service);
-
- proxy = dbus_g_proxy_new_for_name (tp_get_bus (), DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-
- if (!dbus_g_proxy_call (proxy, "RequestName", &error,
- G_TYPE_STRING, bus_name, G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
- G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID))
- {
- DEBUG ("Failed to request name: %s",
- error ? error->message : "No error given");
- g_clear_error (&error);
- goto OUT;
- }
-
- DEBUG ("Creating tube handler %s", bus_name);
- thandler = g_object_new (EMPATHY_TYPE_TUBE_HANDLER, NULL);
- dbus_g_connection_register_g_object (tp_get_bus (), object_path,
- G_OBJECT (thandler));
-
-OUT:
- g_object_unref (proxy);
- g_free (bus_name);
- g_free (object_path);
-
- return thandler;
-}
-
-gchar *
-empathy_tube_handler_build_bus_name (TpTubeType type,
- const gchar *service)
-{
- gchar *str = NULL;
- const gchar *prefix = NULL;
-
- g_return_val_if_fail (type < NUM_TP_TUBE_TYPES, NULL);
- g_return_val_if_fail (service != NULL, NULL);
-
- if (type == TP_TUBE_TYPE_DBUS)
- prefix = "org.gnome.Empathy.DTubeHandler.";
- else if (type == TP_TUBE_TYPE_STREAM)
- prefix = "org.gnome.Empathy.StreamTubeHandler.";
- else
- g_return_val_if_reached (NULL);
-
- str = g_strconcat (prefix, service, NULL);
-
- return str;
-}
-
-gchar *
-empathy_tube_handler_build_object_path (TpTubeType type,
- const gchar *service)
-{
- gchar *bus_name;
- gchar *str;
-
- g_return_val_if_fail (type < NUM_TP_TUBE_TYPES, NULL);
- g_return_val_if_fail (service != NULL, NULL);
-
- bus_name = empathy_tube_handler_build_bus_name (type, service);
- str = g_strdelimit (g_strdup_printf ("/%s", bus_name), ".", '/');
- g_free (bus_name);
-
- return str;
-}
-
diff --git a/libempathy/empathy-tube-handler.h b/libempathy/empathy-tube-handler.h
deleted file mode 100644
index f20527a68..000000000
--- a/libempathy/empathy-tube-handler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Elliot Fairweather <elliot.fairweather@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_TUBE_HANDLER_H__
-#define __EMPATHY_TUBE_HANDLER_H__
-
-#include <glib.h>
-
-#include <telepathy-glib/enums.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_TUBE_HANDLER (empathy_tube_handler_get_type ())
-#define EMPATHY_TUBE_HANDLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- EMPATHY_TYPE_TUBE_HANDLER, EmpathyTubeHandler))
-#define EMPATHY_TUBE_HANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
- EMPATHY_TYPE_TUBE_HANDLER, EmpathyTubeHandlerClass))
-#define EMPATHY_IS_TUBE_HANDLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- EMPATHY_TYPE_TUBE_HANDLER))
-#define EMPATHY_IS_TUBE_HANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- EMPATHY_TYPE_TUBE_HANDLER))
-#define EMPATHY_TUBE_HANDLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- EMPATHY_TYPE_TUBE_HANDLER, EmpathyTubeHandlerClass))
-
-typedef struct _EmpathyTubeHandler EmpathyTubeHandler;
-typedef struct _EmpathyTubeHandlerClass EmpathyTubeHandlerClass;
-
-struct _EmpathyTubeHandler {
- GObject parent;
-};
-
-struct _EmpathyTubeHandlerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_tube_handler_get_type (void) G_GNUC_CONST;
-EmpathyTubeHandler *empathy_tube_handler_new (TpTubeType type,
- const gchar *service);
-gchar *empathy_tube_handler_build_bus_name (TpTubeType type,
- const gchar *service);
-gchar *empathy_tube_handler_build_object_path (TpTubeType type,
- const gchar *service);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_TUBE_HANDLER_H__ */
diff --git a/libempathy/empathy-types.h b/libempathy/empathy-types.h
deleted file mode 100644
index b124924d4..000000000
--- a/libempathy/empathy-types.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_TYPES_H__
-#define __EMPATHY_TYPES_H__
-
-typedef struct _EmpathyContactList EmpathyContactList;
-
-typedef struct _EmpathyContactMonitor EmpathyContactMonitor;
-
-#endif /* __EMPATHY_TYPES_H__ */
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
deleted file mode 100644
index a476d9e54..000000000
--- a/libempathy/empathy-utils.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Richard Hult <richard@imendio.com>
- * Martyn Russell <martyn@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <libxml/uri.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/dbus.h>
-
-#include "empathy-utils.h"
-#include "empathy-contact-factory.h"
-#include "empathy-contact-manager.h"
-#include "empathy-dispatcher.h"
-#include "empathy-dispatch-operation.h"
-#include "empathy-idle.h"
-#include "empathy-tp-call.h"
-
-#include <extensions/extensions.h>
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include "empathy-debug.h"
-
-
-void
-empathy_init (void)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- g_type_init ();
-
- /* Setup gettext */
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- /* Setup debug output for empathy and telepathy-glib */
- if (g_getenv ("EMPATHY_TIMING") != NULL) {
- g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
- }
- empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
- tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
-
- emp_cli_init ();
-
- initialized = TRUE;
-}
-
-gchar *
-empathy_substring (const gchar *str,
- gint start,
- gint end)
-{
- return g_strndup (str + start, end - start);
-}
-
-gint
-empathy_strcasecmp (const gchar *s1,
- const gchar *s2)
-{
- return empathy_strncasecmp (s1, s2, -1);
-}
-
-gint
-empathy_strncasecmp (const gchar *s1,
- const gchar *s2,
- gsize n)
-{
- gchar *u1, *u2;
- gint ret_val;
-
- u1 = g_utf8_casefold (s1, n);
- u2 = g_utf8_casefold (s2, n);
-
- ret_val = g_utf8_collate (u1, u2);
- g_free (u1);
- g_free (u2);
-
- return ret_val;
-}
-
-gboolean
-empathy_xml_validate (xmlDoc *doc,
- const gchar *dtd_filename)
-{
- gchar *path, *escaped;
- xmlValidCtxt cvp;
- xmlDtd *dtd;
- gboolean ret;
-
- path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy",
- dtd_filename, NULL);
- if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
- g_free (path);
- path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL);
- }
- DEBUG ("Loading dtd file %s", path);
-
- /* The list of valid chars is taken from libxml. */
- escaped = xmlURIEscapeStr (path, ":@&=+$,/?;");
- g_free (path);
-
- memset (&cvp, 0, sizeof (cvp));
- dtd = xmlParseDTD (NULL, escaped);
- ret = xmlValidateDtd (&cvp, doc, dtd);
-
- xmlFree (escaped);
- xmlFreeDtd (dtd);
-
- return ret;
-}
-
-xmlNodePtr
-empathy_xml_node_get_child (xmlNodePtr node,
- const gchar *child_name)
-{
- xmlNodePtr l;
-
- g_return_val_if_fail (node != NULL, NULL);
- g_return_val_if_fail (child_name != NULL, NULL);
-
- for (l = node->children; l; l = l->next) {
- if (l->name && strcmp (l->name, child_name) == 0) {
- return l;
- }
- }
-
- return NULL;
-}
-
-xmlChar *
-empathy_xml_node_get_child_content (xmlNodePtr node,
- const gchar *child_name)
-{
- xmlNodePtr l;
-
- g_return_val_if_fail (node != NULL, NULL);
- g_return_val_if_fail (child_name != NULL, NULL);
-
- l = empathy_xml_node_get_child (node, child_name);
- if (l) {
- return xmlNodeGetContent (l);
- }
-
- return NULL;
-}
-
-xmlNodePtr
-empathy_xml_node_find_child_prop_value (xmlNodePtr node,
- const gchar *prop_name,
- const gchar *prop_value)
-{
- xmlNodePtr l;
- xmlNodePtr found = NULL;
-
- g_return_val_if_fail (node != NULL, NULL);
- g_return_val_if_fail (prop_name != NULL, NULL);
- g_return_val_if_fail (prop_value != NULL, NULL);
-
- for (l = node->children; l && !found; l = l->next) {
- xmlChar *prop;
-
- if (!xmlHasProp (l, prop_name)) {
- continue;
- }
-
- prop = xmlGetProp (l, prop_name);
- if (prop && strcmp (prop, prop_value) == 0) {
- found = l;
- }
-
- xmlFree (prop);
- }
-
- return found;
-}
-
-guint
-empathy_account_hash (gconstpointer key)
-{
- g_return_val_if_fail (MC_IS_ACCOUNT (key), 0);
-
- return g_str_hash (mc_account_get_unique_name (MC_ACCOUNT (key)));
-}
-
-gboolean
-empathy_account_equal (gconstpointer a,
- gconstpointer b)
-{
- const gchar *name_a;
- const gchar *name_b;
-
- g_return_val_if_fail (MC_IS_ACCOUNT (a), FALSE);
- g_return_val_if_fail (MC_IS_ACCOUNT (b), FALSE);
-
- name_a = mc_account_get_unique_name (MC_ACCOUNT (a));
- name_b = mc_account_get_unique_name (MC_ACCOUNT (b));
-
- return g_str_equal (name_a, name_b);
-}
-
-MissionControl *
-empathy_mission_control_dup_singleton (void)
-{
- static MissionControl *mc = NULL;
-
- if (!mc) {
- mc = mission_control_new (tp_get_bus ());
- g_object_add_weak_pointer (G_OBJECT (mc), (gpointer) &mc);
- } else {
- g_object_ref (mc);
- }
-
- return mc;
-}
-
-const gchar *
-empathy_presence_get_default_message (McPresence presence)
-{
- switch (presence) {
- case MC_PRESENCE_AVAILABLE:
- return _("Available");
- case MC_PRESENCE_DO_NOT_DISTURB:
- return _("Busy");
- case MC_PRESENCE_AWAY:
- case MC_PRESENCE_EXTENDED_AWAY:
- return _("Away");
- case MC_PRESENCE_HIDDEN:
- return _("Hidden");
- case MC_PRESENCE_OFFLINE:
- case MC_PRESENCE_UNSET:
- return _("Offline");
- default:
- g_assert_not_reached ();
- }
-
- return NULL;
-}
-
-const gchar *
-empathy_presence_to_str (McPresence presence)
-{
- switch (presence) {
- case MC_PRESENCE_AVAILABLE:
- return "available";
- case MC_PRESENCE_DO_NOT_DISTURB:
- return "busy";
- case MC_PRESENCE_AWAY:
- return "away";
- case MC_PRESENCE_EXTENDED_AWAY:
- return "ext_away";
- case MC_PRESENCE_HIDDEN:
- return "hidden";
- case MC_PRESENCE_OFFLINE:
- return "offline";
- case MC_PRESENCE_UNSET:
- return "unset";
- default:
- g_assert_not_reached ();
- }
-
- return NULL;
-}
-
-McPresence
-empathy_presence_from_str (const gchar *str)
-{
- if (strcmp (str, "available") == 0) {
- return MC_PRESENCE_AVAILABLE;
- } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
- return MC_PRESENCE_DO_NOT_DISTURB;
- } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
- return MC_PRESENCE_AWAY;
- } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) {
- return MC_PRESENCE_EXTENDED_AWAY;
- } else if (strcmp (str, "hidden") == 0) {
- return MC_PRESENCE_HIDDEN;
- } else if (strcmp (str, "offline") == 0) {
- return MC_PRESENCE_OFFLINE;
- } else if (strcmp (str, "unset") == 0) {
- return MC_PRESENCE_UNSET;
- }
-
- return MC_PRESENCE_UNSET;
-}
-
-gchar *
-empathy_file_lookup (const gchar *filename, const gchar *subdir)
-{
- gchar *path;
-
- if (!subdir) {
- subdir = ".";
- }
-
- path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), subdir, filename, NULL);
- if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
- g_free (path);
- path = g_build_filename (DATADIR, "empathy", filename, NULL);
- }
-
- return path;
-}
-
-typedef struct {
- EmpathyRunUntilReadyFunc func;
- gpointer user_data;
- GObject *object;
- GMainLoop *loop;
-} RunUntilReadyData;
-
-static void
-run_until_ready_cb (RunUntilReadyData *data)
-{
- if (!data->func || data->func (data->object, data->user_data)) {
- DEBUG ("Object %p is ready", data->object);
- g_main_loop_quit (data->loop);
- }
-}
-
-static gboolean
-object_is_ready (GObject *object,
- gpointer user_data)
-{
- gboolean ready;
-
- g_object_get (object, "ready", &ready, NULL);
-
- return ready;
-}
-
-void
-empathy_run_until_ready_full (gpointer object,
- const gchar *signal,
- EmpathyRunUntilReadyFunc func,
- gpointer user_data,
- GMainLoop **loop)
-{
- RunUntilReadyData data;
- gulong signal_id;
-
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (signal != NULL);
-
- if (func && func (object, user_data)) {
- return;
- }
-
- DEBUG ("Starting run until ready for object %p", object);
-
- data.func = func;
- data.user_data = user_data;
- data.object = object;
- data.loop = g_main_loop_new (NULL, FALSE);
-
- signal_id = g_signal_connect_swapped (object, signal,
- G_CALLBACK (run_until_ready_cb),
- &data);
- if (loop != NULL) {
- *loop = data.loop;
- }
-
- g_main_loop_run (data.loop);
-
- if (loop != NULL) {
- *loop = NULL;
- }
-
- g_signal_handler_disconnect (object, signal_id);
- g_main_loop_unref (data.loop);
-}
-
-void
-empathy_run_until_ready (gpointer object)
-{
- empathy_run_until_ready_full (object, "notify::ready", object_is_ready,
- NULL, NULL);
-}
-
-McAccount *
-empathy_channel_get_account (TpChannel *channel)
-{
- TpConnection *connection;
- McAccount *account;
- MissionControl *mc;
-
- g_object_get (channel, "connection", &connection, NULL);
- mc = empathy_mission_control_dup_singleton ();
- account = mission_control_get_account_for_tpconnection (mc, connection, NULL);
- g_object_unref (connection);
- g_object_unref (mc);
-
- return account;
-}
-
-guint
-empathy_proxy_hash (gconstpointer key)
-{
- TpProxy *proxy = TP_PROXY (key);
- TpProxyClass *proxy_class = TP_PROXY_GET_CLASS (key);
-
- g_return_val_if_fail (TP_IS_PROXY (proxy), 0);
- g_return_val_if_fail (proxy_class->must_have_unique_name, 0);
-
- return g_str_hash (proxy->object_path) ^ g_str_hash (proxy->bus_name);
-}
-
-gboolean
-empathy_proxy_equal (gconstpointer a,
- gconstpointer b)
-{
- TpProxy *proxy_a = TP_PROXY (a);
- TpProxy *proxy_b = TP_PROXY (b);
- TpProxyClass *proxy_a_class = TP_PROXY_GET_CLASS (a);
- TpProxyClass *proxy_b_class = TP_PROXY_GET_CLASS (b);
-
- g_return_val_if_fail (TP_IS_PROXY (proxy_a), FALSE);
- g_return_val_if_fail (TP_IS_PROXY (proxy_b), FALSE);
- g_return_val_if_fail (proxy_a_class->must_have_unique_name, 0);
- g_return_val_if_fail (proxy_b_class->must_have_unique_name, 0);
-
- return g_str_equal (proxy_a->object_path, proxy_b->object_path) &&
- g_str_equal (proxy_a->bus_name, proxy_b->bus_name);
-}
-
-gboolean
-empathy_check_available_state (void)
-{
- McPresence presence;
- EmpathyIdle *idle;
-
- idle = empathy_idle_dup_singleton ();
- presence = empathy_idle_get_state (idle);
- g_object_unref (idle);
-
- if (presence != MC_PRESENCE_AVAILABLE &&
- presence != MC_PRESENCE_UNSET) {
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
deleted file mode 100644
index 8684acc00..000000000
--- a/libempathy/empathy-utils.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Richard Hult <richard@imendio.com>
- * Martyn Russell <martyn@imendio.com>
- * Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_UTILS_H__
-#define __EMPATHY_UTILS_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <libmissioncontrol/mc-account.h>
-#include <libmissioncontrol/mission-control.h>
-
-#include "empathy-contact.h"
-
-#define EMPATHY_GET_PRIV(obj,type) ((type##Priv*) ((type*)obj)->priv)
-#define EMP_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
-
-G_BEGIN_DECLS
-
-void empathy_init (void);
-/* Strings */
-gchar * empathy_substring (const gchar *str,
- gint start,
- gint end);
-gint empathy_strcasecmp (const gchar *s1,
- const gchar *s2);
-gint empathy_strncasecmp (const gchar *s1,
- const gchar *s2,
- gsize n);
-
-/* XML */
-gboolean empathy_xml_validate (xmlDoc *doc,
- const gchar *dtd_filename);
-xmlNodePtr empathy_xml_node_get_child (xmlNodePtr node,
- const gchar *child_name);
-xmlChar * empathy_xml_node_get_child_content (xmlNodePtr node,
- const gchar *child_name);
-xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node,
- const gchar *prop_name,
- const gchar *prop_value);
-
-/* Others */
-guint empathy_account_hash (gconstpointer key);
-gboolean empathy_account_equal (gconstpointer a,
- gconstpointer b);
-MissionControl *empathy_mission_control_dup_singleton (void);
-const gchar * empathy_presence_get_default_message (McPresence presence);
-const gchar * empathy_presence_to_str (McPresence presence);
-McPresence empathy_presence_from_str (const gchar *str);
-gchar * empathy_file_lookup (const gchar *filename,
- const gchar *subdir);
-
-typedef gboolean (*EmpathyRunUntilReadyFunc) (GObject *object,
- gpointer user_data);
-void empathy_run_until_ready (gpointer object);
-void empathy_run_until_ready_full (gpointer object,
- const gchar *signal,
- EmpathyRunUntilReadyFunc func,
- gpointer user_data,
- GMainLoop **loop);
-McAccount * empathy_channel_get_account (TpChannel *channel);
-gboolean empathy_proxy_equal (gconstpointer a,
- gconstpointer b);
-guint empathy_proxy_hash (gconstpointer key);
-gboolean empathy_check_available_state (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_UTILS_H__ */
diff --git a/libempathy/irc-networks.xml b/libempathy/irc-networks.xml
deleted file mode 100644
index 7a9d96bdc..000000000
--- a/libempathy/irc-networks.xml
+++ /dev/null
@@ -1,542 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<networks>
- <network name="Debian Servers" id="debian_servers">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.debian.org"/>
- </servers>
- </network>
- <network name="Ubuntu Servers" id="ubuntu_servers">
- <servers>
- <server ssl="FALSE" port="8001" address="irc.ubuntu.com"/>
- </servers>
- </network>
- <network name="2600net" id="a2600net">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.2600.net"/>
- </servers>
- </network>
- <network name="AccessIRC" id="accessirc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.accessirc.net"/>
- <server ssl="FALSE" port="6667" address="eu.accessirc.net"/>
- </servers>
- </network>
- <network name="AfterNET" id="afternet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.afternet.org"/>
- <server ssl="FALSE" port="6667" address="us.afternet.org"/>
- <server ssl="FALSE" port="6667" address="eu.afternet.org"/>
- </servers>
- </network>
- <network name="Aitvaras" id="aitvaras">
- <servers>
- <server ssl="TRUE" port="6668" address="irc.data.lt"/>
- <server ssl="TRUE" port="6668" address="irc-ssl.omnitel.net"/>
- <server ssl="TRUE" port="9999" address="irc-ssl.le.lt"/>
- <server ssl="FALSE" port="6667" address="irc.data.lt"/>
- <server ssl="FALSE" port="6667" address="irc.omnitel.net"/>
- <server ssl="FALSE" port="6667" address="irc.ktu.lt"/>
- <server ssl="FALSE" port="6667" address="irc.le.lt"/>
- <server ssl="FALSE" port="6667" address="irc.takas.lt"/>
- <server ssl="FALSE" port="6667" address="irc.5ci.net"/>
- <server ssl="FALSE" port="6667" address="irc.kis.lt"/>
- </servers>
- </network>
- <network name="AmigaNet" id="amiganet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.amiganet.org"/>
- <server ssl="FALSE" port="6667" address="us.amiganet.org"/>
- <server ssl="FALSE" port="6667" address="uk.amiganet.org"/>
- </servers>
- </network>
- <network name="ARCNet" id="arcnet">
- <servers>
- <server ssl="FALSE" port="6667" address="se1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="us1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="us2.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="us3.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="ca1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="de1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="de3.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="ch1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="be1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="nl3.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="uk1.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="uk2.arcnet.vapor.com"/>
- <server ssl="FALSE" port="6667" address="fr1.arcnet.vapor.com"/>
- </servers>
- </network>
- <network name="AstroLink" id="astrolink">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.astrolink.org"/>
- </servers>
- </network>
- <network name="AustNet" id="austnet">
- <servers>
- <server ssl="FALSE" port="6667" address="au.austnet.org"/>
- <server ssl="FALSE" port="6667" address="us.austnet.org"/>
- <server ssl="FALSE" port="6667" address="ca.austnet.org"/>
- </servers>
- </network>
- <network name="AzzurraNet" id="azzurranet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.azzurra.org"/>
- <server ssl="FALSE" port="6667" address="crypto.azzurra.org"/>
- </servers>
- </network>
- <network name="Beirut" id="beirut">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.beirut.com"/>
- </servers>
- </network>
- <network name="ChatJunkies" id="chatjunkies">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.chatjunkies.org"/>
- <server ssl="FALSE" port="6667" address="nl.chatjunkies.org"/>
- </servers>
- </network>
- <network name="ChatNet" id="chatnet">
- <servers>
- <server ssl="FALSE" port="6667" address="US.ChatNet.Org"/>
- <server ssl="FALSE" port="6667" address="EU.ChatNet.Org"/>
- </servers>
- </network>
- <network name="ChatSociety" id="chatsociety">
- <servers>
- <server ssl="FALSE" port="6667" address="us.chatsociety.net"/>
- <server ssl="FALSE" port="6667" address="eu.chatsociety.net"/>
- </servers>
- </network>
- <network name="ChatSpike" id="chatspike">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.chatspike.net"/>
- </servers>
- </network>
- <network name="ChillFactory" id="chillfactory">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.chillfactory.net"/>
- </servers>
- </network>
- <network name="CoolChat" id="coolchat">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.coolchat.net"/>
- </servers>
- </network>
- <network name="Criten" id="criten">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.criten.net"/>
- <server ssl="FALSE" port="6667" address="irc.eu.criten.net"/>
- </servers>
- </network>
- <network name="DALnet" id="dalnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.dal.net"/>
- <server ssl="FALSE" port="6667" address="irc.eu.dal.net"/>
- </servers>
- </network>
- <network name="Dark-Tou-Net" id="dark-tou-net">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.d-t-net.de"/>
- <server ssl="FALSE" port="6667" address="bw.d-t-net.de"/>
- <server ssl="FALSE" port="6667" address="nc.d-t-net.de"/>
- <server ssl="FALSE" port="6667" address="wakka.d-t-net.de"/>
- </servers>
- </network>
- <network name="DarkMyst" id="darkmyst">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.darkmyst.org"/>
- </servers>
- </network>
- <network name="DeepIRC" id="deepirc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.deepirc.net"/>
- </servers>
- </network>
- <network name="DeltaAnime" id="deltaanime">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.deltaanime.net"/>
- </servers>
- </network>
- <network name="EFnet" id="efnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.blackened.com"/>
- <server ssl="FALSE" port="6667" address="irc.Prison.NET"/>
- <server ssl="FALSE" port="6667" address="irc.Qeast.net"/>
- <server ssl="FALSE" port="6667" address="irc.efnet.pl"/>
- <server ssl="FALSE" port="6667" address="efnet.demon.co.uk"/>
- <server ssl="FALSE" port="6667" address="irc.lightning.net"/>
- <server ssl="FALSE" port="6667" address="irc.mindspring.com"/>
- <server ssl="FALSE" port="6667" address="irc.easynews.com"/>
- <server ssl="FALSE" port="6667" address="irc.servercentral.net"/>
- </servers>
- </network>
- <network name="EnterTheGame" id="enterthegame">
- <servers>
- <server ssl="FALSE" port="6667" address="IRC.EnterTheGame.Com"/>
- </servers>
- </network>
- <network name="EUIrc" id="euirc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.ham.de.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.ber.de.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.ffm.de.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.bre.de.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.hes.de.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.vie.at.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.inn.at.euirc.net"/>
- <server ssl="FALSE" port="6667" address="irc.bas.ch.euirc.net"/>
- </servers>
- </network>
- <network name="EuropNet" id="europnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.europnet.org"/>
- </servers>
- </network>
- <network name="EU-IRC" id="eu-irc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.eu-irc.net"/>
- </servers>
- </network>
- <network name="FDFNet" id="fdfnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.fdfnet.net"/>
- <server ssl="FALSE" port="6667" address="irc.eu.fdfnet.net"/>
- </servers>
- </network>
- <network name="FEFNet" id="fefnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.fef.net"/>
- <server ssl="FALSE" port="6667" address="irc.ggn.net"/>
- <server ssl="FALSE" port="6667" address="irc.vendetta.com"/>
- </servers>
- </network>
- <network name="FreeNode" id="freenode">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.freenode.net"/>
- </servers>
- </network>
- <network name="GalaxyNet" id="galaxynet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.galaxynet.org"/>
- </servers>
- </network>
- <network name="GamesNET" id="gamesnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.gamesnet.net"/>
- <server ssl="FALSE" port="6667" address="irc.ca.gamesnet.net"/>
- <server ssl="FALSE" port="6667" address="irc.eu.gamesnet.net"/>
- </servers>
- </network>
- <network name="German-Elite" id="german-elite">
- <servers>
- <server ssl="FALSE" port="6667" address="dominion.german-elite.net"/>
- <server ssl="FALSE" port="6667" address="komatu.german-elite.net"/>
- </servers>
- </network>
- <network name="GimpNet" id="gimpnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.gimp.org"/>
- <server ssl="FALSE" port="6667" address="irc.us.gimp.org"/>
- </servers>
- </network>
- <network name="HabberNet" id="habbernet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.habber.net"/>
- </servers>
- </network>
- <network name="Hashmark" id="hashmark">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.hashmark.net"/>
- </servers>
- </network>
- <network name="IdleMonkeys" id="idlemonkeys">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.idlemonkeys.net"/>
- </servers>
- </network>
- <network name="insiderZ.DE" id="insiderz.de">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.insiderz.de"/>
- <server ssl="FALSE" port="6666" address="irc.insiderz.de"/>
- </servers>
- </network>
- <network name="IrcLink" id="irclink">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.irclink.net"/>
- <server ssl="FALSE" port="6667" address="Alesund.no.eu.irclink.net"/>
- <server ssl="FALSE" port="6667" address="Oslo.no.eu.irclink.net"/>
- <server ssl="FALSE" port="6667" address="frogn.no.eu.irclink.net"/>
- <server ssl="FALSE" port="6667" address="tonsberg.no.eu.irclink.net"/>
- </servers>
- </network>
- <network name="IRCNet" id="ircnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.ircnet.com"/>
- <server ssl="FALSE" port="6668" address="irc.stealth.net"/>
- <server ssl="FALSE" port="6667" address="ircnet.demon.co.uk"/>
- <server ssl="FALSE" port="6667" address="irc.datacomm.ch"/>
- <server ssl="FALSE" port="6667" address="random.ircd.de"/>
- <server ssl="FALSE" port="6667" address="ircnet.netvision.net.il"/>
- <server ssl="FALSE" port="6667" address="irc.cs.hut.fi"/>
- </servers>
- </network>
- <network name="Irctoo.net" id="irctoo.net">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.irctoo.net"/>
- </servers>
- </network>
- <network name="Krstarica" id="krstarica">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.krstarica.com"/>
- </servers>
- </network>
- <network name="Librenet" id="librenet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.librenet.net"/>
- <server ssl="FALSE" port="6667" address="ielf.fr.librenet.net"/>
- </servers>
- </network>
- <network name="LinkNet" id="linknet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.link-net.org"/>
- <server ssl="FALSE" port="6667" address="irc.no.link-net.org"/>
- <server ssl="FALSE" port="6667" address="irc.bahnhof.se"/>
- </servers>
- </network>
- <network name="MagicStar" id="magicstar">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.magicstar.net"/>
- </servers>
- </network>
- <network name="Majistic" id="majistic">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.majistic.net"/>
- </servers>
- </network>
- <network name="MindForge" id="mindforge">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.mindforge.org"/>
- </servers>
- </network>
- <network name="MIXXnet" id="mixxnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.mixxnet.net"/>
- </servers>
- </network>
- <network name="NeverNET" id="nevernet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.nevernet.net"/>
- <server ssl="FALSE" port="6667" address="imagine.nevernet.net"/>
- <server ssl="FALSE" port="6667" address="dimension.nevernet.net"/>
- <server ssl="FALSE" port="6667" address="universe.nevernet.net"/>
- <server ssl="FALSE" port="6667" address="wayland.nevernet.net"/>
- <server ssl="FALSE" port="6667" address="forte.nevernet.net"/>
- </servers>
- </network>
- <network name="NixHelpNet" id="nixhelpnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="us.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="uk.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="uk2.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="uk3.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="nl.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="ca.ld.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="us.co.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="us.ca.nixhelp.org"/>
- <server ssl="FALSE" port="6667" address="us.pa.nixhelp.org"/>
- </servers>
- </network>
- <network name="NullusNet" id="nullusnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.nullus.net"/>
- </servers>
- </network>
- <network name="Oceanius" id="oceanius">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.oceanius.com"/>
- </servers>
- </network>
- <network name="OFTC" id="oftc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.oftc.net"/>
- </servers>
- </network>
- <network name="OtherNet" id="othernet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.othernet.org"/>
- </servers>
- </network>
- <network name="Oz.org" id="oz.org">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.oz.org"/>
- <server ssl="FALSE" port="6667" address="germany.oz.org"/>
- <server ssl="FALSE" port="6667" address="sandiego.oz.org"/>
- <server ssl="FALSE" port="6667" address="us.oz.org"/>
- <server ssl="FALSE" port="6667" address="au.oz.org"/>
- <server ssl="FALSE" port="6667" address="rockhampton.oz.org"/>
- <server ssl="FALSE" port="6667" address="wollongong.oz.org"/>
- <server ssl="FALSE" port="6667" address="waix.oz.org"/>
- </servers>
- </network>
- <network name="PTlink" id="ptlink">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.PTlink.net"/>
- <server ssl="FALSE" port="6667" address="aaia.PTlink.net"/>
- </servers>
- </network>
- <network name="PTNe" id="ptne">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.PTNet.org"/>
- <server ssl="FALSE" port="6667" address="rccn.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="uevora.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="umoderna.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="ist.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="aaum.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="uc.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="ualg.ptnet.org"/>
- <server ssl="FALSE" port="6667" address="madinfo.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="ua.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="ipg.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="isec.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="utad.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="iscte.PTnet.org"/>
- <server ssl="FALSE" port="6667" address="ubi.PTnet.org"/>
- </servers>
- </network>
- <network name="QuakeNet" id="quakenet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.se.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.dk.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.no.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.fi.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.be.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.uk.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.de.quakenet.org"/>
- <server ssl="FALSE" port="6667" address="irc.it.quakenet.org"/>
- </servers>
- </network>
- <network name="RebelChat" id="rebelchat">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.rebelchat.org"/>
- </servers>
- </network>
- <network name="RizeNET" id="rizenet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.rizenet.org"/>
- <server ssl="FALSE" port="6667" address="omega.rizenet.org"/>
- <server ssl="FALSE" port="6667" address="evelance.rizenet.org"/>
- <server ssl="FALSE" port="6667" address="lisa.rizenet.org"/>
- <server ssl="FALSE" port="6667" address="scott.rizenet.org"/>
- </servers>
- </network>
- <network name="RusNet" id="rusnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.tomsk.net"/>
- <server ssl="FALSE" port="6667" address="irc.rinet.ru"/>
- <server ssl="FALSE" port="6667" address="irc.run.net"/>
- <server ssl="FALSE" port="6667" address="irc.ru"/>
- <server ssl="FALSE" port="6667" address="irc.lucky.net"/>
- </servers>
- </network>
- <network name="SceneNet" id="scenenet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.scene.org"/>
- <server ssl="FALSE" port="6667" address="irc.eu.scene.org"/>
- <server ssl="FALSE" port="6667" address="irc.us.scene.org"/>
- </servers>
- </network>
- <network name="SlashNET" id="slashnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.slashnet.org"/>
- <server ssl="FALSE" port="6667" address="area51.slashnet.org"/>
- <server ssl="FALSE" port="6667" address="moo.slashnet.org"/>
- <server ssl="FALSE" port="6667" address="radon.slashnet.org"/>
- </servers>
- </network>
- <network name="Sohbet.Net" id="sohbet.net">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.sohbet.net"/>
- </servers>
- </network>
- <network name="SolidIRC" id="solidirc">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.solidirc.com"/>
- </servers>
- </network>
- <network name="SorceryNet" id="sorcerynet">
- <servers>
- <server ssl="FALSE" port="9000" address="irc.sorcery.net"/>
- <server ssl="FALSE" port="9000" address="irc.us.sorcery.net"/>
- <server ssl="FALSE" port="9000" address="irc.eu.sorcery.net"/>
- </servers>
- </network>
- <network name="Spidernet" id="spidernet">
- <servers>
- <server ssl="FALSE" port="6667" address="us.spidernet.org"/>
- <server ssl="FALSE" port="6667" address="eu.spidernet.org"/>
- <server ssl="FALSE" port="6667" address="irc.spidernet.org"/>
- </servers>
- </network>
- <network name="StarChat" id="starchat">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.starchat.net"/>
- <server ssl="FALSE" port="6667" address="gainesville.starchat.net"/>
- <server ssl="FALSE" port="6667" address="freebsd.starchat.net"/>
- <server ssl="FALSE" port="6667" address="sunset.starchat.net"/>
- <server ssl="FALSE" port="6667" address="revenge.starchat.net"/>
- <server ssl="FALSE" port="6667" address="tahoma.starchat.net"/>
- <server ssl="FALSE" port="6667" address="neo.starchat.net"/>
- </servers>
- </network>
- <network name="TNI3" id="tni3">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.tni3.com"/>
- </servers>
- </network>
- <network name="UnderNet" id="undernet">
- <servers>
- <server ssl="FALSE" port="6667" address="us.undernet.org"/>
- <server ssl="FALSE" port="6667" address="eu.undernet.org"/>
- </servers>
- </network>
- <network name="UniBG" id="unibg">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.lirex.com"/>
- <server ssl="FALSE" port="6667" address="irc.naturella.com"/>
- <server ssl="FALSE" port="6667" address="irc.spnet.net"/>
- <server ssl="FALSE" port="6667" address="irc.techno-link.com"/>
- <server ssl="FALSE" port="6667" address="irc.telecoms.bg"/>
- <server ssl="FALSE" port="6667" address="irc.tu-varna.edu"/>
- </servers>
- </network>
- <network name="Whiffle" id="whiffle">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.whiffle.org"/>
- </servers>
- </network>
- <network name="Worldnet" id="worldnet">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.worldnet.net"/>
- <server ssl="FALSE" port="6667" address="irc.fr.worldnet.net"/>
- </servers>
- </network>
- <network name="Xentonix.net" id="xentonix.net">
- <servers>
- <server ssl="FALSE" port="6667" address="irc.ffm.de.eu.xentonix.net"/>
- <server ssl="FALSE" port="6667" address="irc.kar.de.eu.xentonix.net"/>
- <server ssl="FALSE" port="6667" address="irc.vie.at.eu.xentonix.net"/>
- </servers>
- </network>
- <network name="XWorld" id="xworld">
- <servers>
- <server ssl="FALSE" port="6667" address="Buffalo.NY.US.XWorld.org"/>
- <server ssl="FALSE" port="6667" address="Minneapolis.MN.US.Xworld.Org"/>
- <server ssl="FALSE" port="6667" address="Rochester.NY.US.XWorld.org"/>
- <server ssl="FALSE" port="6667" address="Bayern.DE.EU.XWorld.Org"/>
- <server ssl="FALSE" port="6667" address="Chicago.IL.US.XWorld.Org"/>
- </servers>
- </network>
-</networks>
diff --git a/libempathy/libempathy.pc.in b/libempathy/libempathy.pc.in
deleted file mode 100644
index a7245cc6c..000000000
--- a/libempathy/libempathy.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libempathy
-Description: Empathy base library
-Requires: pkg-config >= 0.21
-Requires.private: glib-2.0, gobject-2.0, libxml-2.0, libmissioncontrol, gio-2.0, gio-unix-2.0, telepathy-glib
-Version: @VERSION@
-Libs: -L${libdir} -lempathy
-Cflags: -I${includedir}