diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-09 04:08:17 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-09 04:08:17 +0800 |
commit | ae195f5e93d0f92e0c7714b5b27be8d1740803aa (patch) | |
tree | 8db450d3c71386accb1948deb8727fb71fd56973 /libempathy | |
parent | f0f2ad9e9994d43ec6cbae068036e6dd6b76dea6 (diff) | |
download | gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar.gz gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar.bz2 gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar.lz gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar.xz gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.tar.zst gsoc2013-empathy-ae195f5e93d0f92e0c7714b5b27be8d1740803aa.zip |
[darcs-to-svn @ many changes]
svn path=/trunk/; revision=35
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy/empathy-contact-list.c | 80 | ||||
-rw-r--r-- | libempathy/empathy-marshal.list | 2 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 94 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 27 |
5 files changed, 137 insertions, 68 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 98349b205..629fc3663 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -1,4 +1,6 @@ AM_CPPFLAGS = \ + -I. \ + -I$(top_srcdir) \ -DDATADIR=\""$(datadir)"\" \ -DLOCALEDIR=\""$(datadir)/locale"\" \ $(LIBEMPATHY_CFLAGS) \ diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 4d4b692fb..f1cede9eb 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -34,8 +34,9 @@ #include <libtelepathy/tp-conn-iface-avatars-gen.h> #include "empathy-contact-list.h" -#include "gossip-debug.h" #include "gossip-telepathy-group.h" +#include "gossip-debug.h" +#include "gossip-utils.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_CONTACT_LIST, EmpathyContactListPriv)) @@ -46,6 +47,7 @@ struct _EmpathyContactListPriv { TpConn *tp_conn; McAccount *account; + MissionControl *mc; GossipContact *own_contact; GossipTelepathyGroup *known; @@ -191,6 +193,12 @@ static void contact_list_parse_presence_foreach (guint static void contact_list_presences_table_foreach (const gchar *state_str, GHashTable *presences_table, GossipPresence **presence); +static void contact_list_status_changed_cb (MissionControl *mc, + TelepathyConnectionStatus status, + McPresence presence, + TelepathyConnectionStatusReason reason, + const gchar *unique_name, + EmpathyContactList *list); enum { CONTACT_ADDED, @@ -273,8 +281,14 @@ contact_list_finalize (GObject *object) gossip_debug (DEBUG_DOMAIN, "finalize: %p", object); + dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), + "AccountStatusChanged", + G_CALLBACK (contact_list_status_changed_cb), + list); + + contact_list_finalize_proxies (list); + if (priv->tp_conn) { - contact_list_finalize_proxies (list); g_object_unref (priv->tp_conn); } @@ -292,6 +306,7 @@ contact_list_finalize (GObject *object) g_object_unref (priv->account); g_object_unref (priv->own_contact); + g_object_unref (priv->mc); g_hash_table_destroy (priv->groups); g_hash_table_destroy (priv->contacts); @@ -304,7 +319,6 @@ empathy_contact_list_new (McAccount *account) EmpathyContactListPriv *priv; EmpathyContactList *list; MissionControl *mc; - TpConn *tp_conn; guint handle; GError *error = NULL; @@ -317,19 +331,20 @@ empathy_contact_list_new (McAccount *account) return NULL; } - tp_conn = mission_control_get_connection (mc, account, NULL); - g_object_unref (mc); - g_return_val_if_fail (tp_conn != NULL, NULL); - list = g_object_new (EMPATHY_TYPE_CONTACT_LIST, NULL); priv = GET_PRIV (list); - priv->tp_conn = tp_conn; + priv->tp_conn = mission_control_get_connection (mc, account, NULL); priv->account = g_object_ref (account); + priv->mc = mc; g_signal_connect (priv->tp_conn, "destroy", G_CALLBACK (contact_list_destroy_cb), list); + dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc), + "AccountStatusChanged", + G_CALLBACK (contact_list_status_changed_cb), + list, NULL); priv->aliasing_iface = tp_conn_get_interface (priv->tp_conn, TELEPATHY_CONN_IFACE_ALIASING_QUARK); @@ -753,12 +768,14 @@ contact_list_finalize_proxies (EmpathyContactList *list) priv = GET_PRIV (list); - g_signal_handlers_disconnect_by_func (priv->tp_conn, - contact_list_destroy_cb, - list); - dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->tp_conn), "NewChannel", - G_CALLBACK (contact_list_newchannel_cb), - list); + if (priv->tp_conn) { + g_signal_handlers_disconnect_by_func (priv->tp_conn, + contact_list_destroy_cb, + list); + dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->tp_conn), "NewChannel", + G_CALLBACK (contact_list_newchannel_cb), + list); + } if (priv->aliasing_iface) { dbus_g_proxy_disconnect_signal (priv->aliasing_iface, @@ -783,15 +800,15 @@ contact_list_finalize_proxies (EmpathyContactList *list) } static void -contact_list_destroy_cb (DBusGProxy *proxy, +contact_list_destroy_cb (DBusGProxy *proxy, EmpathyContactList *list) { EmpathyContactListPriv *priv; priv = GET_PRIV (list); - gossip_debug (DEBUG_DOMAIN, "Connection destroyed. " - "Account disconnected or CM crashed."); + gossip_debug (DEBUG_DOMAIN, "Connection destroyed... " + "Account disconnected or CM crashed"); /* DBus proxies should NOT be used anymore */ g_object_unref (priv->tp_conn); @@ -1767,3 +1784,32 @@ contact_list_presences_table_foreach (const gchar *state_str, } } +static void +contact_list_status_changed_cb (MissionControl *mc, + TelepathyConnectionStatus status, + McPresence presence, + TelepathyConnectionStatusReason reason, + const gchar *unique_name, + EmpathyContactList *list) +{ + EmpathyContactListPriv *priv; + McAccount *account; + + priv = GET_PRIV (list); + + account = mc_account_lookup (unique_name); + if (status != TP_CONN_STATUS_DISCONNECTED || + !gossip_account_equal (account, priv->account)) { + g_object_unref (account); + return; + } + + /* We are disconnected, do just like if the connection was destroyed */ + g_signal_handlers_disconnect_by_func (priv->tp_conn, + contact_list_destroy_cb, + list); + contact_list_destroy_cb (DBUS_G_PROXY (priv->tp_conn), list); + + g_object_unref (account); +} + diff --git a/libempathy/empathy-marshal.list b/libempathy/empathy-marshal.list index c4c092233..b9bbd27a7 100644 --- a/libempathy/empathy-marshal.list +++ b/libempathy/empathy-marshal.list @@ -2,3 +2,5 @@ VOID:POINTER,UINT,UINT,STRING VOID:OBJECT,UINT VOID:OBJECT,OBJECT VOID:INT,STRING +VOID:OBJECT,OBJECT,UINT +VOID:UINT,BOOLEAN diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 25639dd14..4729cc267 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -51,33 +51,35 @@ struct _EmpathyTpChatPriv { DBusGProxy *chat_state_iface; }; -static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass); -static void empathy_tp_chat_init (EmpathyTpChat *chat); -static void tp_chat_finalize (GObject *object); -static void tp_chat_destroy_cb (TpChan *text_chan, - EmpathyTpChat *chat); -static void tp_chat_received_cb (DBusGProxy *text_iface, - guint message_id, - guint timestamp, - guint from_handle, - guint message_type, - guint message_flags, - gchar *message_body, - EmpathyTpChat *chat); -static void tp_chat_sent_cb (DBusGProxy *text_iface, - guint timestamp, - guint message_type, - gchar *message_body, - EmpathyTpChat *chat); -static void tp_chat_state_changed_cb (DBusGProxy *chat_state_iface, - guint handle, - EmpathyTpChatState state, - EmpathyTpChat *chat); -static void tp_chat_emit_message (EmpathyTpChat *chat, - guint type, - guint timestamp, - guint from_handle, - const gchar *message_body); +static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass); +static void empathy_tp_chat_init (EmpathyTpChat *chat); +static void tp_chat_finalize (GObject *object); +static void tp_chat_destroy_cb (TpChan *text_chan, + EmpathyTpChat *chat); +static void tp_chat_closed_cb (TpChan *text_chan, + EmpathyTpChat *chat); +static void tp_chat_received_cb (DBusGProxy *text_iface, + guint message_id, + guint timestamp, + guint from_handle, + guint message_type, + guint message_flags, + gchar *message_body, + EmpathyTpChat *chat); +static void tp_chat_sent_cb (DBusGProxy *text_iface, + guint timestamp, + guint message_type, + gchar *message_body, + EmpathyTpChat *chat); +static void tp_chat_state_changed_cb (DBusGProxy *chat_state_iface, + guint handle, + TelepathyChannelChatState state, + EmpathyTpChat *chat); +static void tp_chat_emit_message (EmpathyTpChat *chat, + guint type, + guint timestamp, + guint from_handle, + const gchar *message_body); enum { MESSAGE_RECEIVED, @@ -207,6 +209,9 @@ empathy_tp_chat_new (McAccount *account, g_signal_connect (priv->tp_chan, "destroy", G_CALLBACK (tp_chat_destroy_cb), chat); + dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->tp_chan), "Closed", + G_CALLBACK (tp_chat_closed_cb), + chat, NULL); dbus_g_proxy_connect_signal (priv->text_iface, "Received", G_CALLBACK (tp_chat_received_cb), chat, NULL); @@ -354,8 +359,8 @@ empathy_tp_chat_send (EmpathyTpChat *chat, } void -empathy_tp_chat_send_state (EmpathyTpChat *chat, - EmpathyTpChatState state) +empathy_tp_chat_set_state (EmpathyTpChat *chat, + TelepathyChannelChatState state) { EmpathyTpChatPriv *priv; GError *error = NULL; @@ -432,7 +437,7 @@ tp_chat_destroy_cb (TpChan *text_chan, priv = GET_PRIV (chat); - gossip_debug (DEBUG_DOMAIN, "Channel destroyed"); + gossip_debug (DEBUG_DOMAIN, "Channel Closed or CM crashed"); g_object_unref (priv->tp_chan); priv->tp_chan = NULL; @@ -443,6 +448,22 @@ tp_chat_destroy_cb (TpChan *text_chan, } static void +tp_chat_closed_cb (TpChan *text_chan, + EmpathyTpChat *chat) +{ + EmpathyTpChatPriv *priv; + + priv = GET_PRIV (chat); + + /* The channel is closed, do just like if the proxy was destroyed */ + g_signal_handlers_disconnect_by_func (priv->tp_chan, + tp_chat_destroy_cb, + chat); + tp_chat_destroy_cb (text_chan, chat); + +} + +static void tp_chat_received_cb (DBusGProxy *text_iface, guint message_id, guint timestamp, @@ -489,10 +510,10 @@ tp_chat_sent_cb (DBusGProxy *text_iface, } static void -tp_chat_state_changed_cb (DBusGProxy *chat_state_iface, - guint handle, - EmpathyTpChatState state, - EmpathyTpChat *chat) +tp_chat_state_changed_cb (DBusGProxy *chat_state_iface, + guint handle, + TelepathyChannelChatState state, + EmpathyTpChat *chat) { EmpathyTpChatPriv *priv; GossipContact *contact; @@ -501,6 +522,11 @@ tp_chat_state_changed_cb (DBusGProxy *chat_state_iface, contact = empathy_contact_list_get_from_handle (priv->list, handle); + gossip_debug (DEBUG_DOMAIN, "Chat state changed for %s (%d): %d", + gossip_contact_get_name (contact), + handle, + state); + g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state); g_object_unref (contact); diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 5737fcee9..28b7804eb 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -26,6 +26,7 @@ #include <glib.h> #include <libtelepathy/tp-chan.h> +#include <libtelepathy/tp-constants.h> #include <libmissioncontrol/mc-account.h> @@ -54,24 +55,16 @@ struct _EmpathyTpChatClass { GObjectClass parent_class; }; -typedef enum { - EMPATHY_TP_CHAT_STATE_GONE, - EMPATHY_TP_CHAT_STATE_INACTIVE, - EMPATHY_TP_CHAT_STATE_ACTIVE, - EMPATHY_TP_CHAT_STATE_PAUSED, - EMPATHY_TP_CHAT_STATE_COMPOSING -} EmpathyTpChatState; - GType empathy_tp_chat_get_type (void) G_GNUC_CONST; -EmpathyTpChat *empathy_tp_chat_new (McAccount *account, - TpChan *tp_chan); -EmpathyTpChat *empathy_tp_chat_new_with_contact (GossipContact *contact); -void empathy_tp_chat_request_pending (EmpathyTpChat *chat); -void empathy_tp_chat_send (EmpathyTpChat *chat, - GossipMessage *message); -void empathy_tp_chat_send_state (EmpathyTpChat *chat, - EmpathyTpChatState state); -const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat); +EmpathyTpChat *empathy_tp_chat_new (McAccount *account, + TpChan *tp_chan); +EmpathyTpChat *empathy_tp_chat_new_with_contact (GossipContact *contact); +void empathy_tp_chat_request_pending (EmpathyTpChat *chat); +void empathy_tp_chat_send (EmpathyTpChat *chat, + GossipMessage *message); +void empathy_tp_chat_set_state (EmpathyTpChat *chat, + TelepathyChannelChatState state); +const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat); G_END_DECLS |