2 /*global Config, Model, Ui, tizen, setTimeout, navigator */
6 (function () { // strict mode wrapper
10 * Creates a new application object
14 App = function App() {
22 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'],
45 * Initialisation function
47 init: function App_init() {
48 // instantiate the libs
49 this.config = new Config();
50 this.model = new Model();
51 this.model.registerChangeListener(this.updateCallLists.bind(this));
53 this.updateCallLists();
59 * Updates call history and caller detailed history lists
61 updateCallLists: function App_updateCallLists() {
62 // workaround - time zone update
63 tizen.time.getCurrentDateTime().toLocalTimezone();
65 setTimeout(this.showHistoryForCaller(this.lastViewedCaller), 500);
66 this.showCallHistory();
70 * Renders call history view
72 showCallHistory: function App_showCallHistory() {
73 this.model.getCallHistory(this.ui.showCallHistory.bind(this.ui));
77 * Renders history for caller view
78 * @param {string} phoneNumber
80 showHistoryForCaller: function App_showHistoryForCaller(phoneNumber) {
81 this.lastViewedCaller = phoneNumber;
82 this.model.getCallHistoryForCaller(phoneNumber, this.ui.showHistoryForCaller.bind(this.ui, phoneNumber));
86 * @param {number} addressBookId
87 * @param {number} contactId
88 * @returns {string} photoURI Photo URI for specified contact
90 getPhotoURIForContact: function App_getPhotoURIForContact(personId) {
91 return this.model.getPhotoURIForContact(personId);
95 * Launch extension call service
96 * @param {string} phoneNumber
98 makeCall: function App_makeCall(phoneNumber) {
100 appControl = new tizen.ApplicationControl(
101 'http://tizen.org/appcontrol/operation/call',
104 tizen.application.launchAppControl(
110 console.error('Call to ' + phoneNumber
111 + ' failed. Call service is unavailable.', e);
112 self.ui.showErrorPopup('Call failed. '
113 + 'Call service is unavailable.');
116 onsuccess: function () {
118 onfailure: function (e) {
119 console.log('App_makeCall: Call to ' + phoneNumber
120 + ' failed. Call service was busy.', e);
121 //self.ui.showErrorPopup('Call failed.'
122 // + 'Call service was busy.');
129 * Launch extension sms service
130 * @param {string} phoneNumber
132 sendSms: function App_sendSms(phoneNumber) {
135 appControl = new tizen.ApplicationControl(
136 'http://tizen.org/appcontrol/operation/compose',
140 tizen.application.launchAppControl(
145 console.error('Message launch error: ', e);
146 self.ui.showErrorPopup('Message service is unavailable');
147 app.ui.unlockOptionButtons();
150 onfailure: function (er) {
151 console.error('Message service launch error: ', er);
152 self.ui.showErrorPopup('Message service is unavailable');
153 app.ui.unlockOptionButtons();
160 * Deletes specified log entry
161 * @param {CallHistoryEntry} entry
163 deleteLog: function App_deleteLogs(entry) {
164 this.model.deleteLog(entry);
170 exit: function App_exit(event) {
171 event.preventDefault();
172 event.stopPropagation();
173 tizen.application.getCurrentApplication().exit();