Download:
child 21:e43ed046f909
parent 19:8a8b60dadcee
20:aa1eeed14fff
Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 10:29:04 +0800
register: move onConnect to XMPPInterface

6 файлов изменено, 108 вставок(+), 101 удалений(-) [+]
coffee/register.coffee file | annotate | diff | comparison | revisions
coffee/xmpp.coffee file | annotate | diff | comparison | revisions
js/register.js file | annotate | diff | comparison | revisions
js/register.js.map file | annotate | diff | comparison | revisions
js/xmpp.js file | annotate | diff | comparison | revisions
js/xmpp.js.map file | annotate | diff | comparison | revisions
--- a/coffee/register.coffee Sun Mar 20 23:42:22 2016 +0800
+++ b/coffee/register.coffee Mon Mar 21 10:29:04 2016 +0800
@@ -1,58 +1,7 @@
-onConnect = (status, error) ->
- switch status
- when Strophe.Status.CONNECTING
- console.debug('Strophe is connecting.')
-
- when Strophe.Status.AUTHENTICATING
- console.debug('Strophe is authenticating.')
-
- when Strophe.Status.AUTHFAIL
- console.debug('Strophe failed to authenticate:', error)
-
- when Strophe.Status.ERROR
- console.debug('Strophe received an error:', error)
-
- when Strophe.Status.CONNFAIL
- console.debug('Strophe failed to connect:', error)
-
- when Strophe.Status.DISCONNECTING
- console.debug('Strophe is disconnecting.')
-
- when Strophe.Status.DISCONNECTED
- console.debug('Strophe is disconnected.')
-
- when Strophe.Status.CONNECTED
- console.debug('Strophe is connected.')
- console.info('My jid:', X.conn.jid)
- X.trigger('v/start')
-
- when Strophe.Status.REGISTER
- console.debug('Got registration prompt.')
- X.trigger('r/start')
-
- when Strophe.Status.REGISTERED
- console.debug('Registered!')
- X.trigger('r/done')
- X.conn.authenticate()
-
- when Strophe.Status.CONFLICT
- console.debug('Contact already exists!')
- X.trigger('r/conflict')
-
- when Strophe.Status.NOTACCEPTABLE
- console.debug('Registration form not properly filled out.')
- X.trigger('r/failed')
-
- when Strophe.Status.REGIFAIL
- console.debug('The server does not support In-Band Registration.')
- X.trigger('r/closed')
-
-
-
window.X = new Tram.XMPPInterface()
-X.startRegistration(onConnect)
+X.startRegistration()
$('[data-form="registration"], [data-form="vcard"]').each ->
@@ -100,6 +49,7 @@
X.on 'r/done', ->
+ X.finishRegistration()
$('[data-step="registration"]').addClass('uk-hidden')
--- a/coffee/xmpp.coffee Sun Mar 20 23:42:22 2016 +0800
+++ b/coffee/xmpp.coffee Mon Mar 21 10:29:04 2016 +0800
@@ -23,16 +23,19 @@
@conn = null
return
- startRegistration: (onConnect) ->
+ startRegistration: ->
@_prepareConnection()
- @conn.register.connect(Tram.config.domain, onConnect)
+ @conn.register.connect(Tram.config.domain, @onConnect)
register: (username, password) ->
@conn.register.fields.username = username
@conn.register.fields.password = password
@conn.register.submit()
+ finishRegistration: ->
+ @conn.authenticate()
+
savevCard: (data) ->
$vcard = $iq(type: 'set').c('vCard', xmlns: Strophe.NS.VCARD)
@@ -65,5 +68,53 @@
@conn.sendIQ($vcard.tree(), okcb, failcb)
+ onConnect: (status, error) =>
+ switch status
+ when Strophe.Status.CONNECTING
+ console.debug('Strophe is connecting.')
+
+ when Strophe.Status.AUTHENTICATING
+ console.debug('Strophe is authenticating.')
+
+ when Strophe.Status.AUTHFAIL
+ console.debug('Strophe failed to authenticate:', error)
+
+ when Strophe.Status.ERROR
+ console.debug('Strophe received an error:', error)
+
+ when Strophe.Status.CONNFAIL
+ console.debug('Strophe failed to connect:', error)
+
+ when Strophe.Status.DISCONNECTING
+ console.debug('Strophe is disconnecting.')
+
+ when Strophe.Status.DISCONNECTED
+ console.debug('Strophe is disconnected.')
+
+ when Strophe.Status.CONNECTED
+ console.debug('Strophe is connected.')
+ console.info('My jid:', @conn.jid)
+ @trigger('v/start')
+
+ when Strophe.Status.REGISTER
+ console.debug('Got registration prompt.')
+ @trigger('r/start')
+
+ when Strophe.Status.REGISTERED
+ console.debug('Registered!')
+ @trigger('r/done')
+
+ when Strophe.Status.CONFLICT
+ console.debug('Contact already exists!')
+ @trigger('r/conflict')
+
+ when Strophe.Status.NOTACCEPTABLE
+ console.debug('Registration form not properly filled out.')
+ @trigger('r/failed')
+
+ when Strophe.Status.REGIFAIL
+ console.debug('The server does not support In-Band Registration.')
+ @trigger('r/closed')
+
_(Tram.XMPPInterface.prototype).extend(Backbone.Events)
--- a/js/register.js Sun Mar 20 23:42:22 2016 +0800
+++ b/js/register.js Mon Mar 21 10:29:04 2016 +0800
@@ -1,49 +1,8 @@
// Generated by CoffeeScript 1.10.0
(function() {
- var onConnect;
-
- onConnect = function(status, error) {
- switch (status) {
- case Strophe.Status.CONNECTING:
- return console.debug('Strophe is connecting.');
- case Strophe.Status.AUTHENTICATING:
- return console.debug('Strophe is authenticating.');
- case Strophe.Status.AUTHFAIL:
- return console.debug('Strophe failed to authenticate:', error);
- case Strophe.Status.ERROR:
- return console.debug('Strophe received an error:', error);
- case Strophe.Status.CONNFAIL:
- return console.debug('Strophe failed to connect:', error);
- case Strophe.Status.DISCONNECTING:
- return console.debug('Strophe is disconnecting.');
- case Strophe.Status.DISCONNECTED:
- return console.debug('Strophe is disconnected.');
- case Strophe.Status.CONNECTED:
- console.debug('Strophe is connected.');
- console.info('My jid:', X.conn.jid);
- return X.trigger('v/start');
- case Strophe.Status.REGISTER:
- console.debug('Got registration prompt.');
- return X.trigger('r/start');
- case Strophe.Status.REGISTERED:
- console.debug('Registered!');
- X.trigger('r/done');
- return X.conn.authenticate();
- case Strophe.Status.CONFLICT:
- console.debug('Contact already exists!');
- return X.trigger('r/conflict');
- case Strophe.Status.NOTACCEPTABLE:
- console.debug('Registration form not properly filled out.');
- return X.trigger('r/failed');
- case Strophe.Status.REGIFAIL:
- console.debug('The server does not support In-Band Registration.');
- return X.trigger('r/closed');
- }
- };
-
window.X = new Tram.XMPPInterface();
- X.startRegistration(onConnect);
+ X.startRegistration();
$('[data-form="registration"], [data-form="vcard"]').each(function() {
var $form;
@@ -102,6 +61,7 @@
});
X.on('r/done', function() {
+ X.finishRegistration();
return $('[data-step="registration"]').addClass('uk-hidden');
});
--- a/js/register.js.map Sun Mar 20 23:42:22 2016 +0800
+++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AA3B,CAAuC,WAAvC;EADe,CAAjB;AA9EA"
}
\ No newline at end of file
--- a/js/xmpp.js Sun Mar 20 23:42:22 2016 +0800
+++ b/js/xmpp.js Mon Mar 21 10:29:04 2016 +0800
@@ -1,9 +1,13 @@
// Generated by CoffeeScript 1.10.0
(function() {
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
Tram.XMPPInterface = (function() {
XMPPInterface.prototype.conn = null;
- function XMPPInterface() {}
+ function XMPPInterface() {
+ this.onConnect = bind(this.onConnect, this);
+ }
XMPPInterface.prototype._prepareConnection = function() {
if (this.conn != null) {
@@ -27,9 +31,9 @@
this.conn = null;
};
- XMPPInterface.prototype.startRegistration = function(onConnect) {
+ XMPPInterface.prototype.startRegistration = function() {
this._prepareConnection();
- return this.conn.register.connect(Tram.config.domain, onConnect);
+ return this.conn.register.connect(Tram.config.domain, this.onConnect);
};
XMPPInterface.prototype.register = function(username, password) {
@@ -38,6 +42,10 @@
return this.conn.register.submit();
};
+ XMPPInterface.prototype.finishRegistration = function() {
+ return this.conn.authenticate();
+ };
+
XMPPInterface.prototype.savevCard = function(data) {
var $vcard, b, bi, binval, bl, d, dl, failcb, okcb, type;
$vcard = $iq({
@@ -76,6 +84,44 @@
return this.conn.sendIQ($vcard.tree(), okcb, failcb);
};
+ XMPPInterface.prototype.onConnect = function(status, error) {
+ switch (status) {
+ case Strophe.Status.CONNECTING:
+ return console.debug('Strophe is connecting.');
+ case Strophe.Status.AUTHENTICATING:
+ return console.debug('Strophe is authenticating.');
+ case Strophe.Status.AUTHFAIL:
+ return console.debug('Strophe failed to authenticate:', error);
+ case Strophe.Status.ERROR:
+ return console.debug('Strophe received an error:', error);
+ case Strophe.Status.CONNFAIL:
+ return console.debug('Strophe failed to connect:', error);
+ case Strophe.Status.DISCONNECTING:
+ return console.debug('Strophe is disconnecting.');
+ case Strophe.Status.DISCONNECTED:
+ return console.debug('Strophe is disconnected.');
+ case Strophe.Status.CONNECTED:
+ console.debug('Strophe is connected.');
+ console.info('My jid:', this.conn.jid);
+ return this.trigger('v/start');
+ case Strophe.Status.REGISTER:
+ console.debug('Got registration prompt.');
+ return this.trigger('r/start');
+ case Strophe.Status.REGISTERED:
+ console.debug('Registered!');
+ return this.trigger('r/done');
+ case Strophe.Status.CONFLICT:
+ console.debug('Contact already exists!');
+ return this.trigger('r/conflict');
+ case Strophe.Status.NOTACCEPTABLE:
+ console.debug('Registration form not properly filled out.');
+ return this.trigger('r/failed');
+ case Strophe.Status.REGIFAIL:
+ console.debug('The server does not support In-Band Registration.');
+ return this.trigger('r/closed');
+ }
+ };
+
return XMPPInterface;
})();
--- a/js/xmpp.js.map Sun Mar 20 23:42:22 2016 +0800
+++ b/js/xmpp.js.map Mon Mar 21 10:29:04 2016 +0800
@@ -6,5 +6,5 @@
"coffee/xmpp.coffee"
],
"names": [],
- "mappings": ";AAAA;EAAM,IAAI,CAAC;4BACT,IAAA,GAAM;;IAEO,uBAAA,GAAA;;4BAEb,kBAAA,GAAoB,SAAA;MAClB,IAAG,iBAAH;QACE,OAAO,CAAC,KAAR,CAAc,qCAAd,EADF;;aAGA,IAAC,CAAA,IAAD,GAAY,IAAA,OAAO,CAAC,UAAR,CAAmB,UAAA,GAAY,IAAI,CAAC,MAAM,CAAC,IAAxB,GAA8B,YAAjD;IAJM;;4BAMpB,OAAA,GAAS,SAAC,IAAD,EAAO,IAAP,EAAa,SAAb;AACP,UAAA;MAAA,IAAC,CAAA,kBAAD,CAAA;MAEA,GAAA,GAAU,IAAF,GAAQ,GAAR,GAAY,IAAI,CAAC,MAAM,CAAC;aAChC,IAAC,CAAA,IAAI,CAAC,OAAN,CAAc,GAAd,EAAmB,IAAnB,EAAyB,SAAzB;IAJO;;4BAMT,UAAA,GAAY,SAAC,MAAD;MACV,IAAO,iBAAP;AACE,eADF;;MAGA,IAAC,CAAA,IAAI,CAAC,UAAN,CAAiB,MAAjB;MACA,IAAC,CAAA,IAAD,GAAQ;IALE;;4BAQZ,iBAAA,GAAm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