Tue, 11 May 2010 16:28:03 +0000
Improve the handling of user's being kicked from MultiMX rooms.
* If it's us being kicked, clear the user-list and close the conversation.
* Otherwise, display a message and remove the user from the user-list.
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 | * MXit Protocol libPurple Plugin |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 | * -- MultiMx GroupChat -- |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 | * Andrew Victor <libpurple@mxit.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 | * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 | * <http://www.mxitlifestyle.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 | * This program is free software; you can redistribute it and/or modify |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 | * it under the terms of the GNU General Public License as published by |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 | * the Free Software Foundation; either version 2 of the License, or |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 | * (at your option) any later version. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 | * This program is distributed in the hope that it will be useful, |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 | * GNU General Public License for more details. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 | * You should have received a copy of the GNU General Public License |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 | * along with this program; if not, write to the Free Software |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 | |
|
29106
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28945
diff
changeset
|
26 | #include "internal.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 | #include "purple.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 | #include "prpl.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 | #include "protocol.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 | #include "mxit.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 | #include "multimx.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 | #include "markup.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 | #if 0 |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 | static void multimx_dump(struct multimx* multimx) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 | purple_debug_info(MXIT_PLUGIN_ID, "MultiMX:\n"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 | purple_debug_info(MXIT_PLUGIN_ID, " Chat ID: %i\n", multimx->chatid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
41 | purple_debug_info(MXIT_PLUGIN_ID, " Username: %s\n", multimx->roomid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 | purple_debug_info(MXIT_PLUGIN_ID, " Alias: %s\n", multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 | purple_debug_info(MXIT_PLUGIN_ID, " State: %i\n", multimx->state); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 | * Find a MultiMx session based on libpurple chatID. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
52 | * @param id The libpurple group-chat ID |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 | * @return The MultiMX room object (or NULL if not found) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
54 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
55 | static struct multimx* find_room_by_id(struct MXitSession* session, int id) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 | GList* x = session->rooms; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
59 | while (x != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 | struct multimx* multimx = (struct multimx *) x->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
61 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
62 | if (multimx->chatid == id) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
63 | return multimx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 | x = g_list_next(x); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 | return NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
69 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 | * Find a MultiMx session based on Alias |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 | * @param roomname The UI room-name |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 | * @return The MultiMX room object (or NULL if not found) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
78 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 | static struct multimx* find_room_by_alias(struct MXitSession* session, const char* roomname) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 | GList* x = session->rooms; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 | while (x != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 | struct multimx* multimx = (struct multimx *) x->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 | if (!strcmp(multimx->roomname, roomname)) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 | return multimx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
88 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
89 | x = g_list_next(x); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 | return NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
95 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 | * Find a MultiMx session based on Username (MXit RoomId) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 | * @param username The MXit RoomID (MultiMX contact username) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 | * @return The MultiMX room object (or NULL if not found) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 | static struct multimx* find_room_by_username(struct MXitSession* session, const char* username) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
104 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
105 | GList* x = session->rooms; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 | while (x != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 | struct multimx* multimx = (struct multimx *) x->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 | if (!strcmp(multimx->roomid, username)) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 | return multimx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 | x = g_list_next(x); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
114 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
115 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 | return NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 | * Create a GroupChat room, and add to list of rooms. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 | * @param roomid The MXit RoomID (MultiMX contact username) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 | * @param roomname The UI room-name |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 | * @param state The initial state of the room (see multimx.h) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 | * @return The MultiMX room object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 | static struct multimx* room_create(struct MXitSession* session, const char* roomid, const char* roomname, short state) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 | static int groupchatID = 1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat create - roomid='%s' roomname='%s'\n", roomid, roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 | /* Create a new GroupChat */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 | multimx = g_new0(struct multimx, 1); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 | /* Initialize groupchat */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 | g_strlcpy(multimx->roomid, roomid, sizeof(multimx->roomid)); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 | g_strlcpy(multimx->roomname, roomname, sizeof(multimx->roomname)); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 | multimx->chatid = groupchatID++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 | multimx->state = state; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 | |
|
30178
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
145 | /* determine our nickname (from profile) */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
146 | if (session->profile && (session->profile->nickname[0] != '\0')) |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
147 | multimx->nickname = g_strdup(session->profile->nickname); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
148 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
149 | /* Add to GroupChat list */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
150 | session->rooms = g_list_append(session->rooms, multimx); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
151 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
152 | return multimx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
153 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
154 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
157 | * Free the Groupchat room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
158 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
159 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
160 | * @param multimx The MultiMX room object to deallocate |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
161 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
162 | static void room_remove(struct MXitSession* session, struct multimx* multimx) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
163 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
164 | /* Remove from GroupChat list */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 | session->rooms = g_list_remove(session->rooms, multimx); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 | |
|
30178
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
167 | /* free nickname */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
168 | if (multimx->nickname) |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
169 | g_free(multimx->nickname); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
170 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
171 | /* Deallocate it */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
172 | free (multimx); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
173 | multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
174 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
175 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
176 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
177 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
178 | * Another user has join the GroupChat, add them to the member-list. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
179 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
180 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
181 | * @param multimx The MultiMX room object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
182 | * @param nickname The nickname of the user who joined the room |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
183 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
184 | static void member_added(struct MXitSession* session, struct multimx* multimx, const char* nickname) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 | PurpleConversation *convo; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 | purple_debug_info(MXIT_PLUGIN_ID, "member_added: '%s'\n", nickname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
190 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 | if (convo == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 | purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nickname, NULL, PURPLE_CBFLAGS_NONE, TRUE); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
200 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
201 | * Another user has left the GroupChat, remove them from the member-list. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
202 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
203 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 | * @param multimx The MultiMX room object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 | * @param nickname The nickname of the user who left the room |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 | static void member_removed(struct MXitSession* session, struct multimx* multimx, const char* nickname) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 | PurpleConversation *convo; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 | purple_debug_info(MXIT_PLUGIN_ID, "member_removed: '%s'\n", nickname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
212 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 | if (convo == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 | purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nickname, NULL); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
223 | /*------------------------------------------------------------------------ |
|
30178
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
224 | * A user was kicked from the GroupChat. |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
225 | * |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
226 | * @param session The MXit session object |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
227 | * @param multimx The MultiMX room object |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
228 | * @param nickname The nickname of the user who was kicked |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
229 | */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
230 | static void member_kicked(struct MXitSession* session, struct multimx* multimx, const char* nickname) |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
231 | { |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
232 | PurpleConversation *convo; |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
233 | gboolean isMe = FALSE; |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
234 | |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
235 | purple_debug_info(MXIT_PLUGIN_ID, "member_kicked: '%s'\n", nickname); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
236 | |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
237 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
238 | if (convo == NULL) { |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
239 | purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
240 | return; |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
241 | } |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
242 | |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
243 | /* who was kicked? - compare to our original nickname */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
244 | if (purple_utf8_strcasecmp(nickname, multimx->nickname) == 0) |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
245 | { |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
246 | /* you were kicked */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
247 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "MXit", _("You have been kicked from this MultiMX."), PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
248 | purple_conv_chat_clear_users(PURPLE_CONV_CHAT(convo)); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
249 | serv_got_chat_left(session->con, multimx->chatid); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
250 | } |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
251 | else |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
252 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nickname, _("was kicked")); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
253 | } |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
254 | |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
255 | |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
256 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
257 | * Update the full GroupChat member list. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
258 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
259 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
260 | * @param multimx The MultiMX room object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
261 | * @param data The nicknames of the users in the room (separated by \n) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
262 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
263 | static void member_update(struct MXitSession* session, struct multimx* multimx, char* data) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
264 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
265 | PurpleConversation *convo; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
266 | gchar** userlist; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
267 | int i = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
268 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
269 | purple_debug_info(MXIT_PLUGIN_ID, "member_update: '%s'\n", data); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
270 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
271 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
272 | if (convo == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
273 | purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
275 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
276 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
277 | /* Clear list */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
278 | purple_conv_chat_clear_users(PURPLE_CONV_CHAT(convo)); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
279 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
280 | /* Add each member */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
281 | data = g_strstrip(data); /* string leading & trailing whitespace */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
282 | userlist = g_strsplit(data, "\n", 0); /* tokenize string */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
283 | while (userlist[i] != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
284 | purple_debug_info(MXIT_PLUGIN_ID, "member_update - adding: '%s'\n", userlist[i]); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
285 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), userlist[i], NULL, PURPLE_CBFLAGS_NONE, FALSE); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 | i++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
288 | g_strfreev(userlist); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
289 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
291 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
292 | /* ------------------------------------------------------------------------------------------------- |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 | * Calls from MXit Protocol layer |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
294 | * ------------------------------------------------------------------------------------------------- */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
295 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
296 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
297 | * Received a Subscription Request to a MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
298 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
299 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
300 | * @param contact The invited MultiMX room's contact information |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
301 | * @param creator The nickname of the room's creator / invitor |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
302 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
303 | void multimx_invite(struct MXitSession* session, struct contact* contact, const char* creator) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
304 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
305 | GHashTable *components; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
306 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
307 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
308 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat invite to '%s' by '%s'\n", contact->alias, creator); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
309 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
310 | /* Create a new room */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
311 | multimx = room_create(session, contact->username, contact->alias, STATE_INVITED); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
312 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
313 | components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
314 | g_hash_table_insert(components, g_strdup("room"), g_strdup(contact->alias)); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
315 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
316 | /* Call libpurple - will trigger either 'mxit_chat_join' or 'mxit_chat_reject' */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
317 | serv_got_chat_invite(session->con, contact->alias, creator, NULL, components); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
322 | * MultiMX room has been added to the roster. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
325 | * @param contact The MultiMX room's contact information |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
326 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
327 | void multimx_created(struct MXitSession* session, struct contact* contact) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
328 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
329 | PurpleConnection *gc = session->con; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
331 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
332 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat '%s' created as '%s'\n", contact->alias, contact->username); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
333 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
334 | /* Find matching MultiMX group */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
335 | multimx = find_room_by_username(session, contact->username); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
337 | multimx = room_create(session, contact->username, contact->alias, TRUE); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
338 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
339 | else if (multimx->state == STATE_INVITED) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
340 | /* After successfully accepting an invitation */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
341 | multimx->state = STATE_JOINED; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
342 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
343 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
344 | /* Call libpurple - will trigger 'mxit_chat_join' */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
345 | serv_got_joined_chat(gc, multimx->chatid, multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
346 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
347 | /* Send ".list" command to GroupChat server to retrieve current member-list */ |
|
29216
9284748dd744
Add extra parameter to mxit_send_message() function to indicate if the message should be
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
348 | mxit_send_message(session, multimx->roomid, ".list", FALSE, FALSE); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
349 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
350 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
351 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
353 | * Is this username a MultiMX contact? |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 | * @param username The username of the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
357 | * @return TRUE if this contacts matches the RoomID of a MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
358 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
359 | gboolean is_multimx_contact(struct MXitSession* session, const char* username) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 | /* Check for username in list of open rooms */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 | return (find_room_by_username(session, username) != NULL); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
364 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
366 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
367 | * Received a message from a MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
369 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
370 | void multimx_message_received(struct RXMsgData* mx, char* msg, int msglen, short msgtype, int msgflags) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
371 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
372 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat message received: %s\n", msg); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
375 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
376 | /* Find matching multimx group */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
377 | multimx = find_room_by_username(mx->session, mx->from); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
378 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
379 | purple_debug_error(MXIT_PLUGIN_ID, "Groupchat '%s' not found\n", mx->from); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
380 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
381 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
382 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
383 | /* Determine if system message or a message from a contact */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
384 | if (msg[0] == '<') { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
385 | /* Message contains embedded nickname - must be from contact */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
386 | unsigned int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
388 | for (i = 1; i < strlen(msg); i++) { /* search for end of nickname */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 | if (msg[i] == '>') { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 | msg[i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 | g_free(mx->from); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 | mx->from = g_strdup(&msg[1]); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 | msg = &msg[i+2]; /* skip '>' and newline */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
395 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
397 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
398 | /* now do markup processing on the message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 | mx->chatid = multimx->chatid; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 | mxit_parse_markup(mx, msg, strlen(msg), msgtype, msgflags); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 | /* Must be a service message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
404 | char* ofs; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 | /* Determine if somebody has joined or left - update member-list */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 | if ((ofs = strstr(msg, " has joined")) != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 | /* Somebody has joined */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 | *ofs = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 | member_added(mx->session, multimx, msg); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
411 | mx->processed = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
412 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 | else if ((ofs = strstr(msg, " has left")) != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 | /* Somebody has left */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 | *ofs = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 | member_removed(mx->session, multimx, msg); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
417 | mx->processed = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 | } |
|
30178
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
419 | else if ((ofs = strstr(msg, " has been kicked")) != NULL) { |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
420 | /* Somebody has been kicked */ |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
421 | *ofs = '\0'; |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
422 | member_kicked(mx->session, multimx, msg); |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
423 | mx->processed = TRUE; |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
424 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
425 | else if (g_str_has_prefix(msg, "The following users are in this MultiMx:") == TRUE) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 | member_update(mx->session, multimx, msg + strlen("The following users are in this MultiMx:") + 1); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 | mx->processed = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
428 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
430 | /* Display server message in chat window */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
431 | serv_got_chat_in(mx->session->con, multimx->chatid, "MXit", PURPLE_MESSAGE_SYSTEM, msg, mx->timestamp); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
432 | mx->processed = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
435 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
436 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
437 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
438 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
439 | /* ------------------------------------------------------------------------------------------------- |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
440 | * Callbacks from libpurple |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
441 | * ------------------------------------------------------------------------------------------------- */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
442 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
443 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
444 | * User has selected "Add Chat" from the main menu. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
445 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
446 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
447 | * @return A list of chat configuration values |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
448 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
449 | GList* mxit_chat_info(PurpleConnection *gc) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
450 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
451 | GList *m = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
452 | struct proto_chat_entry *pce; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
453 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
454 | /* Configuration option: Room Name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
455 | pce = g_new0(struct proto_chat_entry, 1); |
|
28945
f94c51ec07d9
Mark a bunch of mxit strings for translation
Mark Doliner <markdoliner@pidgin.im>
parents:
28841
diff
changeset
|
456 | pce->label = _( "_Room Name:" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
457 | pce->identifier = "room"; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
458 | pce->required = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
459 | m = g_list_append(m, pce); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
460 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
461 | return m; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
462 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
463 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
464 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
465 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
466 | * User has joined a chatroom, either because they are creating it or they |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
467 | * accepted an invite. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
468 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
469 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
470 | * @param components The list of chat configuration values |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
471 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
472 | void mxit_chat_join(PurpleConnection *gc, GHashTable *components) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
473 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
474 | struct MXitSession* session = (struct MXitSession*) gc->proto_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
475 | const char* roomname = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
476 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
477 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
478 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_join\n"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
479 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
480 | /* Determine if groupchat already exists */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
481 | roomname = g_hash_table_lookup(components, "room"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
482 | multimx = find_room_by_alias(session, roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 | if (multimx != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 | /* The room information already exists */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 | if (multimx->state == STATE_INVITED) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 | /* Invite is pending */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i accept sent\n", multimx->chatid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 | /* Send Subscription Accept to MXit */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
492 | mxit_send_allow_sub(session, multimx->roomid, multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
495 | /* Join existing room */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
496 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i rejoined\n", multimx->chatid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
497 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
498 | serv_got_joined_chat(gc, multimx->chatid, multimx->roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
499 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 | /* Send Groupchat Create to MXit */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
503 | mxit_send_groupchat_create(session, roomname, 0, NULL); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
507 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
509 | * User has rejected an invite to join a MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 | * @param components The list of chat configuration values |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
514 | void mxit_chat_reject(PurpleConnection *gc, GHashTable* components) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
515 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
516 | struct MXitSession* session = (struct MXitSession*) gc->proto_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
517 | const char* roomname = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
518 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
519 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
520 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_reject\n"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
521 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
522 | roomname = g_hash_table_lookup(components, "room"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
523 | multimx = find_room_by_alias(session, roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
524 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
525 | purple_debug_error(MXIT_PLUGIN_ID, "Groupchat '%s' not found\n", roomname); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
526 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
527 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
528 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 | /* Send Subscription Reject to MXit */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
530 | mxit_send_deny_sub(session, multimx->roomid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
531 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
532 | /* Remove from our list of rooms */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 | room_remove(session, multimx); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
534 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
535 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
536 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
538 | * Return name of chatroom (on mouse hover) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
539 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
540 | * @param components The list of chat configuration values. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 | * @return The name of the chat room |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
542 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
543 | char* mxit_chat_name(GHashTable *components) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
544 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
545 | return g_strdup(g_hash_table_lookup(components, "room")); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
546 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
547 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
548 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
549 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
550 | * User has selected to invite somebody to a chatroom. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
551 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
552 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
553 | * @param id The chat room ID |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
554 | * @param msg The invitation message entered by the user |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
555 | * @param name The username of the person to invite |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
556 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 | void mxit_chat_invite(PurpleConnection *gc, int id, const char *msg, const char *username) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 | struct MXitSession* session = (struct MXitSession*) gc->proto_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
562 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat invite to '%s'\n", username); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
563 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
564 | /* Find matching MultiMX group */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
565 | multimx = find_room_by_id(session, id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
566 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
567 | purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
568 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
569 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
570 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
571 | /* Send invite to MXit */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
572 | mxit_send_groupchat_invite(session, multimx->roomid, 1, &username); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
573 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
574 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
575 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
577 | * User as closed the chat window, and the chatroom is not marked as persistent. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 | * @param id The chat room ID |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 | void mxit_chat_leave(PurpleConnection *gc, int id) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
583 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
584 | struct MXitSession* session = (struct MXitSession*) gc->proto_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
585 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
587 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i leave\n", id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
588 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 | /* Find matching multimx group */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 | multimx = find_room_by_id(session, id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
592 | purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
593 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 | /* Send Remove Groupchat to MXit */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 | mxit_send_remove(session, multimx->roomid); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
599 | /* Remove from our list of rooms */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 | room_remove(session, multimx); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 | * User has entered a message in a chatroom window, send it to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
606 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
607 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 | * @param id The chat room ID |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 | * @param message The sent message data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
610 | * @param flags The message flags |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
611 | * @return Indicates success / failure |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
612 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
613 | int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
614 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 | struct MXitSession* session = (struct MXitSession*) gc->proto_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
616 | struct multimx* multimx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 | const char* nickname; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
619 | purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i message send: '%s'\n", id, message); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
620 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 | /* Find matching MultiMX group */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 | multimx = find_room_by_id(session, id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 | if (multimx == NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 | purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
625 | return -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
626 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
627 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 | /* Send packet to MXit */ |
|
29216
9284748dd744
Add extra parameter to mxit_send_message() function to indicate if the message should be
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
629 | mxit_send_message(session, multimx->roomid, message, TRUE, FALSE); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 | /* Determine our nickname to display */ |
|
30178
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
632 | if (multimx->nickname) |
|
1c8b5d36dc42
Improve the handling of user's being kicked from MultiMX rooms.
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
633 | nickname = multimx->nickname; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 | nickname = purple_account_get_alias(purple_connection_get_account(gc)); /* local alias */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 | /* Display message in chat window */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 | serv_got_chat_in(gc, id, nickname, flags, message, time(NULL)); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 |