Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / src / app / FApp_DataControlManager.h
1 //
2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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        FApp_DataControlManager.h
19  * @brief       This is the header file for the _DataControlManager class.
20  */
21
22 #ifndef _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_
23 #define _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_
24
25 #include <FBaseObject.h>
26 #include <FBaseColHashMap.h>
27 #include <FBaseColLinkedList.h>
28 #include <FBaseRtEvent.h>
29 #include <FBaseRtMutex.h>
30 #include <FAppTypes.h>
31
32 namespace Tizen { namespace App
33 {
34
35 class _SqlDataControlImpl;
36 class _MapDataControlImpl;
37
38 class _DataControlRequestInfo
39         : public Tizen::Base::Object
40 {
41 public:
42         _DataControlRequestInfo(Tizen::Base::Runtime::Event* pEvent)
43                 : __pEvent(null)
44                 , __pSqlDcImpl(null)
45                 , __pMapDcImpl(null)
46         {
47                 __pEvent = pEvent;
48         }
49
50         virtual ~_DataControlRequestInfo(void)
51         {
52         }
53
54         Tizen::Base::Runtime::Event* GetEvent(void)
55         {
56                 return __pEvent;
57         }
58
59         void SetSqlDataControlImpl(_SqlDataControlImpl* pSqlDcImpl)
60         {
61                 __pSqlDcImpl = pSqlDcImpl;
62         }
63
64         void SetMapDataControlImpl(_MapDataControlImpl* pMapDcImpl)
65         {
66                 __pMapDcImpl = pMapDcImpl;
67         }
68
69         _SqlDataControlImpl* GetSqlDataControlImpl(void)
70         {
71                 return __pSqlDcImpl;
72         }
73
74         _MapDataControlImpl* GetMapDataControlImpl(void)
75         {
76                 return __pMapDcImpl;
77         }
78
79 private:
80         _DataControlRequestInfo(void);
81
82 private:
83         Tizen::Base::Runtime::Event* __pEvent;
84         _SqlDataControlImpl* __pSqlDcImpl;
85         _MapDataControlImpl* __pMapDcImpl;
86 };
87
88 class _DataControlManager
89         : public Tizen::Base::Object
90 {
91 public:
92         static _DataControlManager* GetInstance(void);
93
94         result AddRequestInfo(Tizen::Base::Integer* pReqId, _DataControlRequestInfo* pReqInfo);
95
96         _DataControlRequestInfo* GetRequestInfo(Tizen::Base::Integer& reqId);
97
98         int GetRequestCount(void) const;
99
100         void RemoveRequestInfo(Tizen::Base::Integer& reqId);
101
102         void RemoveAllRequests(void);
103
104         int GetUniqueId(void);
105
106         result AllowAccess(const AppId& appId);
107
108 private:
109         _DataControlManager(void);
110
111         result Construct(void);
112
113         virtual ~_DataControlManager(void);
114
115         void Cache(const AppId& appId);
116
117         bool IsCached(const AppId& appId);
118
119         static void InitSingleton(void);
120
121         static void DestroySingleton(void);
122
123 private:
124         static _DataControlManager* __pDataControlManagerInstance;
125         Tizen::Base::Collection::HashMap* __pDataControlRequestList;
126         Tizen::Base::Collection::LinkedList* __pProviderList;
127         int __uniqueId;
128         mutable Tizen::Base::Runtime::Mutex __mutex;
129
130 }; // _DataControlManager
131
132 }} // Tizen::App
133
134 #endif // _FAPP_INTERNAL_DATA_CONTROL_MANAGER_H_
135