Tizen 2.0 Release
[apps/osp/Phone.git] / inc / PhnCallSettingDataService.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                PhnCallSettingDataService.h
19  * @brief               This is the header file for the %CallSettingDataService class.
20  *
21  * This header file contains the declarations for %CallSettingDataService class.
22  */
23 #ifndef _PHN_CALL_SETTING_DATA_SERVICE_H_
24 #define _PHN_CALL_SETTING_DATA_SERVICE_H_
25
26 #include <FApp.h>
27 #include <FBase.h>
28 #include <FIo.h>
29 #include "PhnCallRejectInfo.h"
30 #include "PhnSpeedDialInfo.h"
31
32 /**
33  * @class CallSettingDataService
34  * @brief This class providing database service APIS to CallRejectInfo Application forms
35  *
36  */
37 class CallSettingDataService
38 {
39 public:
40         /**
41          * Creates an instance of its own.
42          * creates CallSettingDataService(singleton) if it does not exist else returns the existing form
43          */
44         static CallSettingDataService* CreateInstance(void);
45
46         virtual ~CallSettingDataService(void);
47
48         ///Opens the Database.
49         /**
50          * Only one Database is maintained. Its name is hardcoded.
51          * It is assumed that OpenDB is called once while starting the application and CloseDB is called once while closing application.
52          */
53         result OpenDatabase(void);
54
55         ///Closes the Database
56         result CloseDatabase(void);
57
58         ///Creates a database table to store CallRejectInfo information
59         result CreateCallRejectTableDatabase(void);
60         ///Creates a database table to store SpeedDial information
61         result CreateSpeedDialTableDatabase(void);
62         ///Adds a CallRejectInfo to the database
63         result AddCallRejectInfoToDatabase(CallRejectInfo* pNewItem);
64
65         ///Deletes a CallRejectInfo from Database
66         /**
67          * @param an array of indexs of the CallRejectInfos to be deleted
68          * @param number of CallRejectInfo to be deleted
69          */
70         result DeleteCallRejectInfoListFromDatabase(Tizen::Base::Collection::ArrayList* pIndexArray);
71
72         /// Deletes a CallRejectInfo from Database
73         /**
74          * @param index of the CallRejectInfo to be deleted
75          */
76         result DeleteCallRejectInfoFromDatabase(int index);
77
78         ///Updates the CallRejectInfo details(contents, modification time etc) in Database
79         /**
80          * @param index of the CallRejectInfo to be updated
81          * @param a reference to CallRejectInfoInfo structure having the updated info
82          */
83         result UpdateCallRejectInfoDatabase(int aIndex, CallRejectInfo* pCallRejectInfoItem);
84
85         ///Gets one CallRejectInfo from the database
86         /**
87          * @param index of the CallRejectInfo to be fetched
88          * @param a reference to CallRejectInfoInfo structure into which the CallRejectInfo data is to be stored
89          */
90         result GetCallRejectInfoFromDatabase(int aIndex, CallRejectInfo& dbItem);
91
92         /// Gets all the CallRejectInfo from database into the linked list
93         /**
94          * @param a linked list reference to store the result
95          */
96         result GetAllCallRejectInfoFromDatabaseN(Tizen::Base::Collection::ArrayListT<CallRejectInfo>& callRejectInfoList);
97
98         ///Finds the number of entries in the database
99         /**
100          * @param an int reference to store the result
101          */
102         result GetCallRejectCount(int& count);
103
104         ///Searches for a keyword in the CallRejectInfo Contents from Database
105         /**
106          * @param search keyword
107          * @param Linked list to store the result of the search
108          */
109         bool IsCallToBeRejected(Tizen::Base::String& phoneNumber);
110
111         ///Adds a SpeedDialInfo to the database
112         result AddSpeedDialInfoToDatabase(SpeedDialInfo* pNewItem);
113
114         /// Deletes a SpeedDialInfo from Database
115         /**
116          * @param index of the SpeedDialInfo to be deleted
117          */
118         result DeleteSpeedDialInfoFromDatabase(int aIndex);
119         ///Updates the SpeedDialInfo details(contents, modification time etc) in Database
120         /**
121          * @param index of the SpeedDialInfo to be updated
122          * @param a reference to SpeedDialInfo structure having the updated info
123          */
124         result UpdateSpeedDialInfoDatabase(int aIndex, SpeedDialInfo* pSpeedDialInfoItem);
125
126         /// Gets all the SpeedDialInfo from database into the linked list
127         /**
128          * @param a linked list reference to store the result
129          */
130         Tizen::Base::Collection::IMapT<int,SpeedDialInfo>* GetAllSpeedDialInfoMapFromDatabaseN(void);
131
132         //Gets the SpeedDialContact mapped against "aIndex", if any. Else returns null.
133         Tizen::Base::String* GetSpeedDialContactN(int aIndex);
134
135 private:
136         /**
137          * Constructor
138          * made private as CallSettingDataService a singleton.
139          */
140         CallSettingDataService(void);
141
142         /**
143          * Copy constructor
144          * made private as CallSettingDataService a singleton.
145          */
146         CallSettingDataService(const CallSettingDataService& dataService);
147
148         /**
149          * Operator =
150          * made private as CallSettingDataService a singleton.
151          */
152         CallSettingDataService& operator =(const CallSettingDataService& dataService);
153
154         //checks if the condition is applicable for the passed phoneNumber
155         bool CheckRejectCondition(Tizen::Base::String& phoneNumber, CallRejectInfo& callRejectInfo);
156
157         ///singleton CallSettingDataService object
158         static CallSettingDataService* __pCallSettingDataService;
159
160         void SyncWithCurrentAddressbookStatus(Tizen::Base::Collection::HashMapT<int,SpeedDialInfo>* pSpeedDialInfoList);
161
162         /// Database object
163         /**
164          * Its made static as we need only one instance of it across different CallSettingDataService object calls.
165          * Its created while calling OpenDB and distructed while calling CloseDB.
166          */
167         static Tizen::Io::Database* __pDatabase;
168
169         ///name of the database
170         const Tizen::Base::String __strDbName;
171
172         /// an Enumerator used to iterate through the results of a database query.
173         Tizen::Io::DbEnumerator* __pEnum;
174
175         /// Used to create and execute database statements(queries)
176         Tizen::Io::DbStatement* __pStmt;
177 };
178
179 #endif /* _PHN_CALL_SETTING_DATA_SERVICE_H_ */