2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #ifndef TIZENAPIS_PLATFORM_CALLHISTORY_H_
20 #define TIZENAPIS_PLATFORM_CALLHISTORY_H_
23 #include <dpl/shared_ptr.h>
24 #include <dpl/noncopyable.h>
26 #include "ICallHistory.h"
27 #include "CallHistoryFactory.h"
28 #include "EventCallHistoryTemplate.h"
29 #include "EventCallHistory.h"
30 #include "EventFindCallHistory.h"
31 #include "EventRemoveBatch.h"
32 #include "EventRemoveAll.h"
33 #include "EventCallHistoryListener.h"
34 #include "CallHistoryEntryProperties.h"
35 #include "RemoteParty.h"
39 namespace CallHistory {
41 typedef DPL::SharedPtr<EventCallHistoryPtrs<EventRemoveBatch>> EventRemoveBatchDataPtr;
42 typedef DPL::SharedPtr<EventCallHistoryPtrs<EventRemoveAll>> EventRemoveAllDataPtr;
44 typedef std::vector<unsigned long> MissedCallList;
45 typedef DPL::SharedPtr<MissedCallList> MissedCallListPtr;
50 contacts_phone_log_type_e calllog_type;
55 } callhistory_query_s;
57 class CallHistory : public ICallHistory
63 static void callhistoryListenerCB(const char* view_uri, char *changes, void* user_data);
64 static void removeBatchCB(int error, void *user_data);
65 static void removeAllCB(int error, void *user_data);
66 void find(const EventFindCallHistoryPtr& event);
67 bool remove(const unsigned long entryId);
68 void removeBatch(const EventRemoveBatchPtr& event);
69 void removeAll(const EventRemoveAllPtr& event);
70 long addListener(const EventCallHistoryListenerEmitterPtr& emitter);
71 void removeListener(const long id);
77 EventCallHistoryListenerEmitterPtr m_emitter;
78 unsigned int m_currentLogId;
79 MissedCallListPtr m_missedCallList;
82 Watcher(long handle, const EventCallHistoryListenerEmitterPtr& emitter);
85 void setHandle(long handle)
95 void setCurrentLogId(unsigned int logId)
97 m_currentLogId = logId;
100 unsigned int getCurrentLogId()
102 return m_currentLogId;
105 EventCallHistoryListenerEmitterPtr getEmitter()
110 void emit(const EventCallHistoryListenerPtr& event)
112 m_emitter->emit(event);
115 void stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state);
116 void stateHasRemoved(StringArrayPtr &entryList, EventCallHistoryListener::ResultStates state);
118 bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList);
119 bool parseRemoveRecord(char* record, StringArrayPtr &removeRecords);
121 void ListenerCB(char* changes);
123 typedef DPL::SharedPtr<Watcher> WatcherPtr;
126 bool convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries);
127 bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &callEntries);
128 int updateValidPersonId(char* phoneNum);
129 unsigned int convertAttrName(std::string &name);
131 std::vector<EventRemoveBatchDataPtr> m_removeBatchEvent;
132 std::vector<EventRemoveAllDataPtr> m_removeAllEvent;
134 void callRemoveBatchEvent(int error, const EventRemoveBatchPtr &event);
135 void callRemoveAllEvent(int error, const EventRemoveAllPtr &event);
138 void OnRequestReceived(const EventCallHistoryPtr& event);
139 void OnRequestReceived(const EventFindCallHistoryPtr& event);
140 void OnRequestReceived(const EventRemoveBatchPtr& event);
141 void OnRequestReceived(const EventRemoveAllPtr& event);
144 static std::vector<WatcherPtr> m_watchers;