| 34 #include "util.h" |
34 #include "util.h" |
| 35 |
35 |
| 36 #define SEND_TYPED_TIMEOUT_SECONDS 5 |
36 #define SEND_TYPED_TIMEOUT_SECONDS 5 |
| 37 |
37 |
| 38 /** @copydoc _PurpleConversationPrivate */ |
38 /** @copydoc _PurpleConversationPrivate */ |
| 39 typedef struct _PurpleConversationPrivate PurpleConversationPrivate; |
39 typedef struct _PurpleConversationPrivate PurpleConversationPrivate; |
| 40 /** @copydoc _PurpleChatConversationPrivate */ |
40 /** @copydoc _PurpleChatConversationPrivate */ |
| 41 typedef struct _PurpleChatConversationPrivate PurpleChatConversationPrivate; |
41 typedef struct _PurpleChatConversationPrivate PurpleChatConversationPrivate; |
| 42 /** @copydoc _PurpleIMConversationPrivate */ |
42 /** @copydoc _PurpleIMConversationPrivate */ |
| 43 typedef struct _PurpleIMConversationPrivate PurpleIMConversationPrivate; |
43 typedef struct _PurpleIMConversationPrivate PurpleIMConversationPrivate; |
| |
44 /** @copydoc _PurpleChatConversationBuddyPrivate */ |
| |
45 typedef struct _PurpleChatConversationBuddyPrivate PurpleChatConversationBuddyPrivate; |
| |
46 /** @copydoc _PurpleConversationMessagePrivate */ |
| |
47 typedef struct _PurpleConversationMessagePrivate PurpleConversationMessagePrivate; |
| 44 |
48 |
| 45 /** |
49 /** |
| 46 * A core representation of a conversation between two or more people. |
50 * A core representation of a conversation between two or more people. |
| 47 * |
51 * |
| 48 * The conversation can be an IM or a chat. |
52 * The conversation can be an IM or a chat. |
| 319 who = purple_conversation_get_name(conv); |
323 who = purple_conversation_get_name(conv); |
| 320 |
324 |
| 321 if (err == -E2BIG) { |
325 if (err == -E2BIG) { |
| 322 msg = _("Unable to send message: The message is too large."); |
326 msg = _("Unable to send message: The message is too large."); |
| 323 |
327 |
| 324 if (!purple_conv_present_error(who, account, msg)) { |
328 if (!purple_conversation_helper_present_error(who, account, msg)) { |
| 325 char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who); |
329 char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who); |
| 326 purple_notify_error(gc, NULL, msg2, _("The message is too large.")); |
330 purple_notify_error(gc, NULL, msg2, _("The message is too large.")); |
| 327 g_free(msg2); |
331 g_free(msg2); |
| 328 } |
332 } |
| 329 } |
333 } |
| 332 "Not yet connected.\n"); |
336 "Not yet connected.\n"); |
| 333 } |
337 } |
| 334 else { |
338 else { |
| 335 msg = _("Unable to send message."); |
339 msg = _("Unable to send message."); |
| 336 |
340 |
| 337 if (!purple_conv_present_error(who, account, msg)) { |
341 if (!purple_conversation_helper_present_error(who, account, msg)) { |
| 338 char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who); |
342 char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who); |
| 339 purple_notify_error(gc, NULL, msg2, NULL); |
343 purple_notify_error(gc, NULL, msg2, NULL); |
| 340 g_free(msg2); |
344 g_free(msg2); |
| 341 } |
345 } |
| 342 } |
346 } |
| 447 g_return_val_if_fail(type != PURPLE_CONVERSATION_TYPE_UNKNOWN, NULL); |
451 g_return_val_if_fail(type != PURPLE_CONVERSATION_TYPE_UNKNOWN, NULL); |
| 448 g_return_val_if_fail(account != NULL, NULL); |
452 g_return_val_if_fail(account != NULL, NULL); |
| 449 g_return_val_if_fail(name != NULL, NULL); |
453 g_return_val_if_fail(name != NULL, NULL); |
| 450 |
454 |
| 451 /* Check if this conversation already exists. */ |
455 /* Check if this conversation already exists. */ |
| 452 if ((conv = purple_find_conversation_with_account(type, name, account)) != NULL) |
456 if ((conv = purple_conversations_find_with_account(type, name, account)) != NULL) |
| 453 { |
457 { |
| 454 if (purple_conversation_get_type(conv) == PURPLE_CONVERSATION_TYPE_CHAT && |
458 if (purple_conversation_get_type(conv) == PURPLE_CONVERSATION_TYPE_CHAT && |
| 455 !purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv))) { |
459 !purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv))) { |
| 456 purple_debug_warning("conversation", "Trying to create multiple " |
460 purple_debug_warning("conversation", "Trying to create multiple " |
| 457 "chats (%s) with the same name is deprecated and will be " |
461 "chats (%s) with the same name is deprecated and will be " |
| 675 } |
679 } |
| 676 else if (conv->type == PURPLE_CONVERSATION_TYPE_CHAT) { |
680 else if (conv->type == PURPLE_CONVERSATION_TYPE_CHAT) { |
| 677 g_hash_table_destroy(conv->u.chat->users); |
681 g_hash_table_destroy(conv->u.chat->users); |
| 678 conv->u.chat->users = NULL; |
682 conv->u.chat->users = NULL; |
| 679 |
683 |
| 680 g_list_foreach(conv->u.chat->in_room, (GFunc)purple_chat_conversation_cb_destroy, NULL); |
684 g_list_foreach(conv->u.chat->in_room, (GFunc)purple_chat_conversation_buddy_destroy, NULL); |
| 681 g_list_free(conv->u.chat->in_room); |
685 g_list_free(conv->u.chat->in_room); |
| 682 |
686 |
| 683 g_list_foreach(conv->u.chat->ignored, (GFunc)g_free, NULL); |
687 g_list_foreach(conv->u.chat->ignored, (GFunc)g_free, NULL); |
| 684 g_list_free(conv->u.chat->ignored); |
688 g_list_free(conv->u.chat->ignored); |
| 685 |
689 |
| 953 { |
942 { |
| 954 g_return_val_if_fail(conv != NULL, NULL); |
943 g_return_val_if_fail(conv != NULL, NULL); |
| 955 g_return_val_if_fail(key != NULL, NULL); |
944 g_return_val_if_fail(key != NULL, NULL); |
| 956 |
945 |
| 957 return g_hash_table_lookup(conv->data, key); |
946 return g_hash_table_lookup(conv->data, key); |
| 958 } |
|
| 959 |
|
| 960 PurpleConversation * |
|
| 961 purple_find_conversation_with_account(PurpleConversationType type, |
|
| 962 const char *name, |
|
| 963 const PurpleAccount *account) |
|
| 964 { |
|
| 965 PurpleConversation *c = NULL; |
|
| 966 struct _purple_hconv hc; |
|
| 967 |
|
| 968 g_return_val_if_fail(name != NULL, NULL); |
|
| 969 |
|
| 970 hc.name = (gchar *)purple_normalize(account, name); |
|
| 971 hc.account = account; |
|
| 972 hc.type = type; |
|
| 973 |
|
| 974 switch (type) { |
|
| 975 case PURPLE_CONVERSATION_TYPE_IM: |
|
| 976 case PURPLE_CONVERSATION_TYPE_CHAT: |
|
| 977 c = g_hash_table_lookup(conversation_cache, &hc); |
|
| 978 break; |
|
| 979 case PURPLE_CONVERSATION_TYPE_ANY: |
|
| 980 hc.type = PURPLE_CONVERSATION_TYPE_IM; |
|
| 981 c = g_hash_table_lookup(conversation_cache, &hc); |
|
| 982 if (!c) { |
|
| 983 hc.type = PURPLE_CONVERSATION_TYPE_CHAT; |
|
| 984 c = g_hash_table_lookup(conversation_cache, &hc); |
|
| 985 } |
|
| 986 break; |
|
| 987 default: |
|
| 988 g_return_val_if_reached(NULL); |
|
| 989 } |
|
| 990 |
|
| 991 return c; |
|
| 992 } |
947 } |
| 993 |
948 |
| 994 void |
949 void |
| 995 purple_conversation_write(PurpleConversation *conv, const char *who, |
950 purple_conversation_write(PurpleConversation *conv, const char *who, |
| 996 const char *message, PurpleConversationMessageFlags flags, |
951 const char *message, PurpleConversationMessageFlags flags, |
| 1132 } |
1087 } |
| 1133 |
1088 |
| 1134 /************************************************************************** |
1089 /************************************************************************** |
| 1135 * IM Conversation API |
1090 * IM Conversation API |
| 1136 **************************************************************************/ |
1091 **************************************************************************/ |
| 1137 PurpleConversation * |
|
| 1138 purple_im_conversation_get_conversation(const PurpleIMConversation *im) |
|
| 1139 { |
|
| 1140 g_return_val_if_fail(im != NULL, NULL); |
|
| 1141 |
|
| 1142 return im->conv; |
|
| 1143 } |
|
| 1144 |
|
| 1145 void |
1092 void |
| 1146 purple_im_conversation_set_icon(PurpleIMConversation *im, PurpleBuddyIcon *icon) |
1093 purple_im_conversation_set_icon(PurpleIMConversation *im, PurpleBuddyIcon *icon) |
| 1147 { |
1094 { |
| 1148 g_return_if_fail(im != NULL); |
1095 g_return_if_fail(im != NULL); |
| 1149 |
1096 |
| 1316 c->ui_ops->write_im(c, who, message, flags, mtime); |
1263 c->ui_ops->write_im(c, who, message, flags, mtime); |
| 1317 else |
1264 else |
| 1318 purple_conversation_write(c, who, message, flags, mtime); |
1265 purple_conversation_write(c, who, message, flags, mtime); |
| 1319 } |
1266 } |
| 1320 |
1267 |
| 1321 gboolean purple_conv_present_error(const char *who, PurpleAccount *account, const char *what) |
1268 gboolean purple_conversation_helper_present_error(const char *who, PurpleAccount *account, const char *what) |
| 1322 { |
1269 { |
| 1323 PurpleConversation *conv; |
1270 PurpleConversation *conv; |
| 1324 |
1271 |
| 1325 g_return_val_if_fail(who != NULL, FALSE); |
1272 g_return_val_if_fail(who != NULL, FALSE); |
| 1326 g_return_val_if_fail(account !=NULL, FALSE); |
1273 g_return_val_if_fail(account !=NULL, FALSE); |
| 1327 g_return_val_if_fail(what != NULL, FALSE); |
1274 g_return_val_if_fail(what != NULL, FALSE); |
| 1328 |
1275 |
| 1329 conv = purple_find_conversation_with_account(PURPLE_CONVERSATION_TYPE_ANY, who, account); |
1276 conv = purple_conversations_find_with_account(PURPLE_CONVERSATION_TYPE_ANY, who, account); |
| 1330 if (conv != NULL) |
1277 if (conv != NULL) |
| 1331 purple_conversation_write(conv, NULL, what, PURPLE_CONVERSATION_MESSAGE_ERROR, time(NULL)); |
1278 purple_conversation_write(conv, NULL, what, PURPLE_CONVERSATION_MESSAGE_ERROR, time(NULL)); |
| 1332 else |
1279 else |
| 1333 return FALSE; |
1280 return FALSE; |
| 1334 |
1281 |
| 1340 { |
1287 { |
| 1341 purple_im_conversation_send_with_flags(im, message, 0); |
1288 purple_im_conversation_send_with_flags(im, message, 0); |
| 1342 } |
1289 } |
| 1343 |
1290 |
| 1344 static void |
1291 static void |
| 1345 purple_conv_send_confirm_cb(gpointer *data) |
1292 purple_conversation_send_confirm_cb(gpointer *data) |
| 1346 { |
1293 { |
| 1347 PurpleConversation *conv = data[0]; |
1294 PurpleConversation *conv = data[0]; |
| 1348 char *message = data[1]; |
1295 char *message = data[1]; |
| 1349 |
1296 |
| 1350 g_free(data); |
1297 g_free(data); |
| 1351 common_send(conv, message, 0); |
1298 common_send(conv, message, 0); |
| 1352 } |
1299 } |
| 1353 |
1300 |
| 1354 void |
1301 void |
| 1355 purple_conv_send_confirm(PurpleConversation *conv, const char *message) |
1302 purple_conversation_send_confirm(PurpleConversation *conv, const char *message) |
| 1356 { |
1303 { |
| 1357 char *text; |
1304 char *text; |
| 1358 gpointer *data; |
1305 gpointer *data; |
| 1359 |
1306 |
| 1360 g_return_if_fail(conv != NULL); |
1307 g_return_if_fail(conv != NULL); |
| 1372 data[1] = (gpointer)message; |
1319 data[1] = (gpointer)message; |
| 1373 |
1320 |
| 1374 purple_request_action(conv, NULL, _("Send Message"), text, 0, |
1321 purple_request_action(conv, NULL, _("Send Message"), text, 0, |
| 1375 purple_conversation_get_account(conv), NULL, conv, |
1322 purple_conversation_get_account(conv), NULL, conv, |
| 1376 data, 2, |
1323 data, 2, |
| 1377 _("_Send Message"), G_CALLBACK(purple_conv_send_confirm_cb), |
1324 _("_Send Message"), G_CALLBACK(purple_conversation_send_confirm_cb), |
| 1378 _("Cancel"), NULL); |
1325 _("Cancel"), NULL); |
| 1379 } |
1326 } |
| 1380 |
1327 |
| 1381 void |
1328 void |
| 1382 purple_im_conversation_send_with_flags(PurpleIMConversation *im, const char *message, PurpleConversationMessageFlags flags) |
1329 purple_im_conversation_send_with_flags(PurpleIMConversation *im, const char *message, PurpleConversationMessageFlags flags) |
| 1474 |
1421 |
| 1475 g_return_if_fail(chat != NULL); |
1422 g_return_if_fail(chat != NULL); |
| 1476 g_return_if_fail(name != NULL); |
1423 g_return_if_fail(name != NULL); |
| 1477 |
1424 |
| 1478 /* Make sure the user is actually ignored. */ |
1425 /* Make sure the user is actually ignored. */ |
| 1479 if (!purple_chat_conversation_is_user_ignored(chat, name)) |
1426 if (!purple_chat_conversation_is_ignored_user(chat, name)) |
| 1480 return; |
1427 return; |
| 1481 |
1428 |
| 1482 item = g_list_find(purple_chat_conversation_get_ignored(chat), |
1429 item = g_list_find(purple_chat_conversation_get_ignored(chat), |
| 1483 purple_chat_conversation_get_ignored_user(chat, name)); |
1430 purple_chat_conversation_get_ignored_user(chat, name)); |
| 1484 |
1431 |
| 1749 } |
1696 } |
| 1750 } |
1697 } |
| 1751 |
1698 |
| 1752 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(), |
1699 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(), |
| 1753 "chat-buddy-joining", conv, user, flag)) || |
1700 "chat-buddy-joining", conv, user, flag)) || |
| 1754 purple_chat_conversation_is_user_ignored(chat, user); |
1701 purple_chat_conversation_is_ignored_user(chat, user); |
| 1755 |
1702 |
| 1756 cbuddy = purple_chat_conversation_cb_new(user, alias, flag); |
1703 cbuddy = purple_chat_conversation_buddy_new(user, alias, flag); |
| 1757 cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL; |
1704 cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL; |
| 1758 |
1705 |
| 1759 chat->in_room = g_list_prepend(chat->in_room, cbuddy); |
1706 chat->in_room = g_list_prepend(chat->in_room, cbuddy); |
| 1760 g_hash_table_replace(chat->users, g_strdup(cbuddy->name), cbuddy); |
1707 g_hash_table_replace(chat->users, g_strdup(cbuddy->name), cbuddy); |
| 1761 |
1708 |
| 1845 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), new_user)) != NULL) |
1792 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), new_user)) != NULL) |
| 1846 new_alias = purple_buddy_get_contact_alias(buddy); |
1793 new_alias = purple_buddy_get_contact_alias(buddy); |
| 1847 } |
1794 } |
| 1848 |
1795 |
| 1849 flags = purple_chat_conversation_user_get_flags(chat, old_user); |
1796 flags = purple_chat_conversation_user_get_flags(chat, old_user); |
| 1850 cb = purple_chat_conversation_cb_new(new_user, new_alias, flags); |
1797 cb = purple_chat_conversation_buddy_new(new_user, new_alias, flags); |
| 1851 cb->buddy = purple_find_buddy(conv->account, new_user) != NULL; |
1798 cb->buddy = purple_find_buddy(conv->account, new_user) != NULL; |
| 1852 |
1799 |
| 1853 chat->in_room = g_list_prepend(chat->in_room, cb); |
1800 chat->in_room = g_list_prepend(chat->in_room, cb); |
| 1854 g_hash_table_replace(chat->users, g_strdup(cb->name), cb); |
1801 g_hash_table_replace(chat->users, g_strdup(cb->name), cb); |
| 1855 |
1802 |
| 1856 if (ops != NULL && ops->chat_rename_user != NULL) |
1803 if (ops != NULL && ops->chat_rename_user != NULL) |
| 1857 ops->chat_rename_user(conv, old_user, new_user, new_alias); |
1804 ops->chat_rename_user(conv, old_user, new_user, new_alias); |
| 1858 |
1805 |
| 1859 cb = purple_chat_conversation_cb_find(chat, old_user); |
1806 cb = purple_chat_conversation_find_buddy(chat, old_user); |
| 1860 |
1807 |
| 1861 if (cb) { |
1808 if (cb) { |
| 1862 chat->in_room = g_list_remove(chat->in_room, cb); |
1809 chat->in_room = g_list_remove(chat->in_room, cb); |
| 1863 g_hash_table_remove(chat->users, cb->name); |
1810 g_hash_table_remove(chat->users, cb->name); |
| 1864 purple_chat_conversation_cb_destroy(cb); |
1811 purple_chat_conversation_buddy_destroy(cb); |
| 1865 } |
1812 } |
| 1866 |
1813 |
| 1867 if (purple_chat_conversation_is_user_ignored(chat, old_user)) { |
1814 if (purple_chat_conversation_is_ignored_user(chat, old_user)) { |
| 1868 purple_chat_conversation_unignore(chat, old_user); |
1815 purple_chat_conversation_unignore(chat, old_user); |
| 1869 purple_chat_conversation_ignore(chat, new_user); |
1816 purple_chat_conversation_ignore(chat, new_user); |
| 1870 } |
1817 } |
| 1871 else if (purple_chat_conversation_is_user_ignored(chat, new_user)) |
1818 else if (purple_chat_conversation_is_ignored_user(chat, new_user)) |
| 1872 purple_chat_conversation_unignore(chat, new_user); |
1819 purple_chat_conversation_unignore(chat, new_user); |
| 1873 |
1820 |
| 1874 if (is_me) |
1821 if (is_me) |
| 1875 purple_chat_conversation_set_nick(chat, new_user); |
1822 purple_chat_conversation_set_nick(chat, new_user); |
| 1876 |
1823 |
| 1877 if (purple_prefs_get_bool("/purple/conversations/chat/show_nick_change") && |
1824 if (purple_prefs_get_bool("/purple/conversations/chat/show_nick_change") && |
| 1878 !purple_chat_conversation_is_user_ignored(chat, new_user)) { |
1825 !purple_chat_conversation_is_ignored_user(chat, new_user)) { |
| 1879 |
1826 |
| 1880 if (is_me) { |
1827 if (is_me) { |
| 1881 char *escaped = g_markup_escape_text(new_user, -1); |
1828 char *escaped = g_markup_escape_text(new_user, -1); |
| 1882 g_snprintf(tmp, sizeof(tmp), |
1829 g_snprintf(tmp, sizeof(tmp), |
| 1883 _("You are now known as %s"), escaped); |
1830 _("You are now known as %s"), escaped); |
| 1946 |
1893 |
| 1947 for (l = users; l != NULL; l = l->next) { |
1894 for (l = users; l != NULL; l = l->next) { |
| 1948 const char *user = (const char *)l->data; |
1895 const char *user = (const char *)l->data; |
| 1949 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(), |
1896 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(), |
| 1950 "chat-buddy-leaving", conv, user, reason)) | |
1897 "chat-buddy-leaving", conv, user, reason)) | |
| 1951 purple_chat_conversation_is_user_ignored(chat, user); |
1898 purple_chat_conversation_is_ignored_user(chat, user); |
| 1952 |
1899 |
| 1953 cb = purple_chat_conversation_cb_find(chat, user); |
1900 cb = purple_chat_conversation_find_buddy(chat, user); |
| 1954 |
1901 |
| 1955 if (cb) { |
1902 if (cb) { |
| 1956 chat->in_room = g_list_remove(chat->in_room, cb); |
1903 chat->in_room = g_list_remove(chat->in_room, cb); |
| 1957 g_hash_table_remove(chat->users, cb->name); |
1904 g_hash_table_remove(chat->users, cb->name); |
| 1958 purple_chat_conversation_cb_destroy(cb); |
1905 purple_chat_conversation_buddy_destroy(cb); |
| 1959 } |
1906 } |
| 1960 |
1907 |
| 1961 /* NOTE: Don't remove them from ignored in case they re-enter. */ |
1908 /* NOTE: Don't remove them from ignored in case they re-enter. */ |
| 1962 |
1909 |
| 1963 if (!quiet) { |
1910 if (!quiet) { |
| 2029 purple_signal_emit(purple_conversations_get_handle(), |
1976 purple_signal_emit(purple_conversations_get_handle(), |
| 2030 "chat-buddy-leaving", conv, cb->name, NULL); |
1977 "chat-buddy-leaving", conv, cb->name, NULL); |
| 2031 purple_signal_emit(purple_conversations_get_handle(), |
1978 purple_signal_emit(purple_conversations_get_handle(), |
| 2032 "chat-buddy-left", conv, cb->name, NULL); |
1979 "chat-buddy-left", conv, cb->name, NULL); |
| 2033 |
1980 |
| 2034 purple_chat_conversation_cb_destroy(cb); |
1981 purple_chat_conversation_buddy_destroy(cb); |
| 2035 } |
1982 } |
| 2036 |
1983 |
| 2037 g_hash_table_remove_all(chat->users); |
1984 g_hash_table_remove_all(chat->users); |
| 2038 |
1985 |
| 2039 g_list_free(users); |
1986 g_list_free(users); |
| 2045 purple_chat_conversation_find_user(PurpleChatConversation *chat, const char *user) |
1992 purple_chat_conversation_find_user(PurpleChatConversation *chat, const char *user) |
| 2046 { |
1993 { |
| 2047 g_return_val_if_fail(chat != NULL, FALSE); |
1994 g_return_val_if_fail(chat != NULL, FALSE); |
| 2048 g_return_val_if_fail(user != NULL, FALSE); |
1995 g_return_val_if_fail(user != NULL, FALSE); |
| 2049 |
1996 |
| 2050 return (purple_chat_conversation_cb_find(chat, user) != NULL); |
1997 return (purple_chat_conversation_find_buddy(chat, user) != NULL); |
| 2051 } |
1998 } |
| 2052 |
1999 |
| 2053 void |
2000 void |
| 2054 purple_chat_conversation_user_set_flags(PurpleChatConversation *chat, const char *user, |
2001 purple_chat_conversation_user_set_flags(PurpleChatConversation *chat, const char *user, |
| 2055 PurpleChatConversationBuddyFlags flags) |
2002 PurpleChatConversationBuddyFlags flags) |
| 2206 PURPLE_DBUS_REGISTER_POINTER(cb, PurpleChatConversationBuddy); |
2153 PURPLE_DBUS_REGISTER_POINTER(cb, PurpleChatConversationBuddy); |
| 2207 return cb; |
2154 return cb; |
| 2208 } |
2155 } |
| 2209 |
2156 |
| 2210 PurpleChatConversationBuddy * |
2157 PurpleChatConversationBuddy * |
| 2211 purple_chat_conversation_cb_find(PurpleChatConversation *chat, const char *name) |
2158 purple_chat_conversation_find_buddy(PurpleChatConversation *chat, const char *name) |
| 2212 { |
2159 { |
| 2213 g_return_val_if_fail(chat != NULL, NULL); |
2160 g_return_val_if_fail(chat != NULL, NULL); |
| 2214 g_return_val_if_fail(name != NULL, NULL); |
2161 g_return_val_if_fail(name != NULL, NULL); |
| 2215 |
2162 |
| 2216 return g_hash_table_lookup(chat->users, name); |
2163 return g_hash_table_lookup(chat->users, name); |
| 2217 } |
2164 } |
| 2218 |
2165 |
| 2219 void |
2166 void |
| 2220 purple_chat_conversation_cb_destroy(PurpleChatConversationBuddy *cb) |
2167 purple_chat_conversation_buddy_destroy(PurpleChatConversationBuddy *cb) |
| 2221 { |
2168 { |
| 2222 if (cb == NULL) |
2169 if (cb == NULL) |
| 2223 return; |
2170 return; |
| 2224 |
2171 |
| 2225 purple_signal_emit(purple_conversations_get_handle(), |
2172 purple_signal_emit(purple_conversations_get_handle(), |
| 2232 |
2179 |
| 2233 PURPLE_DBUS_UNREGISTER_POINTER(cb); |
2180 PURPLE_DBUS_UNREGISTER_POINTER(cb); |
| 2234 g_free(cb); |
2181 g_free(cb); |
| 2235 } |
2182 } |
| 2236 |
2183 |
| 2237 void purple_chat_conversation_cb_set_ui_data(PurpleChatConversationBuddy *cb, gpointer ui_data) |
2184 void purple_chat_conversation_buddy_set_ui_data(PurpleChatConversationBuddy *cb, gpointer ui_data) |
| 2238 { |
2185 { |
| 2239 g_return_if_fail(cb != NULL); |
2186 g_return_if_fail(cb != NULL); |
| 2240 |
2187 |
| 2241 cb->ui_data = ui_data; |
2188 cb->ui_data = ui_data; |
| 2242 } |
2189 } |
| 2243 |
2190 |
| 2244 gpointer purple_chat_conversation_cb_get_ui_data(const PurpleChatConversationBuddy *cb) |
2191 gpointer purple_chat_conversation_buddy_get_ui_data(const PurpleChatConversationBuddy *cb) |
| 2245 { |
2192 { |
| 2246 g_return_val_if_fail(cb != NULL, NULL); |
2193 g_return_val_if_fail(cb != NULL, NULL); |
| 2247 |
2194 |
| 2248 return cb->ui_data; |
2195 return cb->ui_data; |
| 2249 } |
2196 } |
| 2250 |
2197 |
| 2251 const char * |
2198 const char * |
| 2252 purple_chat_conversation_cb_get_alias(const PurpleChatConversationBuddy *cb) |
2199 purple_chat_conversation_buddy_get_alias(const PurpleChatConversationBuddy *cb) |
| 2253 { |
2200 { |
| 2254 g_return_val_if_fail(cb != NULL, NULL); |
2201 g_return_val_if_fail(cb != NULL, NULL); |
| 2255 |
2202 |
| 2256 return cb->alias; |
2203 return cb->alias; |
| 2257 } |
2204 } |
| 2258 |
2205 |
| 2259 const char * |
2206 const char * |
| 2260 purple_chat_conversation_cb_get_name(const PurpleChatConversationBuddy *cb) |
2207 purple_chat_conversation_buddy_get_name(const PurpleChatConversationBuddy *cb) |
| 2261 { |
2208 { |
| 2262 g_return_val_if_fail(cb != NULL, NULL); |
2209 g_return_val_if_fail(cb != NULL, NULL); |
| 2263 |
2210 |
| 2264 return cb->name; |
2211 return cb->name; |
| 2265 } |
2212 } |
| 2266 |
2213 |
| 2267 PurpleChatConversationBuddyFlags |
2214 PurpleChatConversationBuddyFlags |
| 2268 purple_chat_conversation_cb_get_flags(const PurpleChatConversationBuddy *cb) |
2215 purple_chat_conversation_buddy_get_flags(const PurpleChatConversationBuddy *cb) |
| 2269 { |
2216 { |
| 2270 g_return_val_if_fail(cb != NULL, PURPLE_CHAT_CONVERSATION_BUDDY_NONE); |
2217 g_return_val_if_fail(cb != NULL, PURPLE_CHAT_CONVERSATION_BUDDY_NONE); |
| 2271 |
2218 |
| 2272 return cb->flags; |
2219 return cb->flags; |
| 2273 } |
2220 } |
| 2274 |
2221 |
| 2275 gboolean purple_chat_conversation_cb_is_buddy(const PurpleChatConversationBuddy *cb) |
2222 gboolean purple_chat_conversation_buddy_is_buddy(const PurpleChatConversationBuddy *cb) |
| 2276 { |
2223 { |
| 2277 g_return_val_if_fail(cb != NULL, FALSE); |
2224 g_return_val_if_fail(cb != NULL, FALSE); |
| 2278 |
2225 |
| 2279 return cb->buddy; |
2226 return cb->buddy; |
| 2280 } |
2227 } |
| 2281 |
2228 |
| 2282 const char * |
2229 const char * |
| 2283 purple_chat_conversation_cb_get_attribute(PurpleChatConversationBuddy *cb, const char *key) |
2230 purple_chat_conversation_buddy_get_attribute(PurpleChatConversationBuddy *cb, const char *key) |
| 2284 { |
2231 { |
| 2285 g_return_val_if_fail(cb != NULL, NULL); |
2232 g_return_val_if_fail(cb != NULL, NULL); |
| 2286 g_return_val_if_fail(key != NULL, NULL); |
2233 g_return_val_if_fail(key != NULL, NULL); |
| 2287 |
2234 |
| 2288 return g_hash_table_lookup(cb->attributes, key); |
2235 return g_hash_table_lookup(cb->attributes, key); |
| 2325 if (ops != NULL && ops->chat_update_user != NULL) |
2272 if (ops != NULL && ops->chat_update_user != NULL) |
| 2326 ops->chat_update_user(conv, cb->name); |
2273 ops->chat_update_user(conv, cb->name); |
| 2327 } |
2274 } |
| 2328 |
2275 |
| 2329 void |
2276 void |
| 2330 purple_chat_conversation_cb_set_attributes(PurpleChatConversation *chat, PurpleChatConversationBuddy *cb, GList *keys, GList *values) |
2277 purple_chat_conversation_buddy_set_attributes(PurpleChatConversation *chat, PurpleChatConversationBuddy *cb, GList *keys, GList *values) |
| 2331 { |
2278 { |
| 2332 PurpleConversation *conv; |
2279 PurpleConversation *conv; |
| 2333 PurpleConversationUiOps *ops; |
2280 PurpleConversationUiOps *ops; |
| 2334 |
2281 |
| 2335 g_return_if_fail(cb != NULL); |
2282 g_return_if_fail(cb != NULL); |