diff options
author | Guillaume Desmottes <gdesmott@gnome.org> | 2008-01-06 19:29:23 +0800 |
---|---|---|
committer | Guillaume Desmottes <gdesmott@gnome.org> | 2008-01-06 19:29:23 +0800 |
commit | 7326d702e717d1789429d3c0447a1a978219f77c (patch) | |
tree | c24654fb73c6c01c9e301c4e5f4048ceb32010c9 /libempathy | |
parent | ec6a65e1b4edc05805bfc250823ebc0af9402909 (diff) | |
parent | df879712bde35b86db101cf5940c2dfce3634299 (diff) | |
download | gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar.gz gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar.bz2 gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar.lz gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar.xz gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.tar.zst gsoc2013-empathy-7326d702e717d1789429d3c0447a1a978219f77c.zip |
Merge branch 'irc' of git+ssh://projects.collabora.co.uk/home/cassidy/public_html/git/empathy into irc
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact-list.c | 12 | ||||
-rw-r--r-- | libempathy/empathy-contact-list.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-contact-manager.c | 22 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 43 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 1 | ||||
-rw-r--r-- | libempathy/empathy-tp-contact-list.c | 28 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 30 | ||||
-rw-r--r-- | libempathy/empathy-utils.h | 4 |
8 files changed, 144 insertions, 0 deletions
diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 563265267..5164ccf1a 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -203,3 +203,15 @@ empathy_contact_list_rename_group (EmpathyContactList *list, } } +void +empathy_contact_list_remove_group (EmpathyContactList *list, + const gchar *group) +{ + g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list)); + g_return_if_fail (group != NULL); + + if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) { + EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group); + } +} + diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 96ab79e98..35575e112 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -61,6 +61,8 @@ struct _EmpathyContactListIface { void (*rename_group) (EmpathyContactList *list, const gchar *old_group, const gchar *new_group); + void (*remove_group) (EmpathyContactList *list, + const gchar *group); }; GType empathy_contact_list_get_type (void) G_GNUC_CONST; @@ -84,6 +86,8 @@ void empathy_contact_list_remove_from_group (EmpathyContactList *list, void empathy_contact_list_rename_group (EmpathyContactList *list, const gchar *old_group, const gchar *new_group); +void empathy_contact_list_remove_group (EmpathyContactList *list, + const gchar *group); G_END_DECLS diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 219cf8886..d86275048 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -482,6 +482,27 @@ contact_manager_rename_group (EmpathyContactList *manager, &data); } +static void contact_manager_remove_group_foreach (McAccount *account, + EmpathyTpContactList *list, + const gchar *group) +{ + empathy_contact_list_remove_group (EMPATHY_CONTACT_LIST (list), + group); +} + +static void +contact_manager_remove_group (EmpathyContactList *manager, + const gchar *group) +{ + EmpathyContactManagerPriv *priv = GET_PRIV (manager); + + g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager)); + + g_hash_table_foreach (priv->lists, + (GHFunc) contact_manager_remove_group_foreach, + (gpointer) group); +} + static void contact_manager_iface_init (EmpathyContactListIface *iface) { @@ -494,5 +515,6 @@ contact_manager_iface_init (EmpathyContactListIface *iface) iface->add_to_group = contact_manager_add_to_group; iface->remove_from_group = contact_manager_remove_from_group; iface->rename_group = contact_manager_rename_group; + iface->remove_group = contact_manager_remove_group; } diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 68a0af174..7a7f8dfec 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -561,6 +561,49 @@ empathy_tp_chat_new (McAccount *account, NULL); } +EmpathyTpChat * +empathy_tp_chat_new_with_contact (EmpathyContact *contact) +{ + EmpathyTpChat *chat; + MissionControl *mc; + McAccount *account; + TpConn *tp_conn; + TpChan *text_chan; + const gchar *bus_name; + guint handle; + + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); + + mc = empathy_mission_control_new (); + account = empathy_contact_get_account (contact); + + if (mission_control_get_connection_status (mc, account, NULL) != 0) { + /* The account is not connected. */ + return NULL; + } + + tp_conn = mission_control_get_connection (mc, account, NULL); + g_return_val_if_fail (tp_conn != NULL, NULL); + bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn)); + handle = empathy_contact_get_handle (contact); + + text_chan = tp_conn_new_channel (tp_get_bus (), + tp_conn, + bus_name, + TP_IFACE_CHANNEL_TYPE_TEXT, + TP_HANDLE_TYPE_CONTACT, + handle, + TRUE); + + chat = empathy_tp_chat_new (account, text_chan); + + g_object_unref (tp_conn); + g_object_unref (text_chan); + g_object_unref (mc); + + return chat; +} + gboolean empathy_tp_chat_get_acknowledge (EmpathyTpChat *chat) { diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 7f5ef212e..6de2cad4e 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -57,6 +57,7 @@ struct _EmpathyTpChatClass { GType empathy_tp_chat_get_type (void) G_GNUC_CONST; EmpathyTpChat *empathy_tp_chat_new (McAccount *account, TpChan *tp_chan); +EmpathyTpChat *empathy_tp_chat_new_with_contact (EmpathyContact *contact); gboolean empathy_tp_chat_get_acknowledge (EmpathyTpChat *chat); void empathy_tp_chat_set_acknowledge (EmpathyTpChat *chat, gboolean acknowledge); diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 805150177..2f366ff10 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -981,6 +981,33 @@ tp_contact_list_rename_group (EmpathyContactList *list, } static void +tp_contact_list_remove_group (EmpathyContactList *list, + const gchar *group) +{ + EmpathyTpGroup *tp_group; + GList *members; + + g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list)); + + tp_group = tp_contact_list_find_group (EMPATHY_TP_CONTACT_LIST (list), + group); + + if (!tp_group) { + return; + } + + empathy_debug (DEBUG_DOMAIN, "remove group %s", group); + + /* Remove all members of the group */ + members = empathy_tp_group_get_members (tp_group); + empathy_tp_group_remove_members (tp_group, members, ""); + empathy_tp_group_close (tp_group); + + g_list_foreach (members, (GFunc) g_object_unref, NULL); + g_list_free (members); +} + +static void tp_contact_list_iface_init (EmpathyContactListIface *iface) { iface->add = tp_contact_list_add; @@ -992,5 +1019,6 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface) iface->add_to_group = tp_contact_list_add_to_group; iface->remove_from_group = tp_contact_list_remove_from_group; iface->rename_group = tp_contact_list_rename_group; + iface->remove_group = tp_contact_list_remove_group; } diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index f322f0288..0e2c4b588 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -451,3 +451,33 @@ empathy_call_contact (EmpathyContact *contact) #endif } +void +empathy_chat_with_contact (EmpathyContact *contact) +{ + MissionControl *mc; + + mc = empathy_mission_control_new (); + mission_control_request_channel (mc, + empathy_contact_get_account (contact), + TP_IFACE_CHANNEL_TYPE_TEXT, + empathy_contact_get_handle (contact), + TP_HANDLE_TYPE_CONTACT, + NULL, NULL); + g_object_unref (mc); +} + +void +empathy_chat_with_contact_id (McAccount *account, const gchar *contact_id) +{ + MissionControl *mc; + + mc = empathy_mission_control_new (); + mission_control_request_channel_with_string_handle (mc, + account, + TP_IFACE_CHANNEL_TYPE_TEXT, + contact_id, + TP_HANDLE_TYPE_CONTACT, + NULL, NULL); + g_object_unref (mc); +} + diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 746e8de5b..1f3700d22 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -89,6 +89,10 @@ gchar * empathy_inspect_handle (McAccount *account, gchar * empathy_inspect_channel (McAccount *account, TpChan *tp_chan); void empathy_call_contact (EmpathyContact *contact); +void empathy_chat_with_contact (EmpathyContact *contact); +void empathy_chat_with_contact_id (McAccount *account, + const gchar *contact_id); + G_END_DECLS #endif /* __EMPATHY_UTILS_H__ */ |