Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_wearable / security_origin_dao / include / wrt-commons / security-origin-dao / security_origin_dao.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file    securoty_origin_dao.h
18  * @author  Jihoon Chung (jihoon.chung@samsung.com)
19  * @version 1.0
20  * @brief   This file contains the declaration of security origin dao
21  */
22 #ifndef _SECURITY_ORIGIN_DAO_H_
23 #define _SECURITY_ORIGIN_DAO_H_
24
25 #include <dpl/db/thread_database_support.h>
26 #include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
27 #include <dpl/wrt-dao-ro/common_dao_types.h>
28 #include <dpl/wrt-dao-ro/widget_dao_types.h>
29
30 namespace SecurityOriginDB {
31 class SecurityOriginDAO
32 {
33   public:
34     class Exception
35     {
36       public:
37         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
38         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
39         DECLARE_EXCEPTION_TYPE(Base, DataNotExist)
40     };
41
42     explicit SecurityOriginDAO(const WrtDB::TizenPkgId &pkgName);
43     virtual ~SecurityOriginDAO();
44     SecurityOriginDataList getSecurityOriginDataList();
45     Result getResult(const SecurityOriginData &data);
46     bool isReadOnly(const SecurityOriginData &data);
47     void setSecurityOriginData(const SecurityOriginData &data,
48                                const Result result,
49                                const bool readOnly = false);
50     void setPrivilegeSecurityOriginData(const WrtDB::Feature feature,
51                                         bool isOnlyAllowedLocalOrigin = true);
52     void removeSecurityOriginData(const SecurityOriginData &data);
53     void removeSecurityOriginData(const Result result);
54
55   private:
56     std::string m_dbPath;
57     DPL::DB::ThreadDatabaseSupport m_dbInterface;
58
59     bool hasResult(const SecurityOriginData &data);
60     void insertData(const SecurityOriginData &data,
61                     const Result result,
62                     const bool readOnly);
63     void updateData(const SecurityOriginData &data,
64                     const Result result,
65                     const bool readOnly);
66 };
67
68 typedef std::shared_ptr<SecurityOriginDAO> SecurityOriginDAOPtr;
69 } // namespace SecurityOriginDB
70
71 #endif // _SECURITY_ORIGIN_DAO_H_