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(
108 console.error('App_makeCall: CALL service failure', e);
109 self.ui.showErrorPopup('Call service is unavailable');
112 onsuccess: function () {
114 onfailure: function (er) {
115 console.error('Error during call to ' + phoneNumber, er);
122 * Launch extension sms service
123 * @param {string} phoneNumber
125 sendSms: function App_sendSms(phoneNumber) {
128 appControl = new tizen.ApplicationControl(
129 'http://tizen.org/appcontrol/operation/send_text',
133 tizen.application.launchAppControl(
139 console.error('Message launch error: ', e);
140 self.ui.showErrorPopup('Message service is unavailable');
143 onsuccess: function () {
145 onfailure: function (er) {
146 console.error('Message service launch error: ', er);
147 self.ui.showErrorPopup('Message service is unavailable');
154 * Deletes specified log entry
155 * @param {CallHistoryEntry} entry
157 deleteLog: function App_deleteLogs(entry) {
158 this.model.deleteLog(entry);
164 exit: function App_exit(event) {
165 event.preventDefault();
166 event.stopPropagation();
167 tizen.application.getCurrentApplication().exit();