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.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));
59 * Updates call history and caller detailed history lists
61 updateCallLists: function App_updateCallLists() {
63 setTimeout(this.showHistoryForCaller(this.lastViewedCaller), 500);
64 this.showCallHistory();
68 * Renders call history view
70 showCallHistory: function App_showCallHistory() {
71 this.model.getCallHistory(this.ui.showCallHistory.bind(this.ui));
75 * Renders history for caller view
76 * @param {string} phoneNumber
78 showHistoryForCaller: function App_showHistoryForCaller(phoneNumber) {
79 this.lastViewedCaller = phoneNumber;
80 this.model.getCallHistoryForCaller(phoneNumber, this.ui.showHistoryForCaller.bind(this.ui, phoneNumber));
84 * @param {number} addressBookId
85 * @param {number} contactId
86 * @returns {string} photoURI Photo URI for specified contact
88 getPhotoURIForContact: function App_getPhotoURIForContact(personId) {
89 return this.model.getPhotoURIForContact(personId);
93 * Launch extension call service
94 * @param {string} phoneNumber
96 makeCall: function App_makeCall(phoneNumber) {
98 appControl = new tizen.ApplicationControl(
99 'http://tizen.org/appcontrol/operation/call',
102 tizen.application.launchAppControl(
106 app.ui.unlockOptionButtons();
109 console.error('App_makeCall: CALL service failure', e);
110 self.ui.showErrorPopup('Call service is unavailable');
111 app.ui.unlockOptionButtons();
114 onsuccess: function () {
115 app.ui.unlockOptionButtons();
117 onfailure: function (er) {
118 console.error('Error during call to ' + phoneNumber, er);
119 app.ui.unlockOptionButtons();
126 * Launch extension sms service
127 * @param {string} phoneNumber
129 sendSms: function App_sendSms(phoneNumber) {
132 appControl = new tizen.ApplicationControl(
133 'http://tizen.org/appcontrol/operation/compose',
137 tizen.application.launchAppControl(
141 app.ui.unlockOptionButtons();
144 console.error('Message launch error: ', e);
145 self.ui.showErrorPopup('Message service is unavailable');
146 app.ui.unlockOptionButtons();
149 onsuccess: function () {
150 app.ui.unlockOptionButtons();
152 onfailure: function (er) {
153 console.error('Message service launch error: ', er);
154 self.ui.showErrorPopup('Message service is unavailable');
155 app.ui.unlockOptionButtons();
162 * Deletes specified log entry
163 * @param {CallHistoryEntry} entry
165 deleteLog: function App_deleteLogs(entry) {
166 this.model.deleteLog(entry);
172 exit: function App_exit(event) {
173 event.preventDefault();
174 event.stopPropagation();
175 tizen.application.getCurrentApplication().exit();