Commit 4525e4b7 authored by Sebastien Robin's avatar Sebastien Robin

bug fixes done by Francois (sorry, I do not have details)

parent 2e3330ea
......@@ -14,22 +14,60 @@ var displayNewAccountForm = function(bool) {
}
}
function logIntoDav(wallet) {
var recall = window.location;
window.location.href = wallet.storageLocation+"#"+recall;
}
/**
* create a new storage
*/
function initStorage(wallet) {
if(!wallet.provider) {//local storage
/**
* load JIO file from a DAV and create and return the JIO object
* This function will be replaced. The aim is to load JIO in more various ways, and use JIO.initialize after
* @param userName : name of the user
* @param location : server location
* @param applicant : (optional) information about the person/application needing this JIO object (allow limited access)
* @return JIO object
if(wallet.provider) {//DAV storage
// load JIO file from a DAV and create the JIO object
initializeFromDav(wallet.userName, wallet.storageLocation, {"ID":"www.ungproject.com", "password":wallet.applicationPassword});
} else {
Storage.create('{"type":"local","userName":"'+wallet.userName+'"}');
}
}
/**
* try to log an user just after having logged in their Dav account
* if the user is logged, it means that getApplicationPasswordFromURL has a result
*/
function tryLog() {
var wallet = getWallet();
var applicationPassword = getApplicationPasswordFromURL();
if(applicationPassword) {
wallet.applicationPassword = applicationPassword;
setWallet(wallet);//to delete for new registration each time
initStorage(wallet);
//go to ung when the storage is ready
waitBeforeSucceed(function() {return getCurrentStorage().getUser();},function(){window.location.href = "ung.html";});
}
}
/**
* Log an user after they fill their Name and storage provider
*/
(function initializeFromDav(userName, location, applicant) {
function logUser() {
var wallet = new Wallet();
setWallet(wallet);
if(!wallet.userName) {return;}
if(wallet.provider) {
if(!wallet.storageLocation) {alert("unable to find your storage from your provider");return;}
if(!wallet.applicationPassword) {logIntoDav(wallet);return;}
}
initStorage(wallet);
//go to ung when the storage is ready
waitBeforeSucceed(function() {return getCurrentStorage().getUser();},function(){window.location.href = "ung.html";});
}
/***************************************************************************
********************** Unhosted functions *****************************
* these function are only required to respect the unhosted architecture */
// load JIO file from a DAV and create the JIO object
function initializeFromDav(userName, location, applicant) {
//get the user personal JIO file
$.ajax({
url: location+"/dav/"+userName+"/"+applicant.ID+"/"+"jio.json",//we could use userAdress instead...
......@@ -44,16 +82,9 @@ function initStorage(wallet) {
error: function(type) {alert("Error "+type.status+" : fail while trying to load jio.json");}
});
return JIO;
})(wallet.userName, wallet.storageLocation, {"ID":"www.ungproject.com", "password":wallet.applicationPassword});
} else {
Storage.create('{"type":"local","userName":"'+wallet.userName+'"}');
}
}
//unhosted functions
function getStorageLocation(provider) {
//TODO : uses webFinger
//TODO : use webFinger
return "http://"+provider;
}
function getApplicationPasswordFromURL() {
......@@ -70,36 +101,10 @@ var Wallet = function() {
this.provider = $("input#storage_location").attr("value");
this.storageLocation = getStorageLocation(this.provider);
}
/**
* try to log an user after having logged in their Dav account
*/
function tryLog() {
var wallet = getWallet();
var applicationPassword = getApplicationPasswordFromURL();
if(applicationPassword) {
wallet.applicationPassword = applicationPassword;
setWallet(wallet);//to delete for new registration each time
initStorage(wallet);
waitBeforeSucceed(function() {return getCurrentStorage().getUser();},function(){window.location.href = "ung.html";});
}
}
/**
* Log an user with it's Name and storage provider
*/
function logUser() {
var wallet = new Wallet();
setWallet(wallet);
if(!wallet.userName) {return;}
if(wallet.provider) {
if(!wallet.storageLocation) {alert("unable to find your storage from your provider");return;}
if(!wallet.applicationPassword) {logIntoDav(wallet);return;}
}
initStorage(wallet);
waitBeforeSucceed(function() {return getCurrentStorage().getUser();},function(){window.location.href = "ung.html";});
//redirects the application to the storage of the user to log the application in and get the password for the application
function logIntoDav(wallet) {
var recall = window.location;
window.location.href = wallet.storageLocation+"#"+recall;
}
......@@ -109,7 +114,9 @@ function logUser() {
/**********************************************************************
* functions from UNG Docs 1.0 and not currently used
*/
/**
......
......@@ -287,7 +287,7 @@ Storage.load({
success: function(list) {
delete list[getCurrentUser().getName()+".profile"];//remove the profile file
getCurrentStorage().documentList = list;
fireEvent(Storage.LIST_READY);
Storage.fireEvent(Storage.LIST_READY);
}
}
JIO.getDocumentList(option);
......@@ -303,7 +303,7 @@ Storage.load({
setUser: function(user) {
this.user = user;
this.userName = user.getName();
fireEvent(Storage.USER_READY);
Storage.fireEvent(Storage.USER_READY);
this.updateDocumentList();
getCurrentStorage().save();
......
......@@ -6,7 +6,9 @@
* Class UngObject
* provides useful general methods
*/
UngObject = function() {}
UngObject = function() {
this.listenerList = [];
}
/* return true if this object implements the interface */
UngObject.prototype.implement = function(myInterface)
{
......
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