2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://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.
18 * @file PhnCalllogManager.h
19 * @brief This is the header file for the %CallLogManager class.
21 * This header file contains the declarations for %CallLogManager, %CallLogDetails, %LogListComparer class.
24 #ifndef _PHN_CALL_LOG_MANAGER_H_
25 #define _PHN_CALL_LOG_MANAGER_H_
28 #include "PhnCallInfo.h"
30 #include "PhnICalllogChangeListener.h"
35 * @class LogListComparer
36 * @brief LogListComparer provides comparison functions used to
37 * sort an arraylist of CallLogDetails.
41 : public Tizen::Base::Collection::IComparerT<CallLogDetails>
45 virtual ~LogListComparer() {};
46 result Compare (const CallLogDetails& obj1, const CallLogDetails& obj2, int& cmp) const;
50 * @class CallLogDetails
51 * @brief CallLogDetails used to store information call logs.
55 : public Tizen::Base::Object
59 virtual ~CallLogDetails();
60 bool operator ==(const CallLogDetails& rhs) const;
61 bool operator !=(const CallLogDetails& rhs) const;
62 CallLogDetails& operator =(const CallLogDetails& rhs);
64 void SetCalllogDbId(int id);
65 int GetCalllogDbId(void);
66 void SetCalllogType(contacts_phone_log_type_e type);
67 CallLogType GetCalllogType(void);
68 void SetContactDbId(int id);
69 int GetContactDbId(void);
70 void SetFirstName(char* name);
71 char* GetFirstName(void);
72 void SetLastName(char* name);
73 char* GetLastName(void);
74 void SetDisplayName(char* name);
75 char* GetDisplayName(void);
76 void SetContactImagePath(char* path);
77 char* GetContactImagePath(void);
78 void SetPhoneNumber(char* number);
79 char* GetPhoneNumber(void);
80 void SetShortMessage(char* message);
81 char* GetShortMessage(void);
82 void SetStartTime(time_t time);
83 time_t GetStartTime(void);
84 void SetDuration(int duration);
85 int GetDuration(void);
86 void ConvertTimetoDateTime(void);
87 Tizen::Base::DateTime GetDateTime(void);
90 //TODO: Naming conventions to be followed.
91 //NOTE: Below fields are not owned.
92 int calllog_db_id; /**< Call log entry id */
93 CallLogType calllog_type; /**< Call log entry type */
94 int contact_db_id; /**< Contact's id in database */
95 char* first_name; /**< Contact's first name (also known as given name) */
96 char* last_name; /**< Contact's last name (also known as family name) */
97 char* display_name; /**< Display name (how contact's name should be presented) */
98 char* contact_image_path; /**< Path to image with contact's picture */
99 // contact_number_type_e phone_number_type; /**< Phone number type (i.e.: work, cell) */
100 char* phone_number; /**< Phone number */
101 char* short_message; /**< Short message for this log */
102 time_t startTime; /**< Timestamp of this change */
104 Tizen::Base::DateTime dateTime;
109 * @class CallLogManager
110 * @brief CallLogManager is a singleton class used to save and retrieve call log related data.
116 static CallLogManager* GetInstance(void);
119 CallLogManager(void);
120 virtual ~CallLogManager(void);
121 result Construct(void);
122 static void CreateInstance(void);
123 static void DestroyInstance(void);
126 result AddCallogInfoToDatabase(CallInfo* calllogInfo);
127 void ResetAndNotifyCalllogData(void);
128 //Tizen::Base::Collection::HashMapT<int, CallLogDetails>* GetCallogListByNumberFromDatabaseN(char* number);
129 Tizen::Base::Collection::ArrayListT<CallLogDetails>* GetCallogListByNumberFromDatabaseN(char* number);
130 unsigned long GetDuration(long long start_time);
131 bool GetAllCallogDataFromDatabseCB();
132 bool GetCallogListByNumberFromDatabaseCB(char *number);
133 void changed_db_cb();
134 void CopyDataToCallLogDetails(CallLogDetails* calllogInfo , contacts_record_h record);
136 result GetCallLogItemAtIndex(int index, CallLogDetails& calllogInfo);
138 Tizen::Base::Collection::IListT<int>* GetCalllogListKeys(void);
139 Tizen::Base::Collection::IListT<CallLogDetails>* GetCalllogListValues(void);
140 Tizen::Base::Collection::IMapEnumeratorT<int, CallLogDetails>* GetCalllogListEnum(void);
142 Tizen::Base::Collection::IListT<int>* GetCalllogListByNumKeys(void);
143 Tizen::Base::Collection::IListT<CallLogDetails>* GetCalllogListByNumValues(void);
144 Tizen::Base::Collection::IMapEnumeratorT<int, CallLogDetails>* GetCalllogListByNumEnum(void);
145 void DeleteCalllogByDbId(int dbId);
146 void DeleteAllCalllog(void);
147 int GetAllCalllogCount(void);
148 int GetCalllogCountByNumber(void);
149 //Used to get the latest dialed or incoming number from call log database.
150 Tizen::Base::String* GetLatestCallLogFromDbN(void);
151 //Used to fetch list of call from unknown numbers from logs.
152 Tizen::Base::Collection::HashMapT<int, CallLogDetails>* GetCallogListByUnknownNumberFromDatabaseN(char* number);
155 void SortCalllogList(void);
156 void SortCalllogListByNumber(void);
158 void AddCalllogChangeListener(ICalllogChangeListener& listner );
159 void RemoveCalllogChangeListner(ICalllogChangeListener& listner );
160 void GetCalllogContactName(Tizen::Base::String number,Tizen::Base::String& name);
163 static CallLogManager* __pCallogManager;
164 Tizen::Base::Collection::LinkedListT<CallLogDetails>* __pCalllogList;
165 Tizen::Base::Collection::HashMapT<int,int>* __pCalllogDBIds;
166 //Tizen::Base::Collection::HashMapT<int, CallLogDetails>* __pCalllogListByNumber;
167 Tizen::Base::Collection::ArrayListT<CallLogDetails>* __pCalllogListByNumber;
168 Tizen::Base::Collection::HashMapT<int, CallLogDetails>* __pCalllogUnkownListByNumber;
170 Tizen::Base::Collection::ArrayListT<ICalllogChangeListener*>* __pCalllogChangeListerners;
174 #endif // _PHN_CALL_LOG_MANAGER_H_