From fc6618b443db7f7c93652e2e8617001480bcd480 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Sun, 15 Sep 2013 15:13:19 +0200 Subject: [PATCH] refactor config strings to be maintained centrally --- src/js/app-config.js | 22 ++++++++++++++++++---- src/js/app-controller.js | 22 +++++++++++----------- src/js/dao/email-dao.js | 7 +++---- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/js/app-config.js b/src/js/app-config.js index 6ddf6f5..851f275 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -4,9 +4,7 @@ define([], function() { /** * Create the application namespace */ - var app = { - util: {} - }; + var app = {}; /** * Global app configurations @@ -16,9 +14,25 @@ define([], function() { symKeySize: 128, symIvSize: 128, asymKeySize: 1024, - workerPath: 'js' + workerPath: 'js', + gmail: { + clientId: '440907777130.apps.googleusercontent.com', + imap: { + secure: true, + port: 993, + host: 'imap.gmail.com' + }, + smtp: { + secure: true, + port: 465, + host: 'smtp.gmail.com' + } + } }; + /** + * Strings are maintained here + */ app.string = { signature: 'Sent securely from whiteout mail' }; diff --git a/src/js/app-controller.js b/src/js/app-controller.js index 6c3471d..8967e91 100644 --- a/src/js/app-controller.js +++ b/src/js/app-controller.js @@ -10,7 +10,7 @@ define(function(require) { EmailDAO = require('js/dao/email-dao'), KeychainDAO = require('js/dao/keychain-dao'), cloudstorage = require('js/dao/cloudstorage-dao'), - app = require('js/app-config'); + config = require('js/app-config').config; require('cordova'); var self = {}; @@ -72,20 +72,20 @@ define(function(require) { auth = { XOAuth2: { user: userId, - clientId: '440907777130.apps.googleusercontent.com', + clientId: config.gmail.clientId, accessToken: token } }; imapOptions = { - secure: true, - port: 993, - host: 'imap.gmail.com', + secure: config.gmail.imap.secure, + port: config.gmail.imap.port, + host: config.gmail.imap.host, auth: auth }; smtpOptions = { - secure: true, - port: 465, - host: 'smtp.gmail.com', + secure: config.gmail.smtp.secure, + port: config.gmail.smtp.port, + host: config.gmail.smtp.host, auth: auth }; @@ -98,9 +98,9 @@ define(function(require) { // init email dao var account = { emailAddress: userId, - symKeySize: app.config.symKeySize, - symIvSize: app.config.symIvSize, - asymKeySize: app.config.asymKeySize + symKeySize: config.symKeySize, + symIvSize: config.symIvSize, + asymKeySize: config.asymKeySize }; self._emailDao.init(account, password, callback); }; diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index a91aabb..a16ff7d 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -5,8 +5,7 @@ define(function(require) { util = require('cryptoLib/util'), crypto = require('js/crypto/crypto'), jsonDB = require('js/dao/lawnchair-dao'), - devicestorage = require('js/dao/devicestorage-dao'), - app = require('js/app-config'); + devicestorage = require('js/dao/devicestorage-dao'); var SUBJECT = '[whiteout] Encrypted message', MESSAGE = 'this is a private conversation. To read my encrypted message below, simply install Whiteout Mail for Chrome. The app is really easy to use and automatically encrypts sent emails, so that only the two of us can read them: https://chrome.google.com/webstore/detail/whiteout-mail/jjgghafhamholjigjoghcfcekhkonijg\n\n\n', @@ -511,9 +510,9 @@ define(function(require) { // cache collection in folder memory if (decryptedList.length > 0) { - folder = new app.model.Folder({ + folder = { name: folderName - }); + }; folder.set('items', decryptedList); self._account.get('folders').add(folder); }