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 PhnCallSettingDataService.h
19 * @brief This is the header file for the %CallSettingDataService class.
21 * This header file contains the declarations for %CallSettingDataService class.
23 #ifndef _PHN_CALL_SETTING_DATA_SERVICE_H_
24 #define _PHN_CALL_SETTING_DATA_SERVICE_H_
29 #include "PhnCallRejectInfo.h"
30 #include "PhnSpeedDialInfo.h"
33 * @class CallSettingDataService
34 * @brief This class providing database service APIS to CallRejectInfo Application forms
37 class CallSettingDataService
41 * Creates an instance of its own.
42 * creates CallSettingDataService(singleton) if it does not exist else returns the existing form
44 static CallSettingDataService* CreateInstance(void);
46 virtual ~CallSettingDataService(void);
48 ///Opens the Database.
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.
53 result OpenDatabase(void);
55 ///Closes the Database
56 result CloseDatabase(void);
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);
65 ///Deletes a CallRejectInfo from Database
67 * @param an array of indexs of the CallRejectInfos to be deleted
68 * @param number of CallRejectInfo to be deleted
70 result DeleteCallRejectInfoListFromDatabase(Tizen::Base::Collection::ArrayList* pIndexArray);
72 /// Deletes a CallRejectInfo from Database
74 * @param index of the CallRejectInfo to be deleted
76 result DeleteCallRejectInfoFromDatabase(int index);
78 ///Updates the CallRejectInfo details(contents, modification time etc) in Database
80 * @param index of the CallRejectInfo to be updated
81 * @param a reference to CallRejectInfoInfo structure having the updated info
83 result UpdateCallRejectInfoDatabase(int aIndex, CallRejectInfo* pCallRejectInfoItem);
85 ///Gets one CallRejectInfo from the database
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
90 result GetCallRejectInfoFromDatabase(int aIndex, CallRejectInfo& dbItem);
92 /// Gets all the CallRejectInfo from database into the linked list
94 * @param a linked list reference to store the result
96 result GetAllCallRejectInfoFromDatabaseN(Tizen::Base::Collection::ArrayListT<CallRejectInfo>& callRejectInfoList);
98 ///Finds the number of entries in the database
100 * @param an int reference to store the result
102 result GetCallRejectCount(int& count);
104 ///Searches for a keyword in the CallRejectInfo Contents from Database
106 * @param search keyword
107 * @param Linked list to store the result of the search
109 bool IsCallToBeRejected(Tizen::Base::String& phoneNumber);
111 ///Adds a SpeedDialInfo to the database
112 result AddSpeedDialInfoToDatabase(SpeedDialInfo* pNewItem);
114 /// Deletes a SpeedDialInfo from Database
116 * @param index of the SpeedDialInfo to be deleted
118 result DeleteSpeedDialInfoFromDatabase(int aIndex);
119 ///Updates the SpeedDialInfo details(contents, modification time etc) in Database
121 * @param index of the SpeedDialInfo to be updated
122 * @param a reference to SpeedDialInfo structure having the updated info
124 result UpdateSpeedDialInfoDatabase(int aIndex, SpeedDialInfo* pSpeedDialInfoItem);
126 /// Gets all the SpeedDialInfo from database into the linked list
128 * @param a linked list reference to store the result
130 Tizen::Base::Collection::IMapT<int,SpeedDialInfo>* GetAllSpeedDialInfoMapFromDatabaseN(void);
132 //Gets the SpeedDialContact mapped against "aIndex", if any. Else returns null.
133 Tizen::Base::String* GetSpeedDialContactN(int aIndex);
138 * made private as CallSettingDataService a singleton.
140 CallSettingDataService(void);
144 * made private as CallSettingDataService a singleton.
146 CallSettingDataService(const CallSettingDataService& dataService);
150 * made private as CallSettingDataService a singleton.
152 CallSettingDataService& operator =(const CallSettingDataService& dataService);
154 //checks if the condition is applicable for the passed phoneNumber
155 bool CheckRejectCondition(Tizen::Base::String& phoneNumber, CallRejectInfo& callRejectInfo);
157 ///singleton CallSettingDataService object
158 static CallSettingDataService* __pCallSettingDataService;
160 void SyncWithCurrentAddressbookStatus(Tizen::Base::Collection::HashMapT<int,SpeedDialInfo>* pSpeedDialInfoList);
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.
167 static Tizen::Io::Database* __pDatabase;
169 ///name of the database
170 const Tizen::Base::String __strDbName;
172 /// an Enumerator used to iterate through the results of a database query.
173 Tizen::Io::DbEnumerator* __pEnum;
175 /// Used to create and execute database statements(queries)
176 Tizen::Io::DbStatement* __pStmt;
179 #endif /* _PHN_CALL_SETTING_DATA_SERVICE_H_ */