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

Xmpp server is now an url parameter

parent 05e29c21
......@@ -90,10 +90,14 @@
return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) {
return contactlist_gadget.messagesAreRead(jid[0]);
});
}).allowPublicAcquisition("renderConnection", function() {
return this.aq_pleasePublishMyState({
}).allowPublicAcquisition("renderConnection", function(options) {
var new_options = {
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) {
g.props = {};
$("[data-role='header']").toolbar();
......@@ -124,14 +128,13 @@
}).push(function(is_connected) {
// default page
if (options.page === undefined) {
return gadget.aq_pleasePublishMyState({
page: "contactlist"
}).push(gadget.pleaseRedirectMyHash.bind(gadget));
options.page = "contactlist";
return gadget.aq_pleasePublishMyState(options).push(gadget.pleaseRedirectMyHash.bind(gadget));
}
if (!is_connected && options.page !== "connection") {
gadget.props.came_from = options;
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) {
......
......@@ -17,11 +17,9 @@
<script class="login-template" type="text/x-handlebars-template">
<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">
<div class="ui-field-contain">
<input type="url" name="server" placeholder="Jabber server url" value="{{server}}" required>
</div>
<div class="ui-field-contain">
<input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required>
</div>
......
......@@ -99,7 +99,7 @@
}
function showLogin(gadget, options) {
var params = {
server: "https://mail.tiolive.com/chat/http-bind/"
server: options.server
};
return new RSVP.Queue().push(function() {
if (options && options.authfail) {
......@@ -126,16 +126,20 @@
return this.props.connection.send(parseXML(xmlString));
}).declareMethod("logout", function() {
logout(this);
}).declareAcquiredMethod("renderConnection", "renderConnection").declareMethod("tryAutoConnect", function() {
}).declareAcquiredMethod("renderConnection", "renderConnection").declareMethod("tryAutoConnect", function(options) {
var params = JSON.parse(sessionStorage.getItem("connection_params"));
if (params !== null && typeof params === "object" && Object.keys(params).length === 3) {
this.manageService(connectionListener(this, params));
} else {
return this.renderConnection();
return this.renderConnection(options);
}
}).ready(function(g) {
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) {
return showLogout(this);
}
......
......@@ -135,8 +135,14 @@
});
})
.allowPublicAcquisition('renderConnection', function () {
return this.aq_pleasePublishMyState({page: "connection"})
.allowPublicAcquisition('renderConnection', function (options) {
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));
})
......@@ -183,7 +189,8 @@
.push(function (is_connected) {
// default page
if (options.page === undefined) {
return gadget.aq_pleasePublishMyState({page: "contactlist"})
options.page = "contactlist";
return gadget.aq_pleasePublishMyState(options)
.push(gadget.pleaseRedirectMyHash.bind(gadget));
}
......@@ -191,7 +198,7 @@
gadget.props.came_from = options;
return gadget.getDeclaredGadget("connection")
.push(function (connection_gadget) {
return connection_gadget.tryAutoConnect();
return connection_gadget.tryAutoConnect(options);
});
}
return gadget.getDeclaredGadget(options.page)
......
......@@ -17,11 +17,9 @@
<script class="login-template" type="text/x-handlebars-template">
<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">
<div class="ui-field-contain">
<input type="url" name="server" placeholder="Jabber server url" value="{{server}}" required>
</div>
<div class="ui-field-contain">
<input type="text" name="jid" placeholder="Jabber ID" value="{{jid}}" required>
</div>
......
......@@ -139,7 +139,7 @@
function showLogin(gadget, options) {
var params = {
server: "https://mail.tiolive.com/chat/http-bind/"
server: options.server
};
return new RSVP.Queue()
.push(function () {
......@@ -193,14 +193,14 @@
.declareAcquiredMethod("renderConnection", "renderConnection")
.declareMethod("tryAutoConnect", function () {
.declareMethod("tryAutoConnect", function (options) {
var params = JSON.parse(sessionStorage.getItem('connection_params'));
if (params !== null &&
typeof params === 'object' &&
Object.keys(params).length === 3) {
this.manageService(connectionListener(this, params));
} else {
return this.renderConnection();
return this.renderConnection(options);
}
})
......@@ -208,7 +208,16 @@
g.props = {};
})
.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) {
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