diff options
author | Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> | 2009-08-01 16:32:39 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> | 2009-08-01 16:32:39 +0800 |
commit | 3e8f25168aadd741ecc0fe8da4d1847eece5ff83 (patch) | |
tree | 69b2fc8984c98b9cad38d2ca5e8563da2b9aad8a /libempathy | |
parent | 41e5b31c1918f40c3ba47bff2dc9ab682fe0391f (diff) | |
parent | 87070d25c5f2d9a0ecba73e8ce913eca7f183c79 (diff) | |
download | gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar.gz gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar.bz2 gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar.lz gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar.xz gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.tar.zst gsoc2013-empathy-3e8f25168aadd741ecc0fe8da4d1847eece5ff83.zip |
Merge branch 'sjoerd-mc5' into mc5
Conflicts:
libempathy-gtk/empathy-account-widget.c
libempathy-gtk/empathy-protocol-chooser.c
Diffstat (limited to 'libempathy')
24 files changed, 385 insertions, 130 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index b037f5d30..18eff355f 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -167,6 +167,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)) { @@ -731,8 +734,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; @@ -755,18 +759,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 * @@ -914,10 +912,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 *res; 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-account-settings.c b/libempathy/empathy-account-settings.c index 256d05ba4..df99ea1c5 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -302,7 +302,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; @@ -386,7 +386,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); @@ -479,7 +480,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; @@ -498,7 +499,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); @@ -517,7 +518,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; @@ -531,7 +532,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; @@ -545,7 +546,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; @@ -888,7 +889,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); @@ -911,8 +913,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); @@ -959,7 +961,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); @@ -977,8 +980,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); @@ -1017,8 +1020,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 bb55abed7..ffb6e6786 100644 --- a/libempathy/empathy-account.c +++ b/libempathy/empathy-account.c @@ -202,7 +202,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; @@ -358,7 +359,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; } @@ -402,7 +404,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; @@ -469,7 +471,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, @@ -609,6 +611,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) { @@ -620,14 +637,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) @@ -773,7 +783,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, @@ -787,13 +798,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 { @@ -902,7 +912,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); } diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index a512f5b25..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); @@ -411,7 +411,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); @@ -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++; } } @@ -707,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-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-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-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..28238e44a 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -34,6 +34,13 @@ 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, + EMPATHY_CONTACT_LIST_CAN_ALIAS = 1 << 2, + EMPATHY_CONTACT_LIST_CAN_GROUP = 1 << 3, +} EmpathyContactListFlags; + typedef struct _EmpathyContactListIface EmpathyContactListIface; struct _EmpathyContactListIface { @@ -64,6 +71,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 +101,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-contact-manager.c b/libempathy/empathy-contact-manager.c index 7af2bd349..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) { @@ -527,19 +544,24 @@ 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); - 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; } diff --git a/libempathy/empathy-contact-manager.h b/libempathy/empathy-contact-manager.h index fbe9e2df0..97e21464a 100644 --- a/libempathy/empathy-contact-manager.h +++ b/libempathy/empathy-contact-manager.h @@ -50,10 +50,12 @@ 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); -gboolean empathy_contact_manager_can_add (EmpathyContactManager *manager, +EmpathyContactListFlags empathy_contact_manager_get_flags_for_connection ( + EmpathyContactManager *manager, TpConnection *connection); G_END_DECLS diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index d351aecbc..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); } @@ -802,6 +803,30 @@ empathy_contact_can_voip (EmpathyContact *contact) } 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) { EmpathyContactPriv *priv; 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); 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); diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index 0b2a74a2e..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)); @@ -1801,7 +1800,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 +1823,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-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); diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index d0487e761..81cbcade7 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -27,7 +27,14 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> + +/* 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 <glib/gstdio.h> +#define G_DISABLE_DEPRECATED #include <telepathy-glib/util.h> @@ -398,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); @@ -515,6 +524,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..a8fe6084c 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); 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); diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 091871034..51ce79bb6 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -876,6 +876,34 @@ 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) { + continue; + } + + 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, @@ -889,23 +917,30 @@ tp_chat_group_members_changed_cb (TpChannel *self, { EmpathyTpChatPriv *priv = GET_PRIV (chat); EmpathyContact *contact; - TpHandle handle; + EmpathyContact *actor_contact = NULL; guint i; - GList *l; + + if (actor != 0) { + actor_contact = chat_lookup_contact (chat, actor, FALSE); + if (actor_contact == NULL) { + /* 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); + } + } /* 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); } } @@ -918,6 +953,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 diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 6564deb2b..4bbe46b4f 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -51,6 +51,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 { @@ -470,7 +472,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 @@ -510,6 +512,64 @@ tp_contact_list_publish_request_channel_cb (TpConnection *connection, } 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_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 (!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; + break; + } + } +} + +static void tp_contact_list_publish_request_handle_cb (TpConnection *connection, const GArray *handles, const GError *error, @@ -559,7 +619,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 @@ -723,6 +783,32 @@ 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)); + } + + /* 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, -1, @@ -1075,6 +1161,31 @@ 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; + 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); + + 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) { @@ -1088,23 +1199,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; -} - -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; + iface->get_flags = tp_contact_list_get_flags; } void diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 525f2fe06..db35e94dd 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -227,21 +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) -{ - return a == b; -} - const gchar * empathy_presence_get_default_message (TpConnectionPresenceType presence) { @@ -363,6 +348,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..c6aebb4f2 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -62,9 +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); const gchar * empathy_presence_to_str (TpConnectionPresenceType presence); TpConnectionPresenceType empathy_presence_from_str (const gchar *str); @@ -77,6 +74,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); |