Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jab_iq.c @ 1492:563ba5a861ae
Improve last ad-hoc fix
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 28 Apr 2008 19:34:10 +0200 |
parents | 3d47694b4dcc |
children | 2eaa52d314e3 |
comparison
equal
deleted
inserted
replaced
1491:3d47694b4dcc | 1492:563ba5a861ae |
---|---|
1145 xmlnode value; | 1145 xmlnode value; |
1146 | 1146 |
1147 sessionid = generate_session_id("set-status"); | 1147 sessionid = generate_session_id("set-status"); |
1148 xmlnode_put_attrib(command, "sessionid", sessionid); | 1148 xmlnode_put_attrib(command, "sessionid", sessionid); |
1149 g_free(sessionid); | 1149 g_free(sessionid); |
1150 sessionid = NULL; | |
1150 xmlnode_put_attrib(command, "status", "executing"); | 1151 xmlnode_put_attrib(command, "status", "executing"); |
1151 | 1152 |
1152 x = xmlnode_insert_tag(command, "x"); | 1153 x = xmlnode_insert_tag(command, "x"); |
1153 xmlnode_put_attrib(x, "type", "form"); | 1154 xmlnode_put_attrib(x, "type", "form"); |
1154 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); | 1155 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); |
1188 // priority like gossip and gajim do (misc) | 1189 // priority like gossip and gajim do (misc) |
1189 y = xmlnode_insert_tag(x, "field"); | 1190 y = xmlnode_insert_tag(x, "field"); |
1190 xmlnode_put_attrib(y, "type", "text-multi"); | 1191 xmlnode_put_attrib(y, "type", "text-multi"); |
1191 xmlnode_put_attrib(y, "var", "status-message"); | 1192 xmlnode_put_attrib(y, "var", "status-message"); |
1192 xmlnode_put_attrib(y, "label", "Message"); | 1193 xmlnode_put_attrib(y, "label", "Message"); |
1193 } | 1194 } else if (!strcmp(action, "cancel")) { |
1194 else // (if sessionid) | 1195 xmlnode_put_attrib(command, "status", "canceled"); |
1195 { | 1196 } else { // (if sessionid and not canceled) |
1196 y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); | 1197 y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); |
1197 if (y) { | 1198 if (y) { |
1198 char *value, *message; | 1199 char *value, *message; |
1199 value = xmlnode_get_tag_data(xmlnode_get_tag(y, "field?var=status"), | 1200 value = xmlnode_get_tag_data(xmlnode_get_tag(y, "field?var=status"), |
1200 "value"); | 1201 "value"); |
1204 if (s->name) { | 1205 if (s->name) { |
1205 char *status = g_strdup_printf("%s %s", s->status, | 1206 char *status = g_strdup_printf("%s %s", s->status, |
1206 message ? message : ""); | 1207 message ? message : ""); |
1207 cmd_setstatus(NULL, status); | 1208 cmd_setstatus(NULL, status); |
1208 g_free(status); | 1209 g_free(status); |
1209 xmlnode_put_attrib(command, "sessionid", sessionid); | |
1210 xmlnode_put_attrib(command, "status", "completed"); | 1210 xmlnode_put_attrib(command, "status", "completed"); |
1211 xmlnode_put_attrib(iq, "type", "result"); | 1211 xmlnode_put_attrib(iq, "type", "result"); |
1212 xmlnode_insert_dataform_result_message(command, | 1212 xmlnode_insert_dataform_result_message(command, |
1213 "Status has been changed"); | 1213 "Status has been changed"); |
1214 } | 1214 } |
1215 } | 1215 } |
1216 } | 1216 } |
1217 if (sessionid) | |
1218 xmlnode_put_attrib(command, "sessionid", sessionid); | |
1217 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); | 1219 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); |
1218 xmlnode_put_attrib(iq, "id", id); | 1220 xmlnode_put_attrib(iq, "id", id); |
1219 jab_send(jc, iq); | 1221 jab_send(jc, iq); |
1220 xmlnode_free(iq); | 1222 xmlnode_free(iq); |
1221 } | 1223 } |
1261 xmlnode title, instructions, field, value; | 1263 xmlnode title, instructions, field, value; |
1262 | 1264 |
1263 sessionid = generate_session_id("leave-groupchats"); | 1265 sessionid = generate_session_id("leave-groupchats"); |
1264 xmlnode_put_attrib(command, "sessionid", sessionid); | 1266 xmlnode_put_attrib(command, "sessionid", sessionid); |
1265 g_free(sessionid); | 1267 g_free(sessionid); |
1268 sessionid = NULL; | |
1266 xmlnode_put_attrib(command, "status", "executing"); | 1269 xmlnode_put_attrib(command, "status", "executing"); |
1267 | 1270 |
1268 x = xmlnode_insert_tag(command, "x"); | 1271 x = xmlnode_insert_tag(command, "x"); |
1269 xmlnode_put_attrib(x, "type", "form"); | 1272 xmlnode_put_attrib(x, "type", "form"); |
1270 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); | 1273 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); |
1288 xmlnode_put_attrib(field, "var", "groupchats"); | 1291 xmlnode_put_attrib(field, "var", "groupchats"); |
1289 xmlnode_put_attrib(field, "label", "Groupchats: "); | 1292 xmlnode_put_attrib(field, "label", "Groupchats: "); |
1290 xmlnode_insert_tag(field, "required"); | 1293 xmlnode_insert_tag(field, "required"); |
1291 | 1294 |
1292 foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field); | 1295 foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field); |
1293 } | 1296 } else if (!strcmp(action, "cancel")) { |
1294 else // (if sessionid) | 1297 xmlnode_put_attrib(command, "status", "canceled"); |
1295 { | 1298 } else { // (if sessionid and not canceled) |
1296 xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); | 1299 xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); |
1297 if (form) { | 1300 if (form) { |
1298 xmlnode x, gc; | 1301 xmlnode x, gc; |
1299 | 1302 |
1300 xmlnode_put_attrib(command, "status", "completed"); | 1303 xmlnode_put_attrib(command, "status", "completed"); |
1304 { | 1307 { |
1305 char* to_leave = xmlnode_get_tag_data(x, "value"); | 1308 char* to_leave = xmlnode_get_tag_data(x, "value"); |
1306 if (to_leave) { | 1309 if (to_leave) { |
1307 GList* b = buddy_search_jid(to_leave); | 1310 GList* b = buddy_search_jid(to_leave); |
1308 if (b) | 1311 if (b) |
1309 cmd_room_leave(b->data, "Asked by remote command"); | 1312 cmd_room_leave(b->data, "Requested by remote command"); |
1310 } | 1313 } |
1311 } | 1314 } |
1312 xmlnode_put_attrib(iq, "type", "result"); | 1315 xmlnode_put_attrib(iq, "type", "result"); |
1313 xmlnode_insert_dataform_result_message(command, | 1316 xmlnode_insert_dataform_result_message(command, |
1314 "Groupchats have been left"); | 1317 "Groupchats have been left"); |
1315 } | 1318 } |
1316 } | 1319 } |
1320 if (sessionid) | |
1321 xmlnode_put_attrib(command, "sessionid", sessionid); | |
1317 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); | 1322 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); |
1318 xmlnode_put_attrib(iq, "id", id); | 1323 xmlnode_put_attrib(iq, "id", id); |
1319 jab_send(jc, iq); | 1324 jab_send(jc, iq); |
1320 xmlnode_free(iq); | 1325 xmlnode_free(iq); |
1321 } | 1326 } |
1708 } else { | 1713 } else { |
1709 x = xmlnode_get_tag(xmldata, "command"); | 1714 x = xmlnode_get_tag(xmldata, "command"); |
1710 ns = xmlnode_get_attrib(x, "xmlns"); | 1715 ns = xmlnode_get_attrib(x, "xmlns"); |
1711 if (ns && !strcmp(ns, NS_COMMANDS)) { | 1716 if (ns && !strcmp(ns, NS_COMMANDS)) { |
1712 handle_iq_commands(conn, from, id, xmldata); | 1717 handle_iq_commands(conn, from, id, xmldata); |
1718 return; | |
1713 } else { | 1719 } else { |
1714 iq_not_implemented = TRUE; | 1720 iq_not_implemented = TRUE; |
1715 } | 1721 } |
1716 } | 1722 } |
1717 | 1723 |