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
34 tizen.callhistory.addChangeListener(callHistoryListener);
38 * @param {function} onSuccess callback
39 * @param {function} onError callback
41 getCallHistory: function Model_getCallHistory(onSuccess, onError) {
42 if (typeof onError !== 'function') {
43 onError = function (e) {
44 console.error('Model_getCallHistory error', e);
48 tizen.callhistory.find(onSuccess, onError, null, new tizen.SortMode('startTime', 'DESC'));
52 * @param {number} phoneNumber
53 * @param {function} onSuccess Callback
55 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(addressBookId, contactId) {
82 var addressBook = tizen.contact.getAddressBook(addressBookId),
86 contact = addressBook.get(contactId);
87 return contact.photoURI || false;
90 console.error('updatePhotoByContactId error:' + e.message);