comparison mcabber/mcabber/xmpp_muc.c @ 1682:d1e8fb14ce2d

Destroy lm connection object on disconnect
author Myhailo Danylenko <isbear@ukrpost.net>
date Tue, 19 Jan 2010 09:53:12 +0200
parents 41c26b7d2890
children 95df4ea512c8
comparison
equal deleted inserted replaced
1681:687f6b515d87 1682:d1e8fb14ce2d
111 LmMessage *x; 111 LmMessage *x;
112 LmMessageNode *y; 112 LmMessageNode *y;
113 gchar *roomid; 113 gchar *roomid;
114 GSList *room_elt; 114 GSList *room_elt;
115 115
116 if (!lm_connection_is_authenticated(lconnection) || !room) return; 116 if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
117 return;
117 if (!nickname) return; 118 if (!nickname) return;
118 119
119 roomid = g_strdup_printf("%s/%s", room, nickname); 120 roomid = g_strdup_printf("%s/%s", room, nickname);
120 if (check_jid_syntax(roomid)) { 121 if (check_jid_syntax(roomid)) {
121 scr_LogPrint(LPRINT_NORMAL, "<%s/%s> is not a valid Jabber room", room, 122 scr_LogPrint(LPRINT_NORMAL, "<%s/%s> is not a valid Jabber room", room,
159 void xmpp_room_invite(const char *room, const char *fjid, const char *reason) 160 void xmpp_room_invite(const char *room, const char *fjid, const char *reason)
160 { 161 {
161 LmMessage *msg; 162 LmMessage *msg;
162 LmMessageNode *x, *y; 163 LmMessageNode *x, *y;
163 164
164 if (!lm_connection_is_authenticated(lconnection) || !room || !fjid) return; 165 if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room || !fjid)
166 return;
165 167
166 msg = lm_message_new(room, LM_MESSAGE_TYPE_MESSAGE); 168 msg = lm_message_new(room, LM_MESSAGE_TYPE_MESSAGE);
167 169
168 x = lm_message_node_add_child(msg->node, "x", NULL); 170 x = lm_message_node_add_child(msg->node, "x", NULL);
169 lm_message_node_set_attribute(x, "xmlns", 171 lm_message_node_set_attribute(x, "xmlns",
184 const char *reason) 186 const char *reason)
185 { 187 {
186 LmMessage *iq; 188 LmMessage *iq;
187 LmMessageNode *query, *x; 189 LmMessageNode *query, *x;
188 190
189 if (!lm_connection_is_authenticated(lconnection) || !roomid) return 1; 191 if (!lconnection || !lm_connection_is_authenticated(lconnection) || !roomid)
192 return 1;
190 if (!fjid && !nick) return 1; 193 if (!fjid && !nick) return 1;
191 194
192 if (check_jid_syntax((char*)roomid)) { 195 if (check_jid_syntax((char*)roomid)) {
193 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", roomid); 196 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", roomid);
194 return 1; 197 return 1;
233 void xmpp_room_unlock(const char *room) 236 void xmpp_room_unlock(const char *room)
234 { 237 {
235 LmMessageNode *node; 238 LmMessageNode *node;
236 LmMessage *iq; 239 LmMessage *iq;
237 240
238 if (!lm_connection_is_authenticated(lconnection) || !room) return; 241 if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
242 return;
239 243
240 iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ, 244 iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ,
241 LM_MESSAGE_SUB_TYPE_SET); 245 LM_MESSAGE_SUB_TYPE_SET);
242 246
243 node = lm_message_node_add_child(iq->node, "query", NULL); 247 node = lm_message_node_add_child(iq->node, "query", NULL);
256 void xmpp_room_destroy(const char *room, const char *venue, const char *reason) 260 void xmpp_room_destroy(const char *room, const char *venue, const char *reason)
257 { 261 {
258 LmMessage *iq; 262 LmMessage *iq;
259 LmMessageNode *query, *x; 263 LmMessageNode *query, *x;
260 264
261 if (!lm_connection_is_authenticated(lconnection) || !room) return; 265 if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
266 return;
262 267
263 iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ, 268 iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ,
264 LM_MESSAGE_SUB_TYPE_SET); 269 LM_MESSAGE_SUB_TYPE_SET);
265 query = lm_message_node_add_child(iq->node, "query", NULL); 270 query = lm_message_node_add_child(iq->node, "query", NULL);
266 lm_message_node_set_attribute(query, "xmlns", 271 lm_message_node_set_attribute(query, "xmlns",