Commit 75d7758a authored by Thibaut Frain's avatar Thibaut Frain

Xmpp server is now an url parameter

parent 05e29c21
...@@ -90,10 +90,14 @@ ...@@ -90,10 +90,14 @@
return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) { return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) {
return contactlist_gadget.messagesAreRead(jid[0]); return contactlist_gadget.messagesAreRead(jid[0]);
}); });
}).allowPublicAcquisition("renderConnection", function() { }).allowPublicAcquisition("renderConnection", function(options) {
return this.aq_pleasePublishMyState({ var new_options = {
page: "connection" page: "connection"
}).push(this.pleaseRedirectMyHash.bind(this)); };
if (options[0].server !== undefined) {
new_options.server = options[0].server;
}
return this.aq_pleasePublishMyState(new_options).push(this.pleaseRedirectMyHash.bind(this));
}).ready(function(g) { }).ready(function(g) {
g.props = {}; g.props = {};
$("[data-role='header']").toolbar(); $("[data-role='header']").toolbar();
...@@ -124,14 +128,13 @@ ...@@ -124,14 +128,13 @@
}).push(function(is_connected) { }).push(function(is_connected) {
// default page // default page
if (options.page === undefined) { if (options.page === undefined) {
return gadget.aq_pleasePublishMyState({ options.page = "contactlist";
page: "contactlist" return gadget.aq_pleasePublishMyState(options).push(gadget.pleaseRedirectMyHash.bind(gadget));
}).push(gadget.pleaseRedirectMyHash.bind(gadget));
} }
if (!is_connected && options.page !== "connection") { if (!is_connected && options.page !== "connection") {
gadget.props.came_from = options; gadget.props.came_from = options;
return gadget.getDeclaredGadget("connection").push(function(connection_gadget) { return gadget.getDeclaredGadget("connection").push(function(connection_gadget) {
return connection_gadget.tryAutoConnect(); return connection_gadget.tryAutoConnect(options);
}); });
} }
return gadget.getDeclaredGadget(options.page).push(function(g) { return gadget.getDeclaredGadget(options.page).push(function(g) {
......
...@@ -17,11 +17,9 @@ ...@@ -17,11 +17,9 @@
<script class="login-template" type="text/x-handlebars-template"> <script class="login-template" type="text/x-handlebars-template">
<div class="login-box ui-corner-all ui-shadow"> <div class="login-box ui-corner-all ui-shadow">
<h3>Status: Not connected</h3><br/> <h3>Status: Not connected</h3>
<h5>XMPP Server:&nbsp{{server}}</h5>
<form class="login-form" data-ajax="false"> <form class="login-form" data-ajax="false">
<div class="ui-field-contain">
<input type="url" name="server" placeholder="Jabber server url" value="{{server}}" required>
</div>
<div class="ui-field-contain"> <div class="ui-field-contain">
<input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required> <input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required>
</div> </div>
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
} }
function showLogin(gadget, options) { function showLogin(gadget, options) {
var params = { var params = {
server: "https://mail.tiolive.com/chat/http-bind/" server: options.server
}; };
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
if (options && options.authfail) { if (options && options.authfail) {
...@@ -126,16 +126,20 @@ ...@@ -126,16 +126,20 @@
return this.props.connection.send(parseXML(xmlString)); return this.props.connection.send(parseXML(xmlString));
}).declareMethod("logout", function() { }).declareMethod("logout", function() {
logout(this); logout(this);
}).declareAcquiredMethod("renderConnection", "renderConnection").declareMethod("tryAutoConnect", function() { }).declareAcquiredMethod("renderConnection", "renderConnection").declareMethod("tryAutoConnect", function(options) {
var params = JSON.parse(sessionStorage.getItem("connection_params")); var params = JSON.parse(sessionStorage.getItem("connection_params"));
if (params !== null && typeof params === "object" && Object.keys(params).length === 3) { if (params !== null && typeof params === "object" && Object.keys(params).length === 3) {
this.manageService(connectionListener(this, params)); this.manageService(connectionListener(this, params));
} else { } else {
return this.renderConnection(); return this.renderConnection(options);
} }
}).ready(function(g) { }).ready(function(g) {
g.props = {}; g.props = {};
}).declareMethod("render", function(options) { }).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("getHash", "getHash").declareMethod("render", function(options) {
if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/";
return this.getHash(options).push(this.pleaseRedirectMyHash.bind(this));
}
if (this.props.connection && this.props.connection.authenticated) { if (this.props.connection && this.props.connection.authenticated) {
return showLogout(this); return showLogout(this);
} }
......
...@@ -135,8 +135,14 @@ ...@@ -135,8 +135,14 @@
}); });
}) })
.allowPublicAcquisition('renderConnection', function () { .allowPublicAcquisition('renderConnection', function (options) {
return this.aq_pleasePublishMyState({page: "connection"}) var new_options = {
page: "connection"
};
if (options[0].server !== undefined) {
new_options.server = options[0].server;
}
return this.aq_pleasePublishMyState(new_options)
.push(this.pleaseRedirectMyHash.bind(this)); .push(this.pleaseRedirectMyHash.bind(this));
}) })
...@@ -183,7 +189,8 @@ ...@@ -183,7 +189,8 @@
.push(function (is_connected) { .push(function (is_connected) {
// default page // default page
if (options.page === undefined) { if (options.page === undefined) {
return gadget.aq_pleasePublishMyState({page: "contactlist"}) options.page = "contactlist";
return gadget.aq_pleasePublishMyState(options)
.push(gadget.pleaseRedirectMyHash.bind(gadget)); .push(gadget.pleaseRedirectMyHash.bind(gadget));
} }
...@@ -191,7 +198,7 @@ ...@@ -191,7 +198,7 @@
gadget.props.came_from = options; gadget.props.came_from = options;
return gadget.getDeclaredGadget("connection") return gadget.getDeclaredGadget("connection")
.push(function (connection_gadget) { .push(function (connection_gadget) {
return connection_gadget.tryAutoConnect(); return connection_gadget.tryAutoConnect(options);
}); });
} }
return gadget.getDeclaredGadget(options.page) return gadget.getDeclaredGadget(options.page)
......
...@@ -17,11 +17,9 @@ ...@@ -17,11 +17,9 @@
<script class="login-template" type="text/x-handlebars-template"> <script class="login-template" type="text/x-handlebars-template">
<div class="login-box ui-corner-all ui-shadow"> <div class="login-box ui-corner-all ui-shadow">
<h3>Status: Not connected</h3><br/> <h3>Status: Not connected</h3>
<h5>XMPP Server:&nbsp{{server}}</h5>
<form class="login-form" data-ajax="false"> <form class="login-form" data-ajax="false">
<div class="ui-field-contain">
<input type="url" name="server" placeholder="Jabber server url" value="{{server}}" required>
</div>
<div class="ui-field-contain"> <div class="ui-field-contain">
<input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required> <input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required>
</div> </div>
......
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
function showLogin(gadget, options) { function showLogin(gadget, options) {
var params = { var params = {
server: "https://mail.tiolive.com/chat/http-bind/" server: options.server
}; };
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -193,14 +193,14 @@ ...@@ -193,14 +193,14 @@
.declareAcquiredMethod("renderConnection", "renderConnection") .declareAcquiredMethod("renderConnection", "renderConnection")
.declareMethod("tryAutoConnect", function () { .declareMethod("tryAutoConnect", function (options) {
var params = JSON.parse(sessionStorage.getItem('connection_params')); var params = JSON.parse(sessionStorage.getItem('connection_params'));
if (params !== null && if (params !== null &&
typeof params === 'object' && typeof params === 'object' &&
Object.keys(params).length === 3) { Object.keys(params).length === 3) {
this.manageService(connectionListener(this, params)); this.manageService(connectionListener(this, params));
} else { } else {
return this.renderConnection(); return this.renderConnection(options);
} }
}) })
...@@ -208,7 +208,16 @@ ...@@ -208,7 +208,16 @@
g.props = {}; g.props = {};
}) })
.declareAcquiredMethod('pleaseRedirectMyHash', 'pleaseRedirectMyHash')
.declareAcquiredMethod('getHash', 'getHash')
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/";
return this.getHash(options)
.push(this.pleaseRedirectMyHash.bind(this));
}
if (this.props.connection && if (this.props.connection &&
this.props.connection.authenticated) { this.props.connection.authenticated) {
return showLogout(this); return showLogout(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment