diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy/empathy-contact-list.c | 12 | ||||
-rw-r--r-- | libempathy/empathy-contact-list.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-contact-manager.c | 20 | ||||
-rw-r--r-- | libempathy/empathy-contact-monitor.c | 417 | ||||
-rw-r--r-- | libempathy/empathy-contact-monitor.h | 63 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 24 |
7 files changed, 0 insertions, 542 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 1f1423952..6d596beda 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -36,7 +36,6 @@ libempathy_headers = \ empathy-contact-groups.h \ empathy-contact-list.h \ empathy-contact-manager.h \ - empathy-contact-monitor.h \ empathy-contact.h \ empathy-debug.h \ empathy-dispatch-operation.h \ @@ -81,7 +80,6 @@ libempathy_la_SOURCES = \ empathy-contact-groups.c \ empathy-contact-list.c \ empathy-contact-manager.c \ - empathy-contact-monitor.c \ empathy-contact.c \ empathy-debug.c \ empathy-dispatch-operation.c \ diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 0a3d361d4..5cbe1cb15 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -143,18 +143,6 @@ empathy_contact_list_get_members (EmpathyContactList *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) { diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 8d2f445e1..3817af876 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -69,8 +69,6 @@ struct _EmpathyContactListIface { const gchar *new_group); void (*remove_group) (EmpathyContactList *list, const gchar *group); - EmpathyContactMonitor * - (*get_monitor) (EmpathyContactList *list); EmpathyContactListFlags (*get_flags) (EmpathyContactList *list); gboolean (*is_favourite) (EmpathyContactList *list, @@ -104,8 +102,6 @@ void empathy_contact_list_rename_group (EmpathyContactList *list, const gchar *new_group); void empathy_contact_list_remove_group (EmpathyContactList *list, const gchar *group); -EmpathyContactMonitor * - empathy_contact_list_get_monitor (EmpathyContactList *list); EmpathyContactListFlags empathy_contact_list_get_flags (EmpathyContactList *list); diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index e0b51aafa..a900fa610 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -31,7 +31,6 @@ #include <extensions/extensions.h> #include "empathy-contact-manager.h" -#include "empathy-contact-monitor.h" #include "empathy-contact-list.h" #include "empathy-utils.h" @@ -44,7 +43,6 @@ typedef struct { The contact list associated with each connected connection */ GHashTable *lists; TpAccountManager *account_manager; - EmpathyContactMonitor *contact_monitor; TpProxy *logger; /* account object path (gchar *) => GHashTable containing favorite contacts * (contact ID (gchar *) => TRUE) */ @@ -378,10 +376,6 @@ contact_manager_finalize (GObject *object) g_hash_table_destroy (priv->favourites); g_object_unref (priv->account_manager); - - if (priv->contact_monitor) { - g_object_unref (priv->contact_monitor); - } } static GObject * @@ -583,7 +577,6 @@ empathy_contact_manager_init (EmpathyContactManager *manager) g_hash_table_unref); priv->account_manager = tp_account_manager_dup (); - priv->contact_monitor = NULL; tp_account_manager_prepare_async (priv->account_manager, NULL, account_manager_prepared_cb, manager); @@ -698,18 +691,6 @@ contact_manager_get_members (EmpathyContactList *manager) 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 (TpConnection *connection, EmpathyTpContactList *list, @@ -889,7 +870,6 @@ 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; diff --git a/libempathy/empathy-contact-monitor.c b/libempathy/empathy-contact-monitor.c deleted file mode 100644 index f41b8bd5c..000000000 --- a/libempathy/empathy-contact-monitor.c +++ /dev/null @@ -1,417 +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 "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, - TpConnectionPresenceType current_presence, - TpConnectionPresenceType 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_UINT_UINT, - G_TYPE_NONE, - 3, EMPATHY_TYPE_CONTACT, - G_TYPE_UINT, - G_TYPE_UINT); - 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 51957d1d6..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-tp-chat.c b/libempathy/empathy-tp-chat.c index 485510214..daf24a36a 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -29,7 +29,6 @@ #include "empathy-tp-chat.h" #include "empathy-tp-contact-factory.h" -#include "empathy-contact-monitor.h" #include "empathy-contact-list.h" #include "empathy-dispatcher.h" #include "empathy-marshal.h" @@ -43,7 +42,6 @@ typedef struct { gboolean dispose_has_run; TpConnection *connection; - EmpathyContactMonitor *contact_monitor; EmpathyContact *user; EmpathyContact *remote_contact; GList *members; @@ -205,22 +203,6 @@ tp_chat_get_members (EmpathyContactList *list) 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 void tp_chat_emit_queued_messages (EmpathyTpChat *chat) { @@ -775,10 +757,6 @@ tp_chat_dispose (GObject *object) g_object_unref (priv->user); priv->user = NULL; - if (priv->contact_monitor) - g_object_unref (priv->contact_monitor); - priv->contact_monitor = NULL; - g_queue_foreach (priv->messages_queue, (GFunc) g_object_unref, NULL); g_queue_clear (priv->messages_queue); @@ -1493,7 +1471,6 @@ empathy_tp_chat_init (EmpathyTpChat *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 (); } @@ -1504,7 +1481,6 @@ 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 * |