2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*jslint devel: true*/
18 /*global tizen, $, app, localStorage */
29 (function () { // strict mode wrapper
35 * API module initialisation
37 init: function Model_init() {
41 * Registers listener for call history change
42 * @param {onSuccessCallback} function
44 registerChangeListener: function Model_registerChangeListener(
47 var callHistoryListener = {
48 onadded: onSuccessCallback,
49 onchanged: onSuccessCallback,
50 onremoved: onSuccessCallback
52 tizen.callhistory.addChangeListener(callHistoryListener);
56 * @param {function} onSuccess callback
57 * @param {function} onError callback
59 getCallHistory: function Model_getCallHistory(onSuccess, onError) {
60 if (typeof onError !== 'function') {
61 onError = function (e) {
62 console.error('Model_getCallHistory error', e);
66 tizen.callhistory.find(
70 new tizen.SortMode('startTime', 'DESC')
75 * @param {number} phoneNumber
76 * @param {function} onSuccess Callback
78 getCallHistoryForCaller: function Model_getCallHistoryForCaller(
82 var filter = null, success;
84 filter = new tizen.AttributeFilter(
85 'remoteParties.remoteParty',
91 success = function (calls) {
92 onSuccess(calls.filter(function (element) {
93 if (!element.remoteParties[0].remoteParty) {
100 tizen.callhistory.find(success,
105 new tizen.SortMode('startTime', 'DESC')
110 * Deletes specified log entry
111 * @param {CallHistoryEntry} entry
113 deleteLog: function Model_deleteLog(entry) {
115 tizen.callhistory.remove(entry);
117 console.error('Error on entry delete: ' + e.message);
122 * @param {number} addressBookId
123 * @param {number} contactId
124 * @returns {string} photoURI
126 getPhotoURIForContact: function Model_getPhotoURIForContact(personId) {
128 var addressBook = tizen.contact.getDefaultAddressBook(),
131 contact = addressBook.get(personId);
132 return contact.photoURI || false;
135 console.error('updatePhotoByContactId error:' + e.message);