author | Mikael Berthe <mikael@lilotux.net> |
Sun, 04 Jun 2017 23:51:53 +0200 | |
changeset 2319 | 457891789a7d |
parent 2303 | 4f3821bda633 |
child 2337 | ffd0e57e9563 |
permissions | -rw-r--r-- |
1599 | 1 |
/* |
2 |
* xmpp_muc.c -- Jabber MUC protocol handling |
|
3 |
* |
|
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1722
diff
changeset
|
4 |
* Copyright (C) 2008-2010 Frank Zschockelt <mcabber@freakysoft.de> |
2134
fc7a758ebbde
Remove deprecated options comments, update headers
Mikael Berthe <mikael@lilotux.net>
parents:
2132
diff
changeset
|
5 |
* Copyright (C) 2005-2014 Mikael Berthe <mikael@lilotux.net> |
2019
33483d3324cf
s/Copyrigth/Copyright/ and so on
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2006
diff
changeset
|
6 |
* Copyright (C) 2010 Myhailo Danylenko <isbear@ukrpost.net> |
1599 | 7 |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation; either version 2 of the License, or (at |
|
11 |
* your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, but |
|
14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
* General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
2268
f5402d705f67
Fix FSF addresses in all files
Mikael Berthe <mikael@lilotux.net>
parents:
2134
diff
changeset
|
19 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
1599 | 20 |
*/ |
29 | 21 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
22 |
#include <string.h> |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
23 |
#include <stdlib.h> |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
24 |
|
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
25 |
#include "xmpp_helper.h" |
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
26 |
#include "xmpp_iq.h" |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
27 |
#include "xmpp_muc.h" |
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
28 |
#include "events.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
29 |
#include "hooks.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
30 |
#include "screen.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
31 |
#include "hbuf.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
32 |
#include "roster.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
33 |
#include "commands.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
34 |
#include "settings.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
35 |
#include "utils.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
36 |
#include "histolog.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
37 |
|
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
38 |
extern enum imstatus mystatus; |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
39 |
extern gchar *mystatusmsg; |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
40 |
|
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
41 |
static GSList *invitations = NULL; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
42 |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
43 |
static void decline_invitation(event_muc_invitation *invitation, const char *reason) |
29 | 44 |
{ |
1598 | 45 |
// cut and paste from xmpp_room_invite |
46 |
LmMessage *m; |
|
47 |
LmMessageNode *x, *y; |
|
1014
99c5278bf6b8
Keep the status and status messages when we're disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1013
diff
changeset
|
48 |
|
1598 | 49 |
if (!invitation) return; |
50 |
if (!invitation->to || !invitation->from) return; |
|
1426
a64778f5f26b
Implement FIFO named command pipe
Mikael Berthe <mikael@lilotux.net>
parents:
1419
diff
changeset
|
51 |
|
1598 | 52 |
m = lm_message_new(invitation->to, LM_MESSAGE_TYPE_MESSAGE); |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
924
diff
changeset
|
53 |
|
1598 | 54 |
x = lm_message_node_add_child(m->node, "x", NULL); |
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
55 |
lm_message_node_set_attribute(x, "xmlns", NS_MUC_USER); |
444 | 56 |
|
1598 | 57 |
y = lm_message_node_add_child(x, "decline", NULL); |
58 |
lm_message_node_set_attribute(y, "to", invitation->from); |
|
29 | 59 |
|
1598 | 60 |
if (reason) |
61 |
lm_message_node_add_child(y, "reason", reason); |
|
164 | 62 |
|
1598 | 63 |
lm_connection_send(lconnection, m, NULL); |
64 |
lm_message_unref(m); |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
65 |
} |
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
66 |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
67 |
void destroy_event_muc_invitation(event_muc_invitation *invitation) |
35 | 68 |
{ |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
69 |
invitations = g_slist_remove(invitations, invitation); |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
70 |
g_free(invitation->to); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
71 |
g_free(invitation->from); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
72 |
g_free(invitation->passwd); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
73 |
g_free(invitation->reason); |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
74 |
g_free(invitation->evid); |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
75 |
g_free(invitation); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
76 |
} |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
77 |
|
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
78 |
// invitation event handler |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
79 |
// TODO: if event is accepted, check if other events to the same room exist and |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
80 |
// destroy them? (need invitation registry list for that) |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
81 |
static gboolean evscallback_invitation(guint evcontext, const char *arg, gpointer userdata) |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
82 |
{ |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
83 |
event_muc_invitation *invitation = userdata; |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
84 |
|
1598 | 85 |
// Sanity check |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
86 |
if (G_UNLIKELY(!invitation)) { |
1598 | 87 |
// Shouldn't happen. |
88 |
scr_LogPrint(LPRINT_LOGNORM, "Error in evs callback."); |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
89 |
return FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
90 |
} |
989
859ab76e5093
Send JEP-22 delivered messages
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
91 |
|
1598 | 92 |
if (evcontext == EVS_CONTEXT_TIMEOUT) { |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
93 |
scr_LogPrint(LPRINT_LOGNORM, "Invitation event %s timed out, cancelled.", invitation->to); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
94 |
return FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
95 |
} |
1598 | 96 |
if (evcontext == EVS_CONTEXT_CANCEL) { |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
97 |
scr_LogPrint(LPRINT_LOGNORM, "Invitation event %s cancelled.", invitation->to); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
98 |
return FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
99 |
} |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
100 |
if (!(evcontext == EVS_CONTEXT_ACCEPT || evcontext == EVS_CONTEXT_REJECT)) |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
101 |
return FALSE; |
999
9687ecc59303
Redo chat states detection if we receive a message error packet from a contact
Mikael Berthe <mikael@lilotux.net>
parents:
998
diff
changeset
|
102 |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
103 |
// Ok, let's work now |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
104 |
if (evcontext == EVS_CONTEXT_ACCEPT) { |
1598 | 105 |
char *nickname = default_muc_nickname(invitation->to); |
106 |
xmpp_room_join(invitation->to, nickname, invitation->passwd); |
|
107 |
g_free(nickname); |
|
108 |
} else { |
|
109 |
scr_LogPrint(LPRINT_LOGNORM, "Invitation to %s refused.", invitation->to); |
|
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
110 |
if (invitation->reply) |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
111 |
decline_invitation(invitation, arg); |
124 | 112 |
} |
113 |
||
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
114 |
return FALSE; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
686
diff
changeset
|
115 |
} |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
686
diff
changeset
|
116 |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
117 |
// Join a MUC room |
1598 | 118 |
void xmpp_room_join(const char *room, const char *nickname, const char *passwd) |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
119 |
{ |
1598 | 120 |
LmMessage *x; |
121 |
LmMessageNode *y; |
|
643
dd73c3dad815
Fix double UTF-8 encoding when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
642
diff
changeset
|
122 |
gchar *roomid; |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
123 |
GSList *room_elt; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
124 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
125 |
if (!xmpp_is_online() || !room) |
1682
d1e8fb14ce2d
Destroy lm connection object on disconnect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
126 |
return; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
127 |
if (!nickname) return; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
128 |
|
643
dd73c3dad815
Fix double UTF-8 encoding when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
642
diff
changeset
|
129 |
roomid = g_strdup_printf("%s/%s", room, nickname); |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
130 |
if (check_jid_syntax(roomid)) { |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
131 |
scr_LogPrint(LPRINT_NORMAL, "<%s/%s> is not a valid Jabber room", room, |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
132 |
nickname); |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
133 |
g_free(roomid); |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
134 |
return; |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
135 |
} |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
136 |
|
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
137 |
room_elt = roster_find(room, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
138 |
// Add room if it doesn't already exist |
649
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
645
diff
changeset
|
139 |
if (!room_elt) { |
1355 | 140 |
room_elt = roster_add_user(room, NULL, NULL, ROSTER_TYPE_ROOM, |
141 |
sub_none, -1); |
|
649
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
645
diff
changeset
|
142 |
} else { |
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
645
diff
changeset
|
143 |
// Make sure this is a room (it can be a conversion user->room) |
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
645
diff
changeset
|
144 |
buddy_settype(room_elt->data, ROSTER_TYPE_ROOM); |
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
645
diff
changeset
|
145 |
} |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
146 |
// If insideroom is TRUE, this is a nickname change and we don't care here |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
147 |
if (!buddy_getinsideroom(room_elt->data)) { |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
148 |
// We're trying to enter a room |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
149 |
buddy_setnickname(room_elt->data, nickname); |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
150 |
} |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
151 |
|
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
152 |
// Send the XML request |
1598 | 153 |
x = lm_message_new_presence(mystatus, roomid, mystatusmsg); |
1920
bfa507815e0c
Add caps to presence when joining a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
1908
diff
changeset
|
154 |
xmpp_insert_entity_capabilities(x->node, mystatus); // Entity Caps (XEP-0115) |
1598 | 155 |
y = lm_message_node_add_child(x->node, "x", NULL); |
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
156 |
lm_message_node_set_attribute(y, "xmlns", NS_MUC); |
1598 | 157 |
if (passwd) |
158 |
lm_message_node_add_child(y, "password", passwd); |
|
159 |
||
160 |
lm_connection_send(lconnection, x, NULL); |
|
161 |
lm_message_unref(x); |
|
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
162 |
g_free(roomid); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
163 |
} |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
164 |
|
1598 | 165 |
// Invite a user to a MUC room |
449 | 166 |
// room syntax: "room@server" |
1598 | 167 |
// reason can be null. |
168 |
void xmpp_room_invite(const char *room, const char *fjid, const char *reason) |
|
449 | 169 |
{ |
1598 | 170 |
LmMessage *msg; |
171 |
LmMessageNode *x, *y; |
|
449 | 172 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
173 |
if (!xmpp_is_online() || !room || !fjid) |
1682
d1e8fb14ce2d
Destroy lm connection object on disconnect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
174 |
return; |
1598 | 175 |
|
176 |
msg = lm_message_new(room, LM_MESSAGE_TYPE_MESSAGE); |
|
449 | 177 |
|
1598 | 178 |
x = lm_message_node_add_child(msg->node, "x", NULL); |
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
179 |
lm_message_node_set_attribute(x, "xmlns", NS_MUC_USER); |
449 | 180 |
|
1598 | 181 |
y = lm_message_node_add_child(x, "invite", NULL); |
182 |
lm_message_node_set_attribute(y, "to", fjid); |
|
183 |
||
184 |
if (reason) |
|
185 |
lm_message_node_add_child(y, "reason", reason); |
|
186 |
||
187 |
lm_connection_send(lconnection, msg, NULL); |
|
188 |
lm_message_unref(msg); |
|
449 | 189 |
} |
190 |
||
1598 | 191 |
int xmpp_room_setattrib(const char *roomid, const char *fjid, |
192 |
const char *nick, struct role_affil ra, |
|
193 |
const char *reason) |
|
599 | 194 |
{ |
1598 | 195 |
LmMessage *iq; |
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
196 |
LmMessageHandler *handler; |
1598 | 197 |
LmMessageNode *query, *x; |
599 | 198 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
199 |
if (!xmpp_is_online() || !roomid) |
1682
d1e8fb14ce2d
Destroy lm connection object on disconnect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
200 |
return 1; |
1058 | 201 |
if (!fjid && !nick) return 1; |
568 | 202 |
|
203 |
if (check_jid_syntax((char*)roomid)) { |
|
204 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", roomid); |
|
205 |
return 1; |
|
206 |
} |
|
1058 | 207 |
if (fjid && check_jid_syntax((char*)fjid)) { |
208 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", fjid); |
|
568 | 209 |
return 1; |
210 |
} |
|
211 |
||
1058 | 212 |
if (ra.type == type_affil && ra.val.affil == affil_outcast && !fjid) |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
569
diff
changeset
|
213 |
return 1; // Shouldn't happen (jid mandatory when banning) |
568 | 214 |
|
1598 | 215 |
iq = lm_message_new_with_sub_type(roomid, LM_MESSAGE_TYPE_IQ, |
216 |
LM_MESSAGE_SUB_TYPE_SET); |
|
217 |
query = lm_message_node_add_child(iq->node, "query", NULL); |
|
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
218 |
lm_message_node_set_attribute(query, "xmlns", NS_MUC_ADMIN); |
1598 | 219 |
x = lm_message_node_add_child(query, "item", NULL); |
568 | 220 |
|
1058 | 221 |
if (fjid) { |
1598 | 222 |
lm_message_node_set_attribute(x, "jid", fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
223 |
} else { // nickname |
1598 | 224 |
lm_message_node_set_attribute(x, "nick", nick); |
568 | 225 |
} |
584 | 226 |
|
227 |
if (ra.type == type_affil) |
|
1598 | 228 |
lm_message_node_set_attribute(x, "affiliation", straffil[ra.val.affil]); |
584 | 229 |
else if (ra.type == type_role) |
1598 | 230 |
lm_message_node_set_attribute(x, "role", strrole[ra.val.role]); |
568 | 231 |
|
1598 | 232 |
if (reason) |
233 |
lm_message_node_add_child(x, "reason", reason); |
|
568 | 234 |
|
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
235 |
handler = lm_message_handler_new(handle_iq_dummy, NULL, FALSE); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
236 |
lm_connection_send_with_reply(lconnection, iq, handler, NULL); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
237 |
lm_message_handler_unref(handler); |
1598 | 238 |
lm_message_unref(iq); |
568 | 239 |
|
240 |
return 0; |
|
241 |
} |
|
486 | 242 |
|
1598 | 243 |
// Unlock a MUC room |
486 | 244 |
// room syntax: "room@server" |
1598 | 245 |
void xmpp_room_unlock(const char *room) |
486 | 246 |
{ |
1664 | 247 |
LmMessageNode *node; |
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
248 |
LmMessageHandler *handler; |
1598 | 249 |
LmMessage *iq; |
1363
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
250 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
251 |
if (!xmpp_is_online() || !room) |
1682
d1e8fb14ce2d
Destroy lm connection object on disconnect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
252 |
return; |
1363
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
253 |
|
1598 | 254 |
iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ, |
255 |
LM_MESSAGE_SUB_TYPE_SET); |
|
1664 | 256 |
|
257 |
node = lm_message_node_add_child(iq->node, "query", NULL); |
|
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
258 |
lm_message_node_set_attribute(node, "xmlns", NS_MUC_OWNER); |
1664 | 259 |
node = lm_message_node_add_child(node, "x", NULL); |
260 |
lm_message_node_set_attributes(node, "xmlns", "jabber:x:data", |
|
261 |
"type", "submit", NULL); |
|
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
262 |
|
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
263 |
handler = lm_message_handler_new(handle_iq_dummy, NULL, FALSE); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
264 |
lm_connection_send_with_reply(lconnection, iq, handler, NULL); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
265 |
lm_message_handler_unref(handler); |
1598 | 266 |
lm_message_unref(iq); |
1016 | 267 |
} |
268 |
||
1598 | 269 |
// Destroy a MUC room |
270 |
// room syntax: "room@server" |
|
271 |
void xmpp_room_destroy(const char *room, const char *venue, const char *reason) |
|
1104
382972712208
Allow short key format in check_signature()
Mikael Berthe <mikael@lilotux.net>
parents:
1099
diff
changeset
|
272 |
{ |
1598 | 273 |
LmMessage *iq; |
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
274 |
LmMessageHandler *handler; |
1598 | 275 |
LmMessageNode *query, *x; |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1042
diff
changeset
|
276 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
277 |
if (!xmpp_is_online() || !room) |
1682
d1e8fb14ce2d
Destroy lm connection object on disconnect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
278 |
return; |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
279 |
|
1598 | 280 |
iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ, |
281 |
LM_MESSAGE_SUB_TYPE_SET); |
|
282 |
query = lm_message_node_add_child(iq->node, "query", NULL); |
|
1908
e2def760c6d0
Introduce NS_MUC_{USER,ADMIN,OWNER}
Mikael Berthe <mikael@lilotux.net>
parents:
1899
diff
changeset
|
283 |
lm_message_node_set_attribute(query, "xmlns", NS_MUC_OWNER); |
1598 | 284 |
x = lm_message_node_add_child(query, "destroy", NULL); |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
285 |
|
1598 | 286 |
if (venue && *venue) |
287 |
lm_message_node_set_attribute(x, "jid", venue); |
|
31 | 288 |
|
1598 | 289 |
if (reason) |
290 |
lm_message_node_add_child(x, "reason", reason); |
|
35 | 291 |
|
1994
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
292 |
handler = lm_message_handler_new(handle_iq_dummy, NULL, FALSE); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
293 |
lm_connection_send_with_reply(lconnection, iq, handler, NULL); |
024bdd1c6418
Add a dummy handler for some unhandled IQ replies
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
294 |
lm_message_handler_unref(handler); |
1598 | 295 |
lm_message_unref(iq); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
624
diff
changeset
|
296 |
} |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
624
diff
changeset
|
297 |
|
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
298 |
// muc_get_item_info(...) |
2279 | 299 |
// Get room member's information from xmldata. |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
300 |
// The variables must be initialized before calling this function, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
301 |
// because they are not touched if the relevant information is missing. |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
302 |
// Note that *actor should be freed by the caller. |
1598 | 303 |
static void muc_get_item_info(const char *from, LmMessageNode *xmldata, |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
304 |
enum imrole *mbrole, enum imaffiliation *mbaffil, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
305 |
const char **mbjid, const char **mbnick, |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
306 |
char **actor, const char **reason) |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
307 |
{ |
1598 | 308 |
LmMessageNode *y, *z; |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
309 |
const char *p, *actorjid, *actornick; |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
310 |
|
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
311 |
y = lm_message_node_get_child(xmldata, "item"); |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
312 |
if (!y) |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
313 |
return; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
314 |
|
1598 | 315 |
p = lm_message_node_get_attribute(y, "affiliation"); |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
316 |
if (p) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
317 |
if (!strcmp(p, "owner")) *mbaffil = affil_owner; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
318 |
else if (!strcmp(p, "admin")) *mbaffil = affil_admin; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
319 |
else if (!strcmp(p, "member")) *mbaffil = affil_member; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
320 |
else if (!strcmp(p, "outcast")) *mbaffil = affil_outcast; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
321 |
else if (!strcmp(p, "none")) *mbaffil = affil_none; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
322 |
else scr_LogPrint(LPRINT_LOGNORM, "<%s>: Unknown affiliation \"%s\"", |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
323 |
from, p); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
324 |
} |
1598 | 325 |
p = lm_message_node_get_attribute(y, "role"); |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
326 |
if (p) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
327 |
if (!strcmp(p, "moderator")) *mbrole = role_moderator; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
328 |
else if (!strcmp(p, "participant")) *mbrole = role_participant; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
329 |
else if (!strcmp(p, "visitor")) *mbrole = role_visitor; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
330 |
else if (!strcmp(p, "none")) *mbrole = role_none; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
331 |
else scr_LogPrint(LPRINT_LOGNORM, "<%s>: Unknown role \"%s\"", |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
332 |
from, p); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
333 |
} |
1598 | 334 |
*mbjid = lm_message_node_get_attribute(y, "jid"); |
335 |
*mbnick = lm_message_node_get_attribute(y, "nick"); |
|
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
336 |
// For kick/ban, there can be actor and reason tags |
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
337 |
z = lm_message_node_get_child(y, "actor"); |
2124
af7e705380b2
MUC: when supported, prefer to show actor's nick over actor's jid on kick/ban.
sh!zeeg <shizeeque@gmail.com>
parents:
2026
diff
changeset
|
338 |
if (z) { |
2126
36170c97a0b7
show actor's nick and jid on kick/ban if available
sh!zeeg <shizeeque@gmail.com>
parents:
2125
diff
changeset
|
339 |
actornick = lm_message_node_get_attribute(z, "nick"); |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
340 |
actorjid = lm_message_node_get_attribute(z, "jid"); |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
341 |
if (actorjid) { |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
342 |
if (actornick) { |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
343 |
// We have both the actor's jid and nick |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
344 |
*actor = g_strdup_printf("%s <%s>", actornick, actorjid); |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
345 |
} else { |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
346 |
*actor = g_strdup(actorjid); // jid only |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
347 |
} |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
348 |
} else if (!actorjid && actornick) { |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
349 |
// We only have the nickname |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
350 |
*actor = g_strdup(actornick); |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
351 |
} |
2124
af7e705380b2
MUC: when supported, prefer to show actor's nick over actor's jid on kick/ban.
sh!zeeg <shizeeque@gmail.com>
parents:
2026
diff
changeset
|
352 |
} |
af7e705380b2
MUC: when supported, prefer to show actor's nick over actor's jid on kick/ban.
sh!zeeg <shizeeque@gmail.com>
parents:
2026
diff
changeset
|
353 |
|
1598 | 354 |
*reason = lm_message_node_get_child_value(y, "reason"); |
1899
decf94827efe
More lm_message_node_get_child_value() return value checks
Mikael Berthe <mikael@lilotux.net>
parents:
1898
diff
changeset
|
355 |
if (*reason && !**reason) |
decf94827efe
More lm_message_node_get_child_value() return value checks
Mikael Berthe <mikael@lilotux.net>
parents:
1898
diff
changeset
|
356 |
*reason = NULL; |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
357 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
358 |
|
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
359 |
// muc_handle_join(...) |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
360 |
// Handle a join event in a MUC room. |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
361 |
// This function will return the new_member value TRUE if somebody else joins |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
362 |
// the room (and FALSE if _we_ are joining the room). |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
363 |
static bool muc_handle_join(const GSList *room_elt, const char *rname, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
364 |
const char *roomjid, const char *ournick, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
365 |
enum room_printstatus printstatus, |
2005 | 366 |
time_t usttime, int log_muc_conf, |
367 |
enum room_autowhois autowhois, const char *mbjid) |
|
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
368 |
{ |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
369 |
bool new_member = FALSE; // True if somebody else joins the room (not us) |
2005 | 370 |
gchar *nickjid; |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
371 |
gchar *mbuf; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
372 |
enum room_flagjoins flagjoins; |
2006 | 373 |
char *tmp = NULL; |
374 |
int printjid; |
|
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
375 |
|
2006 | 376 |
printjid = settings_opt_get_int("muc_print_jid"); |
377 |
if (mbjid && autowhois == autowhois_off && printjid) { |
|
378 |
if (printjid == 1) |
|
379 |
tmp = strchr(mbjid, JID_RESOURCE_SEPARATOR); |
|
380 |
if (tmp) *tmp = '\0'; |
|
2005 | 381 |
nickjid = g_strdup_printf("%s <%s>", rname, mbjid); |
2006 | 382 |
if (tmp) *tmp = JID_RESOURCE_SEPARATOR; |
383 |
} else { |
|
2005 | 384 |
nickjid = g_strdup(rname); |
2006 | 385 |
} |
2005 | 386 |
|
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
387 |
if (!buddy_getinsideroom(room_elt->data)) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
388 |
// We weren't inside the room yet. Now we are. |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
389 |
// However, this could be a presence packet from another room member |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
390 |
|
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
391 |
buddy_setinsideroom(room_elt->data, TRUE); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
392 |
// Set the message flag unless we're already in the room buffer window |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
393 |
scr_setmsgflag_if_needed(roomjid, FALSE); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
394 |
// Add a message to the tracelog file |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
395 |
mbuf = g_strdup_printf("You have joined %s as \"%s\"", roomjid, ournick); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
396 |
scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
397 |
g_free(mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
398 |
mbuf = g_strdup_printf("You have joined as \"%s\"", ournick); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
399 |
|
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
400 |
// The 1st presence message could be for another room member |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
401 |
if (strcmp(ournick, rname)) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
402 |
// Display current mbuf and create a new message for the member |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
403 |
// Note: the usttime timestamp is related to the other member, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
404 |
// so we use 0 here. |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
405 |
scr_WriteIncomingMessage(roomjid, mbuf, 0, |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
406 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
407 |
if (log_muc_conf) |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
408 |
hlog_write_message(roomjid, 0, -1, mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
409 |
g_free(mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
410 |
if (printstatus != status_none) |
2005 | 411 |
mbuf = g_strdup_printf("%s has joined", nickjid); |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
412 |
else |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
413 |
mbuf = NULL; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
414 |
new_member = TRUE; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
415 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
416 |
} else { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
417 |
mbuf = NULL; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
418 |
if (strcmp(ournick, rname)) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
419 |
if (printstatus != status_none) |
2005 | 420 |
mbuf = g_strdup_printf("%s has joined", nickjid); |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
421 |
new_member = TRUE; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
422 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
423 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
424 |
|
2005 | 425 |
g_free(nickjid); |
426 |
||
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
427 |
if (mbuf) { |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
428 |
guint msgflags = HBB_PREFIX_INFO; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
429 |
flagjoins = buddy_getflagjoins(room_elt->data); |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
430 |
if (flagjoins == flagjoins_default && |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
431 |
!settings_opt_get_int("muc_flag_joins")) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
432 |
flagjoins = flagjoins_none; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
433 |
if (flagjoins == flagjoins_none) |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
434 |
msgflags |= HBB_PREFIX_NOFLAG; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
435 |
scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
436 |
if (log_muc_conf) |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
437 |
hlog_write_message(roomjid, 0, -1, mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
438 |
g_free(mbuf); |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
439 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
440 |
|
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
441 |
return new_member; |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
442 |
} |
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
443 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
444 |
void handle_muc_presence(const char *from, LmMessageNode *xmldata, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
445 |
const char *roomjid, const char *rname, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
446 |
enum imstatus ust, const char *ustmsg, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
447 |
time_t usttime, char bpprio) |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
448 |
{ |
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
449 |
char *mbuf; |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
450 |
const char *ournick; |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
451 |
enum imrole mbrole = role_none; |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
452 |
enum imaffiliation mbaffil = affil_none; |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
453 |
enum room_printstatus printstatus; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
454 |
enum room_autowhois autowhois; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
455 |
enum room_flagjoins flagjoins; |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
456 |
const char *mbjid = NULL, *mbnick = NULL; |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
457 |
const char *reason = NULL; |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
458 |
char *actor = NULL; |
837
7c74eef1d0e0
New option "muc_auto_whois"
Mikael Berthe <mikael@lilotux.net>
parents:
834
diff
changeset
|
459 |
bool new_member = FALSE; // True if somebody else joins the room (not us) |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
460 |
bool our_presence = FALSE; // True if this presence is from us (i.e. bears |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
461 |
// code 110) |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
462 |
guint statuscode = 0; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
463 |
guint nickchange = 0; |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
464 |
GSList *room_elt; |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
465 |
int log_muc_conf; |
1013
f1a9ca2348e5
Set the msg_flag when we leave a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
466 |
guint msgflags; |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
467 |
|
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
468 |
log_muc_conf = settings_opt_get_int("log_muc_conf"); |
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
469 |
|
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
470 |
room_elt = roster_find(roomjid, jidsearch, 0); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
471 |
if (!room_elt) { |
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
472 |
// Add room if it doesn't already exist |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
473 |
// It shouldn't happen, there is probably something wrong (server or |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
474 |
// network issue?) |
1355 | 475 |
room_elt = roster_add_user(roomjid, NULL, NULL, ROSTER_TYPE_ROOM, |
476 |
sub_none, -1); |
|
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
477 |
scr_LogPrint(LPRINT_LOGNORM, "Strange MUC presence message"); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
478 |
} else { |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
479 |
// Make sure this is a room (it can be a conversion user->room) |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
480 |
buddy_settype(room_elt->data, ROSTER_TYPE_ROOM); |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
481 |
} |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
482 |
|
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
483 |
// Get room member's information |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
484 |
muc_get_item_info(from, xmldata, &mbrole, &mbaffil, &mbjid, &mbnick, |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
485 |
&actor, &reason); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
486 |
|
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
487 |
// Get our room nickname |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
488 |
ournick = buddy_getnickname(room_elt->data); |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
489 |
|
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
490 |
if (!ournick) { |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
491 |
// It shouldn't happen, probably a server issue |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
492 |
const gchar msg[] = "Unexpected groupchat packet!"; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
493 |
scr_LogPrint(LPRINT_LOGNORM, msg); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
494 |
scr_WriteIncomingMessage(roomjid, msg, 0, HBB_PREFIX_INFO, 0); |
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
495 |
// Send back an unavailable packet |
1598 | 496 |
xmpp_setstatus(offline, roomjid, "", TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2280
diff
changeset
|
497 |
scr_update_roster(); |
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
498 |
return; |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
499 |
} |
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
500 |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
501 |
#define SETSTATUSCODE(VALUE) \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
502 |
{ \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
503 |
if (G_UNLIKELY(statuscode)) \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
504 |
scr_LogPrint(LPRINT_DEBUG, "handle_muc_presence: WARNING: " \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
505 |
"replacing status code %u with %u.", statuscode, VALUE); \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
506 |
statuscode = VALUE; \ |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
507 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
508 |
|
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
509 |
{ // Get the status code |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
510 |
LmMessageNode *node; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
511 |
for (node = xmldata -> children; node; node = node -> next) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
512 |
if (!g_strcmp0(node -> name, "status")) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
513 |
const char *codestr = lm_message_node_get_attribute(node, "code"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
514 |
if (codestr) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
515 |
const char *mesg = NULL; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
516 |
switch (atoi(codestr)) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
517 |
// initial |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
518 |
case 100: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
519 |
mesg = "The room is not anonymous."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
520 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
521 |
case 110: // It is our presence |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
522 |
our_presence = TRUE; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
523 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
524 |
// initial |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
525 |
case 170: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
526 |
mesg = "The room is logged."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
527 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
528 |
// initial |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
529 |
case 201: // Room created |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
530 |
SETSTATUSCODE(201); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
531 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
532 |
// initial |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
533 |
case 210: // Your nick change (on join) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
534 |
// FIXME: print nick |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
535 |
mesg = "The room has changed your nick!"; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
536 |
buddy_setnickname(room_elt->data, rname); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
537 |
ournick = rname; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
538 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
539 |
case 301: // User banned |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
540 |
SETSTATUSCODE(301); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
541 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
542 |
case 303: // Nick change |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
543 |
SETSTATUSCODE(303); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
544 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
545 |
case 307: // User kicked |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
546 |
SETSTATUSCODE(307); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
547 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
548 |
// XXX (next three) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
549 |
case 321: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
550 |
mesg = "User leaves room due to affilation change."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
551 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
552 |
case 322: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
553 |
mesg = "User leaves room, as room is only for members now."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
554 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
555 |
case 332: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
556 |
mesg = "User leaves room due to system shutdown."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
557 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
558 |
default: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
559 |
scr_LogPrint(LPRINT_DEBUG, |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
560 |
"handle_muc_presence: Unknown MUC status code: %s.", |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
561 |
codestr); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
562 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
563 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
564 |
if (mesg) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
565 |
scr_WriteIncomingMessage(roomjid, mesg, usttime, |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
566 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
567 |
if (log_muc_conf) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
568 |
hlog_write_message(roomjid, 0, -1, mesg); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
569 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
570 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
571 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
572 |
} |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
573 |
} |
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
574 |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
575 |
#undef SETSTATUSCODE |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
576 |
|
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
577 |
if (!our_presence) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
578 |
if (ournick && !strcmp(ournick, rname)) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
579 |
our_presence = TRUE; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
580 |
|
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
581 |
// Get the room's "print_status" settings |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
582 |
printstatus = buddy_getprintstatus(room_elt->data); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
583 |
if (printstatus == status_default) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
584 |
printstatus = (guint) settings_opt_get_int("muc_print_status"); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
585 |
if (printstatus > 3) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
586 |
printstatus = status_default; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
587 |
} |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
588 |
|
1396
8f9928839a36
Automatically unlock new rooms (suggested by Michael Weiser)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
589 |
// A new room has been created; accept MUC default config |
8f9928839a36
Automatically unlock new rooms (suggested by Michael Weiser)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
590 |
if (statuscode == 201) |
1598 | 591 |
xmpp_room_unlock(roomjid); |
1396
8f9928839a36
Automatically unlock new rooms (suggested by Michael Weiser)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
592 |
|
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
593 |
// Check for nickname change |
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
594 |
if (statuscode == 303 && mbnick) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
595 |
mbuf = g_strdup_printf("%s is now known as %s", rname, mbnick); |
632
cfab93886a88
MUC: use timestamp when available
Mikael Berthe <mikael@lilotux.net>
parents:
628
diff
changeset
|
596 |
scr_WriteIncomingMessage(roomjid, mbuf, usttime, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1282
diff
changeset
|
597 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
1166
c4da23bf8958
Add option 'muc_flag_joins'
Mikael Berthe <mikael@lilotux.net>
parents:
1164
diff
changeset
|
598 |
if (log_muc_conf) |
1342
06441b6cc23a
History logfile: Use a special code (MI) for local MUC info messages
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
599 |
hlog_write_message(roomjid, 0, -1, mbuf); |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
600 |
g_free(mbuf); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
601 |
buddy_resource_setname(room_elt->data, rname, mbnick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
602 |
// Maybe it's _our_ nickname... |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
603 |
if (our_presence) |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
604 |
buddy_setnickname(room_elt->data, mbnick); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
605 |
nickchange = TRUE; |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
606 |
} |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
607 |
|
2005 | 608 |
autowhois = buddy_getautowhois(room_elt->data); |
609 |
if (autowhois == autowhois_default) |
|
610 |
autowhois = (settings_opt_get_int("muc_auto_whois") ? |
|
611 |
autowhois_on : autowhois_off); |
|
612 |
||
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
613 |
// Check for departure/arrival |
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
614 |
if (statuscode != 303 && ust == offline) { |
1384
f762805b3f42
Split function handle_presence_muc()
Mikael Berthe <mikael@lilotux.net>
parents:
1383
diff
changeset
|
615 |
// Somebody is leaving |
586 | 616 |
enum { leave=0, kick, ban } how = leave; |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
617 |
|
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
618 |
if (statuscode == 307) |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
619 |
how = kick; |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
620 |
else if (statuscode == 301) |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
621 |
how = ban; |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
622 |
|
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
623 |
// If this is a leave, check if it is ourself |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
624 |
if (our_presence) { |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
625 |
buddy_setinsideroom(room_elt->data, FALSE); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
626 |
buddy_setnickname(room_elt->data, NULL); |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
627 |
buddy_del_all_resources(room_elt->data); |
600
483a87c99990
Free room personal data when receiving the unavailable stanza, not before
Mikael Berthe <mikael@lilotux.net>
parents:
599
diff
changeset
|
628 |
buddy_settopic(room_elt->data, NULL); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
629 |
scr_update_chat_status(FALSE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2280
diff
changeset
|
630 |
scr_update_roster(); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
631 |
} |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
632 |
|
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
633 |
// The message depends on _who_ left, and _how_ |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
634 |
if (how) { |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
635 |
gchar *mbuf_end; |
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
636 |
gchar *reason_msg = NULL; |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
637 |
// Forced leave |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
638 |
if (actor) { |
2126
36170c97a0b7
show actor's nick and jid on kick/ban if available
sh!zeeg <shizeeque@gmail.com>
parents:
2125
diff
changeset
|
639 |
mbuf_end = g_strdup_printf("%s from %s by %s", |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
640 |
(how == ban ? "banned" : "kicked"), |
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
641 |
roomjid, actor); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
642 |
} else { |
2126
36170c97a0b7
show actor's nick and jid on kick/ban if available
sh!zeeg <shizeeque@gmail.com>
parents:
2125
diff
changeset
|
643 |
mbuf_end = g_strdup_printf("%s from %s", |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
644 |
(how == ban ? "banned" : "kicked"), |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
645 |
roomjid); |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
646 |
} |
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
647 |
if (reason) |
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
648 |
reason_msg = g_strdup_printf("\nReason: %s", reason); |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
649 |
if (our_presence) |
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
650 |
mbuf = g_strdup_printf("You have been %s%s", mbuf_end, |
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
651 |
reason_msg ? reason_msg : ""); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
652 |
else |
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
653 |
mbuf = g_strdup_printf("%s has been %s%s", rname, mbuf_end, |
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
654 |
reason_msg ? reason_msg : ""); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
655 |
|
1898
e25cec543da1
Fix two MUC issues (reported by VarLog)
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
656 |
g_free(reason_msg); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
657 |
g_free(mbuf_end); |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
658 |
} else { |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
659 |
// Natural leave |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
660 |
if (our_presence) { |
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
661 |
LmMessageNode *destroynode = lm_message_node_get_child(xmldata, |
1598 | 662 |
"destroy"); |
616
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
663 |
if (destroynode) { |
1899
decf94827efe
More lm_message_node_get_child_value() return value checks
Mikael Berthe <mikael@lilotux.net>
parents:
1898
diff
changeset
|
664 |
reason = lm_message_node_get_child_value(destroynode, "reason"); |
decf94827efe
More lm_message_node_get_child_value() return value checks
Mikael Berthe <mikael@lilotux.net>
parents:
1898
diff
changeset
|
665 |
if (reason && *reason) { |
616
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
666 |
mbuf = g_strdup_printf("You have left %s, " |
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
667 |
"the room has been destroyed: %s", |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
756
diff
changeset
|
668 |
roomjid, reason); |
616
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
669 |
} else { |
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
670 |
mbuf = g_strdup_printf("You have left %s, " |
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
671 |
"the room has been destroyed", roomjid); |
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
672 |
} |
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
673 |
} else { |
599 | 674 |
mbuf = g_strdup_printf("You have left %s", roomjid); |
616
a61a257ec38b
MUC: display reason, if any, when a room has been destroyed
Mikael Berthe <mikael@lilotux.net>
parents:
612
diff
changeset
|
675 |
} |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
676 |
} else { |
845
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
677 |
if (ust != offline) { |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
678 |
// This can happen when a network failure occurs, |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
679 |
// this isn't an official leave but the user isn't there anymore. |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
680 |
mbuf = g_strdup_printf("%s has disappeared!", rname); |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
681 |
ust = offline; |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
682 |
} else { |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
683 |
if (ustmsg) |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
684 |
mbuf = g_strdup_printf("%s has left: %s", rname, ustmsg); |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
685 |
else |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
686 |
mbuf = g_strdup_printf("%s has left", rname); |
51829325fe21
MUC: Fix a strange bug when a user isn't in a room anymore (network issue)
Mikael Berthe <mikael@lilotux.net>
parents:
842
diff
changeset
|
687 |
} |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
688 |
} |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
689 |
} |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
690 |
|
2132
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
691 |
g_free(actor); |
a09cdfceae17
Rework muc_get_item_info()
Mikael Berthe <mikael@lilotux.net>
parents:
2126
diff
changeset
|
692 |
|
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
693 |
// Display the mbuf message if we're concerned |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
694 |
// or if the print_status isn't set to none. |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
695 |
if (our_presence || printstatus != status_none) { |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
696 |
msgflags = HBB_PREFIX_INFO; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
697 |
flagjoins = buddy_getflagjoins(room_elt->data); |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
698 |
if (flagjoins == flagjoins_default && |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
699 |
settings_opt_get_int("muc_flag_joins") == 2) |
2279 | 700 |
flagjoins = flagjoins_all; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
701 |
if (!our_presence && flagjoins != flagjoins_all) |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
702 |
msgflags |= HBB_PREFIX_NOFLAG; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1953
diff
changeset
|
703 |
//silent message if someone else joins, and we care about noone |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
704 |
scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
705 |
} |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
706 |
|
1166
c4da23bf8958
Add option 'muc_flag_joins'
Mikael Berthe <mikael@lilotux.net>
parents:
1164
diff
changeset
|
707 |
if (log_muc_conf) |
1342
06441b6cc23a
History logfile: Use a special code (MI) for local MUC info messages
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
708 |
hlog_write_message(roomjid, 0, -1, mbuf); |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
709 |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
710 |
if (our_presence) { |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
711 |
scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); |
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
712 |
g_free(mbuf); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
713 |
return; |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
714 |
} |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
715 |
g_free(mbuf); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
716 |
} else { |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
717 |
enum imstatus old_ust = buddy_getstatus(room_elt->data, rname); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
718 |
if (old_ust == offline && ust != offline) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
719 |
// Somebody is joining |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
720 |
new_member = muc_handle_join(room_elt, rname, roomjid, ournick, |
2005 | 721 |
printstatus, usttime, log_muc_conf, |
722 |
autowhois, mbjid); |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
723 |
} else { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
724 |
// This is a simple member status change |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
725 |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
726 |
if (printstatus == status_all && !nickchange) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
727 |
const char *old_ustmsg = buddy_getstatusmsg(room_elt->data, rname); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
728 |
if (old_ust != ust || g_strcmp0(old_ustmsg, ustmsg)) { |
2125
fef71336e429
shorten 'status change' message in MUC
sh!zeeg <shizeeque@gmail.com>
parents:
2124
diff
changeset
|
729 |
mbuf = g_strdup_printf("%s [%c>%c] %s", rname, imstatus2char[old_ust], |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
730 |
imstatus2char[ust], ((ustmsg) ? ustmsg : "")); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
731 |
scr_WriteIncomingMessage(roomjid, mbuf, usttime, |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
732 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
733 |
g_free(mbuf); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
734 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
735 |
} |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
736 |
} |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
737 |
} |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
738 |
|
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
739 |
// Sanity check, shouldn't happen... |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
740 |
if (!rname) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
741 |
return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
742 |
|
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
743 |
// Update room member status |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
744 |
roster_setstatus(roomjid, rname, bpprio, ust, ustmsg, usttime, |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
745 |
mbrole, mbaffil, mbjid); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
746 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
747 |
if (new_member && autowhois == autowhois_on) { |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1920
diff
changeset
|
748 |
cmd_room_whois(room_elt->data, rname, FALSE); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
749 |
} |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
750 |
|
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2280
diff
changeset
|
751 |
scr_update_roster(); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
752 |
} |
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
753 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1599
diff
changeset
|
754 |
void roompresence(gpointer room, void *presencedata) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
755 |
{ |
1598 | 756 |
const char *bjid; |
757 |
const char *nickname; |
|
758 |
char *to; |
|
759 |
struct T_presence *pres = presencedata; |
|
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
760 |
|
1598 | 761 |
if (!buddy_getinsideroom(room)) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
762 |
return; |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
763 |
|
1598 | 764 |
bjid = buddy_getjid(room); |
765 |
if (!bjid) return; |
|
766 |
nickname = buddy_getnickname(room); |
|
767 |
if (!nickname) return; |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
624
diff
changeset
|
768 |
|
1598 | 769 |
to = g_strdup_printf("%s/%s", bjid, nickname); |
770 |
xmpp_setstatus(pres->st, to, pres->msg, TRUE); |
|
771 |
g_free(to); |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
772 |
} |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
773 |
|
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
774 |
// got_invite(from, to, reason, passwd, reply) |
1330
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
775 |
// This function should be called when receiving an invitation from user |
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
776 |
// "from", to enter the room "to". Optional reason and room password can |
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
777 |
// be provided. |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
778 |
void got_invite(const char* from, const char *to, const char* reason, |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
779 |
const char* passwd, gboolean reply) |
1128 | 780 |
{ |
781 |
GString *sbuf; |
|
1236
f7b35b1c343d
Fix a roster bug when receiving a MUC invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1215
diff
changeset
|
782 |
char *barejid; |
1237
dcb99f0b5aaa
Small MUC invitation improvement
Mikael Berthe <mikael@lilotux.net>
parents:
1236
diff
changeset
|
783 |
GSList *room_elt; |
1128 | 784 |
|
785 |
sbuf = g_string_new(""); |
|
2025
33426f7fb4a9
MUC mediated invitation: don't show empty reason on declined invitation
Mikael Berthe <mikael@lilotux.net>
parents:
2019
diff
changeset
|
786 |
if (reason && reason[0]) { |
1128 | 787 |
g_string_printf(sbuf, |
788 |
"Received an invitation to <%s>, from <%s>, reason: %s", |
|
789 |
to, from, reason); |
|
790 |
} else { |
|
791 |
g_string_printf(sbuf, "Received an invitation to <%s>, from <%s>", |
|
792 |
to, from); |
|
793 |
} |
|
1236
f7b35b1c343d
Fix a roster bug when receiving a MUC invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1215
diff
changeset
|
794 |
|
f7b35b1c343d
Fix a roster bug when receiving a MUC invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1215
diff
changeset
|
795 |
barejid = jidtodisp(from); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1282
diff
changeset
|
796 |
scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1128 | 797 |
scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
798 |
||
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
799 |
{ // remove any equal older invites |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
800 |
GSList *iel = invitations; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
801 |
while (iel) { |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
802 |
event_muc_invitation *invitation = iel->data; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
803 |
iel = iel -> next; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
804 |
if (!g_strcmp0(to, invitation->to) && |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
805 |
!g_strcmp0(passwd, invitation->passwd)) { |
2026
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
806 |
// found a previous invitation |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
807 |
// We keep the old one, unless the current one is better and allows us |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
808 |
// to send a reply. |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
809 |
if (!reply || invitation->reply) { |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
810 |
g_free(barejid); |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
811 |
return; |
564d99cdf0d1
MUC: do not destroy previous room invitation to create a new one
Mikael Berthe <mikael@lilotux.net>
parents:
2025
diff
changeset
|
812 |
} |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
813 |
scr_LogPrint(LPRINT_DEBUG, "Destroying previous invitation event %s.", |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
814 |
invitation->evid); |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
815 |
evs_del(invitation->evid); |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
816 |
} |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
817 |
} |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
818 |
} |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
819 |
|
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
820 |
{ // create event |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
821 |
const char *id; |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
822 |
char *desc = g_strdup_printf("<%s> invites you to %s", from, to); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
823 |
event_muc_invitation *invitation; |
1722
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1687
diff
changeset
|
824 |
|
1128 | 825 |
invitation = g_new(event_muc_invitation, 1); |
826 |
invitation->to = g_strdup(to); |
|
827 |
invitation->from = g_strdup(from); |
|
828 |
invitation->passwd = g_strdup(passwd); |
|
829 |
invitation->reason = g_strdup(reason); |
|
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
830 |
invitation->reply = reply; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
831 |
invitation->evid = NULL; |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
832 |
|
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
833 |
invitations = g_slist_append(invitations, invitation); |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
834 |
|
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
835 |
id = evs_new(desc, NULL, 0, evscallback_invitation, invitation, |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
836 |
(GDestroyNotify)destroy_event_muc_invitation); |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
837 |
g_free(desc); |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
838 |
if (id) { |
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
839 |
invitation->evid = g_strdup(id); |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
840 |
g_string_printf(sbuf, "Please use /event %s accept|reject", id); |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
841 |
} else |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
842 |
g_string_printf(sbuf, "Unable to create a new event!"); |
1128 | 843 |
} |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1282
diff
changeset
|
844 |
scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1128 | 845 |
scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
846 |
g_string_free(sbuf, TRUE); |
|
1330
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
847 |
g_free(barejid); |
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
848 |
|
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
849 |
// Make sure the MUC room barejid is a room in the roster |
7ba1b6d7ddcd
Fix a bug when receiving an invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
850 |
barejid = jidtodisp(to); |
1237
dcb99f0b5aaa
Small MUC invitation improvement
Mikael Berthe <mikael@lilotux.net>
parents:
1236
diff
changeset
|
851 |
room_elt = roster_find(barejid, jidsearch, 0); |
dcb99f0b5aaa
Small MUC invitation improvement
Mikael Berthe <mikael@lilotux.net>
parents:
1236
diff
changeset
|
852 |
if (room_elt) |
dcb99f0b5aaa
Small MUC invitation improvement
Mikael Berthe <mikael@lilotux.net>
parents:
1236
diff
changeset
|
853 |
buddy_settype(room_elt->data, ROSTER_TYPE_ROOM); |
dcb99f0b5aaa
Small MUC invitation improvement
Mikael Berthe <mikael@lilotux.net>
parents:
1236
diff
changeset
|
854 |
|
1236
f7b35b1c343d
Fix a roster bug when receiving a MUC invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1215
diff
changeset
|
855 |
g_free(barejid); |
1128 | 856 |
} |
857 |
||
1598 | 858 |
|
1128 | 859 |
// Specific MUC message handling (for example invitation processing) |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
860 |
void got_muc_message(const char *from, LmMessageNode *x, time_t timestamp) |
1128 | 861 |
{ |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
862 |
LmMessageNode *node; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
863 |
// invitation |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
864 |
node = lm_message_node_get_child(x, "invite"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
865 |
if (node) { |
1598 | 866 |
const char *invite_from; |
867 |
const char *reason = NULL; |
|
868 |
const char *password = NULL; |
|
1128 | 869 |
|
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
870 |
invite_from = lm_message_node_get_attribute(node, "from"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
871 |
reason = lm_message_node_get_child_value(node, "reason"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
872 |
password = lm_message_node_get_child_value(node, "password"); |
1128 | 873 |
if (invite_from) |
1951
1a01a7ef4e43
Add support for XEP-0249 / Direct MUC Invitations (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
874 |
got_invite(invite_from, from, reason, password, TRUE); |
1128 | 875 |
} |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
876 |
|
1128 | 877 |
// declined invitation |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
878 |
node = lm_message_node_get_child(x, "decline"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
879 |
if (node) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
880 |
const char *decline_from = lm_message_node_get_attribute(node, "from"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
881 |
const char *reason = lm_message_node_get_child_value(node, "reason"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
882 |
if (decline_from) { |
2025
33426f7fb4a9
MUC mediated invitation: don't show empty reason on declined invitation
Mikael Berthe <mikael@lilotux.net>
parents:
2019
diff
changeset
|
883 |
if (reason && reason[0]) |
33426f7fb4a9
MUC mediated invitation: don't show empty reason on declined invitation
Mikael Berthe <mikael@lilotux.net>
parents:
2019
diff
changeset
|
884 |
scr_LogPrint(LPRINT_LOGNORM, "<%s> declined your invitation: %s.", |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
885 |
from, reason); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
886 |
else |
2025
33426f7fb4a9
MUC mediated invitation: don't show empty reason on declined invitation
Mikael Berthe <mikael@lilotux.net>
parents:
2019
diff
changeset
|
887 |
scr_LogPrint(LPRINT_LOGNORM, "<%s> declined your invitation.", from); |
1953
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
888 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
889 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
890 |
|
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
891 |
// status codes |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
892 |
for (node = x -> children; node; node = node -> next) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
893 |
if (!g_strcmp0(node -> name, "status")) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
894 |
const char *codestr = lm_message_node_get_attribute(node, "code"); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
895 |
if (codestr) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
896 |
const char *mesg = NULL; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
897 |
switch (atoi(codestr)) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
898 |
// initial |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
899 |
case 100: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
900 |
mesg = "The room is not anonymous."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
901 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
902 |
case 101: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
903 |
mesg = "Your affilation has changed while absent."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
904 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
905 |
case 102: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
906 |
mesg = "The room shows unavailable members."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
907 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
908 |
case 103: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
909 |
mesg = "The room does not show unavailable members."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
910 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
911 |
case 104: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
912 |
mesg = "The room configuration has changed."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
913 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
914 |
case 170: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
915 |
mesg = "The room is logged."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
916 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
917 |
case 171: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
918 |
mesg = "The room is not logged."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
919 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
920 |
case 172: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
921 |
mesg = "The room is not anonymous."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
922 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
923 |
case 173: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
924 |
mesg = "The room is semi-anonymous."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
925 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
926 |
case 174: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
927 |
mesg = "The room is anonymous."; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
928 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
929 |
default: |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
930 |
scr_LogPrint(LPRINT_DEBUG, |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
931 |
"got_muc_message: Unknown MUC status code: %s.", |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
932 |
codestr); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
933 |
break; |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
934 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
935 |
if (mesg) { |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
936 |
scr_WriteIncomingMessage(from, mesg, timestamp, |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
937 |
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
938 |
if (settings_opt_get_int("log_muc_conf")) |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
939 |
hlog_write_message(from, 0, -1, mesg); |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
940 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
941 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
942 |
} |
9f443617e96b
Improve MUC support (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1951
diff
changeset
|
943 |
} |
1128 | 944 |
} |
945 |
||
1811 | 946 |
/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |