Fri, 01 Oct 2021 05:09:16 -0500
move the gadu-gadu protocol plugins icons to a resource in the plugin
Testing Done:
Ran in devenv with a logo inverted (which was reverted before committing).
Reviewed at https://reviews.imfreedom.org/r/976/
|
35358
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
1 | /* purple |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
2 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
5 | * source distribution. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
6 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
7 | * Component written by Tomek Wasilczyk (http://www.wasilczyk.pl). |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
8 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
9 | * This file is dual-licensed under the GPL2+ and the X11 (MIT) licences. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
10 | * As a recipient of this file you may choose, which license to receive the |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
11 | * code under. As a contributor, you have to ensure the new code is |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
12 | * compatible with both. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
13 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
14 | * This program is free software; you can redistribute it and/or modify |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
15 | * it under the terms of the GNU General Public License as published by |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
16 | * the Free Software Foundation; either version 2 of the License, or |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
17 | * (at your option) any later version. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
18 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
19 | * This program is distributed in the hope that it will be useful, |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
22 | * GNU General Public License for more details. |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
23 | * |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
24 | * You should have received a copy of the GNU General Public License |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
25 | * along with this program; if not, write to the Free Software |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
7beae478c905
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
27 | */ |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
28 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
29 | #include <glib.h> |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
30 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
31 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
32 | #include "chat.h" |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
33 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
34 | #include "gg.h" |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
35 | #include "utils.h" |
|
34369
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
36 | #include "message-prpl.h" |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
37 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
38 | typedef struct _ggp_chat_local_info ggp_chat_local_info; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
39 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | struct _ggp_chat_session_data |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
41 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | ggp_chat_local_info *chats; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | int chats_count; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
44 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
45 | gboolean got_all_chats_info; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
46 | GSList *pending_joins; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | }; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
48 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
49 | struct _ggp_chat_local_info |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
51 | int local_id; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | uint64_t id; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
53 | |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
54 | PurpleChatConversation *conv; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | PurpleConnection *gc; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
56 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
57 | gboolean left; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
58 | gboolean previously_joined; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
59 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
60 | uin_t *participants; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
61 | int participants_count; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
62 | }; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
63 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | static ggp_chat_local_info * ggp_chat_new(PurpleConnection *gc, uint64_t id); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
65 | static ggp_chat_local_info * ggp_chat_get(PurpleConnection *gc, uint64_t id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
66 | static void ggp_chat_open_conv(ggp_chat_local_info *chat); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | static ggp_chat_local_info * ggp_chat_get_local(PurpleConnection *gc, |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
68 | int local_id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
69 | static void ggp_chat_joined(ggp_chat_local_info *chat, uin_t uin); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
70 | static void ggp_chat_left(ggp_chat_local_info *chat, uin_t uin); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
71 | static const gchar * ggp_chat_get_name_from_id(uint64_t id); |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
72 | static uint64_t ggp_chat_get_id_from_name(const gchar * name); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
73 | static void ggp_chat_join_id(PurpleConnection *gc, uint64_t id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
74 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | static inline ggp_chat_session_data * |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | ggp_chat_get_sdata(PurpleConnection *gc) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
77 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
79 | return accdata->chat_data; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | void ggp_chat_setup(PurpleConnection *gc) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
84 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
85 | ggp_chat_session_data *sdata = g_new0(ggp_chat_session_data, 1); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
86 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
87 | accdata->chat_data = sdata; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
90 | void ggp_chat_cleanup(PurpleConnection *gc) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
34354
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
93 | int i; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
94 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
95 | g_slist_free_full(sdata->pending_joins, g_free); |
|
34354
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
96 | for (i = 0; i < sdata->chats_count; i++) |
|
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
97 | g_free(sdata->chats[i].participants); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
98 | g_free(sdata->chats); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
99 | g_free(sdata); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
100 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
101 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
102 | static ggp_chat_local_info * ggp_chat_new(PurpleConnection *gc, uint64_t id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
103 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
104 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
105 | int local_id; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
106 | ggp_chat_local_info *chat; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
108 | if (NULL != (chat = ggp_chat_get(gc, id))) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
109 | return chat; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
110 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
111 | local_id = sdata->chats_count++; |
|
34354
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
112 | sdata->chats = g_realloc(sdata->chats, |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
113 | sdata->chats_count * sizeof(ggp_chat_local_info)); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
114 | chat = &sdata->chats[local_id]; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
116 | chat->local_id = local_id; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
117 | chat->id = id; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
118 | chat->conv = NULL; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
119 | chat->gc = gc; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
120 | chat->left = FALSE; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
121 | chat->previously_joined = FALSE; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
122 | chat->participants = NULL; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
123 | chat->participants_count = 0; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
124 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
125 | return chat; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
126 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
127 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
128 | static ggp_chat_local_info * ggp_chat_get(PurpleConnection *gc, uint64_t id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
130 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
131 | int i; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
132 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
133 | for (i = 0; i < sdata->chats_count; i++) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
134 | if (sdata->chats[i].id == id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
135 | return &sdata->chats[i]; |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
136 | } |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
137 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
138 | return NULL; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
139 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
140 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
141 | static void ggp_chat_open_conv(ggp_chat_local_info *chat) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
142 | { |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
143 | PurpleConversation *conv; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
144 | int i; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
145 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
146 | if (chat->conv != NULL) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
147 | return; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
148 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
149 | conv = purple_serv_got_joined_chat(chat->gc, chat->local_id, |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
150 | ggp_chat_get_name_from_id(chat->id)); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
151 | chat->conv = PURPLE_CHAT_CONVERSATION(conv); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
152 | if (chat->previously_joined) { |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
153 | purple_conversation_write_system_message( |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
154 | PURPLE_CONVERSATION(chat->conv), |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
155 | _("You have re-joined the chat"), 0); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
156 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
157 | chat->previously_joined = TRUE; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
158 | |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
159 | purple_chat_conversation_clear_users(chat->conv); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
160 | for (i = 0; i < chat->participants_count; i++) { |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
161 | purple_chat_conversation_add_user(chat->conv, |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
162 | ggp_uin_to_str(chat->participants[i]), NULL, |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
163 | PURPLE_CHAT_USER_NONE, FALSE); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
164 | } |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
165 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
166 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
167 | static ggp_chat_local_info * ggp_chat_get_local(PurpleConnection *gc, |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
168 | int local_id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
169 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
170 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
171 | int i; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
172 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
173 | for (i = 0; i < sdata->chats_count; i++) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
174 | if (sdata->chats[i].local_id == local_id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
175 | return &sdata->chats[i]; |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
176 | } |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
177 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
178 | return NULL; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
180 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
181 | void ggp_chat_got_event(PurpleConnection *gc, const struct gg_event *ev) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
182 | { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
183 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
184 | ggp_chat_local_info *chat; |
|
34430
15639e15839e
Gadu-Gadu: fix -Wsign-compare errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34418
diff
changeset
|
185 | uint32_t i; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
186 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
187 | if (ev->type == GG_EVENT_CHAT_INFO) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
188 | const struct gg_event_chat_info *eci = &ev->event.chat_info; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
189 | chat = ggp_chat_new(gc, eci->id); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
190 | for (i = 0; i < eci->participants_count; i++) |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
191 | ggp_chat_joined(chat, eci->participants[i]); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
192 | } else if (ev->type == GG_EVENT_CHAT_INFO_GOT_ALL) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
193 | GSList *it = sdata->pending_joins; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
194 | sdata->got_all_chats_info = TRUE; |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
195 | while (it) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
196 | uint64_t *id_p = it->data; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
197 | ggp_chat_join_id(gc, *id_p); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
198 | it = g_slist_next(it); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
199 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
200 | g_slist_free_full(sdata->pending_joins, g_free); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
201 | sdata->pending_joins = NULL; |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
202 | } else if (ev->type == GG_EVENT_CHAT_INFO_UPDATE) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
203 | const struct gg_event_chat_info_update *eciu = |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
204 | &ev->event.chat_info_update; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
205 | chat = ggp_chat_get(gc, eciu->id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
206 | if (!chat) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
207 | purple_debug_error("gg", "ggp_chat_got_event: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
208 | "chat %" G_GUINT64_FORMAT " not found\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
209 | eciu->id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
210 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
211 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
212 | if (eciu->type == GG_CHAT_INFO_UPDATE_ENTERED) |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
213 | ggp_chat_joined(chat, eciu->participant); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
214 | else if (eciu->type == GG_CHAT_INFO_UPDATE_EXITED) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
215 | ggp_chat_left(chat, eciu->participant); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
216 | else |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
217 | purple_debug_warning("gg", "ggp_chat_got_event: " |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
218 | "unknown update type - %d", eciu->type); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
219 | } else if (ev->type == GG_EVENT_CHAT_CREATED) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
220 | const struct gg_event_chat_created *ecc = |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
221 | &ev->event.chat_created; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
222 | uin_t me = ggp_str_to_uin(purple_account_get_username( |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
223 | purple_connection_get_account(gc))); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
224 | chat = ggp_chat_new(gc, ecc->id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
225 | ggp_chat_joined(chat, me); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
226 | ggp_chat_open_conv(chat); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
227 | } else if (ev->type == GG_EVENT_CHAT_INVITE_ACK) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
228 | /* ignore */ |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
229 | } else { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
230 | purple_debug_fatal("gg", "ggp_chat_got_event: unexpected event " |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
231 | "- %d\n", ev->type); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
232 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
233 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
234 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
235 | static int ggp_chat_participant_find(ggp_chat_local_info *chat, uin_t uin) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
236 | { |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
237 | int i; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
238 | for (i = 0; i < chat->participants_count; i++) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
239 | if (chat->participants[i] == uin) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
240 | return i; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
241 | return -1; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
242 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
243 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
244 | static void ggp_chat_joined(ggp_chat_local_info *chat, uin_t uin) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
245 | { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
246 | int idx = ggp_chat_participant_find(chat, uin); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
247 | if (idx >= 0) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
248 | purple_debug_warning("gg", "ggp_chat_joined: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
249 | "user %u is already present in chat %" G_GUINT64_FORMAT |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
250 | "\n", uin, chat->id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
251 | return; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
252 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
253 | chat->participants_count++; |
|
34354
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
254 | chat->participants = g_realloc(chat->participants, |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
255 | sizeof(uin) * chat->participants_count); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
256 | chat->participants[chat->participants_count - 1] = uin; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
257 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
258 | if (!chat->conv) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
259 | return; |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
260 | purple_chat_conversation_add_user(chat->conv, |
|
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
261 | ggp_uin_to_str(uin), NULL, PURPLE_CHAT_USER_NONE, TRUE); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
262 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
263 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
264 | static void ggp_chat_left(ggp_chat_local_info *chat, uin_t uin) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
265 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
266 | uin_t me; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
267 | int idx = ggp_chat_participant_find(chat, uin); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
268 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
269 | if (idx < 0) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
270 | purple_debug_warning("gg", "ggp_chat_joined: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
271 | "user %u isn't present in chat %" G_GUINT64_FORMAT "\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
272 | uin, chat->id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
273 | return; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
274 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
275 | chat->participants[idx] = |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
276 | chat->participants[chat->participants_count - 1]; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
277 | chat->participants_count--; |
|
34354
7618c770a586
Gadu-Gadu: fix leaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34353
diff
changeset
|
278 | chat->participants = g_realloc(chat->participants, |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
279 | sizeof(uin) * chat->participants_count); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
280 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
281 | if (chat->conv == NULL) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
282 | return; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
283 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
284 | me = ggp_str_to_uin(purple_account_get_username( |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
285 | purple_connection_get_account(chat->gc))); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
286 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
287 | if (me == uin) { |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
288 | purple_conversation_write_system_message( |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
289 | PURPLE_CONVERSATION(chat->conv), |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
290 | _("You have left the chat"), 0); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35360
diff
changeset
|
291 | purple_serv_got_chat_left(chat->gc, chat->local_id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
292 | chat->conv = NULL; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
293 | chat->left = TRUE; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
294 | } |
|
34954
6cafff03b4c2
Refactored some non-gobjectified purple code in gg according to the new conversation API
Ankit Vani <a@nevitus.org>
parents:
34437
diff
changeset
|
295 | purple_chat_conversation_remove_user(chat->conv, ggp_uin_to_str(uin), NULL); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
296 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
297 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
298 | GList * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
299 | ggp_chat_info(PurpleProtocolChat *protocol_chat, PurpleConnection *gc) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
300 | GList *m = NULL; |
| 37159 | 301 | PurpleProtocolChatEntry *pce; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
302 | |
| 37159 | 303 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
304 | pce->label = _("_Conference identifier:"); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
305 | pce->identifier = "id"; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
306 | pce->required = FALSE; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
307 | m = g_list_append(m, pce); |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
308 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
309 | return m; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
310 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
311 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
312 | GHashTable * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
313 | ggp_chat_info_defaults(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
314 | const gchar *chat_name) |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
315 | { |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
316 | GHashTable *defaults; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
317 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
318 | defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
319 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
320 | if (chat_name != NULL && ggp_chat_get_id_from_name(chat_name) != 0) |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
321 | g_hash_table_insert(defaults, "id", g_strdup(chat_name)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
322 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
323 | return defaults; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
324 | } |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
325 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
326 | gchar * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
327 | ggp_chat_get_name(PurpleProtocolChat *protocol_chat, GHashTable *components) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
328 | return g_strdup((gchar*)g_hash_table_lookup(components, "id")); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
329 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
330 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
331 | static const gchar * ggp_chat_get_name_from_id(uint64_t id) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
332 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
333 | static gchar buff[30]; |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
334 | g_snprintf(buff, sizeof(buff), "%" G_GUINT64_FORMAT, id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
335 | return buff; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
336 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
337 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
338 | static uint64_t ggp_chat_get_id_from_name(const gchar * name) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
339 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
340 | uint64_t id; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
341 | gchar *endptr; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
342 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
343 | if (name == NULL) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
344 | return 0; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
345 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
346 | id = g_ascii_strtoull(name, &endptr, 10); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
347 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
348 | if (*endptr != '\0' || id == G_MAXUINT64) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
349 | return 0; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
350 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
351 | return id; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
352 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
353 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
354 | void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
355 | ggp_chat_join(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
356 | GHashTable *components) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
357 | { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
358 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
359 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
360 | const gchar *id_cs; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
361 | gchar *id_s; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
362 | uint64_t id; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
363 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
364 | id_cs = g_hash_table_lookup(components, "id"); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
365 | id_s = g_strdup(id_cs); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
366 | if (id_s) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
367 | g_strstrip(id_s); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
368 | if (id_s == NULL || id_s[0] == '\0') { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
369 | g_free(id_s); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
370 | if (gg_chat_create(info->session) < 0) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
371 | purple_debug_error("gg", "ggp_chat_join; " |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
372 | "cannot create\n"); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
373 | purple_serv_got_join_chat_failed(gc, components); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
374 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
375 | return; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
376 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
377 | id = ggp_chat_get_id_from_name(id_s); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
378 | g_free(id_s); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
379 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
380 | if (!id) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
381 | char *buff = g_strdup_printf( |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
382 | _("%s is not a valid room identifier"), id_cs); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
383 | purple_notify_error(gc, _("Invalid Room Identifier"), |
|
34473
fb04c75906e0
Gadu-Gadu: update code for the new libpurple and libgadu APIs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
384 | _("Invalid Room Identifier"), buff, NULL); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
385 | g_free(buff); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
386 | purple_serv_got_join_chat_failed(gc, components); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
387 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
388 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
389 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
390 | if (sdata->got_all_chats_info) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
391 | ggp_chat_join_id(gc, id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
392 | else { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
393 | uint64_t *id_p = g_new(uint64_t, 1); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
394 | *id_p = id; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
395 | sdata->pending_joins = g_slist_append(sdata->pending_joins, id_p); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
396 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
397 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
398 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
399 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
400 | static void ggp_chat_join_id(PurpleConnection *gc, uint64_t id) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
401 | { |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
402 | GHashTable *components; |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
403 | PurpleProtocol *protocol = purple_connection_get_protocol(gc); |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
404 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
405 | ggp_chat_local_info *chat = ggp_chat_get(gc, id); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
406 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
407 | if (chat && !chat->left) { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
408 | ggp_chat_open_conv(chat); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
409 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
410 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
411 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
412 | if (!chat) { |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
413 | char *id_s = g_strdup_printf("%" G_GUINT64_FORMAT, id); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
414 | char *buff = g_strdup_printf( |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
415 | _("%s is not a valid room identifier"), id_s); |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
416 | g_free(id_s); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
417 | purple_notify_error(gc, _("Invalid Room Identifier"), |
|
34473
fb04c75906e0
Gadu-Gadu: update code for the new libpurple and libgadu APIs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
418 | _("Invalid Room Identifier"), buff, NULL); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
419 | g_free(buff); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
420 | } else { /* if (chat->left) */ |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
421 | purple_notify_error(gc, _("Could not join chat room"), |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
422 | _("Could not join chat room"), |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
423 | _("You have to ask for invitation from another chat " |
|
34473
fb04c75906e0
Gadu-Gadu: update code for the new libpurple and libgadu APIs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34437
diff
changeset
|
424 | "participant"), NULL); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
425 | } |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
426 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
427 | components = ggp_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol), gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
428 | ggp_chat_get_name_from_id(id)); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
429 | purple_serv_got_join_chat_failed(gc, components); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
430 | g_hash_table_destroy(components); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
431 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
432 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
433 | void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
434 | ggp_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
435 | gint local_id) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
436 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
437 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
438 | ggp_chat_local_info *chat; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
439 | uin_t me; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
440 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
441 | chat = ggp_chat_get_local(gc, local_id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
442 | if (!chat) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
443 | purple_debug_error("gg", "ggp_chat_leave: " |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
444 | "chat %u doesn't exists\n", local_id); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
445 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
446 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
447 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
448 | if (gg_chat_leave(info->session, chat->id) < 0) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
449 | purple_debug_error("gg", "ggp_chat_leave: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
450 | "unable to leave chat %" G_GUINT64_FORMAT "\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
451 | chat->id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
452 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
453 | chat->conv = NULL; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
454 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
455 | me = ggp_str_to_uin(purple_account_get_username( |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
456 | purple_connection_get_account(chat->gc))); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
457 | |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
458 | ggp_chat_left(chat, me); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
459 | chat->left = TRUE; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
460 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
461 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
462 | void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
463 | ggp_chat_invite(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
464 | gint local_id, const gchar *message, const gchar *who) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
465 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
466 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
467 | ggp_chat_local_info *chat; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
468 | uin_t invited; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
469 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
470 | chat = ggp_chat_get_local(gc, local_id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
471 | if (!chat) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
472 | purple_debug_error("gg", "ggp_chat_invite: " |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
473 | "chat %u doesn't exists\n", local_id); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
474 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
475 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
476 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
477 | invited = ggp_str_to_uin(who); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
478 | if (gg_chat_invite(info->session, chat->id, &invited, 1) < 0) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
479 | purple_debug_error("gg", "ggp_chat_invite: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
480 | "unable to invite %s to chat %" G_GUINT64_FORMAT "\n", |
|
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
481 | who, chat->id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
482 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
483 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
484 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
485 | gint |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
486 | ggp_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
487 | gint local_id, PurpleMessage *msg) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
488 | { |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
489 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
490 | GDateTime *dt = NULL; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
491 | PurpleConversation *conv; |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
492 | PurpleConversationManager *manager; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
493 | ggp_chat_local_info *chat; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
494 | gboolean succ = TRUE; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
495 | const gchar *me; |
|
34369
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
496 | gchar *gg_msg; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
497 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
498 | chat = ggp_chat_get_local(gc, local_id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
499 | if (!chat) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
500 | purple_debug_error("gg", "ggp_chat_send: " |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
501 | "chat %u doesn't exists\n", local_id); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
502 | return -1; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
503 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
504 | |
|
40997
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
505 | manager = purple_conversation_manager_get_default(); |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
506 | conv = purple_conversation_manager_find_chat(manager, |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
507 | purple_connection_get_account(gc), |
|
997ab408c113
Port the protocol plugins to the purple_conversation_manager_api
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
508 | ggp_chat_get_name_from_id(chat->id)); |
|
34369
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
509 | |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
510 | gg_msg = ggp_message_format_to_gg(conv, |
| 36090 | 511 | purple_message_get_contents(msg)); |
|
34369
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
512 | |
|
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
513 | if (gg_chat_send_message(info->session, chat->id, gg_msg, TRUE) < 0) |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
514 | succ = FALSE; |
|
34369
6ae053435538
Gadu-Gadu: enable inline images and GG11 formatting for conferences
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34361
diff
changeset
|
515 | g_free(gg_msg); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
516 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
517 | me = purple_account_get_username(purple_connection_get_account(gc)); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
518 | dt = purple_message_get_timestamp(msg); |
| 36090 | 519 | purple_serv_got_chat_in(gc, chat->local_id, me, |
| 520 | purple_message_get_flags(msg), | |
| 521 | purple_message_get_contents(msg), | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
522 | (time_t)g_date_time_to_unix(dt)); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
523 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
524 | return succ ? 0 : -1; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
525 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
526 | |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
527 | void ggp_chat_got_message(PurpleConnection *gc, uint64_t chat_id, |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
528 | const char *message, time_t time, uin_t who) |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
529 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
530 | PurpleAccount *account = NULL; |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
531 | ggp_chat_local_info *chat; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
532 | uin_t me; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
533 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
534 | account = purple_connection_get_account(gc); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
535 | me = ggp_str_to_uin(purple_account_get_username(account)); |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
536 | |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
537 | chat = ggp_chat_get(gc, chat_id); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
538 | if (!chat) { |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
539 | purple_debug_error("gg", "ggp_chat_got_message: " |
|
34418
c27e31267e8d
Gadu-Gadu: fix compilation on 64-bit targets
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34406
diff
changeset
|
540 | "chat %" G_GUINT64_FORMAT " doesn't exists\n", chat_id); |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
541 | return; |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
542 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
543 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
544 | ggp_chat_open_conv(chat); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
545 | if (who == me) { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
546 | GDateTime *dt = NULL; |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
547 | PurpleMessage *pmsg; |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
548 | |
| 36101 | 549 | pmsg = purple_message_new_outgoing( |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
550 | purple_account_get_name_for_display(account), |
| 36101 | 551 | ggp_uin_to_str(who), message, 0); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
552 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
553 | dt = g_date_time_new_from_unix_local((gint64)time); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
554 | purple_message_set_timestamp(pmsg, dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
555 | g_date_time_unref(dt); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
556 | |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
557 | purple_conversation_write_message( |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
558 | PURPLE_CONVERSATION(chat->conv), pmsg); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
559 | } else { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35360
diff
changeset
|
560 | purple_serv_got_chat_in(gc, chat->local_id, ggp_uin_to_str(who), |
|
34350
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
561 | PURPLE_MESSAGE_RECV, message, time); |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
562 | } |
|
89441dbabc83
Gadu-Gadu: initial GG11 conferences support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
563 | } |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
564 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
565 | static gboolean ggp_chat_roomlist_get_list_finish(gpointer roomlist) |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
566 | { |
|
34991
63c14353a0f4
Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents:
34954
diff
changeset
|
567 | purple_roomlist_set_in_progress(PURPLE_ROOMLIST(roomlist), FALSE); |
|
63c14353a0f4
Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents:
34954
diff
changeset
|
568 | g_object_unref(roomlist); |
|
63c14353a0f4
Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents:
34954
diff
changeset
|
569 | |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
570 | return FALSE; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
571 | } |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
572 | |
|
41028
943b2cb45314
Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
573 | PurpleRoomlist * |
|
943b2cb45314
Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
574 | ggp_chat_roomlist_get_list(PurpleProtocolRoomlist *protocol_roomlist, |
|
943b2cb45314
Separate PurpleProtocolRoomlist into its own file and modernize it.
Gary Kramlich <grim@reaperworld.com>
parents:
40997
diff
changeset
|
575 | PurpleConnection *gc) |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
576 | { |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
577 | ggp_chat_session_data *sdata = ggp_chat_get_sdata(gc); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
578 | PurpleRoomlist *roomlist; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
579 | GList *fields = NULL; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
580 | int i; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
581 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
582 | purple_debug_info("gg", "ggp_chat_roomlist_get_list\n"); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
583 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
584 | roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
585 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
586 | fields = g_list_append(fields, purple_roomlist_field_new( |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
587 | PURPLE_ROOMLIST_FIELD_STRING, _("Conference identifier"), "id", |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
588 | TRUE)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
589 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
590 | fields = g_list_append(fields, purple_roomlist_field_new( |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
591 | PURPLE_ROOMLIST_FIELD_STRING, _("Start Date"), "date", |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
592 | FALSE)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
593 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
594 | fields = g_list_append(fields, purple_roomlist_field_new( |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
595 | PURPLE_ROOMLIST_FIELD_INT, _("User Count"), "users", |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
596 | FALSE)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
597 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
598 | fields = g_list_append(fields, purple_roomlist_field_new( |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
599 | PURPLE_ROOMLIST_FIELD_STRING, _("Status"), "status", |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
600 | FALSE)); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
601 | |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
602 | purple_roomlist_set_fields(roomlist, fields); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
603 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
604 | for (i = sdata->chats_count - 1; i >= 0 ; i--) { |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
605 | PurpleRoomlistRoom *room; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
606 | ggp_chat_local_info *chat = &sdata->chats[i]; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
607 | const gchar *name; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
608 | time_t date; |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
609 | const gchar *status; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
610 | int count = chat->participants_count; |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
611 | |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
612 | date = (uint32_t)(chat->id >> 32); |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
613 | |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
614 | if (chat->conv) |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
615 | status = _("Joined"); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
616 | else if (chat->left) |
|
36134
a6b42301c095
Add string hint for translators.
Mark Doliner <mark@kingant.net>
parents:
36124
diff
changeset
|
617 | /* Translators: For Gadu-Gadu, this is one possible status for a |
|
a6b42301c095
Add string hint for translators.
Mark Doliner <mark@kingant.net>
parents:
36124
diff
changeset
|
618 | chat room. It means you had previously joined the chat room but |
|
a6b42301c095
Add string hint for translators.
Mark Doliner <mark@kingant.net>
parents:
36124
diff
changeset
|
619 | you have since left it. You cannot rejoin without another |
|
a6b42301c095
Add string hint for translators.
Mark Doliner <mark@kingant.net>
parents:
36124
diff
changeset
|
620 | invitation. */ |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
621 | status = _("Chat left"); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35358
diff
changeset
|
622 | else { |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
623 | status = _("Can join chat"); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
624 | count--; |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
625 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35006
diff
changeset
|
626 | |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
627 | name = ggp_chat_get_name_from_id(chat->id); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
628 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
629 | name, NULL); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
630 | purple_roomlist_room_add_field(roomlist, room, name); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
631 | purple_roomlist_room_add_field(roomlist, room, purple_date_format_full(localtime(&date))); |
|
34353
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
632 | purple_roomlist_room_add_field(roomlist, room, GINT_TO_POINTER(count)); |
|
300c246402ac
Gadu-Gadu: delayed chat joining
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34352
diff
changeset
|
633 | purple_roomlist_room_add_field(roomlist, room, status); |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
634 | purple_roomlist_room_add(roomlist, room); |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
635 | } |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
636 | |
|
35354
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
637 | /* TODO |
|
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
638 | * purple_roomlist_set_in_progress(roomlist, FALSE); |
|
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
639 | */ |
|
34991
63c14353a0f4
Manage refcounts in some libpurple callbacks
Ankit Vani <a@nevitus.org>
parents:
34954
diff
changeset
|
640 | g_object_ref(roomlist); |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37159
diff
changeset
|
641 | g_timeout_add(1, ggp_chat_roomlist_get_list_finish, roomlist); |
|
34352
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
642 | return roomlist; |
|
16ee13f507a0
Gadu-Gadu: room list
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34350
diff
changeset
|
643 | } |