2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef TIZENAPIS_PLATFORM_CALLHISTORY_H_
19 #define TIZENAPIS_PLATFORM_CALLHISTORY_H_
22 #include <dpl/shared_ptr.h>
23 #include <dpl/noncopyable.h>
25 #include <API/Call/ICallHistory.h>
26 #include <API/Call/CallHistoryFactory.h>
27 #include <API/Call/EventFindCallHistory.h>
28 #include <API/Call/EventRemoveBatch.h>
29 #include <API/Call/EventRemoveAll.h>
30 #include <API/Call/EventCallHistoryListener.h>
31 #include <API/Call/CallHistoryEntryProperties.h>
32 #include <API/Call/RemoteParty.h>
33 #include "CallHistoryQuery.h"
39 typedef std::vector<unsigned long> MissedCallList;
40 typedef DPL::SharedPtr<MissedCallList> MissedCallListPtr;
42 class CallHistory : public Api::Call::ICallHistory
48 void find(const Api::Call::EventFindCallHistoryPtr& event);
49 bool remove(const unsigned long entryId);
50 void removeBatch(const Api::Call::EventRemoveBatchPtr& event);
51 void removeAll(const Api::Call::EventRemoveAllPtr& event);
52 long addListener(const Api::Call::EventCallHistoryListenerEmitterPtr& emitter);
53 void removeListener(const Api::Call::EventCallHistoryListenerEmitter::IdType id);
55 static void addedListenerCB(void *user_data);
56 static void changedListenerCB(void *user_data);
62 Api::Call::EventCallHistoryListenerEmitterPtr m_emitter;
63 unsigned int m_currentLogId;
64 Platform::Call::MissedCallListPtr m_missedCallList;
67 Watcher(int handle, const Api::Call::EventCallHistoryListenerEmitterPtr& emitter);
70 void setHandle(int handle)
80 void setCurrentLogId(unsigned int logId)
82 m_currentLogId = logId;
85 unsigned int getCurrentLogId()
87 return m_currentLogId;
90 void setMissedCallList(const Platform::Call::MissedCallListPtr &missedCallList)
92 m_missedCallList = missedCallList;
95 Platform::Call::MissedCallListPtr getMissedCallList()
97 return m_missedCallList;
100 Api::Call::EventCallHistoryListenerEmitterPtr getEmitter()
105 void emit(const Api::Call::EventCallHistoryListenerPtr& event)
107 m_emitter->emit(event);
110 void stateHasChanged(Api::Call::CallHistoryEntryListPtr &entryList, Api::Call::EventCallHistoryListener::ResultStates state);
111 bool executeQuery(std::string &query, Api::Call::CallHistoryEntryListPtr &entryList);
112 bool addMissedCall(Api::Call::CallHistoryEntryListPtr &entryList);
113 bool updateCurrentMissedCall();
115 typedef DPL::SharedPtr<Watcher> WatcherPtr;
118 bool convertCallHistory(callhistory_query_s *query_log, Api::Call::CallHistoryEntryListPtr &callEntries);
119 bool executeQuery(std::string &query, Api::Call::CallHistoryEntryListPtr &callEntries);
120 std::string convertAttrName(std::string &name);
121 std::string makeQuerySortMode(Api::Tizen::SortModePtr attr);
122 Platform::Call::MissedCallListPtr updateCurrentMissedCall();
125 void OnRequestReceived(const Api::Call::EventFindCallHistoryPtr& event);
126 void OnRequestReceived(const Api::Call::EventRemoveBatchPtr& event);
127 void OnRequestReceived(const Api::Call::EventRemoveAllPtr& event);
130 static std::vector<WatcherPtr> m_watchers;