25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2009 Collecta, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/examples/crossdomain.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Strophe.js Basic Cross-Domain Example
5 |
6 |
8 |
10 |
11 |
13 |
15 |
16 |
18 |
19 |
20 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/attach/README:
--------------------------------------------------------------------------------
1 | This is an example of Strophe attaching to a pre-existing BOSH session
2 | that is created externally. This example requires a bit more than
3 | HTML and JavaScript. Specifically it contains a very simple Web
4 | application written in Django which creates a BOSH session before
5 | rendering the page.
6 |
7 | Requirements:
8 |
9 | * Django 1.0 (http://www.djangoproject.com)
10 | * Twisted 8.1.x (http://twistedmatrix.com)
11 | * Punjab 0.3 (http://code.stanziq.com/punjab)
12 |
13 | Note that Twisted and Punjab are only used for small functions related
14 | to JID and BOSH parsing.
15 |
16 | How It Works:
17 |
18 | The Django app contains one view which is tied to the root URL. This
19 | view uses the BOSHClient class to start a BOSH session using the
20 | settings from settings.py.
21 |
22 | Once the connection is established, Django passes the JID, SID, and
23 | RID for the BOSH session into the template engine and renders the
24 | page.
25 |
26 | The template assigns the JID, SID, and RID to global vars like so:
27 |
28 | var BOSH_JID = {{ jid }};
29 | var BOSH_SID = {{ sid }};
30 | var BOSH_RID = {{ rid }};
31 |
32 | The connection is attached to Strophe by calling
33 | Strophe.Connection.attach() with this data and a connection callback
34 | handler.
35 |
36 | To show that the session is attached and works, a disco info ping is
37 | done to jabber.org.
38 |
--------------------------------------------------------------------------------
/plugins/strophe.flxhr.js:
--------------------------------------------------------------------------------
1 | /* flXHR plugin
2 | **
3 | ** This plugin implements cross-domain XmlHttpRequests via an invisible
4 | ** Flash plugin.
5 | **
6 | ** In order for this to work, the BOSH service *must* serve a
7 | ** crossdomain.xml file that allows the client access.
8 | **
9 | ** flXHR.js should be loaded before this plugin.
10 | */
11 |
12 | Strophe.addConnectionPlugin('flxhr', {
13 | init: function (conn) {
14 | // replace Strophe.Request._newXHR with new flXHR version
15 | // if flXHR is detected
16 | if (flensed && flensed.flXHR) {
17 | Strophe.Request.prototype._newXHR = function () {
18 | var xhr = new flensed.flXHR({
19 | autoUpdatePlayer: true,
20 | instancePooling: true,
21 | noCacheHeader: false,
22 | onerror: function () {
23 | conn._changeConnectStatus(Strophe.Status.CONNFAIL,
24 | "flXHR connection error");
25 | conn._onDisconnectTimeout();
26 | }});
27 | xhr.onreadystatechange = this.func.bind(null, this);
28 |
29 | return xhr;
30 | };
31 | } else {
32 | Strophe.error("flXHR plugin loaded, but flXHR not found." +
33 | " Falling back to native XHR implementation.");
34 | }
35 | }
36 | });
37 |
--------------------------------------------------------------------------------
/contrib/discojs/README.txt:
--------------------------------------------------------------------------------
1 | Disco Dancing with XMPP
2 |
3 | There are many things one can do via XMPP. The list is
4 | endlist. But one thing that some forget about is discovering
5 | services a XMPP entity or server provides. In most cases a human or
6 | user does not care about this information and should not care. But
7 | you may have a website or web application that needs this
8 | information in order to decide what options to show to your
9 | users. You can do this very easily with JQuery, Strophe, and
10 | Punjab.
11 |
12 | We start with Punjab or a BOSH connection manager. This is
13 | needed so we can connect to a XMPP server. First, lets download
14 | punjab.
15 |
16 | svn co https://code.stanziq.com/svn/punjab/trunk punjab
17 |
18 | After we have punjab go into the directory and install punjab.
19 |
20 | cd punjab
21 | python setup.py install
22 |
23 | Then create a .tac file to configure Punjab.
24 |
25 | See punjab.tac
26 |
27 | Next, we will need Strophe. Lets download thelatest version from
28 | svn too.
29 |
30 | cd /directory/where/you/configured/punjab/html
31 |
32 | svn co https://code.stanziq.com/svn/strophe/trunk/strophejs
33 |
34 | In your html directory you will then begin to create your disco browser.
35 |
36 | Version 1 we take the basic example and modify it to do disco.
37 |
38 | Version 2 we add anonymous login
39 |
40 | Version 3 we make it pretty
41 |
42 | Version 4 we add handlers for different services
43 |
--------------------------------------------------------------------------------
/CHANGELOG.txt:
--------------------------------------------------------------------------------
1 | # Strophe.js Change Log
2 |
3 | ## Version 1.0.2 - 2011-06-19
4 |
5 | * Fix security bug where DIGEST-MD5 client nonce was not properly
6 | randomized.
7 | * Fix double escaping in copyElement.
8 | * Fix IE errors related to importNode.
9 | * Add ability to pass text into Builder.c().
10 | * Improve performance by skipping debugging callbacks when not
11 | overridden.
12 | * Wrap handler runs in try/catch so they don't affect or remove later
13 | handlers.
14 | * Add ' and " to escaped characters and other escaping fixes.
15 | * Fix _throttledRequestHandler to use proper window size.
16 | * Fix timed handler management.
17 | * Fix flXHR plugin to better deal with errors.
18 | * Fix bind() to be ECMAScript 5 compatible.
19 | * Use bosh.metajack.im in examples so they work out of the box.
20 | * Add simple XHR tests.
21 | * Update basic example to HTML5.
22 | * Move community plugins to their own repository.
23 | * Fix bug causing infinite retries.
24 | * Fix 5xx error handling.
25 | * Store stream:features for later use by plugins.
26 | * Fix to prevent passing stanzas during disconnect.
27 | * Fix handling of disconnect responses.
28 | * Fix getBareJidFromJid to return null on error.
29 | * Fix equality testing in matchers so that string literals and string
30 | objects both match.
31 | * Fix bare matching on missing from attributes.
32 | * Remove use of reserved word self.
33 | * Fix various documentation errors.
34 |
35 | ## Version 1.0.1 - 2010-01-27
36 |
37 | * Fix handling of window, hold, and wait attributes. Bug #75.
38 |
39 | ## Version 1.0 - 2010-01-01
40 |
41 | * First release.
42 |
--------------------------------------------------------------------------------
/examples/basic.js:
--------------------------------------------------------------------------------
1 | var BOSH_SERVICE = 'http://bosh.metajack.im:5280/xmpp-httpbind'
2 | var connection = null;
3 |
4 | function log(msg)
5 | {
6 | $('#log').append('').append(document.createTextNode(msg));
7 | }
8 |
9 | function rawInput(data)
10 | {
11 | log('RECV: ' + data);
12 | }
13 |
14 | function rawOutput(data)
15 | {
16 | log('SENT: ' + data);
17 | }
18 |
19 | function onConnect(status)
20 | {
21 | if (status == Strophe.Status.CONNECTING) {
22 | log('Strophe is connecting.');
23 | } else if (status == Strophe.Status.CONNFAIL) {
24 | log('Strophe failed to connect.');
25 | $('#connect').get(0).value = 'connect';
26 | } else if (status == Strophe.Status.DISCONNECTING) {
27 | log('Strophe is disconnecting.');
28 | } else if (status == Strophe.Status.DISCONNECTED) {
29 | log('Strophe is disconnected.');
30 | $('#connect').get(0).value = 'connect';
31 | } else if (status == Strophe.Status.CONNECTED) {
32 | log('Strophe is connected.');
33 | connection.disconnect();
34 | }
35 | }
36 |
37 | $(document).ready(function () {
38 | connection = new Strophe.Connection(BOSH_SERVICE);
39 | connection.rawInput = rawInput;
40 | connection.rawOutput = rawOutput;
41 |
42 | $('#connect').bind('click', function () {
43 | var button = $('#connect').get(0);
44 | if (button.value == 'connect') {
45 | button.value = 'disconnect';
46 |
47 | connection.connect($('#jid').get(0).value,
48 | $('#pass').get(0).value,
49 | onConnect);
50 | } else {
51 | button.value = 'connect';
52 | connection.disconnect();
53 | }
54 | });
55 | });
--------------------------------------------------------------------------------
/contrib/discojs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | XMPP Disco Dancing
5 |
8 |
11 |
14 |
17 |
20 |
23 |
26 |
27 |
28 |
29 |