Commits

watermelon committed df5fd48

add license to every file, put settings storage to utils

Comments (0)

Files changed (16)

+#
+#  Copyright (C) 2011
+#    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+#    Metalab, 1010 Vienna, Austria
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
 SHELL = /bin/sh
 
 NODE = node

src/main/client/comm/Communicator.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class Communicator
  *

src/main/client/controller/Controller.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 //TODO MOVE ARGUMENT VALIDATION TO THOSE WHO CALL THE CONTROLLER
 //(keeps controller/the actual application logic code simple and readable)
 
 
 
 
-/**
- * bookmaak.controller.SETTING_TYPE = USER | GLOBAL
- * 
- * Enumeration of all setting types.
- **/
-bookmaak.controller.SETTING_TYPE = {
-	
-	USER:	"user_setting",
-	GLOBAL:	"global_setting"
-};
+
 
 
 /**
 
 
 /**
- * bookmaak.controller.Controller.addSetting(String, ANY, SETTING_TYPE) -> Boolean
- * 
- * Adds a setting by key/value, according to _type.
- * Assumes as state in http://dev.w3.org/html5/webstorage/#storage
- * 
- * **_key** the key
- * **_value** the value, my be of any type
- * **_type** the type
- * returns true on success, otherwise false.
- **/
-bookmaak.controller.Controller.addSetting = function(_key, _value, _type){
-	
-	if(typeof _key == 'undefined')
-		throw "_key is undefined.";
-	else if(Object.prototype.toString.call(_key) == "[object String]")
-			var key = _key;
-	else
-		throw "illegal argument _key.";
-	
-	if(typeof _value == 'undefined')
-		throw "_value is undefined.";
-	else
-		var value = _value;
-	
-	if(typeof _type == 'undefined')
-		throw "_type is undefined.";
-	else if(Object.prototype.toString.call(_type) == "[object String]")
-			var type = _type;
-	else
-		throw "illegal argument _type.";
-	
-	switch(type) {
-	
-		case bookmaak.controller.SETTING_TYPE.USER:
-			return addSetting(SETTINGS_PREFIX_USER, key, value);
-			break;
-			
-		case bookmaak.controller.SETTING_TYPE.GLOBAL:
-			return addSetting(SETTINGS_PREFIX_GLOBAL, key, value);
-			break;
-		default:
-			throw "illegal type.";
-	}
-};
-
-/**
- * bookmaak.controller.Controller.getSetting(String, SETTING_TYPE) -> ANY | null
- * 
- * Retrieves a setting by key, according to _type.
- * Assumes as state in http://dev.w3.org/html5/webstorage/#storage
- * 
- * **_key** the key
- * **_type** the type
- * returns true on success, otherwise false.
- **/
-bookmaak.controller.Controller.getSetting = function(_key, _type){
-	
-	if(typeof _key == 'undefined')
-		throw "_key is undefined.";
-	else if(Object.prototype.toString.call(_key) == "[object String]")
-			var key = _key;
-	else
-		throw "illegal argument _key.";
-	
-	if(typeof _type == 'undefined')
-		throw "_type is undefined.";
-	else if(Object.prototype.toString.call(_type) == "[object String]")
-			var type = _type;
-	else
-		throw "illegal argument _type.";
-	
-	switch(type) {
-	
-		case bookmaak.controller.SETTING_TYPE.USER:
-			return getSetting(SETTINGS_PREFIX_USER, key);
-			break;
-			
-		case bookmaak.controller.SETTING_TYPE.GLOBAL:
-			return getSetting(SETTINGS_PREFIX_GLOBAL, key);
-			break;
-		default:
-			throw "illegal type.";
-	}
-};
-
-/**
- * bookmaak.controller.Controller.removeSetting(String, SETTING_TYPE) -> Boolean
- * 
- * Removes a setting by key, according to _type.
- * Assumes as state in http://dev.w3.org/html5/webstorage/#storage
- * 
- * **_key** the key
- * **_type** the type
- * returns true on success, otherwise false.
- **/
-bookmaak.controller.Controller.removeSetting = function(_key, _type){
-	
-	if(typeof _key == 'undefined')
-		throw "_key is undefined.";
-	else if(Object.prototype.toString.call(_key) == "[object String]")
-			var key = _key;
-	else
-		throw "illegal argument _key.";
-	
-	if(typeof _type == 'undefined')
-		throw "_type is undefined.";
-	else if(Object.prototype.toString.call(_type) == "[object String]")
-			var type = _type;
-	else
-		throw "illegal argument _type.";
-	
-	switch(type) {
-	
-		case bookmaak.controller.SETTING_TYPE.USER:
-			return removeSetting(SETTINGS_PREFIX_USER, key);
-			break;
-			
-		case bookmaak.controller.SETTING_TYPE.GLOBAL:
-			return removeSetting(SETTINGS_PREFIX_GLOBAL, key);
-			break;
-		default:
-			throw "illegal type.";
-	}
-	
-};
-
-
-
-var SETTINGS_PREFIX_USER = "usr_";
-var SETTINGS_PREFIX_GLOBAL = "global_";
-
-function addSetting(key_prefix, key, serializedValue) {
-	
-	var prefixed_key = key_prefix + key;
-	var serialized_value = JSON.stringify(value);
-	
-	try {
-		
-		//send to localstore
-		localStorage.setItem(prefixed_key, serialized_value);
-		
-		return true;
-	}
-	catch(e) {//QuotaExceededError
-		
-		return false;
-	}
-}
-
-function getSetting(key_prefix, key) {
-	
-	var prefixed_key = key_prefix + key;
-	
-	//get from localstore
-	var serialized_value = localStorage.getItem(prefixed_key);
-	
-	if(serialized_value == null)
-		return true;
-	else
-		return JSON.parse(serialized_value);
-}
-
-function removeSetting(key_prefix, key) {
-	
-	var prefixed_key = key_prefix + key;
-	
-	//delete from localstore
-	localStorage.removeItem(prefixed_key);
-	
-	return true;
-}
-
-
-
-
-
-/**
  * bookmaak.controller.Controller.register(Object) -> Boolean
  *
  * To register a new "account".
 //						}
 						if(result.success) {
 							
-							//TODO
+							//save params to localstore TODO check results
+							bookmaak.controller.Controller.addSetting(
+									registrationData.login,
+									bookmaak.controller.SETTING_KEY.LOGIN,
+									registrationData.login);
+							
+							bookmaak.controller.Controller.addSetting(
+									registrationData.login,
+									bookmaak.controller.SETTING_KEY.PRIVATE_KEY,
+									registrationData.rsa_private_key_pem);
+							
+							bookmaak.controller.Controller.addSetting(
+									registrationData.login,
+									bookmaak.controller.SETTING_KEY.PUBLIC_KEY,
+									registrationData.rsa_public_key_pem);
+							
 							callback(result);
 						}
 						else {

src/main/client/crypto/BookmarkCrypto.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class BookmarkCrypto
  * 

src/main/client/crypto/CryptoUtils.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * bookmaak.crypto.CryptoUtils
  * 

src/main/client/crypto/UserCrypto.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class UserCrypto
  * 

src/main/client/dao/BookmarkDao.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class BookmarkDao
  *

src/main/client/domain/Bookmark.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class Bookmark
  *

src/main/client/domain/File.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * class File
  * 

src/main/client/namespaces.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * bookmaak
  *
  * Contains classes of domain objects.
  **/
 bookmaak.domain = bookmaak.domain || {};
