License and Privilege changes
[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.1 (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 <FSocial.h>
29 #include "CallInfo.h"
30 #include "CallTypes.h"
31 #include "CallICalllogChangeListener.h"
32
33 using namespace Tizen::Social;
34 class CallLogDetails;
35
36 /**
37  * @class LogListComparer
38  * @brief LogListComparer provides comparison functions used to
39  * sort an arraylist of CallLogDetails.
40  *
41  */
42 class LogListComparer
43 : public Tizen::Base::Collection::IComparerT<CallLogDetails>
44 {
45 public:
46         LogListComparer() {};
47         virtual ~LogListComparer() {};
48         result Compare (const CallLogDetails& obj1, const CallLogDetails& obj2, int& cmp) const;
49 };
50
51 /**
52  * @class CallLogDetails
53  * @brief CallLogDetails used to store information call logs.
54  *
55  */
56 class CallLogDetails
57 : public Tizen::Base::Object
58 {
59 public:
60         CallLogDetails();
61         virtual ~CallLogDetails();
62         bool operator ==(const CallLogDetails& rhs) const;
63         bool operator !=(const CallLogDetails& rhs) const;
64         CallLogDetails& operator =(const CallLogDetails& rhs);
65
66         void SetCalllogDbId(int id);
67         int GetCalllogDbId(void);
68         void SetCalllogType(contacts_phone_log_type_e type);
69         CallLogType GetCalllogType(void);
70         void SetContactDbId(int id);
71         int GetContactDbId(void);
72         void SetFirstName(char* name);
73         char*   GetFirstName(void);
74         void SetLastName(char* name);
75         char*   GetLastName(void);
76         void SetDisplayName(char* name);
77         char*   GetDisplayName(void);
78         void SetContactImagePath(char* path);
79         char* GetContactImagePath(void);
80         void SetPhoneNumber(char* number);
81         char* GetPhoneNumber(void);
82         void SetShortMessage(char* message);
83         char* GetShortMessage(void);
84         void SetStartTime(time_t time);
85         time_t GetStartTime(void);
86         void SetDuration(int duration);
87         int GetDuration(void);
88         void ConvertTimetoDateTime(void);
89         Tizen::Base::DateTime GetDateTime(void);
90
91 private:
92         //TODO: Naming conventions to be followed.
93         //NOTE: Below fields are not owned.
94         int                     calllog_db_id;             /**< Call log entry id */
95         CallLogType                     calllog_type;           /**< Call log entry type */
96         int                     contact_db_id;          /**< Contact's id in database */
97         char*                   first_name;         /**< Contact's first name (also known as given name) */
98         char*                   last_name;          /**< Contact's last name (also known as family name) */
99         char*                   display_name;       /**< Display name (how contact's name should be presented) */
100         char*                   contact_image_path;  /**< Path to image with contact's picture */
101   //  contact_number_type_e   phone_number_type;  /**< Phone number type (i.e.: work, cell) */
102         char*                   phone_number;       /**< Phone number */
103         char*                   short_message;      /**< Short message for this log */
104         time_t                  startTime;          /**< Timestamp of this change */
105         int                     duration_sec;
106         Tizen::Base::DateTime           dateTime;
107
108 };
109
110 /**
111  * @class CallLogManager
112  * @brief CallLogManager is a singleton class used to save and retrieve call log related data.
113  *
114  */
115 class CallLogManager
116 {
117 public:
118         static CallLogManager* GetInstance(void);
119
120 private:
121         CallLogManager(void);
122         virtual ~CallLogManager(void);
123         result Construct(void);
124         static void CreateInstance(void);
125         static void DestroyInstance(void);
126         unsigned long GetDuration(long long start_time);
127         int GetPersonId(Tizen::Base::String& personId);
128 public:
129         result AddCallogInfoToDatabase(AppCallInfo* calllogInfo);
130 private:
131         static CallLogManager*                                                                                  __pCallogManager;
132         Addressbook* pAddressBook;
133 };
134
135
136 #endif // _PHN_CALL_LOG_MANAGER_H_