From cbfe2006c6b8e0fae731cd26c0284d7767fc4662 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 18 Jun 2009 11:04:40 +0100 Subject: Include actor in members-changed if possible --- libempathy/empathy-tp-chat.c | 65 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 14 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 794e3e3b7..1bee75ed8 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -875,6 +875,33 @@ tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory, tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat)); } +static EmpathyContact * +chat_lookup_contact (EmpathyTpChat *chat, + TpHandle handle, + gboolean remove) +{ + EmpathyTpChatPriv *priv = GET_PRIV (chat); + GList *l; + + for (l = priv->members; l; l = l->next) { + EmpathyContact *c = l->data; + + if (empathy_contact_get_handle (c) == handle) { + if (remove) { + /* Caller takes the reference. */ + priv->members = g_list_delete_link ( + priv->members, l); + } else { + g_object_ref (c); + } + + return c; + } + } + + return NULL; +} + static void tp_chat_group_members_changed_cb (TpChannel *self, gchar *message, @@ -887,24 +914,30 @@ tp_chat_group_members_changed_cb (TpChannel *self, EmpathyTpChat *chat) { EmpathyTpChatPriv *priv = GET_PRIV (chat); - EmpathyContact *contact; - TpHandle handle; + EmpathyContact *contact, *actor_contact = NULL; guint i; - GList *l; + + if (actor != 0) { + actor_contact = chat_lookup_contact (chat, actor, FALSE); + if (actor_contact == NULL) { + /* TODO: handle this a tad more gracefully: perhaps the + * actor was a server op. We could use the contact-ids + * detail of MembersChangedDetailed. + */ + DEBUG ("actor %u not a channel member", actor); + } + } /* Remove contacts that are not members anymore */ for (i = 0; i < removed->len; i++) { - for (l = priv->members; l; l = l->next) { - contact = l->data; - handle = empathy_contact_get_handle (contact); - if (handle == g_array_index (removed, TpHandle, i)) { - priv->members = g_list_delete_link (priv->members, l); - g_signal_emit_by_name (chat, "members-changed", - contact, NULL, reason, - message, FALSE); - g_object_unref (contact); - break; - } + contact = chat_lookup_contact (chat, + g_array_index (removed, TpHandle, i), TRUE); + + if (contact != NULL) { + g_signal_emit_by_name (chat, "members-changed", contact, + actor_contact, reason, message, + FALSE); + g_object_unref (contact); } } @@ -917,6 +950,10 @@ tp_chat_group_members_changed_cb (TpChannel *self, } tp_chat_update_remote_contact (chat); + + if (actor_contact != NULL) { + g_object_unref (actor_contact); + } } static void -- cgit v1.2.3 From 367084af410d31a3fa8a9f040dd70ba5238816f4 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 18 Jun 2009 21:26:41 +0100 Subject: Coding style: one declaration per line. --- libempathy/empathy-tp-chat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 1bee75ed8..1df1cf8a9 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -914,7 +914,8 @@ tp_chat_group_members_changed_cb (TpChannel *self, EmpathyTpChat *chat) { EmpathyTpChatPriv *priv = GET_PRIV (chat); - EmpathyContact *contact, *actor_contact = NULL; + EmpathyContact *contact; + EmpathyContact *actor_contact = NULL; guint i; if (actor != 0) { -- cgit v1.2.3 From a0813b0a5b90e959994f0f6f029af30364ddd258 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 18 Jun 2009 21:26:50 +0100 Subject: Style: use FIXME not TODO --- libempathy/empathy-tp-chat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 1df1cf8a9..8327c4f26 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -921,9 +921,9 @@ tp_chat_group_members_changed_cb (TpChannel *self, if (actor != 0) { actor_contact = chat_lookup_contact (chat, actor, FALSE); if (actor_contact == NULL) { - /* TODO: handle this a tad more gracefully: perhaps the - * actor was a server op. We could use the contact-ids - * detail of MembersChangedDetailed. + /* FIXME: handle this a tad more gracefully: perhaps + * the actor was a server op. We could use the + * contact-ids detail of MembersChangedDetailed. */ DEBUG ("actor %u not a channel member", actor); } -- cgit v1.2.3 From fdbb5ae44e2b82a36f7103b63e5c8a2041faea6c Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 18 Jun 2009 21:29:31 +0100 Subject: Style: avoid marching off the right margin --- libempathy/empathy-tp-chat.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 8327c4f26..6810476d1 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -886,17 +886,18 @@ chat_lookup_contact (EmpathyTpChat *chat, for (l = priv->members; l; l = l->next) { EmpathyContact *c = l->data; - if (empathy_contact_get_handle (c) == handle) { - if (remove) { - /* Caller takes the reference. */ - priv->members = g_list_delete_link ( - priv->members, l); - } else { - g_object_ref (c); - } + if (empathy_contact_get_handle (c) != handle) { + continue; + } - return c; + if (remove) { + /* Caller takes the reference. */ + priv->members = g_list_delete_link (priv->members, l); + } else { + g_object_ref (c); } + + return c; } return NULL; -- cgit v1.2.3 From 9fe194288e580fcbd79fcae90050ccb8b6380a63 Mon Sep 17 00:00:00 2001 From: Jonathan Tellier Date: Thu, 2 Jul 2009 12:08:43 -0400 Subject: Added functions to determine if a contact has video capabilities Activating the "Video Call" button only if the remote contact support video. The call window's "Send Video" is only sensitive if the contact has video capabilities. --- libempathy/empathy-contact.c | 24 ++++++++++++++++++++++++ libempathy/empathy-contact.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index d351aecbc..c82ecd467 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -801,6 +801,30 @@ empathy_contact_can_voip (EmpathyContact *contact) EMPATHY_CAPABILITIES_VIDEO); } +gboolean +empathy_contact_can_voip_audio (EmpathyContact *contact) +{ + EmpathyContactPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE); + + priv = GET_PRIV (contact); + + return priv->capabilities & EMPATHY_CAPABILITIES_AUDIO; +} + +gboolean +empathy_contact_can_voip_video (EmpathyContact *contact) +{ + EmpathyContactPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE); + + priv = GET_PRIV (contact); + + return priv->capabilities & EMPATHY_CAPABILITIES_VIDEO; +} + gboolean empathy_contact_can_send_files (EmpathyContact *contact) { diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h index d4e385924..4e9c98756 100644 --- a/libempathy/empathy-contact.h +++ b/libempathy/empathy-contact.h @@ -99,6 +99,8 @@ void empathy_contact_set_is_user (EmpathyContact *contact, 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_voip_audio (EmpathyContact *contact); +gboolean empathy_contact_can_voip_video (EmpathyContact *contact); gboolean empathy_contact_can_send_files (EmpathyContact *contact); gboolean empathy_contact_can_use_stream_tube (EmpathyContact *contact); guint empathy_contact_hash (gconstpointer key); -- cgit v1.2.3 From 3b848301b06feddc82cbf667876ae502b95bbe6e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Sun, 5 Jul 2009 16:29:09 +0100 Subject: empathy_contact_manager_can_add: raise an error if connection is NULL --- libempathy/empathy-contact-manager.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 7af2bd349..059382b60 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -535,6 +535,7 @@ empathy_contact_manager_can_add (EmpathyContactManager *manager, EmpathyTpContactList *list; g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE); + g_return_val_if_fail (connection != NULL, FALSE); list = g_hash_table_lookup (priv->lists, connection); if (list == NULL) -- cgit v1.2.3 From ee5227403193fe7b5dae7d5c15e33d8a9c385c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Chieffo?= <84yelo3@gmail.com> Date: Wed, 8 Jul 2009 16:39:17 +0100 Subject: Support for history message in Adium themes. Use context HTMLs. --- libempathy/empathy-log-store-empathy.c | 1 + libempathy/empathy-message.c | 36 ++++++++++++++++++++++++++++++++++ libempathy/empathy-message.h | 3 +++ 3 files changed, 40 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 7e50cb12f..b73c7218c 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -497,6 +497,7 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self, empathy_message_set_sender (message, sender); empathy_message_set_timestamp (message, t); empathy_message_set_tptype (message, msg_type); + empathy_message_set_is_backlog (message, TRUE); if (cm_id_str) empathy_message_set_id (message, cm_id); diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index d020b72e4..41b44bfb3 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -39,6 +39,7 @@ typedef struct { EmpathyContact *receiver; gchar *body; time_t timestamp; + gboolean is_backlog; guint id; } EmpathyMessagePriv; @@ -61,6 +62,7 @@ enum { PROP_RECEIVER, PROP_BODY, PROP_TIMESTAMP, + PROP_IS_BACKLOG, }; static void @@ -112,6 +114,13 @@ empathy_message_class_init (EmpathyMessageClass *class) G_MAXLONG, -1, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_IS_BACKLOG, + g_param_spec_boolean ("is-backlog", + "History message", + "If the message belongs to history", + FALSE, + G_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (EmpathyMessagePriv)); @@ -387,6 +396,33 @@ empathy_message_set_timestamp (EmpathyMessage *message, g_object_notify (G_OBJECT (message), "timestamp"); } +gboolean +empathy_message_is_backlog (EmpathyMessage *message) +{ + EmpathyMessagePriv *priv; + + g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE); + + priv = GET_PRIV (message); + + return priv->is_backlog; +} + +void +empathy_message_set_is_backlog (EmpathyMessage *message, + gboolean is_backlog) +{ + EmpathyMessagePriv *priv; + + g_return_if_fail (EMPATHY_IS_MESSAGE (message)); + + priv = GET_PRIV (message); + + priv->is_backlog = is_backlog; + + g_object_notify (G_OBJECT (message), "is-backlog"); +} + #define IS_SEPARATOR(ch) (ch == ' ' || ch == ',' || ch == '.' || ch == ':') gboolean empathy_message_should_highlight (EmpathyMessage *message) diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h index 2172c9784..00064df57 100644 --- a/libempathy/empathy-message.h +++ b/libempathy/empathy-message.h @@ -68,6 +68,9 @@ void empathy_message_set_body (EmpathyMessage time_t empathy_message_get_timestamp (EmpathyMessage *message); void empathy_message_set_timestamp (EmpathyMessage *message, time_t timestamp); +gboolean empathy_message_is_backlog (EmpathyMessage *message); +void empathy_message_set_is_backlog (EmpathyMessage *message, + gboolean is_backlog); 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); -- cgit v1.2.3 From 69a72d65e8c5341230965098b38dea4c632efca7 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 13 Jul 2009 18:05:07 +0100 Subject: empathy-message.c: remove a trailing space --- libempathy/empathy-message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index 41b44bfb3..a8fe6084c 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -421,7 +421,7 @@ empathy_message_set_is_backlog (EmpathyMessage *message, priv->is_backlog = is_backlog; g_object_notify (G_OBJECT (message), "is-backlog"); -} +} #define IS_SEPARATOR(ch) (ch == ' ' || ch == ',' || ch == '.' || ch == ':') gboolean -- cgit v1.2.3 From 736807e3c658aee559cb3d41413e775023d29c51 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 14:25:27 +0800 Subject: Expose channel group flags via EmpathyContactList iface --- libempathy/empathy-contact-list.c | 11 +++++++++++ libempathy/empathy-contact-list.h | 10 ++++++++++ libempathy/empathy-tp-contact-list.c | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 1fe894e99..d9493af1e 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -229,3 +229,14 @@ empathy_contact_list_remove_group (EmpathyContactList *list, } } +EmpathyContactListFlags +empathy_contact_list_get_flags (EmpathyContactList *list) +{ + g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), 0); + + if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags) { + return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags (list); + } else { + return 0; + } +} diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 5eabf32c3..0296b6486 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -34,6 +34,11 @@ G_BEGIN_DECLS #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 enum { + EMPATHY_CONTACT_LIST_CAN_ADD = 1 << 0, + EMPATHY_CONTACT_LIST_CAN_REMOVE = 1 << 1, +} EmpathyContactListFlags; + typedef struct _EmpathyContactListIface EmpathyContactListIface; struct _EmpathyContactListIface { @@ -64,6 +69,8 @@ struct _EmpathyContactListIface { const gchar *group); EmpathyContactMonitor * (*get_monitor) (EmpathyContactList *list); + EmpathyContactListFlags + (*get_flags) (EmpathyContactList *list); }; GType empathy_contact_list_get_type (void) G_GNUC_CONST; @@ -92,6 +99,9 @@ void empathy_contact_list_remove_group (EmpathyContactList *list, EmpathyContactMonitor * empathy_contact_list_get_monitor (EmpathyContactList *list); +EmpathyContactListFlags + empathy_contact_list_get_flags (EmpathyContactList *list); + G_END_DECLS #endif /* __EMPATHY_CONTACT_LIST_H__ */ diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index cdb0431c4..4ae5c88c9 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -1074,6 +1074,30 @@ tp_contact_list_remove_group (EmpathyContactList *list, g_array_free (handles, TRUE); } +static EmpathyContactListFlags +tp_contact_list_get_flags (EmpathyContactList *list) +{ + EmpathyTpContactListPriv *priv; + EmpathyContactListFlags flags = 0; + TpChannelGroupFlags group_flags; + + g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE); + + priv = GET_PRIV (list); + + group_flags = tp_channel_group_get_flags (priv->subscribe); + + if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) { + flags |= EMPATHY_CONTACT_LIST_CAN_ADD; + } + + if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) { + flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE; + } + + return flags; +} + static void tp_contact_list_iface_init (EmpathyContactListIface *iface) { @@ -1087,6 +1111,7 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface) 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; + iface->get_flags = tp_contact_list_get_flags; } gboolean -- cgit v1.2.3 From 0c0c427ea240b0615cc08658fc318516d4259d3e Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 14:26:19 +0800 Subject: Remove redundant empathy_tp_contact_list_can_add() --- libempathy/empathy-contact-manager.c | 9 ++++++--- libempathy/empathy-tp-contact-list.c | 17 ----------------- 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 059382b60..49155c8c5 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -532,15 +532,18 @@ empathy_contact_manager_can_add (EmpathyContactManager *manager, TpConnection *connection) { EmpathyContactManagerPriv *priv = GET_PRIV (manager); - EmpathyTpContactList *list; + EmpathyContactList *list; + EmpathyContactListFlags flags; g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE); g_return_val_if_fail (connection != NULL, FALSE); list = g_hash_table_lookup (priv->lists, connection); - if (list == NULL) + if (list == NULL) { return FALSE; + } + flags = empathy_contact_list_get_flags (list); - return empathy_tp_contact_list_can_add (list); + return (flags & EMPATHY_CONTACT_LIST_CAN_ADD); } diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 4ae5c88c9..514f7a6b5 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -1114,23 +1114,6 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface) iface->get_flags = tp_contact_list_get_flags; } -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 = tp_channel_group_get_flags (priv->subscribe); - return (flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) != 0; -} - void empathy_tp_contact_list_remove_all (EmpathyTpContactList *list) { -- cgit v1.2.3 From 98d43b78d70e1a2ff6a0b931ad1b8e11790daff0 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 14:36:23 +0800 Subject: Convert empathy_contact_manager_can_add() to empathy_contact_manager_get_flags_for_connection() --- libempathy/empathy-contact-manager.c | 9 +++++---- libempathy/empathy-contact-manager.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 49155c8c5..5ce463c4c 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -527,9 +527,10 @@ contact_manager_iface_init (EmpathyContactListIface *iface) iface->remove_group = contact_manager_remove_group; } -gboolean -empathy_contact_manager_can_add (EmpathyContactManager *manager, - TpConnection *connection) +EmpathyContactListFlags +empathy_contact_manager_get_flags_for_connection ( + EmpathyContactManager *manager, + TpConnection *connection) { EmpathyContactManagerPriv *priv = GET_PRIV (manager); EmpathyContactList *list; @@ -544,6 +545,6 @@ empathy_contact_manager_can_add (EmpathyContactManager *manager, } flags = empathy_contact_list_get_flags (list); - return (flags & EMPATHY_CONTACT_LIST_CAN_ADD); + return flags; } diff --git a/libempathy/empathy-contact-manager.h b/libempathy/empathy-contact-manager.h index fbe9e2df0..d68b4ea26 100644 --- a/libempathy/empathy-contact-manager.h +++ b/libempathy/empathy-contact-manager.h @@ -53,7 +53,8 @@ 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, TpConnection *connection); -gboolean empathy_contact_manager_can_add (EmpathyContactManager *manager, +EmpathyContactListFlags empathy_contact_manager_get_flags_for_connection ( + EmpathyContactManager *manager, TpConnection *connection); G_END_DECLS -- cgit v1.2.3 From 4afeb994e1fb9bdef315d0eaa24c3821536e30c1 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 15:16:46 +0800 Subject: call GetAliasFlags() to determine if an alias can be set on a ContactList Pending FIXMEs: - need to lookup RequestableChannelClasses to see if Groups can be requested on this connection - need to work out the best way to pass ContactListFlags to empathy_contact_menu_new() --- libempathy/empathy-contact-list.h | 2 ++ libempathy/empathy-tp-contact-list.c | 37 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 0296b6486..28238e44a 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -37,6 +37,8 @@ G_BEGIN_DECLS typedef enum { EMPATHY_CONTACT_LIST_CAN_ADD = 1 << 0, EMPATHY_CONTACT_LIST_CAN_REMOVE = 1 << 1, + EMPATHY_CONTACT_LIST_CAN_ALIAS = 1 << 2, + EMPATHY_CONTACT_LIST_CAN_GROUP = 1 << 3, } EmpathyContactListFlags; typedef struct _EmpathyContactListIface EmpathyContactListIface; diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 514f7a6b5..e81528c80 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -50,6 +50,8 @@ typedef struct { GHashTable *pendings; /* handle -> EmpathyContact */ GHashTable *groups; /* group name -> TpChannel */ GHashTable *add_to_group; /* group name -> GArray of handles */ + + EmpathyContactListFlags flags; } EmpathyTpContactListPriv; typedef enum { @@ -508,6 +510,25 @@ tp_contact_list_publish_request_channel_cb (TpConnection *connection, list); } +static void +tp_contact_list_get_alias_flags_cb (TpConnection *connection, + guint flags, + const GError *error, + gpointer user_data, + GObject *list) +{ + EmpathyTpContactListPriv *priv = GET_PRIV (list); + + if (error) { + DEBUG ("Error: %s", error->message); + return; + } + + if (flags & TP_CONNECTION_ALIAS_FLAG_USER_SET) { + priv->flags |= EMPATHY_CONTACT_LIST_CAN_ALIAS; + } +} + static void tp_contact_list_publish_request_handle_cb (TpConnection *connection, const GArray *handles, @@ -722,6 +743,19 @@ tp_contact_list_constructed (GObject *list) priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection); + /* call GetAliasFlags() */ + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING)) { + tp_cli_connection_interface_aliasing_call_get_alias_flags ( + priv->connection, + -1, + tp_contact_list_get_alias_flags_cb, + NULL, NULL, + G_OBJECT (list)); + } + + /* FIXME: lookup RequestableChannelClasses */ + names[0] = "publish"; tp_cli_connection_call_request_handles (priv->connection, -1, @@ -1078,12 +1112,13 @@ static EmpathyContactListFlags tp_contact_list_get_flags (EmpathyContactList *list) { EmpathyTpContactListPriv *priv; - EmpathyContactListFlags flags = 0; + EmpathyContactListFlags flags; TpChannelGroupFlags group_flags; g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE); priv = GET_PRIV (list); + flags = priv->flags; group_flags = tp_channel_group_get_flags (priv->subscribe); -- cgit v1.2.3 From 24f3f86b2bd9c42a9ea9f498980f0d255e35bb32 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Sat, 25 Apr 2009 09:39:55 +0800 Subject: Add empathy_contact_manager_initialized() --- libempathy/empathy-contact-manager.c | 17 +++++++++++++++++ libempathy/empathy-contact-manager.h | 1 + 2 files changed, 18 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 5ce463c4c..302fad3c5 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -204,6 +204,23 @@ contact_manager_constructor (GType type, return retval; } +/** + * empathy_contact_manager_initialized: + * + * Reports whether or not the singleton has already been created. + * + * There can be instances where you want to access the #EmpathyContactManager + * only if it has been set up for this process. + * + * Returns: %TRUE if the #EmpathyContactManager singleton has previously + * been initialized. + */ +gboolean +empathy_contact_manager_initialized (void) +{ + return (manager_singleton != NULL); +} + static void empathy_contact_manager_class_init (EmpathyContactManagerClass *klass) { diff --git a/libempathy/empathy-contact-manager.h b/libempathy/empathy-contact-manager.h index d68b4ea26..97e21464a 100644 --- a/libempathy/empathy-contact-manager.h +++ b/libempathy/empathy-contact-manager.h @@ -50,6 +50,7 @@ struct _EmpathyContactManagerClass { }; GType empathy_contact_manager_get_type (void) G_GNUC_CONST; +gboolean empathy_contact_manager_initialized (void); EmpathyContactManager *empathy_contact_manager_dup_singleton (void); EmpathyTpContactList * empathy_contact_manager_get_list (EmpathyContactManager *manager, TpConnection *connection); -- cgit v1.2.3 From 76af883334b3ae82e718c65d74484cc327501cde Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Sun, 26 Apr 2009 11:01:00 +0800 Subject: Implement CAN_GROUP by looking at RequestableChannelClasses --- libempathy/empathy-tp-contact-list.c | 54 +++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index e81528c80..5e52fe351 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -529,6 +529,45 @@ tp_contact_list_get_alias_flags_cb (TpConnection *connection, } } +static void +tp_contact_list_get_requestablechannelclasses_cb (TpProxy *connection, + const GValue *value, + const GError *error, + gpointer user_data, + GObject *list) +{ + EmpathyTpContactListPriv *priv = GET_PRIV (list); + GPtrArray *classes; + int i; + + if (error) { + DEBUG ("Error: %s", error->message); + return; + } + + classes = g_value_get_boxed (value); + for (i = 0; i < classes->len; i++) { + GValueArray *class = g_ptr_array_index (classes, i); + GHashTable *props; + const char *channel_type; + guint handle_type; + + props = g_value_get_boxed (g_value_array_get_nth (class, 0)); + + channel_type = tp_asv_get_string (props, + TP_IFACE_CHANNEL ".ChannelType"); + handle_type = tp_asv_get_uint32 (props, + TP_IFACE_CHANNEL ".TargetHandleType", NULL); + + if (!strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) && + handle_type == TP_HANDLE_TYPE_GROUP) { + DEBUG ("Got channel class for a contact group"); + priv->flags |= EMPATHY_CONTACT_LIST_CAN_GROUP; + break; + } + } +} + static void tp_contact_list_publish_request_handle_cb (TpConnection *connection, const GArray *handles, @@ -754,7 +793,20 @@ tp_contact_list_constructed (GObject *list) G_OBJECT (list)); } - /* FIXME: lookup RequestableChannelClasses */ + /* lookup RequestableChannelClasses */ + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS)) { + tp_cli_dbus_properties_call_get (priv->connection, + -1, + TP_IFACE_CONNECTION_INTERFACE_REQUESTS, + "RequestableChannelClasses", + tp_contact_list_get_requestablechannelclasses_cb, + NULL, NULL, + G_OBJECT (list)); + } else { + /* we just don't know... better mark the flag just in case */ + priv->flags |= EMPATHY_CONTACT_LIST_CAN_GROUP; + } names[0] = "publish"; tp_cli_connection_call_request_handles (priv->connection, -- cgit v1.2.3 From 0ade362fb9343ec984c396a202565c4e5faa1f12 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Tue, 14 Jul 2009 10:11:03 +0100 Subject: Remove deprecated call to g_mapped_file_free() Change to g_mapped_file_unref() --- libempathy/empathy-log-store-empathy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index b73c7218c..13146882d 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -601,7 +601,7 @@ log_store_empathy_search_new (EmpathyLogStore *self, contents = g_mapped_file_get_contents (file); contents_casefold = g_utf8_casefold (contents, length); - g_mapped_file_free (file); + g_mapped_file_unref (file); if (strstr (contents_casefold, text_casefold)) { -- cgit v1.2.3 From a55d556e43624ced7d3c55863078669cfeebde84 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 15 Jul 2009 10:58:17 +0100 Subject: Small style fixes --- libempathy/empathy-tp-contact-list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 5e52fe351..c1c46b3ca 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -559,7 +559,7 @@ tp_contact_list_get_requestablechannelclasses_cb (TpProxy *connection, handle_type = tp_asv_get_uint32 (props, TP_IFACE_CHANNEL ".TargetHandleType", NULL); - if (!strcmp (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) && + if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) && handle_type == TP_HANDLE_TYPE_GROUP) { DEBUG ("Got channel class for a contact group"); priv->flags |= EMPATHY_CONTACT_LIST_CAN_GROUP; @@ -782,7 +782,7 @@ tp_contact_list_constructed (GObject *list) priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection); - /* call GetAliasFlags() */ + /* call GetAliasFlags */ if (tp_proxy_has_interface_by_id (priv->connection, TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING)) { tp_cli_connection_interface_aliasing_call_get_alias_flags ( -- cgit v1.2.3 From 0343c43f77ab5e59c614af0c0fa60d518d78a774 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 15 Jul 2009 12:38:55 +0100 Subject: Revert "Remove deprecated call to g_mapped_file_free()" This commit breaks older GLib. When we're ready to bump our requirement to GLib 2.22, simply revert this commit. This reverts commit 0ade362fb9343ec984c396a202565c4e5faa1f12 but with an extra comment to explain what the hell is going on. --- libempathy/empathy-log-store-empathy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 13146882d..b814defe7 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -27,7 +27,14 @@ #include #include #include + +/* FIXME: g_mapped_file_free has been deprecated in GLib 2.22, but the + * replacement symbol, g_mapped_file_unref is not available in older Glib + * and we're not ready to bump our version requirement just for this. When + * we're ready to bump our version requirement, just revert this patch. */ +#undef G_DISABLE_DEPRECATED #include +#define G_DISABLE_DEPRECATED #include "empathy-log-store.h" #include "empathy-log-store-empathy.h" @@ -601,7 +608,7 @@ log_store_empathy_search_new (EmpathyLogStore *self, contents = g_mapped_file_get_contents (file); contents_casefold = g_utf8_casefold (contents, length); - g_mapped_file_unref (file); + g_mapped_file_free (file); if (strstr (contents_casefold, text_casefold)) { -- cgit v1.2.3 From 719ae62b7c7a33e8338470b386386c7fd807b560 Mon Sep 17 00:00:00 2001 From: Arnaud Maillet Date: Mon, 20 Jul 2009 16:06:57 +0200 Subject: Add EMPATHY_DEBUG_SHARE_DESKTOP in libempathy/empathy-debug.h --- libempathy/empathy-debug.h | 1 + 1 file changed, 1 insertion(+) (limited to 'libempathy') diff --git a/libempathy/empathy-debug.h b/libempathy/empathy-debug.h index 9df728922..0d25f22dd 100644 --- a/libempathy/empathy-debug.h +++ b/libempathy/empathy-debug.h @@ -41,6 +41,7 @@ typedef enum EMPATHY_DEBUG_FT = 1 << 7, EMPATHY_DEBUG_LOCATION = 1 << 8, EMPATHY_DEBUG_OTHER = 1 << 9, + EMPATHY_DEBUG_SHARE_DESKTOP = 1 << 10, } EmpathyDebugFlags; gboolean empathy_debug_flag_is_set (EmpathyDebugFlags flag); -- cgit v1.2.3 From e1fa17399fc137a508f195aa6976b5f32189de96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 17 Jun 2009 10:01:52 +0200 Subject: Put configuration data in XDG_CONFIG_DIRS (GNOME bug 494007) --- libempathy/empathy-chatroom-manager.c | 2 +- libempathy/empathy-contact-groups.c | 4 ++-- libempathy/empathy-status-presets.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 1ce7a6e5d..940b56220 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -409,7 +409,7 @@ empathy_chatroom_manager_constructor (GType type, /* Set the default file path */ gchar *dir; - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), 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); diff --git a/libempathy/empathy-contact-groups.c b/libempathy/empathy-contact-groups.c index a9040f2df..22d81d051 100644 --- a/libempathy/empathy-contact-groups.c +++ b/libempathy/empathy-contact-groups.c @@ -67,7 +67,7 @@ empathy_contact_groups_get_all (void) groups = NULL; } - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); file_with_path = g_build_filename (dir, CONTACT_GROUPS_XML_FILENAME, NULL); g_free (dir); @@ -190,7 +190,7 @@ contact_groups_file_save (void) gchar *dir; gchar *file; - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), 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); diff --git a/libempathy/empathy-status-presets.c b/libempathy/empathy-status-presets.c index 135212cc5..1fa991b0b 100644 --- a/libempathy/empathy-status-presets.c +++ b/libempathy/empathy-status-presets.c @@ -176,7 +176,7 @@ empathy_status_presets_get_all (void) presets = NULL; } - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), 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); @@ -203,7 +203,7 @@ status_presets_file_save (void) count[i] = 0; } - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), 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); -- cgit v1.2.3 From 66f198c160fd6a8c1f3cce1a5e6237aeb1b20c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Thu, 23 Jul 2009 10:56:42 -0400 Subject: Fixed copy/paste mistake (Remove members from the right set) --- libempathy/empathy-tp-contact-list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index c1c46b3ca..7c94bc756 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -471,7 +471,7 @@ tp_contact_list_publish_group_members_changed_cb (TpChannel *channel, /* We refuse to send our presence to those contacts, remove from pendings */ for (i = 0; i < removed->len; i++) { tp_contact_list_remove_handle (list, priv->pendings, - g_array_index (added, TpHandle, i)); + g_array_index (removed, TpHandle, i)); } /* Those contacts want our presence, auto accept those that are already @@ -618,7 +618,7 @@ tp_contact_list_subscribe_group_members_changed_cb (TpChannel *channel, /* Those contacts refuse to send us their presence, remove from members. */ for (i = 0; i < removed->len; i++) { tp_contact_list_remove_handle (list, priv->members, - g_array_index (added, TpHandle, i)); + g_array_index (removed, TpHandle, i)); } /* We want those contacts in our contact list but we don't get their -- cgit v1.2.3 From 1bcccdbc977cc35af2edccc9b222d53a63a8c0b6 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 16:46:24 +0200 Subject: Add a utility function to may protocols to their icons --- libempathy/empathy-account.c | 2 +- libempathy/empathy-utils.c | 6 ++++++ libempathy/empathy-utils.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index cc982aea7..db2ca1f56 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -467,7 +467,7 @@ empathy_account_constructed (GObject *object) empathy_account_parse_unique_name (priv->unique_name, &(priv->proto_name), &(priv->cm_name)); - priv->icon_name = g_strdup_printf ("im-%s", priv->proto_name); + priv->icon_name = empathy_protocol_icon_name (priv->proto_name); tp_cli_account_connect_to_account_property_changed (priv->account, empathy_account_properties_changed, diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 525f2fe06..fe54ce85a 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -363,6 +363,12 @@ empathy_uint_compare (gconstpointer a, return *(guint *) a - *(guint *) b; } +gchar * +empathy_protocol_icon_name (const gchar *protocol) +{ + return g_strdup_printf ("im-%s", protocol); +} + GType empathy_type_dbus_ao (void) { diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 3de6047f4..59ea15403 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -77,6 +77,8 @@ gboolean empathy_check_available_state (void); gint empathy_uint_compare (gconstpointer a, gconstpointer b); +gchar *empathy_protocol_icon_name (const gchar *protocol); + #define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ()) GType empathy_type_dbus_ao (void); -- cgit v1.2.3 From bb2d63c7d3964a3cd68e6667a19907aa72bb686b Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 19:28:56 +0200 Subject: Unref the connection if it fails to become ready or is invalidated --- libempathy/empathy-account.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index db2ca1f56..5cf489769 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -607,6 +607,21 @@ empathy_account_class_init (EmpathyAccountClass *empathy_account_class) G_TYPE_NONE, 0); } +static void +empathy_account_free_connection (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->connection_invalidated_id != 0) + g_signal_handler_disconnect (priv->connection, + priv->connection_invalidated_id); + priv->connection_invalidated_id = 0; + + if (priv->connection != NULL) + g_object_unref (priv->connection); + priv->connection = NULL; +} + void empathy_account_dispose (GObject *object) { @@ -618,14 +633,7 @@ empathy_account_dispose (GObject *object) priv->dispose_has_run = TRUE; - if (priv->connection_invalidated_id != 0) - g_signal_handler_disconnect (priv->connection, - priv->connection_invalidated_id); - priv->connection_invalidated_id = 0; - - if (priv->connection != NULL) - g_object_unref (priv->connection); - priv->connection = NULL; + empathy_account_free_connection (self); /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_account_parent_class)->dispose != NULL) @@ -785,13 +793,12 @@ empathy_account_connection_ready_cb (TpConnection *connection, gpointer user_data) { EmpathyAccount *account = EMPATHY_ACCOUNT (user_data); - EmpathyAccountPriv *priv = GET_PRIV (account); if (error != NULL) { DEBUG ("(%s) Connection failed to become ready: %s", empathy_account_get_unique_name (account), error->message); - priv->connection = NULL; + empathy_account_free_connection (account); } else { -- cgit v1.2.3 From a5a46b1dc612eb29b86f4bdfa3b3d80cb35f8893 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 20:20:57 +0200 Subject: Remove empathy_account_hash --- libempathy/empathy-utils.c | 8 -------- libempathy/empathy-utils.h | 1 - 2 files changed, 9 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index fe54ce85a..1e1377a8d 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -227,14 +227,6 @@ empathy_xml_node_find_child_prop_value (xmlNodePtr node, return found; } -guint -empathy_account_hash (gconstpointer key) -{ - g_return_val_if_fail (EMPATHY_IS_ACCOUNT (key), 0); - - return g_str_hash (empathy_account_get_unique_name (EMPATHY_ACCOUNT (key))); -} - gboolean empathy_account_equal (gconstpointer a, gconstpointer b) diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 59ea15403..3ab4077f5 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -62,7 +62,6 @@ xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node, const gchar *prop_value); /* Others */ -guint empathy_account_hash (gconstpointer key); gboolean empathy_account_equal (gconstpointer a, gconstpointer b); const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence); -- cgit v1.2.3 From 97d122d36a2e387ccdba9689052b0397bbe42a76 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 29 Jul 2009 20:38:13 +0200 Subject: remove usage of empathy_account_equal --- libempathy/empathy-chatroom-manager.c | 11 ++++------- libempathy/empathy-chatroom.c | 3 +-- libempathy/empathy-utils.c | 7 ------- libempathy/empathy-utils.h | 2 -- 4 files changed, 5 insertions(+), 18 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 649dcc9cf..c5f9864a1 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -580,9 +580,8 @@ empathy_chatroom_manager_find (EmpathyChatroomManager *manager, 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) { + if (this_account && this_room && account == this_account + && strcmp (this_room, room) == 0) { return chatroom; } } @@ -611,8 +610,7 @@ empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager, chatroom = l->data; - if (empathy_account_equal (account, - empathy_chatroom_get_account (chatroom))) { + if (account == empathy_chatroom_get_account (chatroom)) { chatrooms = g_list_append (chatrooms, chatroom); } } @@ -641,8 +639,7 @@ empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager, chatroom = l->data; - if (empathy_account_equal (account, - empathy_chatroom_get_account (chatroom))) { + if (account == empathy_chatroom_get_account (chatroom)) { count++; } } diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c index b62d6ad77..33df9a3d6 100644 --- a/libempathy/empathy-chatroom.c +++ b/libempathy/empathy-chatroom.c @@ -480,8 +480,7 @@ empathy_chatroom_equal (gconstpointer v1, 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); + return account_a == account_b && !tp_strdiff (room_a, room_b); } EmpathyTpChat * diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 1e1377a8d..db35e94dd 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -227,13 +227,6 @@ empathy_xml_node_find_child_prop_value (xmlNodePtr node, return found; } -gboolean -empathy_account_equal (gconstpointer a, - gconstpointer b) -{ - return a == b; -} - const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence) { diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 3ab4077f5..c6aebb4f2 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -62,8 +62,6 @@ xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node, const gchar *prop_value); /* Others */ -gboolean empathy_account_equal (gconstpointer a, - gconstpointer b); const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence); const gchar * empathy_presence_to_str (TpConnectionPresenceType presence); TpConnectionPresenceType empathy_presence_from_str (const gchar *str); -- cgit v1.2.3 From c9ef23052d2e5007e6120dcc881d6c382fcf48d3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 17:35:38 +0200 Subject: Chang the API of AccountManager to have the get lookup the account by name EmpathyAccountManager used to have a _lookup function that looked up accounts by name and a _get function that lookup up accounts by connection. This is confusing, as looking up an account for a connection is less common rename have the _get_account be the same _lookup (but without returning a ref) and add a _get_account_for_connection function lookup by account --- libempathy/empathy-account-manager.c | 15 +++++---------- libempathy/empathy-account-manager.h | 4 ++-- libempathy/empathy-chatroom-manager.c | 8 ++++---- libempathy/empathy-contact.c | 3 ++- libempathy/empathy-dispatcher.c | 4 +--- libempathy/empathy-log-store-empathy.c | 4 +++- 6 files changed, 17 insertions(+), 21 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index 7339acb9f..c199e1d3e 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -665,8 +665,9 @@ empathy_account_manager_get_count (EmpathyAccountManager *manager) } EmpathyAccount * -empathy_account_manager_get_account (EmpathyAccountManager *manager, - TpConnection *connection) +empathy_account_manager_get_account_for_connection ( + EmpathyAccountManager *manager, + TpConnection *connection) { EmpathyAccountManagerPriv *priv; GHashTableIter iter; @@ -689,18 +690,12 @@ empathy_account_manager_get_account (EmpathyAccountManager *manager, } EmpathyAccount * -empathy_account_manager_lookup (EmpathyAccountManager *manager, +empathy_account_manager_get_account (EmpathyAccountManager *manager, const gchar *unique_name) { EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - EmpathyAccount *account; - - account = g_hash_table_lookup (priv->accounts, unique_name); - if (account != NULL) - g_object_ref (account); - - return account; + return g_hash_table_lookup (priv->accounts, unique_name); } GList * diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h index 953d8bc75..1f73f635e 100644 --- a/libempathy/empathy-account-manager.h +++ b/libempathy/empathy-account-manager.h @@ -66,10 +66,10 @@ int empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager); int empathy_account_manager_get_count (EmpathyAccountManager *manager); -EmpathyAccount * empathy_account_manager_get_account +EmpathyAccount * empathy_account_manager_get_account_for_connection (EmpathyAccountManager *manager, TpConnection *connection); -EmpathyAccount * empathy_account_manager_lookup +EmpathyAccount * empathy_account_manager_get_account (EmpathyAccountManager *manager, const gchar *unique_name); GList * empathy_account_manager_dup_accounts diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index c5f9864a1..7c3559e2f 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -223,7 +223,8 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, xmlFree (str); } - account = empathy_account_manager_lookup (priv->account_manager, account_id); + account = empathy_account_manager_get_account (priv->account_manager, + account_id); if (!account) { g_free (name); g_free (room); @@ -236,7 +237,6 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, 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); @@ -704,8 +704,8 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher, chat = EMPATHY_TP_CHAT ( empathy_dispatch_operation_get_channel_wrapper (operation)); connection = empathy_tp_chat_get_connection (chat); - account = empathy_account_manager_get_account (priv->account_manager, - connection); + account = empathy_account_manager_get_account_for_connection ( + priv->account_manager, connection); roomname = empathy_tp_chat_get_id (chat); diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index c82ecd467..bbce927b7 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -570,7 +570,8 @@ empathy_contact_get_account (EmpathyContact *contact) /* FIXME: This assume the account manager already exists */ manager = empathy_account_manager_dup_singleton (); connection = tp_contact_get_connection (priv->tp_contact); - priv->account = empathy_account_manager_get_account (manager, connection); + priv->account = empathy_account_manager_get_account_for_connection ( + manager, connection); g_object_ref (priv->account); g_object_unref (manager); } diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index 0b2a74a2e..fe330256d 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -1801,7 +1801,7 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self, EmpathyAccount *account; TpConnection *connection; - account = empathy_account_manager_lookup (priv->account_manager, + account = empathy_account_manager_get_account (priv->account_manager, account_path); /* FIXME */ g_assert (account != NULL); @@ -1824,8 +1824,6 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self, } tp_svc_client_handler_return_from_handle_channels (context); - - g_object_unref (account); } static void diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 4bb17e428..81cbcade7 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -405,8 +405,10 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self, unescaped = g_strdup_printf ("/%s", g_strdelimit (account_name, "%", '/')); - hit->account = empathy_account_manager_lookup (priv->account_manager, + hit->account = empathy_account_manager_get_account (priv->account_manager, unescaped); + if (hit->account != NULL) + g_object_ref (hit->account); hit->filename = g_strdup (filename); g_free (unescaped); -- cgit v1.2.3 From ef19c477deba879906da074361527c7885db35ee Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 19:25:24 +0200 Subject: Fix typo --- libempathy/empathy-idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c index f60fc0f85..b77dd0732 100644 --- a/libempathy/empathy-idle.c +++ b/libempathy/empathy-idle.c @@ -577,7 +577,7 @@ empathy_idle_do_set_presence (EmpathyIdle *idle, const gchar *status_message) { EmpathyIdlePriv *priv = GET_PRIV (idle); - const gchar *statusses[NUM_TP_CONNECTION_PRESENCE_TYPES] = { + const gchar *statuses[NUM_TP_CONNECTION_PRESENCE_TYPES] = { NULL, "offline", "available", @@ -592,7 +592,7 @@ empathy_idle_do_set_presence (EmpathyIdle *idle, g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES); - status = statusses[status_type]; + status = statuses[status_type]; g_return_if_fail (status != NULL); -- cgit v1.2.3 From 4e38b2c3eab6a2a19906db5c4933870beb6ce626 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 19:29:35 +0200 Subject: Add a small comment about emp_account_manager_update_global_presence --- libempathy/empathy-account-manager.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index c199e1d3e..2057581d4 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -150,6 +150,9 @@ emp_account_manager_update_global_presence (EmpathyAccountManager *manager) GHashTableIter iter; gpointer value; + /* Make the global presence is equal to the presence of the account with the + * highest availability */ + g_hash_table_iter_init (&iter, priv->accounts); while (g_hash_table_iter_next (&iter, NULL, &value)) { -- cgit v1.2.3 From f54c1834d7a8dc0de0f6f4c1ae60910a38944d05 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 19:30:25 +0200 Subject: add some slightly nicer debug messages --- libempathy/empathy-account.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index 5cf489769..4585d33cf 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -356,7 +356,8 @@ empathy_account_got_all_cb (TpProxy *proxy, if (error != NULL) { - printf ("Unhappy\n"); + DEBUG ("Failed to get the initial set of account properties: %s", + error->message); return; } @@ -907,7 +908,7 @@ empathy_account_requested_presence_cb (TpProxy *proxy, GObject *weak_object) { if (error) - DEBUG (":( : %s", error->message); + DEBUG ("Failed to set the requested presence: %s", error->message); } -- cgit v1.2.3 From 87070d25c5f2d9a0ecba73e8ce913eca7f183c79 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Jul 2009 19:35:03 +0200 Subject: Fix some coding style issues --- libempathy/empathy-account-manager.c | 11 +++++++---- libempathy/empathy-account-settings.c | 33 ++++++++++++++++++--------------- libempathy/empathy-account.c | 8 +++++--- libempathy/empathy-dispatcher.c | 1 - 4 files changed, 30 insertions(+), 23 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index 2057581d4..727eb7eaf 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -847,10 +847,13 @@ empathy_account_manager_created_cb (TpAccountManager *proxy, void empathy_account_manager_create_account_async (EmpathyAccountManager *manager, - const gchar *connection_manager, - const gchar *protocol, const gchar *display_name, - GHashTable *parameters, GHashTable *properties, - GAsyncReadyCallback callback, gpointer user_data) + const gchar *connection_manager, + const gchar *protocol, + const gchar *display_name, + GHashTable *parameters, + GHashTable *properties, + GAsyncReadyCallback callback, + gpointer user_data) { EmpathyAccountManagerPriv *priv = GET_PRIV (manager); GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (manager), diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index 2763f0702..0b92ec1b1 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -301,7 +301,7 @@ empathy_account_settings_dispose (GObject *object) static void empathy_account_settings_free_unset_parameters ( - EmpathyAccountSettings *settings) + EmpathyAccountSettings *settings) { EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); int i; @@ -368,7 +368,8 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) static void empathy_account_settings_ready_cb (GObject *obj, - GParamSpec *spec, gpointer user_data) + GParamSpec *spec, + gpointer user_data) { EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data); @@ -458,7 +459,7 @@ empathy_account_settings_get_account (EmpathyAccountSettings *settings) static gboolean empathy_account_settings_is_unset (EmpathyAccountSettings *settings, - const gchar *param) + const gchar *param) { EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); GArray *a; @@ -477,7 +478,7 @@ empathy_account_settings_is_unset (EmpathyAccountSettings *settings, static TpConnectionManagerParam * empathy_account_settings_get_tp_param (EmpathyAccountSettings *settings, - const gchar *param) + const gchar *param) { TpConnectionManagerParam *tp_params = empathy_account_settings_get_tp_params (settings); @@ -496,7 +497,7 @@ empathy_account_settings_get_tp_param (EmpathyAccountSettings *settings, const GValue * empathy_account_settings_get_default (EmpathyAccountSettings *settings, - const gchar *param) + const gchar *param) { TpConnectionManagerParam *p; @@ -510,7 +511,7 @@ empathy_account_settings_get_default (EmpathyAccountSettings *settings, const gchar * empathy_settings_get_dbus_signature (EmpathyAccountSettings *settings, - const gchar *param) + const gchar *param) { TpConnectionManagerParam *p; @@ -524,7 +525,7 @@ empathy_settings_get_dbus_signature (EmpathyAccountSettings *settings, const GValue * empathy_account_settings_get (EmpathyAccountSettings *settings, - const gchar *param) + const gchar *param) { EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); const GValue *result = NULL; @@ -821,7 +822,8 @@ empathy_account_settings_set_display_name_finish ( static void empathy_account_settings_account_updated (GObject *source, - GAsyncResult *result, gpointer user_data) + GAsyncResult *result, + gpointer user_data) { EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data); EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); @@ -844,8 +846,8 @@ empathy_account_settings_account_updated (GObject *source, static void empathy_account_settings_created_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) + GAsyncResult *result, + gpointer user_data) { EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data); EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); @@ -892,7 +894,8 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings) static void empathy_account_settings_manager_ready_cb (EmpathyAccountManager *manager, - GParamSpec *spec, gpointer user_data) + GParamSpec *spec, + gpointer user_data) { EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data); EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); @@ -910,8 +913,8 @@ empathy_account_settings_manager_ready_cb (EmpathyAccountManager *manager, void empathy_account_settings_apply_async (EmpathyAccountSettings *settings, - GAsyncReadyCallback callback, - gpointer user_data) + GAsyncReadyCallback callback, + gpointer user_data) { EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); @@ -950,8 +953,8 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings, gboolean empathy_account_settings_apply_finish (EmpathyAccountSettings *settings, - GAsyncResult *result, - GError **error) + GAsyncResult *result, + GError **error) { if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c index 4585d33cf..df948b69c 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -200,7 +200,8 @@ empathy_account_get_property (GObject *object, } static void -empathy_account_update (EmpathyAccount *account, GHashTable *properties) +empathy_account_update (EmpathyAccount *account, + GHashTable *properties) { EmpathyAccountPriv *priv = GET_PRIV (account); const gchar *conn_path; @@ -401,7 +402,7 @@ empathy_account_unescape_protocol (const gchar *protocol, gssize len) static gboolean empathy_account_parse_unique_name (const gchar *bus_name, - gchar **protocol, gchar **manager) + gchar **protocol, gchar **manager) { const gchar *proto, *proto_end; const gchar *cm, *cm_end; @@ -780,7 +781,8 @@ empathy_account_is_ready (EmpathyAccount *account) EmpathyAccount * -empathy_account_new (TpDBusDaemon *dbus, const gchar *unique_name) +empathy_account_new (TpDBusDaemon *dbus, + const gchar *unique_name) { return EMPATHY_ACCOUNT (g_object_new (EMPATHY_TYPE_ACCOUNT, "dbus-daemon", dbus, diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index fe330256d..03f5fc1b8 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -1057,7 +1057,6 @@ empathy_dispatcher_class_init (EmpathyDispatcherClass *klass) g_type_class_add_private (object_class, sizeof (EmpathyDispatcherPriv)); - klass->dbus_props_class.interfaces = prop_interfaces; tp_dbus_properties_mixin_class_init (object_class, G_STRUCT_OFFSET (EmpathyDispatcherClass, dbus_props_class)); -- cgit v1.2.3