Mercurial > psgxs
annotate modules/mod_adhoc.js @ 44:3e0ca96d2dce
Fix an error in strict mode.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 08 Mar 2011 00:22:27 +0100 |
parents | 023f767662d3 |
children |
rev | line source |
---|---|
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
1 /* |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
3 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
4 * This file is part of PSĜS, a PubSub server written in JavaScript. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
5 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
6 * PSĜS is free software: you can redistribute it and/or modify |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
7 * it under the terms of the GNU Affero General Public License as |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
9 * License. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
10 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
11 * PSĜS is distributed in the hope that it will be useful, |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
14 * GNU Affero General Public License for more details. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
15 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
16 * You should have received a copy of the GNU Affero General Public License |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
18 */ |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
19 |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
20 'use strict'; |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
21 |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 // 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
|
23 exports.adHoc = { |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 type: 'set', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 child: 'command', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 ns: NS.COMMANDS, |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 func: function(response, stanza, request, to) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 var action = request.getAttribute('action'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 if (action != 'execute') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 return makeError(response, errors.bad_request.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 var node = request.getAttribute('node'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 if (node == 'ping') { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 var cmd = xmpp.stanza('command', {xmlns: NS.COMMANDS, |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 // sessionid: 'list:20020923T213616Z-700', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 node: node, |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 'status': 'completed'}) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 .c('note', {type: 'info'}).t('pong'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 response.cnode(cmd); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 } else if (node == 'reload') { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 storage.load(); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 response.c('command', {xmlns: NS.COMMANDS, |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 node: node, |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 'status': 'completed'}) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 .c('note', {type: 'info'}).t('The server has correctly reloaded.'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 } else |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 return makeError(response, errors.bad_request.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 return response; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 } |