comparison psgxs.js @ 30:b2faacfefb90

Rewrite of the module manager; fix of some modules; fix of the directory backend.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 04 Nov 2010 17:50:52 +0100
parents c774f2ffb271
children 13011b26181c
comparison
equal deleted inserted replaced
29:e007a6364bf0 30:b2faacfefb90
75 if (id) 75 if (id)
76 response = xmpp.iq({to: to, from: from, type: 'result', id: id}); 76 response = xmpp.iq({to: to, from: from, type: 'result', id: id});
77 else 77 else
78 response = xmpp.iq({to: to, from: from, type: 'result'}); 78 response = xmpp.iq({to: to, from: from, type: 'result'});
79 79
80 var sent = false; 80 var send = false;
81 81
82 for (var i in modules) { 82 for (var i in stanza.tags) {
83 var module = modules[i]; 83 var child1 = stanza.tags[i];
84 if (module.type && (type != module.type)) 84 if (child1.name == 'pubsub') {
85 continue; 85 for (var j in child1.tags) {
86 86 var child2 = child1.tags[j];
87 for (var j in stanza.tags) { 87
88 var child = stanza.tags[j]; 88 for (var k in modules) {
89 if (module.child && (child.name != module.child)) 89 var module = modules[k];
90 continue; 90
91 91 if (module.type && (module.type != type))
92 if (module.ns && (child.attr.xmlns != module.ns)) 92 continue;
93 continue; 93
94 94 if (module.child2 && (module.child2 != child2.name))
95 if (module.child == 'pubsub') { 95 continue;
96 var child2 = child.getChild(module.pschild, child.attr.xmlns); 96
97 if (child2) 97 if (module.ns && (module.ns != child2.attr.xmlns))
98 child = child2; 98 continue;
99 99
100 if (module.pschild && (!child || module.pschild != child.name)) 100 if (module.number && (module.number != j))
101 continue; 101 continue;
102
103 var toSend = module.func(response, stanza, child2, to);
104 if (toSend) {
105 response = toSend;
106 send = true;
107 delete toSend;
108 }
109 }
102 } 110 }
103 111 } else {
104 var toSend = module.func(response, stanza, child, to); 112 for (var k in modules) {
105 if (toSend) { 113 var module = modules[k];
106 conn.send(toSend); 114
107 sent = true; 115 if (module.type && (module.type != type))
116 continue;
117
118 if (module.child && (module.child != child1.name))
119 continue;
120
121 if (module.ns && (module.ns != child1.attr.xmlns))
122 continue;
123
124 if (module.number && (module.number != k))
125 continue;
126
127 var toSend = module.func(response, stanza, child2, to);
128 if (toSend) {
129 response = toSend;
130 send = true;
131 delete toSend;
132 }
108 } 133 }
109 } 134 }
110 } 135 }
111 136
112 if (!sent) 137 conn.send(send? response: makeError(response, errors.feature_not_implemented.n));
113 conn.send(makeError(response, errors.feature_not_implemented.n));
114 } 138 }
115 139
116 function onMessage(stanza) { 140 function onMessage(stanza) {
117 var from = stanza.getAttribute('to'); 141 var from = stanza.getAttribute('to');
118 var to = stanza.getAttribute('from'); 142 var to = stanza.getAttribute('from');