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(addressBookId, contactId) {
89 return this.model.getPhotoURIForContact(addressBookId, contactId);
93 * Launch extension call service
94 * @param {string} phoneNumber
96 makeCall: function App_makeCall(phoneNumber) {
97 var appControl = new tizen.ApplicationControl(
98 'http://tizen.org/appcontrol/operation/call',
101 tizen.application.launchAppControl(
107 console.error('App_makeCall: CALL service failure', e);
108 alert('Call service is unavailable');
111 onsuccess: function () {
113 onfailure: function (er) {
114 console.error('Error during call to ' + phoneNumber, er);
115 alert('Call service is unavailable');
122 * Launch extension sms service
123 * @param {string} phoneNumber
125 sendSms: function App_sendSms(phoneNumber) {
127 var appControl = new tizen.ApplicationControl(
128 'http://tizen.org/appcontrol/operation/send_text',
132 tizen.application.launchAppControl(
138 console.error('Message launch error: ', e);
139 alert('Message service is unavailable');
142 onsuccess: function () {
144 onfailure: function (er) {
145 console.error('Message service launch error: ', er);
146 alert('Message service is unavailable');
153 * Deletes specified log entry
154 * @param {CallHistoryEntry} entry
156 deleteLog: function App_deleteLogs(entry) {
157 this.model.deleteLog(entry);
163 exit: function App_exit(event) {
164 event.preventDefault();
165 event.stopPropagation();
166 tizen.application.getCurrentApplication().exit();