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, void* user_data);
64 static void removeBatchCB(int error, void *user_data);
65 static void removeAllCB(int error, void *user_data);
67 void find(const EventFindCallHistoryPtr& event);
68 bool remove(const unsigned long entryId);
69 void removeBatch(const EventRemoveBatchPtr& event);
70 void removeAll(const EventRemoveAllPtr& event);
71 long addListener(const EventCallHistoryListenerEmitterPtr& emitter);
72 void removeListener(const long id);
78 EventCallHistoryListenerEmitterPtr m_emitter;
79 unsigned int m_currentLogId;
80 MissedCallListPtr m_missedCallList;
83 Watcher(long handle, const EventCallHistoryListenerEmitterPtr& emitter);
86 void setHandle(long handle)
88 LogDebug("setHandle : handle ["<<handle<<"]");
94 LogDebug("getHandle : handle ["<<m_handle<<"]");
98 void setCurrentLogId(unsigned int logId)
100 m_currentLogId = logId;
101 LogDebug("setCurrentLogId : logId ["<<logId);
105 unsigned int getCurrentLogId()
107 return m_currentLogId;
110 void setMissedCallList(const MissedCallListPtr &missedCallList)
112 m_missedCallList = missedCallList;
115 MissedCallListPtr getMissedCallList()
117 return m_missedCallList;
120 EventCallHistoryListenerEmitterPtr getEmitter()
125 void emit(const EventCallHistoryListenerPtr& event)
127 m_emitter->emit(event);
130 void stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state);
131 bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &entryList);
132 bool addMissedCall(CallHistoryEntryListPtr &entryList);
133 bool updateCurrentMissedCall();
134 void addedListenerCB();
135 void changedListenerCB();
137 typedef DPL::SharedPtr<Watcher> WatcherPtr;
140 bool convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries);
141 bool parseRecord(contacts_list_h *recordList, CallHistoryEntryListPtr &callEntries);
142 unsigned int convertAttrName(std::string &name);
143 MissedCallListPtr updateCurrentMissedCall();
145 std::vector<EventRemoveBatchDataPtr> m_removeBatchEvent;
146 std::vector<EventRemoveAllDataPtr> m_removeAllEvent;
148 void callRemoveBatchEvent(int error, const EventRemoveBatchPtr &event);
149 void callRemoveAllEvent(int error, const EventRemoveAllPtr &event);
152 void OnRequestReceived(const EventCallHistoryPtr& event);
153 void OnRequestReceived(const EventFindCallHistoryPtr& event);
154 void OnRequestReceived(const EventRemoveBatchPtr& event);
155 void OnRequestReceived(const EventRemoveAllPtr& event);
158 static std::vector<WatcherPtr> m_watchers;