annotate modules/mod_adhoc.js @ 41:bc717575e66a

Much better handling of modules.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 20 Feb 2011 15:51:12 +0100
parents 4c808bfe0658
children 023f767662d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 // XEP-0050: Ad-Hoc Commands
30
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 24
diff changeset
2 exports.adHoc = {
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 type: 'set',
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 child: 'command',
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ns: NS.COMMANDS,
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 func: function(response, stanza, request, to) {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 var action = request.getAttribute('action');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 if (action != 'execute')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 return makeError(response, errors.bad_request.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 var node = request.getAttribute('node');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 if (node == 'ping') {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 var cmd = xmpp.stanza('command', {xmlns: NS.COMMANDS,
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 // sessionid: 'list:20020923T213616Z-700',
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 node: node,
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 'status': 'completed'})
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 .c('note', {type: 'info'}).t('pong');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 response.cnode(cmd);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 } else if (node == 'reload') {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 storage.load();
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 response.c('command', {xmlns: NS.COMMANDS,
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 node: node,
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 'status': 'completed'})
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 .c('note', {type: 'info'}).t('The server has correctly reloaded.');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 } else
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 return makeError(response, errors.bad_request.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 return response;
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 }
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 }