Fix for N_SE-28854 N_SE-29290 N_SE-27358 N_SE-25429 N_SE-25498 N_SE-25689 N_SE-27155...
[apps/osp/Call.git] / inc / CalllogManager.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                CalllogManager.h
19  * @brief               This is the header file for the %CallLogManager class.
20  *
21  * This header file contains the declarations for %CallLogManager, %CallLogDetails, %LogListComparer class.
22  */
23
24 #ifndef _PHN_CALL_LOG_MANAGER_H_
25 #define _PHN_CALL_LOG_MANAGER_H_
26 #include "contacts.h"
27 #include <FBase.h>
28 #include "CallInfo.h"
29 #include "CallTypes.h"
30 #include "CallICalllogChangeListener.h"
31
32 class CallLogDetails;
33
34 /**
35  * @class LogListComparer
36  * @brief LogListComparer provides comparison functions used to
37  * sort an arraylist of CallLogDetails.
38  *
39  */
40 class LogListComparer
41 : public Tizen::Base::Collection::IComparerT<CallLogDetails>
42 {
43 public:
44         LogListComparer() {};
45         virtual ~LogListComparer() {};
46         result Compare (const CallLogDetails& obj1, const CallLogDetails& obj2, int& cmp) const;
47 };
48
49 /**
50  * @class CallLogDetails
51  * @brief CallLogDetails used to store information call logs.
52  *
53  */
54 class CallLogDetails
55 : public Tizen::Base::Object
56 {
57 public:
58         CallLogDetails();
59         virtual ~CallLogDetails();
60         bool operator ==(const CallLogDetails& rhs) const;
61         bool operator !=(const CallLogDetails& rhs) const;
62         CallLogDetails& operator =(const CallLogDetails& rhs);
63
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);
88
89 private:
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 */
103         int                     duration_sec;
104         Tizen::Base::DateTime           dateTime;
105
106 };
107
108 /**
109  * @class CallLogManager
110  * @brief CallLogManager is a singleton class used to save and retrieve call log related data.
111  *
112  */
113 class CallLogManager
114 {
115 public:
116         static CallLogManager* GetInstance(void);
117
118 private:
119         CallLogManager(void);
120         virtual ~CallLogManager(void);
121         result Construct(void);
122         static void CreateInstance(void);
123         static void DestroyInstance(void);
124         unsigned long GetDuration(long long start_time);
125 public:
126         result AddCallogInfoToDatabase(CallInfo* calllogInfo);
127 private:
128         static CallLogManager*                                                                                  __pCallogManager;
129 };
130
131
132 #endif // _PHN_CALL_LOG_MANAGER_H_