window mode

This commit is contained in:
Rodolphe Breard 2012-11-07 10:53:48 +01:00
parent 6864c4389d
commit d2570a8e41
7 changed files with 60 additions and 68 deletions

View file

@ -16,7 +16,7 @@ Sockets have been introduced in Chromium 24. Therefore, it is required to have a
## Features ## Features
### Password encryption ### Password encryption
Storing your socks password encrypted is a priority but is not available yet. Yes, the chromesoul dev version is unsafe; so is the official NetSoul server which doesn't store a hash but the password itself (it's a requirement from the NetSoul protocol). Storing your socks password encrypted is a priority but is not available yet. Yes, the chromesoul dev version is unsafe; so is the official NetSoul server which doesn't store a hash but the password itself (it's required by the NetSoul protocol).
### Messages ### Messages
Because the only purpose of this extension is to provide an access to internet when you're on the PIE, there is no plan to support messages at this time. Thoses stupid guys who have fun spamming everyone by broadcasting messages are the second reasons why you won't see any message using chromesoul. Maybe one day I'll write a chat interface, however it will be unobtrusive. Because the only purpose of this extension is to provide an access to internet when you're on the PIE, there is no plan to support messages at this time. Thoses stupid guys who have fun spamming everyone by broadcasting messages are the second reasons why you won't see any message using chromesoul. Maybe one day I'll write a chat interface, however it will be unobtrusive.
@ -39,17 +39,11 @@ Because it's not packaged yet, you have to:
### Will you package it? ### Will you package it?
Yes, as soon as sockets are supported in the stable channel. Yes, as soon as sockets are supported in the stable channel.
### Where do I enter my login and password? ### How do I start chromesoul?
Why haven't you already looked at the extension's options? Yes, it's there. Just like any other app:
* open a new tab (Ctrl + T)
## The option pages doesn't work! * click on the "apps" tab (have a look at the bottom of the page)
It used to work, but for unknown reason it doesn't anymore. Such things may happened on the dev channel, however I'll try to fix it. * click on "chromesoul"
### Why chromesoul doesn't start with chrome?
This is a known issue, I'm working on it. Sockets aren't available for extensions, packaged app cannot define custom background pages and hosted app isn't a solution.
## How do I start chromesoul?
In the extension pannel, click on the link "_generated_background_page.html" within the "Inspect views" section.
### Could not load extension from '/path/to/chromesoul'. Invalid value for 'permissions[2]'. ### Could not load extension from '/path/to/chromesoul'. Invalid value for 'permissions[2]'.
It seems your browser doesn't support sockets. Have you checked the requirements? It seems your browser doesn't support sockets. Have you checked the requirements?
@ -69,7 +63,7 @@ Maybe. If someone pay me I will, otherwise I'll do it if have time to invest in
### I talked to you on netsoul but you never reply! ### I talked to you on netsoul but you never reply!
I started this project for my personal usage, which means I use it. Now look at the features list and the previous questions. I started this project for my personal usage, which means I use it. Now look at the features list and the previous questions.
### I found a bug! ### I found a bug, what should I do?
Hum, please [report it](https://github.com/TychoBrahe/chromesoul/issues) with as much details as you can. Thanks in advance. Hum, please [report it](https://github.com/TychoBrahe/chromesoul/issues) with as much details as you can. Thanks in advance.
### I hate chromesoul! ### I hate chromesoul!

24
background.html Normal file
View file

@ -0,0 +1,24 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Chromesoul</title>
</head>
<body>
<h1>Welcome to chromesoul</h1>
<fieldset>
<legend>Connection informations</legend>
Login: <input type="text" id="login" class="opt"><br>
Password (socks): <input type="password" id="pwd_socks", class="opt"><br>
<button id="save">Save</button> <span id="status"></span>
</fieldset>
<p>Status: <span id="status_txt"></span></p>
<div><button id="reconnect">Reconnect</button></div>
<script type="text/javascript" src="third-party/md5-min.js"></script>
<script type="text/javascript" src="third-party/ab-str.js"></script>
<script type="text/javascript" src="lib/ns_client.js"></script>
<script type="text/javascript" src="lib/options.js"></script>
<script type="text/javascript" src="start.js"></script>
</body>
</html>

View file

@ -14,5 +14,9 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// //
var cs = new NsClient(); chrome.app.runtime.onLaunched.addListener(function(intentData) {
cs.init(); //if (window.chrome && window.chrome.app && window.chrome.app.isInstalled) {
if (window.chrome && window.chrome.app) {
window.open("background.html#0", "bg", "background");
}
});

View file

@ -20,26 +20,17 @@ var NsClient = function() {
this.allowed_statuses = ["actif", "away", "idle", "lock"]; this.allowed_statuses = ["actif", "away", "idle", "lock"];
this.is_connected = false; this.is_connected = false;
this.socket = null; this.socket = null;
this.verbose = false;
}; };
NsClient.prototype.connect = function() { NsClient.prototype.connect = function() {
var cnt = function(elem) { var cnt = function(elem) {
return function(infos) { return function(infos) {
if (typeof infos.login !== "undefined" && typeof infos.pwd_socks !== "undefined") { if (typeof infos.login !== "undefined" && typeof infos.pwd_socks !== "undefined") {
if (elem.verbose)
console.log('creating socket...');
chrome.socket.create('tcp', {}, function(sock_inf) { chrome.socket.create('tcp', {}, function(sock_inf) {
if (elem.verbose)
console.log('socket created, id: ' + sock_inf.socketId);
elem.socket = sock_inf.socketId; elem.socket = sock_inf.socketId;
chrome.socket.connect(elem.socket, "ns-server.epita.fr", 4242, function(res) { chrome.socket.connect(elem.socket, "ns-server.epita.fr", 4242, function(res) {
if (elem.verbose)
console.log('connected to server');
chrome.socket.read(elem.socket, null, function(rd_inf) { chrome.socket.read(elem.socket, null, function(rd_inf) {
if (rd_inf.resultCode > 0) { if (rd_inf.resultCode > 0) {
if (elem.verbose)
console.log(ab2str(rd_inf.data));
var data = ab2str(rd_inf.data).split(' '), var data = ab2str(rd_inf.data).split(' '),
auth = "ext_user_log "; auth = "ext_user_log ";
auth += infos.login + " "; auth += infos.login + " ";
@ -92,13 +83,8 @@ NsClient.prototype.daemonize = function() {
if (rd_inf.resultCode > 0) { if (rd_inf.resultCode > 0) {
var data = ab2str(rd_inf.data); var data = ab2str(rd_inf.data);
if (elem.verbose)
console.log("recv: " + data);
if (data.substr(0, 5) === "ping ") { if (data.substr(0, 5) === "ping ") {
chrome.socket.write(elem.socket, rd_inf.data, function(w_inf) { chrome.socket.write(elem.socket, rd_inf.data, function(w_inf) {
if (elem.verbose)
console.log("sent: " + data);
chrome.socket.read(elem.socket, null, this); chrome.socket.read(elem.socket, null, this);
}); });
} }
@ -114,20 +100,20 @@ NsClient.prototype.daemonize = function() {
}; };
NsClient.prototype.updateStatus = function() { NsClient.prototype.updateStatus = function() {
var status_txt = document.getElementById("status_txt");
console.log(status_txt);
if (this.is_connected) { if (this.is_connected) {
if (status_txt !== null)
status_txt.innerHTML = this.state;
var status_msg = "user_cmd state "; var status_msg = "user_cmd state ";
status_msg += this.state + ":"; status_msg += this.state + ":";
status_msg += Math.round(new Date().getTime() / 1000) + "\n"; status_msg += Math.round(new Date().getTime() / 1000) + "\n";
chrome.socket.write(this.socket, str2ab(status_msg), function(w_inf) {}); chrome.socket.write(this.socket, str2ab(status_msg), function(w_inf) {});
} else { } else {
console.warn("not connected"); if (status_txt !== null)
} status_txt.innerHTML = 'disconnected';
};
NsClient.prototype.recv = function() {
if (this.is_connected) {
} else {
console.warn("not connected");
} }
}; };
@ -144,14 +130,12 @@ NsClient.prototype.changeStatus = function(new_status) {
}; };
NsClient.prototype.init = function() { NsClient.prototype.init = function() {
var upd = function(elem) { var status_update = function(elem) {
return function() { return function() {
if (elem.is_connected) {
elem.updateStatus(); elem.updateStatus();
}
}; };
}, },
con = function(elem) { connect = function(elem) {
return function() { return function() {
if (!elem.is_connected) { if (!elem.is_connected) {
elem.connect(); elem.connect();
@ -159,7 +143,8 @@ NsClient.prototype.init = function() {
}; };
}; };
con(this).apply(); status_update(this).apply();
setInterval(con(this), 10000); connect(this).apply();
setInterval(upd(this), 600000); setInterval(connect(this), 10000);
setInterval(status_update(this), 600000);
}; };

View file

@ -1,17 +1,12 @@
{ {
"name": "chromesoul", "name": "chromesoul",
"version": "0.1.1", "version": "0.2.1",
"manifest_version": 2, "manifest_version": 2,
"offline_enabled": false, "offline_enabled": false,
"description": "A minimalist NetSoul client.", "description": "A minimalist NetSoul client.",
"options_page": "options.html",
"app": { "app": {
"background": { "background": {
"scripts": ["third-party/md5-min.js", "scripts": ["background.js"]
"third-party/ab-str.js",
"lib/ns_client.js",
"background.js"
]
} }
}, },
"permissions": [ "permissions": [

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Chromesoul options</title>
</head>
<body>
<div>
Login: <input type="text" id="login" class="opt"><br>
Password (socks): <input type="password" id="pwd_socks", class="opt"><br>
<button id="save">Save</button>
</div>
<div id="status"></div>
<script src="lib/options.js"></script>
</body>
</html>

6
start.js Normal file
View file

@ -0,0 +1,6 @@
var cs = new NsClient();
cs.init();
document.getElementById('reconnect').addEventListener('click', function() {
cs.disconnect();
cs.connect();
}, false);