Thu, 18 Mar 2010 18:14:06 +0000
New logic for controlling the current UI state
18
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | // This code was written by Tyler Akins and has been placed in the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | // public domain. It would be nice if you left this header intact. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | // Base64 code from Tyler Akins -- http://rumkin.com |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | var Base64 = (function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | var obj = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | /** |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | * Encodes a string in base64 |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | * @param {String} input The string to encode in base64. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | encode: function (input) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | var output = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | var chr1, chr2, chr3; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | var enc1, enc2, enc3, enc4; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | var i = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | do { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | chr1 = input.charCodeAt(i++); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | chr2 = input.charCodeAt(i++); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | chr3 = input.charCodeAt(i++); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | enc1 = chr1 >> 2; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 | enc4 = chr3 & 63; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | if (isNaN(chr2)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | enc3 = enc4 = 64; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | } else if (isNaN(chr3)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | enc4 = 64; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | keyStr.charAt(enc3) + keyStr.charAt(enc4); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | } while (i < input.length); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 | return output; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | /** |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | * Decodes a base64 string. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | * @param {String} input The string to decode. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | decode: function (input) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | var output = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | var chr1, chr2, chr3; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 | var enc1, enc2, enc3, enc4; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 | var i = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | // remove all characters that are not A-Z, a-z, 0-9, +, /, or = |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 | do { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | enc1 = keyStr.indexOf(input.charAt(i++)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | enc2 = keyStr.indexOf(input.charAt(i++)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | enc3 = keyStr.indexOf(input.charAt(i++)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | enc4 = keyStr.indexOf(input.charAt(i++)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 | chr1 = (enc1 << 2) | (enc2 >> 4); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 | chr3 = ((enc3 & 3) << 6) | enc4; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 | output = output + String.fromCharCode(chr1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 | if (enc3 != 64) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 | output = output + String.fromCharCode(chr2); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 | if (enc4 != 64) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 | output = output + String.fromCharCode(chr3); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 | } while (i < input.length); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 | return output; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 | return obj; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 | })(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 | * Digest Algorithm, as defined in RFC 1321. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 | * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 | * Distributed under the BSD License |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 | * See http://pajhome.org.uk/crypt/md5 for more info. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 | var MD5 = (function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 | * Configurable variables. You may need to tweak these to be compatible with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 | * the server-side, but the defaults work in most cases. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 | var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 | * Add integers, wrapping at 2^32. This uses 16-bit operations internally |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 | * to work around bugs in some JS interpreters. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 | var safe_add = function (x, y) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 | return (msw << 16) | (lsw & 0xFFFF); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 | * Bitwise rotate a 32-bit number to the left. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 | var bit_rol = function (num, cnt) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 | return (num << cnt) | (num >>> (32 - cnt)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 | * Convert a string to an array of little-endian words |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 | * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 | var str2binl = function (str) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 | var bin = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 | var mask = (1 << chrsz) - 1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 | for(var i = 0; i < str.length * chrsz; i += chrsz) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 | return bin; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 | * Convert an array of little-endian words to a string |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 | var binl2str = function (bin) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 | var str = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | var mask = (1 << chrsz) - 1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | for(var i = 0; i < bin.length * 32; i += chrsz) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 | str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 | return str; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 | * Convert an array of little-endian words to a hex string. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 | var binl2hex = function (binarray) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 | var str = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 | for(var i = 0; i < binarray.length * 4; i++) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 | str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 | hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 | return str; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 | * Convert an array of little-endian words to a base-64 string |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 | var binl2b64 = function (binarray) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 | var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 | var str = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
163 | var triplet, j; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
164 | for(var i = 0; i < binarray.length * 4; i += 3) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
165 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 | triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
167 | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 | for(j = 0; j < 4; j++) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 | if(i * 8 + j * 6 > binarray.length * 32) { str += b64pad; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 | else { str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 | return str; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 | * These functions implement the four basic operations the algorithm uses. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 | var md5_cmn = function (q, a, b, x, s, t) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 | return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 | var md5_ff = function (a, b, c, d, x, s, t) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
186 | return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
187 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 | var md5_gg = function (a, b, c, d, x, s, t) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 | return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
191 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 | var md5_hh = function (a, b, c, d, x, s, t) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 | return md5_cmn(b ^ c ^ d, a, b, x, s, t); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 | var md5_ii = function (a, b, c, d, x, s, t) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
198 | return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
199 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
200 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
201 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
202 | * Calculate the MD5 of an array of little-endian words, and a bit length |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 | var core_md5 = function (x, len) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 | /* append padding */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 | x[len >> 5] |= 0x80 << ((len) % 32); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 | x[(((len + 64) >>> 9) << 4) + 14] = len; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
208 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
209 | var a = 1732584193; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
210 | var b = -271733879; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
211 | var c = -1732584194; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
212 | var d = 271733878; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 | var olda, oldb, oldc, oldd; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 | for (var i = 0; i < x.length; i += 16) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 | olda = a; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 | oldb = b; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 | oldc = c; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 | oldd = d; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
222 | a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
223 | d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
224 | c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
225 | b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
226 | a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
227 | d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 | c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
229 | b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
230 | a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
231 | d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
232 | c = md5_ff(c, d, a, b, x[i+10], 17, -42063); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
233 | b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
234 | a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
235 | d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
236 | c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
237 | b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
238 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
239 | a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
240 | d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
241 | c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
242 | b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 | a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 | d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 | c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
246 | b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
247 | a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 | d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
249 | c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 | b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
251 | a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
252 | d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
253 | c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 | b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
255 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
256 | a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
257 | d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
258 | c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
259 | b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
260 | a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
261 | d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
262 | c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
263 | b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
264 | a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
265 | d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
266 | c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
267 | b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
268 | a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
269 | d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
270 | c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
271 | b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
272 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
273 | a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
274 | d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
275 | c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
276 | b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
277 | a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
278 | d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
279 | c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
280 | b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
281 | a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
282 | d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
283 | c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
284 | b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
285 | a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
286 | d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
287 | c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
288 | b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
289 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
290 | a = safe_add(a, olda); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
291 | b = safe_add(b, oldb); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
292 | c = safe_add(c, oldc); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
293 | d = safe_add(d, oldd); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
294 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
295 | return [a, b, c, d]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
296 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
297 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
298 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
299 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
300 | * Calculate the HMAC-MD5, of a key and some data |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
301 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
302 | var core_hmac_md5 = function (key, data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
303 | var bkey = str2binl(key); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
304 | if(bkey.length > 16) { bkey = core_md5(bkey, key.length * chrsz); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
305 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
306 | var ipad = new Array(16), opad = new Array(16); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
307 | for(var i = 0; i < 16; i++) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
308 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
309 | ipad[i] = bkey[i] ^ 0x36363636; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
310 | opad[i] = bkey[i] ^ 0x5C5C5C5C; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
311 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
312 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
313 | var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
314 | return core_md5(opad.concat(hash), 512 + 128); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
315 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
316 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
317 | var obj = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
318 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
319 | * These are the functions you'll usually want to call. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
320 | * They take string arguments and return either hex or base-64 encoded |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
321 | * strings. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
322 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
323 | hexdigest: function (s) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
324 | return binl2hex(core_md5(str2binl(s), s.length * chrsz)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
325 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
326 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
327 | b64digest: function (s) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
328 | return binl2b64(core_md5(str2binl(s), s.length * chrsz)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
329 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
330 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
331 | hash: function (s) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
332 | return binl2str(core_md5(str2binl(s), s.length * chrsz)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
333 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
334 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
335 | hmac_hexdigest: function (key, data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
336 | return binl2hex(core_hmac_md5(key, data)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
337 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
338 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
339 | hmac_b64digest: function (key, data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
340 | return binl2b64(core_hmac_md5(key, data)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
341 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
342 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
343 | hmac_hash: function (key, data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
344 | return binl2str(core_hmac_md5(key, data)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
345 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
346 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
347 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
348 | * Perform a simple self-test to see if the VM is working |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
349 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
350 | test: function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
351 | return MD5.hexdigest("abc") === "900150983cd24fb0d6963f7d28e17f72"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
352 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
353 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
354 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
355 | return obj; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
356 | })(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
357 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
358 | /* |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
359 | This program is distributed under the terms of the MIT license. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
360 | Please see the LICENSE file for details. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
361 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
362 | Copyright 2006-2008, OGG, LLC |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
363 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
364 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
365 | /* jslint configuration: */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
366 | /*global document, window, setTimeout, clearTimeout, console, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
367 | XMLHttpRequest, ActiveXObject, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
368 | Base64, MD5, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
369 | Strophe, $build, $msg, $iq, $pres */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
370 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
371 | /** File: strophe.js |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
372 | * A JavaScript library for XMPP BOSH. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
373 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
374 | * This is the JavaScript version of the Strophe library. Since JavaScript |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
375 | * has no facilities for persistent TCP connections, this library uses |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
376 | * Bidirectional-streams Over Synchronous HTTP (BOSH) to emulate |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
377 | * a persistent, stateful, two-way connection to an XMPP server. More |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
378 | * information on BOSH can be found in XEP 124. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
379 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
380 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
381 | /** PrivateFunction: Function.prototype.bind |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
382 | * Bind a function to an instance. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
383 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
384 | * This Function object extension method creates a bound method similar |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
385 | * to those in Python. This means that the 'this' object will point |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
386 | * to the instance you want. See |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
387 | * <a href='http://benjamin.smedbergs.us/blog/2007-01-03/bound-functions-and-function-imports-in-javascript/'>Bound Functions and Function Imports in JavaScript</a> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
388 | * for a complete explanation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
389 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
390 | * This extension already exists in some browsers (namely, Firefox 3), but |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
391 | * we provide it to support those that don't. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
392 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
393 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
394 | * (Object) obj - The object that will become 'this' in the bound function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
395 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
396 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
397 | * The bound function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
398 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
399 | if (!Function.prototype.bind) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
400 | Function.prototype.bind = function (obj) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
401 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
402 | var func = this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
403 | return function () { return func.apply(obj, arguments); }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
404 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
405 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
406 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
407 | /** PrivateFunction: Function.prototype.prependArg |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
408 | * Prepend an argument to a function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
409 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
410 | * This Function object extension method returns a Function that will |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
411 | * invoke the original function with an argument prepended. This is useful |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
412 | * when some object has a callback that needs to get that same object as |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
413 | * an argument. The following fragment illustrates a simple case of this |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
414 | * > var obj = new Foo(this.someMethod);</code></blockquote> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
415 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
416 | * Foo's constructor can now use func.prependArg(this) to ensure the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
417 | * passed in callback function gets the instance of Foo as an argument. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
418 | * Doing this without prependArg would mean not setting the callback |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
419 | * from the constructor. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
420 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
421 | * This is used inside Strophe for passing the Strophe.Request object to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
422 | * the onreadystatechange handler of XMLHttpRequests. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
423 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
424 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
425 | * arg - The argument to pass as the first parameter to the function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
426 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
427 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
428 | * A new Function which calls the original with the prepended argument. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
429 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
430 | if (!Function.prototype.prependArg) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
431 | Function.prototype.prependArg = function (arg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
432 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
433 | var func = this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
434 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
435 | return function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
436 | var newargs = [arg]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
437 | for (var i = 0; i < arguments.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
438 | newargs.push(arguments[i]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
439 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
440 | return func.apply(this, newargs); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
441 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
442 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
443 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
444 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
445 | /** PrivateFunction: Array.prototype.indexOf |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
446 | * Return the index of an object in an array. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
447 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
448 | * This function is not supplied by some JavaScript implementations, so |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
449 | * we provide it if it is missing. This code is from: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
450 | * http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:indexOf |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
451 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
452 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
453 | * (Object) elt - The object to look for. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
454 | * (Integer) from - The index from which to start looking. (optional). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
455 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
456 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
457 | * The index of elt in the array or -1 if not found. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
458 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
459 | if (!Array.prototype.indexOf) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
460 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
461 | Array.prototype.indexOf = function(elt /*, from*/) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
462 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
463 | var len = this.length; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
464 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
465 | var from = Number(arguments[1]) || 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
466 | from = (from < 0) ? Math.ceil(from) : Math.floor(from); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
467 | if (from < 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
468 | from += len; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
469 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
470 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
471 | for (; from < len; from++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
472 | if (from in this && this[from] === elt) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
473 | return from; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
474 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
475 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
476 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
477 | return -1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
478 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
479 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
480 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
481 | /* All of the Strophe globals are defined in this special function below so |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
482 | * that references to the globals become closures. This will ensure that |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
483 | * on page reload, these references will still be available to callbacks |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
484 | * that are still executing. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
485 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
486 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
487 | (function (callback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
488 | var Strophe; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
489 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
490 | /** Function: $build |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
491 | * Create a Strophe.Builder. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
492 | * This is an alias for 'new Strophe.Builder(name, attrs)'. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
493 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
494 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
495 | * (String) name - The root element name. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
496 | * (Object) attrs - The attributes for the root element in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
497 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
498 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
499 | * A new Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
500 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
501 | function $build(name, attrs) { return new Strophe.Builder(name, attrs); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
502 | /** Function: $msg |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
503 | * Create a Strophe.Builder with a <message/> element as the root. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
504 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
505 | * Parmaeters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
506 | * (Object) attrs - The <message/> element attributes in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
507 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
508 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
509 | * A new Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
510 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
511 | function $msg(attrs) { return new Strophe.Builder("message", attrs); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
512 | /** Function: $iq |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
513 | * Create a Strophe.Builder with an <iq/> element as the root. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
514 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
515 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
516 | * (Object) attrs - The <iq/> element attributes in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
517 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
518 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
519 | * A new Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
520 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
521 | function $iq(attrs) { return new Strophe.Builder("iq", attrs); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
522 | /** Function: $pres |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
523 | * Create a Strophe.Builder with a <presence/> element as the root. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
524 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
525 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
526 | * (Object) attrs - The <presence/> element attributes in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
527 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
528 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
529 | * A new Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
530 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
531 | function $pres(attrs) { return new Strophe.Builder("presence", attrs); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
532 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
533 | /** Class: Strophe |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
534 | * An object container for all Strophe library functions. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
535 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
536 | * This class is just a container for all the objects and constants |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
537 | * used in the library. It is not meant to be instantiated, but to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
538 | * provide a namespace for library objects, constants, and functions. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
539 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
540 | Strophe = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
541 | /** Constant: VERSION |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
542 | * The version of the Strophe library. Unreleased builds will have |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
543 | * a version of head-HASH where HASH is a partial revision. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
544 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
545 | VERSION: "1.0.1", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
546 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
547 | /** Constants: XMPP Namespace Constants |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
548 | * Common namespace constants from the XMPP RFCs and XEPs. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
549 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
550 | * NS.HTTPBIND - HTTP BIND namespace from XEP 124. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
551 | * NS.BOSH - BOSH namespace from XEP 206. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
552 | * NS.CLIENT - Main XMPP client namespace. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
553 | * NS.AUTH - Legacy authentication namespace. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
554 | * NS.ROSTER - Roster operations namespace. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
555 | * NS.PROFILE - Profile namespace. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
556 | * NS.DISCO_INFO - Service discovery info namespace from XEP 30. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
557 | * NS.DISCO_ITEMS - Service discovery items namespace from XEP 30. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
558 | * NS.MUC - Multi-User Chat namespace from XEP 45. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
559 | * NS.SASL - XMPP SASL namespace from RFC 3920. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
560 | * NS.STREAM - XMPP Streams namespace from RFC 3920. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
561 | * NS.BIND - XMPP Binding namespace from RFC 3920. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
562 | * NS.SESSION - XMPP Session namespace from RFC 3920. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
563 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
564 | NS: { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
565 | HTTPBIND: "http://jabber.org/protocol/httpbind", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
566 | BOSH: "urn:xmpp:xbosh", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
567 | CLIENT: "jabber:client", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
568 | AUTH: "jabber:iq:auth", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
569 | ROSTER: "jabber:iq:roster", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
570 | PROFILE: "jabber:iq:profile", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
571 | DISCO_INFO: "http://jabber.org/protocol/disco#info", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
572 | DISCO_ITEMS: "http://jabber.org/protocol/disco#items", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
573 | MUC: "http://jabber.org/protocol/muc", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
574 | SASL: "urn:ietf:params:xml:ns:xmpp-sasl", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
575 | STREAM: "http://etherx.jabber.org/streams", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
576 | BIND: "urn:ietf:params:xml:ns:xmpp-bind", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
577 | SESSION: "urn:ietf:params:xml:ns:xmpp-session", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
578 | VERSION: "jabber:iq:version", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
579 | STANZAS: "urn:ietf:params:xml:ns:xmpp-stanzas" |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
580 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
581 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
582 | /** Function: addNamespace |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
583 | * This function is used to extend the current namespaces in |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
584 | * Strophe.NS. It takes a key and a value with the key being the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
585 | * name of the new namespace, with its actual value. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
586 | * For example: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
587 | * Strophe.addNamespace('PUBSUB', "http://jabber.org/protocol/pubsub"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
588 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
589 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
590 | * (String) name - The name under which the namespace will be |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
591 | * referenced under Strophe.NS |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
592 | * (String) value - The actual namespace. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
593 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
594 | addNamespace: function (name, value) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
595 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
596 | Strophe.NS[name] = value; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
597 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
598 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
599 | /** Constants: Connection Status Constants |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
600 | * Connection status constants for use by the connection handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
601 | * callback. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
602 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
603 | * Status.ERROR - An error has occurred |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
604 | * Status.CONNECTING - The connection is currently being made |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
605 | * Status.CONNFAIL - The connection attempt failed |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
606 | * Status.AUTHENTICATING - The connection is authenticating |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
607 | * Status.AUTHFAIL - The authentication attempt failed |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
608 | * Status.CONNECTED - The connection has succeeded |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
609 | * Status.DISCONNECTED - The connection has been terminated |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
610 | * Status.DISCONNECTING - The connection is currently being terminated |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
611 | * Status.ATTACHED - The connection has been attached |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
612 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
613 | Status: { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
614 | ERROR: 0, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
615 | CONNECTING: 1, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
616 | CONNFAIL: 2, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
617 | AUTHENTICATING: 3, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
618 | AUTHFAIL: 4, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
619 | CONNECTED: 5, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
620 | DISCONNECTED: 6, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
621 | DISCONNECTING: 7, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
622 | ATTACHED: 8 |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
623 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
624 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
625 | /** Constants: Log Level Constants |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
626 | * Logging level indicators. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
627 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
628 | * LogLevel.DEBUG - Debug output |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
629 | * LogLevel.INFO - Informational output |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
630 | * LogLevel.WARN - Warnings |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
631 | * LogLevel.ERROR - Errors |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
632 | * LogLevel.FATAL - Fatal errors |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
633 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
634 | LogLevel: { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
635 | DEBUG: 0, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
636 | INFO: 1, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
637 | WARN: 2, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
638 | ERROR: 3, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
639 | FATAL: 4 |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
640 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
641 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
642 | /** PrivateConstants: DOM Element Type Constants |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
643 | * DOM element types. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
644 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
645 | * ElementType.NORMAL - Normal element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
646 | * ElementType.TEXT - Text data element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
647 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
648 | ElementType: { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
649 | NORMAL: 1, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
650 | TEXT: 3 |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
651 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
652 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
653 | /** PrivateConstants: Timeout Values |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
654 | * Timeout values for error states. These values are in seconds. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
655 | * These should not be changed unless you know exactly what you are |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
656 | * doing. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
657 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
658 | * TIMEOUT - Timeout multiplier. A waiting request will be considered |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
659 | * failed after Math.floor(TIMEOUT * wait) seconds have elapsed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
660 | * This defaults to 1.1, and with default wait, 66 seconds. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
661 | * SECONDARY_TIMEOUT - Secondary timeout multiplier. In cases where |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
662 | * Strophe can detect early failure, it will consider the request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
663 | * failed if it doesn't return after |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
664 | * Math.floor(SECONDARY_TIMEOUT * wait) seconds have elapsed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
665 | * This defaults to 0.1, and with default wait, 6 seconds. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
666 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
667 | TIMEOUT: 1.1, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
668 | SECONDARY_TIMEOUT: 0.1, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
669 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
670 | /** Function: forEachChild |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
671 | * Map a function over some or all child elements of a given element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
672 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
673 | * This is a small convenience function for mapping a function over |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
674 | * some or all of the children of an element. If elemName is null, all |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
675 | * children will be passed to the function, otherwise only children |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
676 | * whose tag names match elemName will be passed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
677 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
678 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
679 | * (XMLElement) elem - The element to operate on. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
680 | * (String) elemName - The child element tag name filter. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
681 | * (Function) func - The function to apply to each child. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
682 | * function should take a single argument, a DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
683 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
684 | forEachChild: function (elem, elemName, func) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
685 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
686 | var i, childNode; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
687 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
688 | for (i = 0; i < elem.childNodes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
689 | childNode = elem.childNodes[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
690 | if (childNode.nodeType == Strophe.ElementType.NORMAL && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
691 | (!elemName || this.isTagEqual(childNode, elemName))) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
692 | func(childNode); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
693 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
694 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
695 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
696 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
697 | /** Function: isTagEqual |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
698 | * Compare an element's tag name with a string. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
699 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
700 | * This function is case insensitive. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
701 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
702 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
703 | * (XMLElement) el - A DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
704 | * (String) name - The element name. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
705 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
706 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
707 | * true if the element's tag name matches _el_, and false |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
708 | * otherwise. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
709 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
710 | isTagEqual: function (el, name) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
711 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
712 | return el.tagName.toLowerCase() == name.toLowerCase(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
713 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
714 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
715 | /** PrivateVariable: _xmlGenerator |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
716 | * _Private_ variable that caches a DOM document to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
717 | * generate elements. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
718 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
719 | _xmlGenerator: null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
720 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
721 | /** PrivateFunction: _makeGenerator |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
722 | * _Private_ function that creates a dummy XML DOM document to serve as |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
723 | * an element and text node generator. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
724 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
725 | _makeGenerator: function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
726 | var doc; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
727 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
728 | if (window.ActiveXObject) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
729 | doc = new ActiveXObject("Microsoft.XMLDOM"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
730 | doc.appendChild(doc.createElement('strophe')); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
731 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
732 | doc = document.implementation |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
733 | .createDocument('jabber:client', 'strophe', null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
734 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
735 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
736 | return doc; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
737 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
738 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
739 | /** Function: xmlElement |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
740 | * Create an XML DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
741 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
742 | * This function creates an XML DOM element correctly across all |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
743 | * implementations. Specifically the Microsoft implementation of |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
744 | * document.createElement makes DOM elements with 43+ default attributes |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
745 | * unless elements are created with the ActiveX object Microsoft.XMLDOM. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
746 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
747 | * Most DOMs force element names to lowercase, so we use the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
748 | * _realname attribute on the created element to store the case |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
749 | * sensitive name. This is required to generate proper XML for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
750 | * things like vCard avatars (XEP 153). This attribute is stripped |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
751 | * out before being sent over the wire or serialized, but you may |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
752 | * notice it during debugging. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
753 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
754 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
755 | * (String) name - The name for the element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
756 | * (Array) attrs - An optional array of key/value pairs to use as |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
757 | * element attributes in the following format [['key1', 'value1'], |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
758 | * ['key2', 'value2']] |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
759 | * (String) text - The text child data for the element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
760 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
761 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
762 | * A new XML DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
763 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
764 | xmlElement: function (name) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
765 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
766 | if (!name) { return null; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
767 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
768 | var node = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
769 | if (!Strophe._xmlGenerator) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
770 | Strophe._xmlGenerator = Strophe._makeGenerator(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
771 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
772 | node = Strophe._xmlGenerator.createElement(name); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
773 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
774 | // FIXME: this should throw errors if args are the wrong type or |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
775 | // there are more than two optional args |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
776 | var a, i, k; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
777 | for (a = 1; a < arguments.length; a++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
778 | if (!arguments[a]) { continue; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
779 | if (typeof(arguments[a]) == "string" || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
780 | typeof(arguments[a]) == "number") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
781 | node.appendChild(Strophe.xmlTextNode(arguments[a])); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
782 | } else if (typeof(arguments[a]) == "object" && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
783 | typeof(arguments[a].sort) == "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
784 | for (i = 0; i < arguments[a].length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
785 | if (typeof(arguments[a][i]) == "object" && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
786 | typeof(arguments[a][i].sort) == "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
787 | node.setAttribute(arguments[a][i][0], |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
788 | arguments[a][i][1]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
789 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
790 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
791 | } else if (typeof(arguments[a]) == "object") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
792 | for (k in arguments[a]) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
793 | if (arguments[a].hasOwnProperty(k)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
794 | node.setAttribute(k, arguments[a][k]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
795 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
796 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
797 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
798 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
799 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
800 | return node; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
801 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
802 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
803 | /* Function: xmlescape |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
804 | * Excapes invalid xml characters. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
805 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
806 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
807 | * (String) text - text to escape. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
808 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
809 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
810 | * Escaped text. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
811 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
812 | xmlescape: function(text) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
813 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
814 | text = text.replace(/\&/g, "&"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
815 | text = text.replace(/</g, "<"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
816 | text = text.replace(/>/g, ">"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
817 | return text; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
818 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
819 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
820 | /** Function: xmlTextNode |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
821 | * Creates an XML DOM text node. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
822 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
823 | * Provides a cross implementation version of document.createTextNode. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
824 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
825 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
826 | * (String) text - The content of the text node. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
827 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
828 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
829 | * A new XML DOM text node. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
830 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
831 | xmlTextNode: function (text) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
832 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
833 | //ensure text is escaped |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
834 | text = Strophe.xmlescape(text); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
835 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
836 | if (!Strophe._xmlGenerator) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
837 | Strophe._xmlGenerator = Strophe._makeGenerator(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
838 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
839 | return Strophe._xmlGenerator.createTextNode(text); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
840 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
841 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
842 | /** Function: getText |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
843 | * Get the concatenation of all text children of an element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
844 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
845 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
846 | * (XMLElement) elem - A DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
847 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
848 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
849 | * A String with the concatenated text of all text element children. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
850 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
851 | getText: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
852 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
853 | if (!elem) { return null; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
854 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
855 | var str = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
856 | if (elem.childNodes.length === 0 && elem.nodeType == |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
857 | Strophe.ElementType.TEXT) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
858 | str += elem.nodeValue; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
859 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
860 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
861 | for (var i = 0; i < elem.childNodes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
862 | if (elem.childNodes[i].nodeType == Strophe.ElementType.TEXT) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
863 | str += elem.childNodes[i].nodeValue; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
864 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
865 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
866 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
867 | return str; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
868 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
869 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
870 | /** Function: copyElement |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
871 | * Copy an XML DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
872 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
873 | * This function copies a DOM element and all its descendants and returns |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
874 | * the new copy. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
875 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
876 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
877 | * (XMLElement) elem - A DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
878 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
879 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
880 | * A new, copied DOM element tree. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
881 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
882 | copyElement: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
883 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
884 | var i, el; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
885 | if (elem.nodeType == Strophe.ElementType.NORMAL) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
886 | el = Strophe.xmlElement(elem.tagName); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
887 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
888 | for (i = 0; i < elem.attributes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
889 | el.setAttribute(elem.attributes[i].nodeName.toLowerCase(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
890 | elem.attributes[i].value); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
891 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
892 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
893 | for (i = 0; i < elem.childNodes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
894 | el.appendChild(Strophe.copyElement(elem.childNodes[i])); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
895 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
896 | } else if (elem.nodeType == Strophe.ElementType.TEXT) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
897 | el = Strophe.xmlTextNode(elem.nodeValue); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
898 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
899 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
900 | return el; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
901 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
902 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
903 | /** Function: escapeNode |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
904 | * Escape the node part (also called local part) of a JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
905 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
906 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
907 | * (String) node - A node (or local part). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
908 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
909 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
910 | * An escaped node (or local part). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
911 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
912 | escapeNode: function (node) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
913 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
914 | return node.replace(/^\s+|\s+$/g, '') |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
915 | .replace(/\\/g, "\\5c") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
916 | .replace(/ /g, "\\20") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
917 | .replace(/\"/g, "\\22") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
918 | .replace(/\&/g, "\\26") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
919 | .replace(/\'/g, "\\27") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
920 | .replace(/\//g, "\\2f") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
921 | .replace(/:/g, "\\3a") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
922 | .replace(/</g, "\\3c") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
923 | .replace(/>/g, "\\3e") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
924 | .replace(/@/g, "\\40"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
925 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
926 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
927 | /** Function: unescapeNode |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
928 | * Unescape a node part (also called local part) of a JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
929 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
930 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
931 | * (String) node - A node (or local part). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
932 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
933 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
934 | * An unescaped node (or local part). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
935 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
936 | unescapeNode: function (node) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
937 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
938 | return node.replace(/\\20/g, " ") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
939 | .replace(/\\22/g, '"') |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
940 | .replace(/\\26/g, "&") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
941 | .replace(/\\27/g, "'") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
942 | .replace(/\\2f/g, "/") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
943 | .replace(/\\3a/g, ":") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
944 | .replace(/\\3c/g, "<") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
945 | .replace(/\\3e/g, ">") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
946 | .replace(/\\40/g, "@") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
947 | .replace(/\\5c/g, "\\"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
948 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
949 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
950 | /** Function: getNodeFromJid |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
951 | * Get the node portion of a JID String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
952 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
953 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
954 | * (String) jid - A JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
955 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
956 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
957 | * A String containing the node. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
958 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
959 | getNodeFromJid: function (jid) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
960 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
961 | if (jid.indexOf("@") < 0) { return null; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
962 | return jid.split("@")[0]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
963 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
964 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
965 | /** Function: getDomainFromJid |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
966 | * Get the domain portion of a JID String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
967 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
968 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
969 | * (String) jid - A JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
970 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
971 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
972 | * A String containing the domain. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
973 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
974 | getDomainFromJid: function (jid) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
975 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
976 | var bare = Strophe.getBareJidFromJid(jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
977 | if (bare.indexOf("@") < 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
978 | return bare; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
979 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
980 | var parts = bare.split("@"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
981 | parts.splice(0, 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
982 | return parts.join('@'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
983 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
984 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
985 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
986 | /** Function: getResourceFromJid |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
987 | * Get the resource portion of a JID String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
988 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
989 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
990 | * (String) jid - A JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
991 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
992 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
993 | * A String containing the resource. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
994 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
995 | getResourceFromJid: function (jid) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
996 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
997 | var s = jid.split("/"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
998 | if (s.length < 2) { return null; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
999 | s.splice(0, 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1000 | return s.join('/'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1001 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1002 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1003 | /** Function: getBareJidFromJid |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1004 | * Get the bare JID from a JID String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1005 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1006 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1007 | * (String) jid - A JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1008 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1009 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1010 | * A String containing the bare JID. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1011 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1012 | getBareJidFromJid: function (jid) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1013 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1014 | return jid.split("/")[0]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1015 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1016 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1017 | /** Function: log |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1018 | * User overrideable logging function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1019 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1020 | * This function is called whenever the Strophe library calls any |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1021 | * of the logging functions. The default implementation of this |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1022 | * function does nothing. If client code wishes to handle the logging |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1023 | * messages, it should override this with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1024 | * > Strophe.log = function (level, msg) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1025 | * > (user code here) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1026 | * > }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1027 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1028 | * Please note that data sent and received over the wire is logged |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1029 | * via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1030 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1031 | * The different levels and their meanings are |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1032 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1033 | * DEBUG - Messages useful for debugging purposes. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1034 | * INFO - Informational messages. This is mostly information like |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1035 | * 'disconnect was called' or 'SASL auth succeeded'. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1036 | * WARN - Warnings about potential problems. This is mostly used |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1037 | * to report transient connection errors like request timeouts. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1038 | * ERROR - Some error occurred. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1039 | * FATAL - A non-recoverable fatal error occurred. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1040 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1041 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1042 | * (Integer) level - The log level of the log message. This will |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1043 | * be one of the values in Strophe.LogLevel. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1044 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1045 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1046 | log: function (level, msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1047 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1048 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1049 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1050 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1051 | /** Function: debug |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1052 | * Log a message at the Strophe.LogLevel.DEBUG level. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1053 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1054 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1055 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1056 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1057 | debug: function(msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1058 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1059 | this.log(this.LogLevel.DEBUG, msg); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1060 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1061 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1062 | /** Function: info |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1063 | * Log a message at the Strophe.LogLevel.INFO level. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1064 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1065 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1066 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1067 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1068 | info: function (msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1069 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1070 | this.log(this.LogLevel.INFO, msg); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1071 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1072 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1073 | /** Function: warn |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1074 | * Log a message at the Strophe.LogLevel.WARN level. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1075 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1076 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1077 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1078 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1079 | warn: function (msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1080 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1081 | this.log(this.LogLevel.WARN, msg); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1082 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1083 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1084 | /** Function: error |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1085 | * Log a message at the Strophe.LogLevel.ERROR level. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1086 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1087 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1088 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1089 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1090 | error: function (msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1091 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1092 | this.log(this.LogLevel.ERROR, msg); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1093 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1094 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1095 | /** Function: fatal |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1096 | * Log a message at the Strophe.LogLevel.FATAL level. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1097 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1098 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1099 | * (String) msg - The log message. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1100 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1101 | fatal: function (msg) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1102 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1103 | this.log(this.LogLevel.FATAL, msg); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1104 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1105 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1106 | /** Function: serialize |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1107 | * Render a DOM element and all descendants to a String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1108 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1109 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1110 | * (XMLElement) elem - A DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1111 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1112 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1113 | * The serialized element tree as a String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1114 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1115 | serialize: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1116 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1117 | var result; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1118 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1119 | if (!elem) { return null; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1120 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1121 | if (typeof(elem.tree) === "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1122 | elem = elem.tree(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1123 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1124 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1125 | var nodeName = elem.nodeName; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1126 | var i, child; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1127 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1128 | if (elem.getAttribute("_realname")) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1129 | nodeName = elem.getAttribute("_realname"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1130 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1131 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1132 | result = "<" + nodeName; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1133 | for (i = 0; i < elem.attributes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1134 | if(elem.attributes[i].nodeName != "_realname") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1135 | result += " " + elem.attributes[i].nodeName.toLowerCase() + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1136 | "='" + elem.attributes[i].value |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1137 | .replace("&", "&") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1138 | .replace("'", "'") |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1139 | .replace("<", "<") + "'"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1140 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1141 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1142 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1143 | if (elem.childNodes.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1144 | result += ">"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1145 | for (i = 0; i < elem.childNodes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1146 | child = elem.childNodes[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1147 | if (child.nodeType == Strophe.ElementType.NORMAL) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1148 | // normal element, so recurse |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1149 | result += Strophe.serialize(child); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1150 | } else if (child.nodeType == Strophe.ElementType.TEXT) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1151 | // text element |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1152 | result += child.nodeValue; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1153 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1154 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1155 | result += "</" + nodeName + ">"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1156 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1157 | result += "/>"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1158 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1159 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1160 | return result; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1161 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1162 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1163 | /** PrivateVariable: _requestId |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1164 | * _Private_ variable that keeps track of the request ids for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1165 | * connections. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1166 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1167 | _requestId: 0, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1168 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1169 | /** PrivateVariable: Strophe.connectionPlugins |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1170 | * _Private_ variable Used to store plugin names that need |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1171 | * initialization on Strophe.Connection construction. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1172 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1173 | _connectionPlugins: {}, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1174 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1175 | /** Function: addConnectionPlugin |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1176 | * Extends the Strophe.Connection object with the given plugin. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1177 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1178 | * Paramaters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1179 | * (String) name - The name of the extension. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1180 | * (Object) ptype - The plugin's prototype. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1181 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1182 | addConnectionPlugin: function (name, ptype) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1183 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1184 | Strophe._connectionPlugins[name] = ptype; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1185 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1186 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1187 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1188 | /** Class: Strophe.Builder |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1189 | * XML DOM builder. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1190 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1191 | * This object provides an interface similar to JQuery but for building |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1192 | * DOM element easily and rapidly. All the functions except for toString() |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1193 | * and tree() return the object, so calls can be chained. Here's an |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1194 | * example using the $iq() builder helper. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1195 | * > $iq({to: 'you': from: 'me': type: 'get', id: '1'}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1196 | * > .c('query', {xmlns: 'strophe:example'}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1197 | * > .c('example') |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1198 | * > .toString() |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1199 | * The above generates this XML fragment |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1200 | * > <iq to='you' from='me' type='get' id='1'> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1201 | * > <query xmlns='strophe:example'> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1202 | * > <example/> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1203 | * > </query> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1204 | * > </iq> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1205 | * The corresponding DOM manipulations to get a similar fragment would be |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1206 | * a lot more tedious and probably involve several helper variables. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1207 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1208 | * Since adding children makes new operations operate on the child, up() |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1209 | * is provided to traverse up the tree. To add two children, do |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1210 | * > builder.c('child1', ...).up().c('child2', ...) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1211 | * The next operation on the Builder will be relative to the second child. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1212 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1213 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1214 | /** Constructor: Strophe.Builder |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1215 | * Create a Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1216 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1217 | * The attributes should be passed in object notation. For example |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1218 | * > var b = new Builder('message', {to: 'you', from: 'me'}); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1219 | * or |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1220 | * > var b = new Builder('messsage', {'xml:lang': 'en'}); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1221 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1222 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1223 | * (String) name - The name of the root element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1224 | * (Object) attrs - The attributes for the root element in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1225 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1226 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1227 | * A new Strophe.Builder. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1228 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1229 | Strophe.Builder = function (name, attrs) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1230 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1231 | // Set correct namespace for jabber:client elements |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1232 | if (name == "presence" || name == "message" || name == "iq") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1233 | if (attrs && !attrs.xmlns) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1234 | attrs.xmlns = Strophe.NS.CLIENT; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1235 | } else if (!attrs) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1236 | attrs = {xmlns: Strophe.NS.CLIENT}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1237 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1238 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1239 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1240 | // Holds the tree being built. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1241 | this.nodeTree = Strophe.xmlElement(name, attrs); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1242 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1243 | // Points to the current operation node. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1244 | this.node = this.nodeTree; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1245 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1246 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1247 | Strophe.Builder.prototype = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1248 | /** Function: tree |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1249 | * Return the DOM tree. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1250 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1251 | * This function returns the current DOM tree as an element object. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1252 | * is suitable for passing to functions like Strophe.Connection.send(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1253 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1254 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1255 | * The DOM tree as a element object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1256 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1257 | tree: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1258 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1259 | return this.nodeTree; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1260 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1261 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1262 | /** Function: toString |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1263 | * Serialize the DOM tree to a String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1264 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1265 | * This function returns a string serialization of the current DOM |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1266 | * tree. It is often used internally to pass data to a |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1267 | * Strophe.Request object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1268 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1269 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1270 | * The serialized DOM tree in a String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1271 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1272 | toString: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1273 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1274 | return Strophe.serialize(this.nodeTree); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1275 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1276 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1277 | /** Function: up |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1278 | * Make the current parent element the new current element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1279 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1280 | * This function is often used after c() to traverse back up the tree. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1281 | * For example, to add two children to the same element |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1282 | * > builder.c('child1', {}).up().c('child2', {}); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1283 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1284 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1285 | * The Stophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1286 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1287 | up: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1288 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1289 | this.node = this.node.parentNode; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1290 | return this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1291 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1292 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1293 | /** Function: attrs |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1294 | * Add or modify attributes of the current element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1295 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1296 | * The attributes should be passed in object notation. This function |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1297 | * does not move the current element pointer. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1298 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1299 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1300 | * (Object) moreattrs - The attributes to add/modify in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1301 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1302 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1303 | * The Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1304 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1305 | attrs: function (moreattrs) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1306 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1307 | for (var k in moreattrs) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1308 | if (moreattrs.hasOwnProperty(k)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1309 | this.node.setAttribute(k, moreattrs[k]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1310 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1311 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1312 | return this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1313 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1314 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1315 | /** Function: c |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1316 | * Add a child to the current element and make it the new current |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1317 | * element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1318 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1319 | * This function moves the current element pointer to the child. If you |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1320 | * need to add another child, it is necessary to use up() to go back |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1321 | * to the parent in the tree. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1322 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1323 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1324 | * (String) name - The name of the child. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1325 | * (Object) attrs - The attributes of the child in object notation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1326 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1327 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1328 | * The Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1329 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1330 | c: function (name, attrs) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1331 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1332 | var child = Strophe.xmlElement(name, attrs); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1333 | this.node.appendChild(child); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1334 | this.node = child; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1335 | return this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1336 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1337 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1338 | /** Function: cnode |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1339 | * Add a child to the current element and make it the new current |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1340 | * element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1341 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1342 | * This function is the same as c() except that instead of using a |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1343 | * name and an attributes object to create the child it uses an |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1344 | * existing DOM element object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1345 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1346 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1347 | * (XMLElement) elem - A DOM element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1348 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1349 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1350 | * The Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1351 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1352 | cnode: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1353 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1354 | this.node.appendChild(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1355 | this.node = elem; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1356 | return this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1357 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1358 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1359 | /** Function: t |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1360 | * Add a child text element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1361 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1362 | * This *does not* make the child the new current element since there |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1363 | * are no children of text elements. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1364 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1365 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1366 | * (String) text - The text data to append to the current element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1367 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1368 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1369 | * The Strophe.Builder object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1370 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1371 | t: function (text) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1372 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1373 | var child = Strophe.xmlTextNode(text); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1374 | this.node.appendChild(child); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1375 | return this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1376 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1377 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1378 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1379 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1380 | /** PrivateClass: Strophe.Handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1381 | * _Private_ helper class for managing stanza handlers. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1382 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1383 | * A Strophe.Handler encapsulates a user provided callback function to be |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1384 | * executed when matching stanzas are received by the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1385 | * Handlers can be either one-off or persistant depending on their |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1386 | * return value. Returning true will cause a Handler to remain active, and |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1387 | * returning false will remove the Handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1388 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1389 | * Users will not use Strophe.Handler objects directly, but instead they |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1390 | * will use Strophe.Connection.addHandler() and |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1391 | * Strophe.Connection.deleteHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1392 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1393 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1394 | /** PrivateConstructor: Strophe.Handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1395 | * Create and initialize a new Strophe.Handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1396 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1397 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1398 | * (Function) handler - A function to be executed when the handler is run. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1399 | * (String) ns - The namespace to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1400 | * (String) name - The element name to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1401 | * (String) type - The element type to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1402 | * (String) id - The element id attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1403 | * (String) from - The element from attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1404 | * (Object) options - Handler options |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1405 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1406 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1407 | * A new Strophe.Handler object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1408 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1409 | Strophe.Handler = function (handler, ns, name, type, id, from, options) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1410 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1411 | this.handler = handler; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1412 | this.ns = ns; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1413 | this.name = name; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1414 | this.type = type; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1415 | this.id = id; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1416 | this.options = options || {matchbare: false}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1417 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1418 | // default matchBare to false if undefined |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1419 | if (!this.options.matchBare) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1420 | this.options.matchBare = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1421 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1422 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1423 | if (this.options.matchBare) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1424 | this.from = Strophe.getBareJidFromJid(from); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1425 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1426 | this.from = from; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1427 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1428 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1429 | // whether the handler is a user handler or a system handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1430 | this.user = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1431 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1432 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1433 | Strophe.Handler.prototype = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1434 | /** PrivateFunction: isMatch |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1435 | * Tests if a stanza matches the Strophe.Handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1436 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1437 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1438 | * (XMLElement) elem - The XML element to test. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1439 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1440 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1441 | * true if the stanza matches and false otherwise. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1442 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1443 | isMatch: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1444 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1445 | var nsMatch; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1446 | var from = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1447 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1448 | if (this.options.matchBare) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1449 | from = Strophe.getBareJidFromJid(elem.getAttribute('from')); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1450 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1451 | from = elem.getAttribute('from'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1452 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1453 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1454 | nsMatch = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1455 | if (!this.ns) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1456 | nsMatch = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1457 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1458 | var self = this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1459 | Strophe.forEachChild(elem, null, function (elem) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1460 | if (elem.getAttribute("xmlns") == self.ns) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1461 | nsMatch = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1462 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1463 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1464 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1465 | nsMatch = nsMatch || elem.getAttribute("xmlns") == this.ns; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1466 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1467 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1468 | if (nsMatch && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1469 | (!this.name || Strophe.isTagEqual(elem, this.name)) && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1470 | (!this.type || elem.getAttribute("type") === this.type) && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1471 | (!this.id || elem.getAttribute("id") === this.id) && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1472 | (!this.from || from === this.from)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1473 | return true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1474 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1475 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1476 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1477 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1478 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1479 | /** PrivateFunction: run |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1480 | * Run the callback on a matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1481 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1482 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1483 | * (XMLElement) elem - The DOM element that triggered the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1484 | * Strophe.Handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1485 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1486 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1487 | * A boolean indicating if the handler should remain active. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1488 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1489 | run: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1490 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1491 | var result = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1492 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1493 | result = this.handler(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1494 | } catch (e) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1495 | if (e.sourceURL) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1496 | Strophe.fatal("error: " + this.handler + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1497 | " " + e.sourceURL + ":" + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1498 | e.line + " - " + e.name + ": " + e.message); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1499 | } else if (e.fileName) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1500 | if (typeof(console) != "undefined") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1501 | console.trace(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1502 | console.error(this.handler, " - error - ", e, e.message); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1503 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1504 | Strophe.fatal("error: " + this.handler + " " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1505 | e.fileName + ":" + e.lineNumber + " - " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1506 | e.name + ": " + e.message); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1507 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1508 | Strophe.fatal("error: " + this.handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1509 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1510 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1511 | throw e; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1512 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1513 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1514 | return result; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1515 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1516 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1517 | /** PrivateFunction: toString |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1518 | * Get a String representation of the Strophe.Handler object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1519 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1520 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1521 | * A String. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1522 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1523 | toString: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1524 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1525 | return "{Handler: " + this.handler + "(" + this.name + "," + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1526 | this.id + "," + this.ns + ")}"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1527 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1528 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1529 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1530 | /** PrivateClass: Strophe.TimedHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1531 | * _Private_ helper class for managing timed handlers. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1532 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1533 | * A Strophe.TimedHandler encapsulates a user provided callback that |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1534 | * should be called after a certain period of time or at regular |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1535 | * intervals. The return value of the callback determines whether the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1536 | * Strophe.TimedHandler will continue to fire. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1537 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1538 | * Users will not use Strophe.TimedHandler objects directly, but instead |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1539 | * they will use Strophe.Connection.addTimedHandler() and |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1540 | * Strophe.Connection.deleteTimedHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1541 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1542 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1543 | /** PrivateConstructor: Strophe.TimedHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1544 | * Create and initialize a new Strophe.TimedHandler object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1545 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1546 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1547 | * (Integer) period - The number of milliseconds to wait before the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1548 | * handler is called. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1549 | * (Function) handler - The callback to run when the handler fires. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1550 | * function should take no arguments. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1551 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1552 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1553 | * A new Strophe.TimedHandler object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1554 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1555 | Strophe.TimedHandler = function (period, handler) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1556 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1557 | this.period = period; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1558 | this.handler = handler; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1559 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1560 | this.lastCalled = new Date().getTime(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1561 | this.user = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1562 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1563 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1564 | Strophe.TimedHandler.prototype = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1565 | /** PrivateFunction: run |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1566 | * Run the callback for the Strophe.TimedHandler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1567 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1568 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1569 | * true if the Strophe.TimedHandler should be called again, and false |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1570 | * otherwise. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1571 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1572 | run: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1573 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1574 | this.lastCalled = new Date().getTime(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1575 | return this.handler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1576 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1577 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1578 | /** PrivateFunction: reset |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1579 | * Reset the last called time for the Strophe.TimedHandler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1580 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1581 | reset: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1582 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1583 | this.lastCalled = new Date().getTime(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1584 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1585 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1586 | /** PrivateFunction: toString |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1587 | * Get a string representation of the Strophe.TimedHandler object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1588 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1589 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1590 | * The string representation. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1591 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1592 | toString: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1593 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1594 | return "{TimedHandler: " + this.handler + "(" + this.period +")}"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1595 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1596 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1597 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1598 | /** PrivateClass: Strophe.Request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1599 | * _Private_ helper class that provides a cross implementation abstraction |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1600 | * for a BOSH related XMLHttpRequest. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1601 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1602 | * The Strophe.Request class is used internally to encapsulate BOSH request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1603 | * information. It is not meant to be used from user's code. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1604 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1605 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1606 | /** PrivateConstructor: Strophe.Request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1607 | * Create and initialize a new Strophe.Request object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1608 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1609 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1610 | * (XMLElement) elem - The XML data to be sent in the request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1611 | * (Function) func - The function that will be called when the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1612 | * XMLHttpRequest readyState changes. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1613 | * (Integer) rid - The BOSH rid attribute associated with this request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1614 | * (Integer) sends - The number of times this same request has been |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1615 | * sent. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1616 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1617 | Strophe.Request = function (elem, func, rid, sends) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1618 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1619 | this.id = ++Strophe._requestId; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1620 | this.xmlData = elem; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1621 | this.data = Strophe.serialize(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1622 | // save original function in case we need to make a new request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1623 | // from this one. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1624 | this.origFunc = func; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1625 | this.func = func; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1626 | this.rid = rid; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1627 | this.date = NaN; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1628 | this.sends = sends || 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1629 | this.abort = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1630 | this.dead = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1631 | this.age = function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1632 | if (!this.date) { return 0; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1633 | var now = new Date(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1634 | return (now - this.date) / 1000; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1635 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1636 | this.timeDead = function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1637 | if (!this.dead) { return 0; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1638 | var now = new Date(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1639 | return (now - this.dead) / 1000; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1640 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1641 | this.xhr = this._newXHR(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1642 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1643 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1644 | Strophe.Request.prototype = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1645 | /** PrivateFunction: getResponse |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1646 | * Get a response from the underlying XMLHttpRequest. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1647 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1648 | * This function attempts to get a response from the request and checks |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1649 | * for errors. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1650 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1651 | * Throws: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1652 | * "parsererror" - A parser error occured. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1653 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1654 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1655 | * The DOM element tree of the response. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1656 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1657 | getResponse: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1658 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1659 | var node = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1660 | if (this.xhr.responseXML && this.xhr.responseXML.documentElement) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1661 | node = this.xhr.responseXML.documentElement; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1662 | if (node.tagName == "parsererror") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1663 | Strophe.error("invalid response received"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1664 | Strophe.error("responseText: " + this.xhr.responseText); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1665 | Strophe.error("responseXML: " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1666 | Strophe.serialize(this.xhr.responseXML)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1667 | throw "parsererror"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1668 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1669 | } else if (this.xhr.responseText) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1670 | Strophe.error("invalid response received"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1671 | Strophe.error("responseText: " + this.xhr.responseText); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1672 | Strophe.error("responseXML: " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1673 | Strophe.serialize(this.xhr.responseXML)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1674 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1675 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1676 | return node; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1677 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1678 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1679 | /** PrivateFunction: _newXHR |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1680 | * _Private_ helper function to create XMLHttpRequests. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1681 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1682 | * This function creates XMLHttpRequests across all implementations. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1683 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1684 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1685 | * A new XMLHttpRequest. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1686 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1687 | _newXHR: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1688 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1689 | var xhr = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1690 | if (window.XMLHttpRequest) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1691 | xhr = new XMLHttpRequest(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1692 | if (xhr.overrideMimeType) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1693 | xhr.overrideMimeType("text/xml"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1694 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1695 | } else if (window.ActiveXObject) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1696 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1697 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1698 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1699 | xhr.onreadystatechange = this.func.prependArg(this); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1700 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1701 | return xhr; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1702 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1703 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1704 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1705 | /** Class: Strophe.Connection |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1706 | * XMPP Connection manager. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1707 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1708 | * Thie class is the main part of Strophe. It manages a BOSH connection |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1709 | * to an XMPP server and dispatches events to the user callbacks as |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1710 | * data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, and legacy |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1711 | * authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1712 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1713 | * After creating a Strophe.Connection object, the user will typically |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1714 | * call connect() with a user supplied callback to handle connection level |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1715 | * events like authentication failure, disconnection, or connection |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1716 | * complete. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1717 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1718 | * The user will also have several event handlers defined by using |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1719 | * addHandler() and addTimedHandler(). These will allow the user code to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1720 | * respond to interesting stanzas or do something periodically with the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1721 | * connection. These handlers will be active once authentication is |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1722 | * finished. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1723 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1724 | * To send data to the connection, use send(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1725 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1726 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1727 | /** Constructor: Strophe.Connection |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1728 | * Create and initialize a Strophe.Connection object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1729 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1730 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1731 | * (String) service - The BOSH service URL. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1732 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1733 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1734 | * A new Strophe.Connection object. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1735 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1736 | Strophe.Connection = function (service) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1737 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1738 | /* The path to the httpbind service. */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1739 | this.service = service; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1740 | /* The connected JID. */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1741 | this.jid = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1742 | /* request id for body tags */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1743 | this.rid = Math.floor(Math.random() * 4294967295); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1744 | /* The current session ID. */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1745 | this.sid = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1746 | this.streamId = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1747 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1748 | // SASL |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1749 | this.do_session = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1750 | this.do_bind = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1751 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1752 | // handler lists |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1753 | this.timedHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1754 | this.handlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1755 | this.removeTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1756 | this.removeHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1757 | this.addTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1758 | this.addHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1759 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1760 | this._idleTimeout = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1761 | this._disconnectTimeout = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1762 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1763 | this.authenticated = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1764 | this.disconnecting = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1765 | this.connected = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1766 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1767 | this.errors = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1768 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1769 | this.paused = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1770 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1771 | // default BOSH values |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1772 | this.hold = 1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1773 | this.wait = 60; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1774 | this.window = 5; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1775 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1776 | this._data = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1777 | this._requests = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1778 | this._uniqueId = Math.round(Math.random() * 10000); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1779 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1780 | this._sasl_success_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1781 | this._sasl_failure_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1782 | this._sasl_challenge_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1783 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1784 | // setup onIdle callback every 1/10th of a second |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1785 | this._idleTimeout = setTimeout(this._onIdle.bind(this), 100); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1786 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1787 | // initialize plugins |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1788 | for (var k in Strophe._connectionPlugins) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1789 | if (Strophe._connectionPlugins.hasOwnProperty(k)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1790 | var ptype = Strophe._connectionPlugins[k]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1791 | // jslint complaints about the below line, but this is fine |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1792 | var F = function () {}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1793 | F.prototype = ptype; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1794 | this[k] = new F(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1795 | this[k].init(this); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1796 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1797 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1798 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1799 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1800 | Strophe.Connection.prototype = { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1801 | /** Function: reset |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1802 | * Reset the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1803 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1804 | * This function should be called after a connection is disconnected |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1805 | * before that connection is reused. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1806 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1807 | reset: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1808 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1809 | this.rid = Math.floor(Math.random() * 4294967295); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1810 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1811 | this.sid = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1812 | this.streamId = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1813 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1814 | // SASL |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1815 | this.do_session = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1816 | this.do_bind = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1817 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1818 | // handler lists |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1819 | this.timedHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1820 | this.handlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1821 | this.removeTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1822 | this.removeHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1823 | this.addTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1824 | this.addHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1825 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1826 | this.authenticated = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1827 | this.disconnecting = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1828 | this.connected = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1829 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1830 | this.errors = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1831 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1832 | this._requests = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1833 | this._uniqueId = Math.round(Math.random()*10000); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1834 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1835 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1836 | /** Function: pause |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1837 | * Pause the request manager. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1838 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1839 | * This will prevent Strophe from sending any more requests to the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1840 | * server. This is very useful for temporarily pausing while a lot |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1841 | * of send() calls are happening quickly. This causes Strophe to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1842 | * send the data in a single request, saving many request trips. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1843 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1844 | pause: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1845 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1846 | this.paused = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1847 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1848 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1849 | /** Function: resume |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1850 | * Resume the request manager. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1851 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1852 | * This resumes after pause() has been called. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1853 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1854 | resume: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1855 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1856 | this.paused = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1857 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1858 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1859 | /** Function: getUniqueId |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1860 | * Generate a unique ID for use in <iq/> elements. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1861 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1862 | * All <iq/> stanzas are required to have unique id attributes. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1863 | * function makes creating these easy. Each connection instance has |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1864 | * a counter which starts from zero, and the value of this counter |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1865 | * plus a colon followed by the suffix becomes the unique id. If no |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1866 | * suffix is supplied, the counter is used as the unique id. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1867 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1868 | * Suffixes are used to make debugging easier when reading the stream |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1869 | * data, and their use is recommended. The counter resets to 0 for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1870 | * every new connection for the same reason. For connections to the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1871 | * same server that authenticate the same way, all the ids should be |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1872 | * the same, which makes it easy to see changes. This is useful for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1873 | * automated testing as well. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1874 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1875 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1876 | * (String) suffix - A optional suffix to append to the id. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1877 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1878 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1879 | * A unique string to be used for the id attribute. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1880 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1881 | getUniqueId: function (suffix) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1882 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1883 | if (typeof(suffix) == "string" || typeof(suffix) == "number") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1884 | return ++this._uniqueId + ":" + suffix; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1885 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1886 | return ++this._uniqueId + ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1887 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1888 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1889 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1890 | /** Function: connect |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1891 | * Starts the connection process. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1892 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1893 | * As the connection process proceeds, the user supplied callback will |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1894 | * be triggered multiple times with status updates. The callback |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1895 | * should take two arguments - the status code and the error condition. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1896 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1897 | * The status code will be one of the values in the Strophe.Status |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1898 | * constants. The error condition will be one of the conditions |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1899 | * defined in RFC 3920 or the condition 'strophe-parsererror'. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1900 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1901 | * Please see XEP 124 for a more detailed explanation of the optional |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1902 | * parameters below. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1903 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1904 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1905 | * (String) jid - The user's JID. This may be a bare JID, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1906 | * or a full JID. If a node is not supplied, SASL ANONYMOUS |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1907 | * authentication will be attempted. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1908 | * (String) pass - The user's password. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1909 | * (Function) callback The connect callback function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1910 | * (Integer) wait - The optional HTTPBIND wait value. This is the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1911 | * time the server will wait before returning an empty result for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1912 | * a request. The default setting of 60 seconds is recommended. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1913 | * Other settings will require tweaks to the Strophe.TIMEOUT value. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1914 | * (Integer) hold - The optional HTTPBIND hold value. This is the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1915 | * number of connections the server will hold at one time. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1916 | * should almost always be set to 1 (the default). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1917 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1918 | connect: function (jid, pass, callback, wait, hold) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1919 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1920 | this.jid = jid; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1921 | this.pass = pass; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1922 | this.connect_callback = callback; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1923 | this.disconnecting = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1924 | this.connected = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1925 | this.authenticated = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1926 | this.errors = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1927 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1928 | this.wait = wait || this.wait; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1929 | this.hold = hold || this.hold; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1930 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1931 | // parse jid for domain and resource |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1932 | this.domain = Strophe.getDomainFromJid(this.jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1933 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1934 | // build the body tag |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1935 | var body = this._buildBody().attrs({ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1936 | to: this.domain, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1937 | "xml:lang": "en", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1938 | wait: this.wait, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1939 | hold: this.hold, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1940 | content: "text/xml; charset=utf-8", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1941 | ver: "1.6", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1942 | "xmpp:version": "1.0", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1943 | "xmlns:xmpp": Strophe.NS.BOSH |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1944 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1945 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1946 | this._changeConnectStatus(Strophe.Status.CONNECTING, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1947 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1948 | this._requests.push( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1949 | new Strophe.Request(body.tree(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1950 | this._onRequestStateChange.bind(this) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1951 | .prependArg(this._connect_cb.bind(this)), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1952 | body.tree().getAttribute("rid"))); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1953 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1954 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1955 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1956 | /** Function: attach |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1957 | * Attach to an already created and authenticated BOSH session. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1958 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1959 | * This function is provided to allow Strophe to attach to BOSH |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1960 | * sessions which have been created externally, perhaps by a Web |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1961 | * application. This is often used to support auto-login type features |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1962 | * without putting user credentials into the page. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1963 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1964 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1965 | * (String) jid - The full JID that is bound by the session. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1966 | * (String) sid - The SID of the BOSH session. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1967 | * (String) rid - The current RID of the BOSH session. This RID |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1968 | * will be used by the next request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1969 | * (Function) callback The connect callback function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1970 | * (Integer) wait - The optional HTTPBIND wait value. This is the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1971 | * time the server will wait before returning an empty result for |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1972 | * a request. The default setting of 60 seconds is recommended. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1973 | * Other settings will require tweaks to the Strophe.TIMEOUT value. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1974 | * (Integer) hold - The optional HTTPBIND hold value. This is the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1975 | * number of connections the server will hold at one time. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1976 | * should almost always be set to 1 (the default). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1977 | * (Integer) wind - The optional HTTBIND window value. This is the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1978 | * allowed range of request ids that are valid. The default is 5. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1979 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1980 | attach: function (jid, sid, rid, callback, wait, hold, wind) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1981 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1982 | this.jid = jid; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1983 | this.sid = sid; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1984 | this.rid = rid; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1985 | this.connect_callback = callback; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1986 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1987 | this.domain = Strophe.getDomainFromJid(this.jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1988 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1989 | this.authenticated = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1990 | this.connected = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1991 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1992 | this.wait = wait || this.wait; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1993 | this.hold = hold || this.hold; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1994 | this.window = wind || this.window; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1995 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1996 | this._changeConnectStatus(Strophe.Status.ATTACHED, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1997 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1998 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1999 | /** Function: xmlInput |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2000 | * User overrideable function that receives XML data coming into the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2001 | * connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2002 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2003 | * The default function does nothing. User code can override this with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2004 | * > Strophe.Connection.xmlInput = function (elem) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2005 | * > (user code) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2006 | * > }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2007 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2008 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2009 | * (XMLElement) elem - The XML data received by the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2010 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2011 | xmlInput: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2012 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2013 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2014 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2015 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2016 | /** Function: xmlOutput |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2017 | * User overrideable function that receives XML data sent to the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2018 | * connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2019 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2020 | * The default function does nothing. User code can override this with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2021 | * > Strophe.Connection.xmlOutput = function (elem) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2022 | * > (user code) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2023 | * > }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2024 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2025 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2026 | * (XMLElement) elem - The XMLdata sent by the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2027 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2028 | xmlOutput: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2029 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2030 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2031 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2032 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2033 | /** Function: rawInput |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2034 | * User overrideable function that receives raw data coming into the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2035 | * connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2036 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2037 | * The default function does nothing. User code can override this with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2038 | * > Strophe.Connection.rawInput = function (data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2039 | * > (user code) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2040 | * > }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2041 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2042 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2043 | * (String) data - The data received by the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2044 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2045 | rawInput: function (data) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2046 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2047 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2048 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2049 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2050 | /** Function: rawOutput |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2051 | * User overrideable function that receives raw data sent to the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2052 | * connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2053 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2054 | * The default function does nothing. User code can override this with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2055 | * > Strophe.Connection.rawOutput = function (data) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2056 | * > (user code) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2057 | * > }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2058 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2059 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2060 | * (String) data - The data sent by the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2061 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2062 | rawOutput: function (data) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2063 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2064 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2065 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2066 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2067 | /** Function: send |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2068 | * Send a stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2069 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2070 | * This function is called to push data onto the send queue to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2071 | * go out over the wire. Whenever a request is sent to the BOSH |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2072 | * server, all pending data is sent and the queue is flushed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2073 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2074 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2075 | * (XMLElement | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2076 | * [XMLElement] | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2077 | * Strophe.Builder) elem - The stanza to send. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2078 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2079 | send: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2080 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2081 | if (elem === null) { return ; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2082 | if (typeof(elem.sort) === "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2083 | for (var i = 0; i < elem.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2084 | this._queueData(elem[i]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2085 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2086 | } else if (typeof(elem.tree) === "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2087 | this._queueData(elem.tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2088 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2089 | this._queueData(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2090 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2091 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2092 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2093 | clearTimeout(this._idleTimeout); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2094 | this._idleTimeout = setTimeout(this._onIdle.bind(this), 100); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2095 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2096 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2097 | /** Function: flush |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2098 | * Immediately send any pending outgoing data. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2099 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2100 | * Normally send() queues outgoing data until the next idle period |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2101 | * (100ms), which optimizes network use in the common cases when |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2102 | * several send()s are called in succession. flush() can be used to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2103 | * immediately send all pending data. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2104 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2105 | flush: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2106 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2107 | // cancel the pending idle period and run the idle function |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2108 | // immediately |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2109 | clearTimeout(this._idleTimeout); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2110 | this._onIdle(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2111 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2112 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2113 | /** Function: sendIQ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2114 | * Helper function to send IQ stanzas. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2115 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2116 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2117 | * (XMLElement) elem - The stanza to send. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2118 | * (Function) callback - The callback function for a successful request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2119 | * (Function) errback - The callback function for a failed or timed |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2120 | * out request. On timeout, the stanza will be null. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2121 | * (Integer) timeout - The time specified in milliseconds for a |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2122 | * timeout to occur. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2123 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2124 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2125 | * The id used to send the IQ. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2126 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2127 | sendIQ: function(elem, callback, errback, timeout) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2128 | var timeoutHandler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2129 | var that = this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2130 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2131 | if (typeof(elem.tree) === "function") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2132 | elem = elem.tree(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2133 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2134 | var id = elem.getAttribute('id'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2135 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2136 | // inject id if not found |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2137 | if (!id) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2138 | id = this.getUniqueId("sendIQ"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2139 | elem.setAttribute("id", id); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2140 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2141 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2142 | var handler = this.addHandler(function (stanza) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2143 | // remove timeout handler if there is one |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2144 | if (timeoutHandler) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2145 | that.deleteTimedHandler(timeoutHandler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2146 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2147 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2148 | var iqtype = stanza.getAttribute('type'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2149 | if (iqtype === 'result') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2150 | if (callback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2151 | callback(stanza); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2152 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2153 | } else if (iqtype === 'error') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2154 | if (errback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2155 | errback(stanza); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2156 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2157 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2158 | throw { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2159 | name: "StropheError", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2160 | message: "Got bad IQ type of " + iqtype |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2161 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2162 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2163 | }, null, 'iq', null, id); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2164 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2165 | // if timeout specified, setup timeout handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2166 | if (timeout) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2167 | timeoutHandler = this.addTimedHandler(timeout, function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2168 | // get rid of normal handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2169 | that.deleteHandler(handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2170 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2171 | // call errback on timeout with null stanza |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2172 | if (errback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2173 | errback(null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2174 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2175 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2176 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2177 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2178 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2179 | this.send(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2180 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2181 | return id; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2182 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2183 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2184 | /** PrivateFunction: _queueData |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2185 | * Queue outgoing data for later sending. Also ensures that the data |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2186 | * is a DOMElement. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2187 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2188 | _queueData: function (element) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2189 | if (element === null || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2190 | !element.tagName || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2191 | !element.childNodes) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2192 | throw { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2193 | name: "StropheError", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2194 | message: "Cannot queue non-DOMElement." |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2195 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2196 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2197 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2198 | this._data.push(element); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2199 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2200 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2201 | /** PrivateFunction: _sendRestart |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2202 | * Send an xmpp:restart stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2203 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2204 | _sendRestart: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2205 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2206 | this._data.push("restart"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2207 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2208 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2209 | clearTimeout(this._idleTimeout); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2210 | this._idleTimeout = setTimeout(this._onIdle.bind(this), 100); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2211 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2212 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2213 | /** Function: addTimedHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2214 | * Add a timed handler to the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2215 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2216 | * This function adds a timed handler. The provided handler will |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2217 | * be called every period milliseconds until it returns false, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2218 | * the connection is terminated, or the handler is removed. Handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2219 | * that wish to continue being invoked should return true. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2220 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2221 | * Because of method binding it is necessary to save the result of |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2222 | * this function if you wish to remove a handler with |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2223 | * deleteTimedHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2224 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2225 | * Note that user handlers are not active until authentication is |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2226 | * successful. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2227 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2228 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2229 | * (Integer) period - The period of the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2230 | * (Function) handler - The callback function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2231 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2232 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2233 | * A reference to the handler that can be used to remove it. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2234 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2235 | addTimedHandler: function (period, handler) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2236 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2237 | var thand = new Strophe.TimedHandler(period, handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2238 | this.addTimeds.push(thand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2239 | return thand; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2240 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2241 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2242 | /** Function: deleteTimedHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2243 | * Delete a timed handler for a connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2244 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2245 | * This function removes a timed handler from the connection. The |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2246 | * handRef parameter is *not* the function passed to addTimedHandler(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2247 | * but is the reference returned from addTimedHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2248 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2249 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2250 | * (Strophe.TimedHandler) handRef - The handler reference. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2251 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2252 | deleteTimedHandler: function (handRef) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2253 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2254 | // this must be done in the Idle loop so that we don't change |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2255 | // the handlers during iteration |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2256 | this.removeTimeds.push(handRef); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2257 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2258 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2259 | /** Function: addHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2260 | * Add a stanza handler for the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2261 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2262 | * This function adds a stanza handler to the connection. The |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2263 | * handler callback will be called for any stanza that matches |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2264 | * the parameters. Note that if multiple parameters are supplied, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2265 | * they must all match for the handler to be invoked. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2266 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2267 | * The handler will receive the stanza that triggered it as its argument. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2268 | * The handler should return true if it is to be invoked again; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2269 | * returning false will remove the handler after it returns. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2270 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2271 | * As a convenience, the ns parameters applies to the top level element |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2272 | * and also any of its immediate children. This is primarily to make |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2273 | * matching /iq/query elements easy. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2274 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2275 | * The options argument contains handler matching flags that affect how |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2276 | * matches are determined. Currently the only flag is matchBare (a |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2277 | * boolean). When matchBare is true, the from parameter and the from |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2278 | * attribute on the stanza will be matched as bare JIDs instead of |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2279 | * full JIDs. To use this, pass {matchBare: true} as the value of |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2280 | * options. The default value for matchBare is false. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2281 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2282 | * The return value should be saved if you wish to remove the handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2283 | * with deleteHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2284 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2285 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2286 | * (Function) handler - The user callback. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2287 | * (String) ns - The namespace to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2288 | * (String) name - The stanza name to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2289 | * (String) type - The stanza type attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2290 | * (String) id - The stanza id attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2291 | * (String) from - The stanza from attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2292 | * (String) options - The handler options |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2293 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2294 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2295 | * A reference to the handler that can be used to remove it. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2296 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2297 | addHandler: function (handler, ns, name, type, id, from, options) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2298 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2299 | var hand = new Strophe.Handler(handler, ns, name, type, id, from, options); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2300 | this.addHandlers.push(hand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2301 | return hand; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2302 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2303 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2304 | /** Function: deleteHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2305 | * Delete a stanza handler for a connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2306 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2307 | * This function removes a stanza handler from the connection. The |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2308 | * handRef parameter is *not* the function passed to addHandler(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2309 | * but is the reference returned from addHandler(). |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2310 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2311 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2312 | * (Strophe.Handler) handRef - The handler reference. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2313 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2314 | deleteHandler: function (handRef) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2315 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2316 | // this must be done in the Idle loop so that we don't change |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2317 | // the handlers during iteration |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2318 | this.removeHandlers.push(handRef); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2319 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2320 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2321 | /** Function: disconnect |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2322 | * Start the graceful disconnection process. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2323 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2324 | * This function starts the disconnection process. This process starts |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2325 | * by sending unavailable presence and sending BOSH body of type |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2326 | * terminate. A timeout handler makes sure that disconnection happens |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2327 | * even if the BOSH server does not respond. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2328 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2329 | * The user supplied connection callback will be notified of the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2330 | * progress as this process happens. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2331 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2332 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2333 | * (String) reason - The reason the disconnect is occuring. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2334 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2335 | disconnect: function (reason) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2336 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2337 | this._changeConnectStatus(Strophe.Status.DISCONNECTING, reason); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2338 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2339 | Strophe.info("Disconnect was called because: " + reason); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2340 | if (this.connected) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2341 | // setup timeout handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2342 | this._disconnectTimeout = this._addSysTimedHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2343 | 3000, this._onDisconnectTimeout.bind(this)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2344 | this._sendTerminate(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2345 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2346 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2347 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2348 | /** PrivateFunction: _changeConnectStatus |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2349 | * _Private_ helper function that makes sure plugins and the user's |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2350 | * callback are notified of connection status changes. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2351 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2352 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2353 | * (Integer) status - the new connection status, one of the values |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2354 | * in Strophe.Status |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2355 | * (String) condition - the error condition or null |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2356 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2357 | _changeConnectStatus: function (status, condition) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2358 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2359 | // notify all plugins listening for status changes |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2360 | for (var k in Strophe._connectionPlugins) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2361 | if (Strophe._connectionPlugins.hasOwnProperty(k)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2362 | var plugin = this[k]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2363 | if (plugin.statusChanged) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2364 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2365 | plugin.statusChanged(status, condition); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2366 | } catch (err) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2367 | Strophe.error("" + k + " plugin caused an exception " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2368 | "changing status: " + err); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2369 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2370 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2371 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2372 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2373 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2374 | // notify the user's callback |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2375 | if (this.connect_callback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2376 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2377 | this.connect_callback(status, condition); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2378 | } catch (e) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2379 | Strophe.error("User connection callback caused an " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2380 | "exception: " + e); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2381 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2382 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2383 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2384 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2385 | /** PrivateFunction: _buildBody |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2386 | * _Private_ helper function to generate the <body/> wrapper for BOSH. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2387 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2388 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2389 | * A Strophe.Builder with a <body/> element. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2390 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2391 | _buildBody: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2392 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2393 | var bodyWrap = $build('body', { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2394 | rid: this.rid++, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2395 | xmlns: Strophe.NS.HTTPBIND |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2396 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2397 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2398 | if (this.sid !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2399 | bodyWrap.attrs({sid: this.sid}); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2400 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2401 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2402 | return bodyWrap; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2403 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2404 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2405 | /** PrivateFunction: _removeRequest |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2406 | * _Private_ function to remove a request from the queue. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2407 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2408 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2409 | * (Strophe.Request) req - The request to remove. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2410 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2411 | _removeRequest: function (req) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2412 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2413 | Strophe.debug("removing request"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2414 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2415 | var i; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2416 | for (i = this._requests.length - 1; i >= 0; i--) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2417 | if (req == this._requests[i]) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2418 | this._requests.splice(i, 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2419 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2420 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2421 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2422 | // IE6 fails on setting to null, so set to empty function |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2423 | req.xhr.onreadystatechange = function () {}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2424 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2425 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2426 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2427 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2428 | /** PrivateFunction: _restartRequest |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2429 | * _Private_ function to restart a request that is presumed dead. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2430 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2431 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2432 | * (Integer) i - The index of the request in the queue. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2433 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2434 | _restartRequest: function (i) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2435 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2436 | var req = this._requests[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2437 | if (req.dead === null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2438 | req.dead = new Date(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2439 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2440 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2441 | this._processRequest(i); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2442 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2443 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2444 | /** PrivateFunction: _processRequest |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2445 | * _Private_ function to process a request in the queue. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2446 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2447 | * This function takes requests off the queue and sends them and |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2448 | * restarts dead requests. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2449 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2450 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2451 | * (Integer) i - The index of the request in the queue. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2452 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2453 | _processRequest: function (i) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2454 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2455 | var req = this._requests[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2456 | var reqStatus = -1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2457 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2458 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2459 | if (req.xhr.readyState == 4) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2460 | reqStatus = req.xhr.status; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2461 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2462 | } catch (e) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2463 | Strophe.error("caught an error in _requests[" + i + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2464 | "], reqStatus: " + reqStatus); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2465 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2466 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2467 | if (typeof(reqStatus) == "undefined") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2468 | reqStatus = -1; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2469 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2470 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2471 | var time_elapsed = req.age(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2472 | var primaryTimeout = (!isNaN(time_elapsed) && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2473 | time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2474 | var secondaryTimeout = (req.dead !== null && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2475 | req.timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2476 | var requestCompletedWithServerError = (req.xhr.readyState == 4 && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2477 | (reqStatus < 1 || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2478 | reqStatus >= 500)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2479 | if (primaryTimeout || secondaryTimeout || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2480 | requestCompletedWithServerError) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2481 | if (secondaryTimeout) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2482 | Strophe.error("Request " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2483 | this._requests[i].id + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2484 | " timed out (secondary), restarting"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2485 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2486 | req.abort = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2487 | req.xhr.abort(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2488 | // setting to null fails on IE6, so set to empty function |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2489 | req.xhr.onreadystatechange = function () {}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2490 | this._requests[i] = new Strophe.Request(req.xmlData, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2491 | req.origFunc, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2492 | req.rid, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2493 | req.sends); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2494 | req = this._requests[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2495 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2496 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2497 | if (req.xhr.readyState === 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2498 | Strophe.debug("request id " + req.id + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2499 | "." + req.sends + " posting"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2500 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2501 | req.date = new Date(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2502 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2503 | req.xhr.open("POST", this.service, true); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2504 | } catch (e2) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2505 | Strophe.error("XHR open failed."); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2506 | if (!this.connected) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2507 | this._changeConnectStatus(Strophe.Status.CONNFAIL, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2508 | "bad-service"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2509 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2510 | this.disconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2511 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2512 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2513 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2514 | // Fires the XHR request -- may be invoked immediately |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2515 | // or on a gradually expanding retry window for reconnects |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2516 | var sendFunc = function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2517 | req.xhr.send(req.data); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2518 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2519 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2520 | // Implement progressive backoff for reconnects -- |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2521 | // First retry (send == 1) should also be instantaneous |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2522 | if (req.sends > 1) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2523 | // Using a cube of the retry number creats a nicely |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2524 | // expanding retry window |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2525 | var backoff = Math.pow(req.sends, 3) * 1000; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2526 | setTimeout(sendFunc, backoff); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2527 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2528 | sendFunc(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2529 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2530 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2531 | req.sends++; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2532 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2533 | this.xmlOutput(req.xmlData); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2534 | this.rawOutput(req.data); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2535 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2536 | Strophe.debug("_processRequest: " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2537 | (i === 0 ? "first" : "second") + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2538 | " request has readyState of " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2539 | req.xhr.readyState); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2540 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2541 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2542 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2543 | /** PrivateFunction: _throttledRequestHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2544 | * _Private_ function to throttle requests to the connection window. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2545 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2546 | * This function makes sure we don't send requests so fast that the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2547 | * request ids overflow the connection window in the case that one |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2548 | * request died. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2549 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2550 | _throttledRequestHandler: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2551 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2552 | if (!this._requests) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2553 | Strophe.debug("_throttledRequestHandler called with " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2554 | "undefined requests"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2555 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2556 | Strophe.debug("_throttledRequestHandler called with " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2557 | this._requests.length + " requests"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2558 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2559 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2560 | if (!this._requests || this._requests.length === 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2561 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2562 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2563 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2564 | if (this._requests.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2565 | this._processRequest(0); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2566 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2567 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2568 | if (this._requests.length > 1 && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2569 | Math.abs(this._requests[0].rid - |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2570 | this._requests[1].rid) < this.window - 1) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2571 | this._processRequest(1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2572 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2573 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2574 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2575 | /** PrivateFunction: _onRequestStateChange |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2576 | * _Private_ handler for Strophe.Request state changes. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2577 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2578 | * This function is called when the XMLHttpRequest readyState changes. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2579 | * It contains a lot of error handling logic for the many ways that |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2580 | * requests can fail, and calls the request callback when requests |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2581 | * succeed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2582 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2583 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2584 | * (Function) func - The handler for the request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2585 | * (Strophe.Request) req - The request that is changing readyState. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2586 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2587 | _onRequestStateChange: function (func, req) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2588 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2589 | Strophe.debug("request id " + req.id + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2590 | "." + req.sends + " state changed to " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2591 | req.xhr.readyState); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2592 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2593 | if (req.abort) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2594 | req.abort = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2595 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2596 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2597 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2598 | // request complete |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2599 | var reqStatus; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2600 | if (req.xhr.readyState == 4) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2601 | reqStatus = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2602 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2603 | reqStatus = req.xhr.status; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2604 | } catch (e) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2605 | // ignore errors from undefined status attribute. works |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2606 | // around a browser bug |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2607 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2608 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2609 | if (typeof(reqStatus) == "undefined") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2610 | reqStatus = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2611 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2612 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2613 | if (this.disconnecting) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2614 | if (reqStatus >= 400) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2615 | this._hitError(reqStatus); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2616 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2617 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2618 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2619 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2620 | var reqIs0 = (this._requests[0] == req); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2621 | var reqIs1 = (this._requests[1] == req); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2622 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2623 | if ((reqStatus > 0 && reqStatus < 500) || req.sends > 5) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2624 | // remove from internal queue |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2625 | this._removeRequest(req); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2626 | Strophe.debug("request id " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2627 | req.id + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2628 | " should now be removed"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2629 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2630 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2631 | // request succeeded |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2632 | if (reqStatus == 200) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2633 | // if request 1 finished, or request 0 finished and request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2634 | // 1 is over Strophe.SECONDARY_TIMEOUT seconds old, we need to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2635 | // restart the other - both will be in the first spot, as the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2636 | // completed request has been removed from the queue already |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2637 | if (reqIs1 || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2638 | (reqIs0 && this._requests.length > 0 && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2639 | this._requests[0].age() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait))) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2640 | this._restartRequest(0); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2641 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2642 | // call handler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2643 | Strophe.debug("request id " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2644 | req.id + "." + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2645 | req.sends + " got 200"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2646 | func(req); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2647 | this.errors = 0; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2648 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2649 | Strophe.error("request id " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2650 | req.id + "." + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2651 | req.sends + " error " + reqStatus + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2652 | " happened"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2653 | if (reqStatus === 0 || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2654 | (reqStatus >= 400 && reqStatus < 600) || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2655 | reqStatus >= 12000) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2656 | this._hitError(reqStatus); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2657 | if (reqStatus >= 400 && reqStatus < 500) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2658 | this._changeConnectStatus(Strophe.Status.DISCONNECTING, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2659 | null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2660 | this._doDisconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2661 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2662 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2663 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2664 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2665 | if (!((reqStatus > 0 && reqStatus < 10000) || |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2666 | req.sends > 5)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2667 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2668 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2669 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2670 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2671 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2672 | /** PrivateFunction: _hitError |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2673 | * _Private_ function to handle the error count. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2674 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2675 | * Requests are resent automatically until their error count reaches |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2676 | * 5. Each time an error is encountered, this function is called to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2677 | * increment the count and disconnect if the count is too high. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2678 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2679 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2680 | * (Integer) reqStatus - The request status. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2681 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2682 | _hitError: function (reqStatus) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2683 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2684 | this.errors++; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2685 | Strophe.warn("request errored, status: " + reqStatus + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2686 | ", number of errors: " + this.errors); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2687 | if (this.errors > 4) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2688 | this._onDisconnectTimeout(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2689 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2690 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2691 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2692 | /** PrivateFunction: _doDisconnect |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2693 | * _Private_ function to disconnect. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2694 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2695 | * This is the last piece of the disconnection logic. This resets the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2696 | * connection and alerts the user's connection callback. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2697 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2698 | _doDisconnect: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2699 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2700 | Strophe.info("_doDisconnect was called"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2701 | this.authenticated = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2702 | this.disconnecting = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2703 | this.sid = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2704 | this.streamId = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2705 | this.rid = Math.floor(Math.random() * 4294967295); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2706 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2707 | // tell the parent we disconnected |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2708 | if (this.connected) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2709 | this._changeConnectStatus(Strophe.Status.DISCONNECTED, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2710 | this.connected = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2711 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2712 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2713 | // delete handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2714 | this.handlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2715 | this.timedHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2716 | this.removeTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2717 | this.removeHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2718 | this.addTimeds = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2719 | this.addHandlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2720 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2721 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2722 | /** PrivateFunction: _dataRecv |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2723 | * _Private_ handler to processes incoming data from the the connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2724 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2725 | * Except for _connect_cb handling the initial connection request, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2726 | * this function handles the incoming data for all requests. This |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2727 | * function also fires stanza handlers that match each incoming |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2728 | * stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2729 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2730 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2731 | * (Strophe.Request) req - The request that has data ready. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2732 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2733 | _dataRecv: function (req) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2734 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2735 | try { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2736 | var elem = req.getResponse(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2737 | } catch (e) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2738 | if (e != "parsererror") { throw e; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2739 | this.disconnect("strophe-parsererror"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2740 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2741 | if (elem === null) { return; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2742 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2743 | this.xmlInput(elem); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2744 | this.rawInput(Strophe.serialize(elem)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2745 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2746 | // remove handlers scheduled for deletion |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2747 | var i, hand; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2748 | while (this.removeHandlers.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2749 | hand = this.removeHandlers.pop(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2750 | i = this.handlers.indexOf(hand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2751 | if (i >= 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2752 | this.handlers.splice(i, 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2753 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2754 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2755 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2756 | // add handlers scheduled for addition |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2757 | while (this.addHandlers.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2758 | this.handlers.push(this.addHandlers.pop()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2759 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2760 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2761 | // handle graceful disconnect |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2762 | if (this.disconnecting && this._requests.length === 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2763 | this.deleteTimedHandler(this._disconnectTimeout); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2764 | this._disconnectTimeout = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2765 | this._doDisconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2766 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2767 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2768 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2769 | var typ = elem.getAttribute("type"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2770 | var cond, conflict; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2771 | if (typ !== null && typ == "terminate") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2772 | // an error occurred |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2773 | cond = elem.getAttribute("condition"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2774 | conflict = elem.getElementsByTagName("conflict"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2775 | if (cond !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2776 | if (cond == "remote-stream-error" && conflict.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2777 | cond = "conflict"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2778 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2779 | this._changeConnectStatus(Strophe.Status.CONNFAIL, cond); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2780 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2781 | this._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2782 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2783 | this.disconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2784 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2785 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2786 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2787 | // send each incoming stanza through the handler chain |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2788 | var self = this; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2789 | Strophe.forEachChild(elem, null, function (child) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2790 | var i, newList; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2791 | // process handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2792 | newList = self.handlers; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2793 | self.handlers = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2794 | for (i = 0; i < newList.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2795 | var hand = newList[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2796 | if (hand.isMatch(child) && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2797 | (self.authenticated || !hand.user)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2798 | if (hand.run(child)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2799 | self.handlers.push(hand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2800 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2801 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2802 | self.handlers.push(hand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2803 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2804 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2805 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2806 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2807 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2808 | /** PrivateFunction: _sendTerminate |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2809 | * _Private_ function to send initial disconnect sequence. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2810 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2811 | * This is the first step in a graceful disconnect. It sends |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2812 | * the BOSH server a terminate body and includes an unavailable |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2813 | * presence if authentication has completed. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2814 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2815 | _sendTerminate: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2816 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2817 | Strophe.info("_sendTerminate was called"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2818 | var body = this._buildBody().attrs({type: "terminate"}); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2819 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2820 | if (this.authenticated) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2821 | body.c('presence', { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2822 | xmlns: Strophe.NS.CLIENT, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2823 | type: 'unavailable' |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2824 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2825 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2826 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2827 | this.disconnecting = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2828 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2829 | var req = new Strophe.Request(body.tree(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2830 | this._onRequestStateChange.bind(this) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2831 | .prependArg(this._dataRecv.bind(this)), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2832 | body.tree().getAttribute("rid")); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2833 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2834 | this._requests.push(req); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2835 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2836 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2837 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2838 | /** PrivateFunction: _connect_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2839 | * _Private_ handler for initial connection request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2840 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2841 | * This handler is used to process the initial connection request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2842 | * response from the BOSH server. It is used to set up authentication |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2843 | * handlers and start the authentication process. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2844 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2845 | * SASL authentication will be attempted if available, otherwise |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2846 | * the code will fall back to legacy authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2847 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2848 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2849 | * (Strophe.Request) req - The current request. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2850 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2851 | _connect_cb: function (req) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2852 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2853 | Strophe.info("_connect_cb was called"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2854 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2855 | this.connected = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2856 | var bodyWrap = req.getResponse(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2857 | if (!bodyWrap) { return; } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2858 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2859 | this.xmlInput(bodyWrap); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2860 | this.rawInput(Strophe.serialize(bodyWrap)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2861 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2862 | var typ = bodyWrap.getAttribute("type"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2863 | var cond, conflict; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2864 | if (typ !== null && typ == "terminate") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2865 | // an error occurred |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2866 | cond = bodyWrap.getAttribute("condition"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2867 | conflict = bodyWrap.getElementsByTagName("conflict"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2868 | if (cond !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2869 | if (cond == "remote-stream-error" && conflict.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2870 | cond = "conflict"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2871 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2872 | this._changeConnectStatus(Strophe.Status.CONNFAIL, cond); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2873 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2874 | this._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2875 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2876 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2877 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2878 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2879 | // check to make sure we don't overwrite these if _connect_cb is |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2880 | // called multiple times in the case of missing stream:features |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2881 | if (!this.sid) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2882 | this.sid = bodyWrap.getAttribute("sid"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2883 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2884 | if (!this.stream_id) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2885 | this.stream_id = bodyWrap.getAttribute("authid"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2886 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2887 | var wind = bodyWrap.getAttribute('requests'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2888 | if (wind) { this.window = parseInt(wind, 10); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2889 | var hold = bodyWrap.getAttribute('hold'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2890 | if (hold) { this.hold = parseInt(hold, 10); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2891 | var wait = bodyWrap.getAttribute('wait'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2892 | if (wait) { this.wait = parseInt(wait, 10); } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2893 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2894 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2895 | var do_sasl_plain = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2896 | var do_sasl_digest_md5 = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2897 | var do_sasl_anonymous = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2898 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2899 | var mechanisms = bodyWrap.getElementsByTagName("mechanism"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2900 | var i, mech, auth_str, hashed_auth_str; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2901 | if (mechanisms.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2902 | for (i = 0; i < mechanisms.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2903 | mech = Strophe.getText(mechanisms[i]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2904 | if (mech == 'DIGEST-MD5') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2905 | do_sasl_digest_md5 = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2906 | } else if (mech == 'PLAIN') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2907 | do_sasl_plain = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2908 | } else if (mech == 'ANONYMOUS') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2909 | do_sasl_anonymous = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2910 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2911 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2912 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2913 | // we didn't get stream:features yet, so we need wait for it |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2914 | // by sending a blank poll request |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2915 | var body = this._buildBody(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2916 | this._requests.push( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2917 | new Strophe.Request(body.tree(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2918 | this._onRequestStateChange.bind(this) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2919 | .prependArg(this._connect_cb.bind(this)), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2920 | body.tree().getAttribute("rid"))); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2921 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2922 | return; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2923 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2924 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2925 | if (Strophe.getNodeFromJid(this.jid) === null && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2926 | do_sasl_anonymous) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2927 | this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2928 | this._sasl_success_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2929 | this._sasl_success_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2930 | "success", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2931 | this._sasl_failure_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2932 | this._sasl_failure_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2933 | "failure", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2934 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2935 | this.send($build("auth", { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2936 | xmlns: Strophe.NS.SASL, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2937 | mechanism: "ANONYMOUS" |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2938 | }).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2939 | } else if (Strophe.getNodeFromJid(this.jid) === null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2940 | // we don't have a node, which is required for non-anonymous |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2941 | // client connections |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2942 | this._changeConnectStatus(Strophe.Status.CONNFAIL, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2943 | 'x-strophe-bad-non-anon-jid'); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2944 | this.disconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2945 | } else if (do_sasl_digest_md5) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2946 | this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2947 | this._sasl_challenge_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2948 | this._sasl_challenge1_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2949 | "challenge", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2950 | this._sasl_failure_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2951 | this._sasl_failure_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2952 | "failure", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2953 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2954 | this.send($build("auth", { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2955 | xmlns: Strophe.NS.SASL, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2956 | mechanism: "DIGEST-MD5" |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2957 | }).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2958 | } else if (do_sasl_plain) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2959 | // Build the plain auth string (barejid null |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2960 | // username null password) and base 64 encoded. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2961 | auth_str = Strophe.getBareJidFromJid(this.jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2962 | auth_str = auth_str + "\u0000"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2963 | auth_str = auth_str + Strophe.getNodeFromJid(this.jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2964 | auth_str = auth_str + "\u0000"; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2965 | auth_str = auth_str + this.pass; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2966 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2967 | this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2968 | this._sasl_success_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2969 | this._sasl_success_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2970 | "success", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2971 | this._sasl_failure_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2972 | this._sasl_failure_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2973 | "failure", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2974 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2975 | hashed_auth_str = Base64.encode(auth_str); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2976 | this.send($build("auth", { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2977 | xmlns: Strophe.NS.SASL, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2978 | mechanism: "PLAIN" |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2979 | }).t(hashed_auth_str).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2980 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2981 | this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2982 | this._addSysHandler(this._auth1_cb.bind(this), null, null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2983 | null, "_auth_1"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2984 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2985 | this.send($iq({ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2986 | type: "get", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2987 | to: this.domain, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2988 | id: "_auth_1" |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2989 | }).c("query", { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2990 | xmlns: Strophe.NS.AUTH |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2991 | }).c("username", {}).t(Strophe.getNodeFromJid(this.jid)).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2992 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2993 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2994 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2995 | /** PrivateFunction: _sasl_challenge1_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2996 | * _Private_ handler for DIGEST-MD5 SASL authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2997 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2998 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2999 | * (XMLElement) elem - The challenge stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3000 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3001 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3002 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3003 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3004 | _sasl_challenge1_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3005 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3006 | var attribMatch = /([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3007 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3008 | var challenge = Base64.decode(Strophe.getText(elem)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3009 | var cnonce = MD5.hexdigest(Math.random() * 1234567890); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3010 | var realm = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3011 | var host = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3012 | var nonce = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3013 | var qop = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3014 | var matches; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3015 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3016 | // remove unneeded handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3017 | this.deleteHandler(this._sasl_failure_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3018 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3019 | while (challenge.match(attribMatch)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3020 | matches = challenge.match(attribMatch); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3021 | challenge = challenge.replace(matches[0], ""); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3022 | matches[2] = matches[2].replace(/^"(.+)"$/, "$1"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3023 | switch (matches[1]) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3024 | case "realm": |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3025 | realm = matches[2]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3026 | break; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3027 | case "nonce": |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3028 | nonce = matches[2]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3029 | break; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3030 | case "qop": |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3031 | qop = matches[2]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3032 | break; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3033 | case "host": |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3034 | host = matches[2]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3035 | break; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3036 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3037 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3038 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3039 | var digest_uri = "xmpp/" + this.domain; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3040 | if (host !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3041 | digest_uri = digest_uri + "/" + host; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3042 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3043 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3044 | var A1 = MD5.hash(Strophe.getNodeFromJid(this.jid) + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3045 | ":" + realm + ":" + this.pass) + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3046 | ":" + nonce + ":" + cnonce; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3047 | var A2 = 'AUTHENTICATE:' + digest_uri; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3048 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3049 | var responseText = ""; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3050 | responseText += 'username=' + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3051 | this._quote(Strophe.getNodeFromJid(this.jid)) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3052 | responseText += 'realm=' + this._quote(realm) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3053 | responseText += 'nonce=' + this._quote(nonce) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3054 | responseText += 'cnonce=' + this._quote(cnonce) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3055 | responseText += 'nc="00000001",'; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3056 | responseText += 'qop="auth",'; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3057 | responseText += 'digest-uri=' + this._quote(digest_uri) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3058 | responseText += 'response=' + this._quote( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3059 | MD5.hexdigest(MD5.hexdigest(A1) + ":" + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3060 | nonce + ":00000001:" + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3061 | cnonce + ":auth:" + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3062 | MD5.hexdigest(A2))) + ','; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3063 | responseText += 'charset="utf-8"'; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3064 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3065 | this._sasl_challenge_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3066 | this._sasl_challenge2_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3067 | "challenge", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3068 | this._sasl_success_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3069 | this._sasl_success_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3070 | "success", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3071 | this._sasl_failure_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3072 | this._sasl_failure_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3073 | "failure", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3074 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3075 | this.send($build('response', { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3076 | xmlns: Strophe.NS.SASL |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3077 | }).t(Base64.encode(responseText)).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3078 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3079 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3080 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3081 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3082 | /** PrivateFunction: _quote |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3083 | * _Private_ utility function to backslash escape and quote strings. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3084 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3085 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3086 | * (String) str - The string to be quoted. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3087 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3088 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3089 | * quoted string |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3090 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3091 | _quote: function (str) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3092 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3093 | return '"' + str.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"'; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3094 | //" end string workaround for emacs |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3095 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3096 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3097 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3098 | /** PrivateFunction: _sasl_challenge2_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3099 | * _Private_ handler for second step of DIGEST-MD5 SASL authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3100 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3101 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3102 | * (XMLElement) elem - The challenge stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3103 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3104 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3105 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3106 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3107 | _sasl_challenge2_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3108 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3109 | // remove unneeded handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3110 | this.deleteHandler(this._sasl_success_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3111 | this.deleteHandler(this._sasl_failure_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3112 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3113 | this._sasl_success_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3114 | this._sasl_success_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3115 | "success", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3116 | this._sasl_failure_handler = this._addSysHandler( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3117 | this._sasl_failure_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3118 | "failure", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3119 | this.send($build('response', {xmlns: Strophe.NS.SASL}).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3120 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3121 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3122 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3123 | /** PrivateFunction: _auth1_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3124 | * _Private_ handler for legacy authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3125 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3126 | * This handler is called in response to the initial <iq type='get'/> |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3127 | * for legacy authentication. It builds an authentication <iq/> and |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3128 | * sends it, creating a handler (calling back to _auth2_cb()) to |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3129 | * handle the result |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3130 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3131 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3132 | * (XMLElement) elem - The stanza that triggered the callback. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3133 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3134 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3135 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3136 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3137 | _auth1_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3138 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3139 | // build plaintext auth iq |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3140 | var iq = $iq({type: "set", id: "_auth_2"}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3141 | .c('query', {xmlns: Strophe.NS.AUTH}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3142 | .c('username', {}).t(Strophe.getNodeFromJid(this.jid)) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3143 | .up() |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3144 | .c('password').t(this.pass); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3145 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3146 | if (!Strophe.getResourceFromJid(this.jid)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3147 | // since the user has not supplied a resource, we pick |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3148 | // a default one here. unlike other auth methods, the server |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3149 | // cannot do this for us. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3150 | this.jid = Strophe.getBareJidFromJid(this.jid) + '/strophe'; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3151 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3152 | iq.up().c('resource', {}).t(Strophe.getResourceFromJid(this.jid)); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3153 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3154 | this._addSysHandler(this._auth2_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3155 | null, null, "_auth_2"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3156 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3157 | this.send(iq.tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3158 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3159 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3160 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3161 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3162 | /** PrivateFunction: _sasl_success_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3163 | * _Private_ handler for succesful SASL authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3164 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3165 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3166 | * (XMLElement) elem - The matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3167 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3168 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3169 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3170 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3171 | _sasl_success_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3172 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3173 | Strophe.info("SASL authentication succeeded."); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3174 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3175 | // remove old handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3176 | this.deleteHandler(this._sasl_failure_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3177 | this._sasl_failure_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3178 | if (this._sasl_challenge_handler) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3179 | this.deleteHandler(this._sasl_challenge_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3180 | this._sasl_challenge_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3181 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3182 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3183 | this._addSysHandler(this._sasl_auth1_cb.bind(this), null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3184 | "stream:features", null, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3185 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3186 | // we must send an xmpp:restart now |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3187 | this._sendRestart(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3188 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3189 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3190 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3191 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3192 | /** PrivateFunction: _sasl_auth1_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3193 | * _Private_ handler to start stream binding. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3194 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3195 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3196 | * (XMLElement) elem - The matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3197 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3198 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3199 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3200 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3201 | _sasl_auth1_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3202 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3203 | var i, child; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3204 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3205 | for (i = 0; i < elem.childNodes.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3206 | child = elem.childNodes[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3207 | if (child.nodeName == 'bind') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3208 | this.do_bind = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3209 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3210 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3211 | if (child.nodeName == 'session') { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3212 | this.do_session = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3213 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3214 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3215 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3216 | if (!this.do_bind) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3217 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3218 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3219 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3220 | this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3221 | null, "_bind_auth_2"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3222 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3223 | var resource = Strophe.getResourceFromJid(this.jid); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3224 | if (resource) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3225 | this.send($iq({type: "set", id: "_bind_auth_2"}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3226 | .c('bind', {xmlns: Strophe.NS.BIND}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3227 | .c('resource', {}).t(resource).tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3228 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3229 | this.send($iq({type: "set", id: "_bind_auth_2"}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3230 | .c('bind', {xmlns: Strophe.NS.BIND}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3231 | .tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3232 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3233 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3234 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3235 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3236 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3237 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3238 | /** PrivateFunction: _sasl_bind_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3239 | * _Private_ handler for binding result and session start. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3240 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3241 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3242 | * (XMLElement) elem - The matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3243 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3244 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3245 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3246 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3247 | _sasl_bind_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3248 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3249 | if (elem.getAttribute("type") == "error") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3250 | Strophe.info("SASL binding failed."); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3251 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3252 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3253 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3254 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3255 | // TODO - need to grab errors |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3256 | var bind = elem.getElementsByTagName("bind"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3257 | var jidNode; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3258 | if (bind.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3259 | // Grab jid |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3260 | jidNode = bind[0].getElementsByTagName("jid"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3261 | if (jidNode.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3262 | this.jid = Strophe.getText(jidNode[0]); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3263 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3264 | if (this.do_session) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3265 | this._addSysHandler(this._sasl_session_cb.bind(this), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3266 | null, null, null, "_session_auth_2"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3267 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3268 | this.send($iq({type: "set", id: "_session_auth_2"}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3269 | .c('session', {xmlns: Strophe.NS.SESSION}) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3270 | .tree()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3271 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3272 | this.authenticated = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3273 | this._changeConnectStatus(Strophe.Status.CONNECTED, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3274 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3275 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3276 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3277 | Strophe.info("SASL binding failed."); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3278 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3279 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3280 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3281 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3282 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3283 | /** PrivateFunction: _sasl_session_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3284 | * _Private_ handler to finish successful SASL connection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3285 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3286 | * This sets Connection.authenticated to true on success, which |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3287 | * starts the processing of user handlers. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3288 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3289 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3290 | * (XMLElement) elem - The matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3291 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3292 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3293 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3294 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3295 | _sasl_session_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3296 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3297 | if (elem.getAttribute("type") == "result") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3298 | this.authenticated = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3299 | this._changeConnectStatus(Strophe.Status.CONNECTED, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3300 | } else if (elem.getAttribute("type") == "error") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3301 | Strophe.info("Session creation failed."); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3302 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3303 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3304 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3305 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3306 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3307 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3308 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3309 | /** PrivateFunction: _sasl_failure_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3310 | * _Private_ handler for SASL authentication failure. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3311 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3312 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3313 | * (XMLElement) elem - The matching stanza. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3314 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3315 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3316 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3317 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3318 | _sasl_failure_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3319 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3320 | // delete unneeded handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3321 | if (this._sasl_success_handler) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3322 | this.deleteHandler(this._sasl_success_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3323 | this._sasl_success_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3324 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3325 | if (this._sasl_challenge_handler) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3326 | this.deleteHandler(this._sasl_challenge_handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3327 | this._sasl_challenge_handler = null; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3328 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3329 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3330 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3331 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3332 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3333 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3334 | /** PrivateFunction: _auth2_cb |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3335 | * _Private_ handler to finish legacy authentication. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3336 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3337 | * This handler is called when the result from the jabber:iq:auth |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3338 | * <iq/> stanza is returned. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3339 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3340 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3341 | * (XMLElement) elem - The stanza that triggered the callback. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3342 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3343 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3344 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3345 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3346 | _auth2_cb: function (elem) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3347 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3348 | if (elem.getAttribute("type") == "result") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3349 | this.authenticated = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3350 | this._changeConnectStatus(Strophe.Status.CONNECTED, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3351 | } else if (elem.getAttribute("type") == "error") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3352 | this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3353 | this.disconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3354 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3355 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3356 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3357 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3358 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3359 | /** PrivateFunction: _addSysTimedHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3360 | * _Private_ function to add a system level timed handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3361 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3362 | * This function is used to add a Strophe.TimedHandler for the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3363 | * library code. System timed handlers are allowed to run before |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3364 | * authentication is complete. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3365 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3366 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3367 | * (Integer) period - The period of the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3368 | * (Function) handler - The callback function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3369 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3370 | _addSysTimedHandler: function (period, handler) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3371 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3372 | var thand = new Strophe.TimedHandler(period, handler); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3373 | thand.user = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3374 | this.addTimeds.push(thand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3375 | return thand; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3376 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3377 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3378 | /** PrivateFunction: _addSysHandler |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3379 | * _Private_ function to add a system level stanza handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3380 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3381 | * This function is used to add a Strophe.Handler for the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3382 | * library code. System stanza handlers are allowed to run before |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3383 | * authentication is complete. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3384 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3385 | * Parameters: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3386 | * (Function) handler - The callback function. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3387 | * (String) ns - The namespace to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3388 | * (String) name - The stanza name to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3389 | * (String) type - The stanza type attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3390 | * (String) id - The stanza id attribute to match. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3391 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3392 | _addSysHandler: function (handler, ns, name, type, id) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3393 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3394 | var hand = new Strophe.Handler(handler, ns, name, type, id); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3395 | hand.user = false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3396 | this.addHandlers.push(hand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3397 | return hand; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3398 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3399 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3400 | /** PrivateFunction: _onDisconnectTimeout |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3401 | * _Private_ timeout handler for handling non-graceful disconnection. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3402 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3403 | * If the graceful disconnect process does not complete within the |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3404 | * time allotted, this handler finishes the disconnect anyway. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3405 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3406 | * Returns: |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3407 | * false to remove the handler. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3408 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3409 | _onDisconnectTimeout: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3410 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3411 | Strophe.info("_onDisconnectTimeout was called"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3412 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3413 | // cancel all remaining requests and clear the queue |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3414 | var req; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3415 | while (this._requests.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3416 | req = this._requests.pop(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3417 | req.abort = true; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3418 | req.xhr.abort(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3419 | // jslint complains, but this is fine. setting to empty func |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3420 | // is necessary for IE6 |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3421 | req.xhr.onreadystatechange = function () {}; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3422 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3423 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3424 | // actually disconnect |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3425 | this._doDisconnect(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3426 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3427 | return false; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3428 | }, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3429 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3430 | /** PrivateFunction: _onIdle |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3431 | * _Private_ handler to process events during idle cycle. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3432 | * |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3433 | * This handler is called every 100ms to fire timed handlers that |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3434 | * are ready and keep poll requests going. |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3435 | */ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3436 | _onIdle: function () |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3437 | { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3438 | var i, thand, since, newList; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3439 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3440 | // remove timed handlers that have been scheduled for deletion |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3441 | while (this.removeTimeds.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3442 | thand = this.removeTimeds.pop(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3443 | i = this.timedHandlers.indexOf(thand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3444 | if (i >= 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3445 | this.timedHandlers.splice(i, 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3446 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3447 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3448 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3449 | // add timed handlers scheduled for addition |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3450 | while (this.addTimeds.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3451 | this.timedHandlers.push(this.addTimeds.pop()); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3452 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3453 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3454 | // call ready timed handlers |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3455 | var now = new Date().getTime(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3456 | newList = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3457 | for (i = 0; i < this.timedHandlers.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3458 | thand = this.timedHandlers[i]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3459 | if (this.authenticated || !thand.user) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3460 | since = thand.lastCalled + thand.period; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3461 | if (since - now <= 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3462 | if (thand.run()) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3463 | newList.push(thand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3464 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3465 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3466 | newList.push(thand); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3467 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3468 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3469 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3470 | this.timedHandlers = newList; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3471 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3472 | var body, time_elapsed; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3473 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3474 | // if no requests are in progress, poll |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3475 | if (this.authenticated && this._requests.length === 0 && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3476 | this._data.length === 0 && !this.disconnecting) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3477 | Strophe.info("no requests during idle cycle, sending " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3478 | "blank request"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3479 | this._data.push(null); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3480 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3481 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3482 | if (this._requests.length < 2 && this._data.length > 0 && |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3483 | !this.paused) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3484 | body = this._buildBody(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3485 | for (i = 0; i < this._data.length; i++) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3486 | if (this._data[i] !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3487 | if (this._data[i] === "restart") { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3488 | body.attrs({ |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3489 | to: this.domain, |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3490 | "xml:lang": "en", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3491 | "xmpp:restart": "true", |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3492 | "xmlns:xmpp": Strophe.NS.BOSH |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3493 | }); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3494 | } else { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3495 | body.cnode(this._data[i]).up(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3496 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3497 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3498 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3499 | delete this._data; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3500 | this._data = []; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3501 | this._requests.push( |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3502 | new Strophe.Request(body.tree(), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3503 | this._onRequestStateChange.bind(this) |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3504 | .prependArg(this._dataRecv.bind(this)), |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3505 | body.tree().getAttribute("rid"))); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3506 | this._processRequest(this._requests.length - 1); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3507 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3508 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3509 | if (this._requests.length > 0) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3510 | time_elapsed = this._requests[0].age(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3511 | if (this._requests[0].dead !== null) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3512 | if (this._requests[0].timeDead() > |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3513 | Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3514 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3515 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3516 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3517 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3518 | if (time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3519 | Strophe.warn("Request " + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3520 | this._requests[0].id + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3521 | " timed out, over " + Math.floor(Strophe.TIMEOUT * this.wait) + |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3522 | " seconds since last activity"); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3523 | this._throttledRequestHandler(); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3524 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3525 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3526 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3527 | // reactivate the timer |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3528 | clearTimeout(this._idleTimeout); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3529 | this._idleTimeout = setTimeout(this._onIdle.bind(this), 100); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3530 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3531 | }; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3532 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3533 | if (callback) { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3534 | callback(Strophe, $build, $msg, $iq, $pres); |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3535 | } |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3536 | |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3537 | })(function () { |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3538 | window.Strophe = arguments[0]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3539 | window.$build = arguments[1]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3540 | window.$msg = arguments[2]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3541 | window.$iq = arguments[3]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3542 | window.$pres = arguments[4]; |
9e4230bb66e4
Update Strophe.js to 1.0.1 (fixes some issues)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3543 | }); |