mirror of
https://github.com/moparisthebest/mail
synced 2025-01-31 15:10:13 -05:00
WIP: start new service architecture
This commit is contained in:
parent
f11d4e8df3
commit
628beb02e8
@ -41,7 +41,7 @@ ctrl.start = function(options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctrl.started = true;
|
ctrl.started = true;
|
||||||
ctrl.onError = options.onError;
|
ctrl.onError = options.onError; // TODO: replace by errorService
|
||||||
|
|
||||||
// are we running in a cordova app or in a browser environment?
|
// are we running in a cordova app or in a browser environment?
|
||||||
if (window.cordova) {
|
if (window.cordova) {
|
||||||
@ -57,16 +57,21 @@ ctrl.start = function(options, callback) {
|
|||||||
function onDeviceReady() {
|
function onDeviceReady() {
|
||||||
axe.debug('Starting app.');
|
axe.debug('Starting app.');
|
||||||
|
|
||||||
|
// TODO: will be replaced by angular dependency management
|
||||||
ctrl.buildModules();
|
ctrl.buildModules();
|
||||||
|
|
||||||
|
// TODO: move self-contained connection management in emailDao
|
||||||
// Handle offline and online gracefully
|
// Handle offline and online gracefully
|
||||||
window.addEventListener('online', ctrl.onConnect.bind(ctrl, ctrl.onError));
|
window.addEventListener('online', ctrl.onConnect.bind(ctrl, ctrl.onError));
|
||||||
window.addEventListener('offline', ctrl.onDisconnect.bind(ctrl));
|
window.addEventListener('offline', ctrl.onDisconnect.bind(ctrl));
|
||||||
|
|
||||||
|
// TODO: move appConfigService shared singleton
|
||||||
ctrl._appConfigStore.init('app-config', callback);
|
ctrl._appConfigStore.init('app-config', callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: will be replaced by angular dependency management
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the dependency tree.
|
* Initialize the dependency tree.
|
||||||
*/
|
*/
|
||||||
@ -121,6 +126,8 @@ ctrl.checkForUpdate = function() {
|
|||||||
ctrl._updateHandler.checkForUpdate(ctrl.onError);
|
ctrl._updateHandler.checkForUpdate(ctrl.onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: move to AccountService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fire up the database, retrieve the available keys for the user and initialize the email data access object
|
* Fire up the database, retrieve the available keys for the user and initialize the email data access object
|
||||||
*/
|
*/
|
||||||
@ -207,6 +214,8 @@ ctrl.isOnline = function() {
|
|||||||
return navigator.onLine;
|
return navigator.onLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: move to AccountService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler that is called when the user agent goes offline.
|
* Event handler that is called when the user agent goes offline.
|
||||||
*/
|
*/
|
||||||
@ -214,6 +223,8 @@ ctrl.onDisconnect = function() {
|
|||||||
ctrl._emailDao.onDisconnect();
|
ctrl._emailDao.onDisconnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: move to AccountService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log the current user out by clear the app config store and deleting instances of imap-client and pgp-mailer.
|
* Log the current user out by clear the app config store and deleting instances of imap-client and pgp-mailer.
|
||||||
*/
|
*/
|
||||||
@ -243,6 +254,8 @@ ctrl.logout = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: move onConnect to emailDao
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is called when the user agent goes online. This create new instances of the imap-client and pgp-mailer and connects to the mail server.
|
* Event that is called when the user agent goes online. This create new instances of the imap-client and pgp-mailer and connects to the mail server.
|
||||||
*/
|
*/
|
||||||
|
@ -37,8 +37,7 @@ var DialogCtrl = require('./controller/dialog'),
|
|||||||
errorUtil = require('./util/error'),
|
errorUtil = require('./util/error'),
|
||||||
backButtonUtil = require('./util/backbutton-handler');
|
backButtonUtil = require('./util/backbutton-handler');
|
||||||
require('./directive/common'),
|
require('./directive/common'),
|
||||||
require('./service/newsletter'),
|
require('./service');
|
||||||
require('./service/mail-config');
|
|
||||||
|
|
||||||
// init main angular module including dependencies
|
// init main angular module including dependencies
|
||||||
var app = angular.module('mail', [
|
var app = angular.module('mail', [
|
||||||
|
41
src/js/service/account.js
Normal file
41
src/js/service/account.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ngModule = angular.module('woServices');
|
||||||
|
ngModule.service('account', Account);
|
||||||
|
|
||||||
|
var EmailDAO = require('../dao/email-dao');
|
||||||
|
|
||||||
|
function Account() {
|
||||||
|
this._emailDAOs = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all of the current accounts connected to the app
|
||||||
|
* @return {Array<Object>} The account objects containing folder and message objects
|
||||||
|
*/
|
||||||
|
Account.prototype.all = function() {
|
||||||
|
return this._emailDAOs.map(function(emailDao) {
|
||||||
|
return emailDao._account;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login to an existing email account. This creates a new email data access object instance for that account and logs in via IMAP.
|
||||||
|
* @param {String} options.emailAddress The account's email address
|
||||||
|
*/
|
||||||
|
Account.prototype.login = function(options) {
|
||||||
|
var emailDao = new EmailDAO();
|
||||||
|
this._emailDAOs.push(emailDao);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new whiteout account. This creates a new email data access object instance for that account and logs in via IMAP.
|
||||||
|
* @param {String} options.emailAddress The account's email address
|
||||||
|
*/
|
||||||
|
Account.prototype.create = function(options) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout of an email account. This creates a new email data access object instance for that account and logs in via IMAP.
|
||||||
|
* @param {String} options.emailAddress The account's email address
|
||||||
|
*/
|
||||||
|
Account.prototype.logout = function(options) {};
|
7
src/js/service/index.js
Normal file
7
src/js/service/index.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('woServices', []);
|
||||||
|
|
||||||
|
require('./newsletter'),
|
||||||
|
require('./mail-config'),
|
||||||
|
require('./account');
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ngModule = angular.module('woServices', []);
|
var ngModule = angular.module('woServices');
|
||||||
ngModule.service('newsletter', Newsletter);
|
ngModule.service('newsletter', Newsletter);
|
||||||
|
|
||||||
function Newsletter($q) {
|
function Newsletter($q) {
|
||||||
|
Loading…
Reference in New Issue
Block a user