2 /*global tizen, $, app, localStorage */
13 (function () { // strict mode wrapper
18 * API module initialisation
20 init: function Model_init() {
24 * Registers listener for call history change
25 * @param {onSuccessCallback} function
27 registerChangeListener: function Model_registerChangeListener(onSuccessCallback) {
29 var callHistoryListener = {
30 onadded: onSuccessCallback,
31 onchanged: onSuccessCallback,
32 onremoved: onSuccessCallback
35 tizen.callhistory.addChangeListener(callHistoryListener);
39 * @param {function} onSuccess callback
40 * @param {function} onError callback
42 getCallHistory: function Model_getCallHistory(onSuccess, onError) {
43 if (typeof onError !== 'function') {
44 onError = function (e) {
45 console.error('Model_getCallHistory error', e);
49 tizen.callhistory.find(onSuccess, onError, null, new tizen.SortMode('startTime', 'DESC'));
53 * @param {number} phoneNumber
54 * @param {function} onSuccess Callback
56 getCallHistoryForCaller: function Model_getCallHistoryForCaller(phoneNumber, onSuccess) {
57 tizen.callhistory.find(onSuccess, null, // error is ignored
58 new tizen.AttributeFilter('remoteParties.remoteParty', 'EXACTLY', phoneNumber),
59 new tizen.SortMode('startTime', 'DESC')
64 * Deletes specified log entry
65 * @param {CallHistoryEntry} entry
67 deleteLog: function Model_deleteLog(entry) {
69 tizen.callhistory.remove(entry);
71 console.error('Error on entry delete: ' + e.message);
76 * @param {number} addressBookId
77 * @param {number} contactId
78 * @returns {string} photoURI
80 getPhotoURIForContact: function Model_getPhotoURIForContact(personId) {
82 var addressBook = tizen.contact.getDefaultAddressBook(),
86 contact = addressBook.get(personId);
87 return contact.photoURI || false;
90 console.error('updatePhotoByContactId error:' + e.message);