2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*jslint devel: true*/
18 /*global Config, Model, Ui, tizen, setTimeout, navigator, app */
22 (function () { // strict mode wrapper
26 * Creates a new application object
30 App = function App() {
42 'js/app.ui.templateManager.js',
43 'js/app.ui.templateManager.modifiers.js',
68 * Initialisation function
70 init: function App_init() {
71 // instantiate the libs
72 this.config = new Config();
73 this.model = new Model();
74 this.model.registerChangeListener(this.updateCallLists.bind(this));
76 this.updateCallLists();
82 * Updates call history and caller detailed history lists
84 updateCallLists: function App_updateCallLists() {
85 this.ui.updateCheckboxes();
86 // workaround - time zone update
87 tizen.time.getCurrentDateTime().toLocalTimezone();
89 setTimeout(this.showHistoryForCaller(this.lastViewedCaller), 500);
90 this.showCallHistory();
94 * Renders call history view
96 showCallHistory: function App_showCallHistory() {
97 this.model.getCallHistory(this.ui.showCallHistory.bind(this.ui));
101 * Renders history for caller view
102 * @param {string} phoneNumber
104 showHistoryForCaller: function App_showHistoryForCaller(phoneNumber) {
105 this.lastViewedCaller = phoneNumber;
106 this.model.getCallHistoryForCaller(
108 this.ui.showHistoryForCaller.bind(this.ui, phoneNumber)
113 * @param {number} addressBookId
114 * @param {number} contactId
115 * @returns {string} photoURI Photo URI for specified contact
117 getPhotoURIForContact: function App_getPhotoURIForContact(personId) {
118 return this.model.getPhotoURIForContact(personId);
122 * Launch extension call service
123 * @param {string} phoneNumber
125 makeCall: function App_makeCall(phoneNumber) {
127 appControl = new tizen.ApplicationControl(
128 'http://tizen.org/appcontrol/operation/call',
131 tizen.application.launchAppControl(
137 self.ui.unlockButtons();
143 console.error('Call to ' + phoneNumber
144 + ' failed. Call service is unavailable.', e);
145 self.ui.showErrorPopup('Call failed. '
146 + 'Call service is unavailable.');
147 self.ui.unlockButtons();
150 onsuccess: function () {
151 self.ui.unlockButtons();
153 onfailure: function (e) {
154 console.log('App_makeCall: Call to ' + phoneNumber
155 + ' failed. Call service was busy.', e);
156 self.ui.unlockButtons();
157 //self.ui.showErrorPopup('Call failed.'
158 // + 'Call service was busy.');
165 * Launch extension sms service
166 * @param {string} phoneNumber
168 sendSms: function App_sendSms(phoneNumber) {
171 appControl = new tizen.ApplicationControl(
172 'http://tizen.org/appcontrol/operation/compose',
176 tizen.application.launchAppControl(
181 console.error('Message launch error: ', e);
182 self.ui.showErrorPopup('Message service is unavailable');
183 app.ui.unlockOptionButtons();
186 onfailure: function (er) {
187 console.error('Message service launch error: ', er);
188 self.ui.showErrorPopup(
189 'Message service is unavailable'
191 app.ui.unlockOptionButtons();
198 * Deletes specified log entry
199 * @param {CallHistoryEntry} entry
201 deleteLog: function App_deleteLogs(entry) {
202 this.model.deleteLog(entry);
208 exit: function App_exit(event) {
209 event.preventDefault();
210 event.stopPropagation();
211 tizen.application.getCurrentApplication().exit();