-/*
-* Copyright 2013 Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.1 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://floralicense.org/license/
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
/*jslint devel: true*/
-/*global Config, Model, Ui, tizen, setTimeout, navigator, app */
+/*global Config, Model, Ui, tizen, setTimeout, navigator */
var App = null;
(function () { // strict mode wrapper
- 'use strict';
-
- /**
- * Creates a new application object
- *
- * @class Application
- */
- App = function App() {
- this.configData = {};
- };
-
- App.prototype = {
- /**
- * @type Array
- */
- requires: [
- 'js/app.config.js',
- 'js/app.model.js',
- 'js/app.ui.js',
- 'js/app.ui.templateManager.js',
- 'js/app.ui.templateManager.modifiers.js',
- 'js/app.helpers.js'
- ],
-
- /**
- * @type Model
- */
- model: null,
-
- /**
- * @type Ui
- */
- ui: null,
-
- /**
- * @type Config
- */
- config: null,
-
- /**
- * @type {number}
- */
- lastViewedCaller: 0,
-
- /**
- * Initialisation function
- */
- init: function App_init() {
- // instantiate the libs
- this.config = new Config();
- this.model = new Model();
- this.model.registerChangeListener(this.updateCallLists.bind(this));
- this.ui = new Ui();
- this.updateCallLists();
-
- return this;
- },
-
- /**
- * Updates call history and caller detailed history lists
- */
- updateCallLists: function App_updateCallLists() {
- this.ui.updateCheckboxes();
- // workaround - time zone update
- tizen.time.getCurrentDateTime().toLocalTimezone();
- // workaround;
- setTimeout(this.showHistoryForCaller(this.lastViewedCaller), 500);
- this.showCallHistory();
- },
-
- /**
- * Renders call history view
- */
- showCallHistory: function App_showCallHistory() {
- this.model.getCallHistory(this.ui.showCallHistory.bind(this.ui));
- },
-
- /**
- * Renders history for caller view
- * @param {string} phoneNumber
- */
- showHistoryForCaller: function App_showHistoryForCaller(phoneNumber) {
- this.lastViewedCaller = phoneNumber;
- this.model.getCallHistoryForCaller(
- phoneNumber,
- this.ui.showHistoryForCaller.bind(this.ui, phoneNumber)
- );
- },
-
- /**
- * @param {number} addressBookId
- * @param {number} contactId
- * @returns {string} photoURI Photo URI for specified contact
- */
- getPhotoURIForContact: function App_getPhotoURIForContact(personId) {
- return this.model.getPhotoURIForContact(personId);
- },
-
- /**
- * Launch extension call service
- * @param {string} phoneNumber
- */
- makeCall: function App_makeCall(phoneNumber) {
- var self = this,
- appControl = new tizen.ApplicationControl(
- 'http://tizen.org/appcontrol/operation/call',
- 'tel:' + phoneNumber
- );
- tizen.application.launchAppControl(
- appControl,
- null,
- function () {
- setTimeout(
- function () {
- self.ui.unlockButtons();
- },
- 1500
- );
- },
- function (e) {
- console.error('Call to ' + phoneNumber
- + ' failed. Call service is unavailable.', e);
- self.ui.showErrorPopup('Call failed. '
- + 'Call service is unavailable.');
- self.ui.unlockButtons();
- },
- {
- onsuccess: function () {
- self.ui.unlockButtons();
- },
- onfailure: function (e) {
- console.log('App_makeCall: Call to ' + phoneNumber
- + ' failed. Call service was busy.', e);
- self.ui.unlockButtons();
- //self.ui.showErrorPopup('Call failed.'
- // + 'Call service was busy.');
- }
- }
- );
- },
-
- /**
- * Launch extension sms service
- * @param {string} phoneNumber
- */
- sendSms: function App_sendSms(phoneNumber) {
-
- var self = this,
- appControl = new tizen.ApplicationControl(
- 'http://tizen.org/appcontrol/operation/compose',
- 'sms:' + phoneNumber
- );
-
- tizen.application.launchAppControl(
- appControl,
- null,
- null,
- function (e) {
- console.error('Message launch error: ', e);
- self.ui.showErrorPopup('Message service is unavailable');
- app.ui.unlockOptionButtons();
- },
- {
- onfailure: function (er) {
- console.error('Message service launch error: ', er);
- self.ui.showErrorPopup(
- 'Message service is unavailable'
- );
- app.ui.unlockOptionButtons();
- }
- }
- );
- },
-
- /**
- * Deletes specified log entry
- * @param {CallHistoryEntry} entry
- */
- deleteLog: function App_deleteLogs(entry) {
- this.model.deleteLog(entry);
- },
-
- /**
- * App exit
- */
- exit: function App_exit(event) {
- event.preventDefault();
- event.stopPropagation();
- tizen.application.getCurrentApplication().exit();
- }
-
- };
-
+ 'use strict';
+
+ /**
+ * Creates a new application object
+ *
+ * @class Application
+ */
+ App = function App() {
+ this.configData = {};
+ };
+
+ App.prototype = {
+ /**
+ * @type Array
+ */
+ requires: ['js/app.config.js', 'js/app.model.js', 'js/app.ui.js', 'js/app.ui.templateManager.js', 'js/app.ui.templateManager.modifiers.js', 'js/app.helpers.js'],
+
+ /**
+ * @type Model
+ */
+ model: null,
+
+ /**
+ * @type Ui
+ */
+ ui: null,
+
+ /**
+ * @type Config
+ */
+ config: null,
+
+ /**
+ * @type {number}
+ */
+ lastViewedCaller: 0,
+
+ /**
+ * Initialisation function
+ */
+ init: function App_init() {
+ // instantiate the libs
+ this.config = new Config();
+ this.model = new Model();
+ this.model.registerChangeListener(this.updateCallLists.bind(this));
+ this.ui = new Ui();
+ this.updateCallLists();
+
+ return this;
+ },
+
+ /**
+ * Updates call history and caller detailed history lists
+ */
+ updateCallLists: function App_updateCallLists() {
+ // workaround - time zone update
+ tizen.time.getCurrentDateTime().toLocalTimezone();
+ // workaround;
+ setTimeout(this.showHistoryForCaller(this.lastViewedCaller), 500);
+ this.showCallHistory();
+ },
+
+ /**
+ * Renders call history view
+ */
+ showCallHistory: function App_showCallHistory() {
+ this.model.getCallHistory(this.ui.showCallHistory.bind(this.ui));
+ },
+
+ /**
+ * Renders history for caller view
+ * @param {string} phoneNumber
+ */
+ showHistoryForCaller: function App_showHistoryForCaller(phoneNumber) {
+ this.lastViewedCaller = phoneNumber;
+ this.model.getCallHistoryForCaller(phoneNumber, this.ui.showHistoryForCaller.bind(this.ui, phoneNumber));
+ },
+
+ /**
+ * @param {number} addressBookId
+ * @param {number} contactId
+ * @returns {string} photoURI Photo URI for specified contact
+ */
+ getPhotoURIForContact: function App_getPhotoURIForContact(personId) {
+ return this.model.getPhotoURIForContact(personId);
+ },
+
+ /**
+ * Launch extension call service
+ * @param {string} phoneNumber
+ */
+ makeCall: function App_makeCall(phoneNumber) {
+ var self = this,
+ appControl = new tizen.ApplicationControl(
+ 'http://tizen.org/appcontrol/operation/call',
+ 'tel:' + phoneNumber
+ );
+ tizen.application.launchAppControl(
+ appControl,
+ null,
+ function () {
+ },
+ function (e) {
+ console.error('Call to ' + phoneNumber
+ + ' failed. Call service is unavailable.', e);
+ self.ui.showErrorPopup('Call failed. '
+ + 'Call service is unavailable.');
+ },
+ {
+ onsuccess: function () {
+ },
+ onfailure: function (e) {
+ console.log('App_makeCall: Call to ' + phoneNumber
+ + ' failed. Call service was busy.', e);
+ //self.ui.showErrorPopup('Call failed.'
+ // + 'Call service was busy.');
+ }
+ }
+ );
+ },
+
+ /**
+ * Launch extension sms service
+ * @param {string} phoneNumber
+ */
+ sendSms: function App_sendSms(phoneNumber) {
+
+ var self = this,
+ appControl = new tizen.ApplicationControl(
+ 'http://tizen.org/appcontrol/operation/compose',
+ 'sms:' + phoneNumber
+ );
+
+ tizen.application.launchAppControl(
+ appControl,
+ null,
+ null,
+ function (e) {
+ console.error('Message launch error: ', e);
+ self.ui.showErrorPopup('Message service is unavailable');
+ app.ui.unlockOptionButtons();
+ },
+ {
+ onfailure: function (er) {
+ console.error('Message service launch error: ', er);
+ self.ui.showErrorPopup('Message service is unavailable');
+ app.ui.unlockOptionButtons();
+ }
+ }
+ );
+ },
+
+ /**
+ * Deletes specified log entry
+ * @param {CallHistoryEntry} entry
+ */
+ deleteLog: function App_deleteLogs(entry) {
+ this.model.deleteLog(entry);
+ },
+
+ /**
+ * App exit
+ */
+ exit: function App_exit(event) {
+ event.preventDefault();
+ event.stopPropagation();
+ tizen.application.getCurrentApplication().exit();
+ }
+ };
}());