+
+/**
+ * bookmaak.util
+ * 
+ * Utilities maybe used on any layer.
+ * Contains helper functions.
+ **/
+bookmaak.util = bookmaak.util || {};

src/main/client/ui/UiController.js

+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
 /**
  * bookmaak.ui.UiController
  * 

src/main/server/conf.bookmaak.js

-
+//
+//  Copyright (C) 2011
+//    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+//    Metalab, 1010 Vienna, Austria
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU Affero General Public License as published
+//  by the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU Affero General Public License for more details.
+//
+//  You should have received a copy of the GNU Affero General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
 
 
 Conf = function(){};

src/test/client/test.bm

+{
+  links: [
+    { title: 'Wikipedia - Universal Software Radio Peripheral',
+      url: 'http://en.wikipedia.org/wiki/Universal_Software_Radio_Peripheral',
+      tags: ['hardware','gnu','radio','usrp','universal','software','radio','periferal'],
+      metas: ['radio', 'gnu', 'wiki', 'wikipedia']
+    },
+    {}
+  ]
+}

test.bm

-{
-  links: [
-    { title: 'Wikipedia - Universal Software Radio Peripheral',
-      url: 'http://en.wikipedia.org/wiki/Universal_Software_Radio_Peripheral',
-      tags: ['hardware','gnu','radio','usrp','universal','software','radio','periferal'],
-      metas: ['radio', 'gnu', 'wiki', 'wikipedia']
-    },
-    {}
-  ]
-}

util/install-dependencies

 #! /bin/sh
-
+#
+#  Copyright (C) 2011
+#    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+#    Metalab, 1010 Vienna, Austria
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 
 
 install_dependency(){
 #!/bin/sh
+#
+#  Copyright (C) 2011
+#    Mario Gastegger <mario DOT gastegger AT gmx DOT net>, uniqx
+#    Metalab, 1010 Vienna, Austria
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 
 mkdir -p build/javascript/
 
 add src/main/client/domain/Bookmark.js
 add src/main/client/domain/File.js
 
+add src/main/client/util/FTS.js
+add src/main/client/util/Settings.js
+
 add src/main/client/dao/BookmarkDao.js
 
 add src/main/client/crypto/CryptoUtils.js