tizen 2.4 release
[framework/web/wrt-commons.git] / modules / certificate_dao / include / wrt-commons / certificate-dao / certificate_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       certificate_dao.h
18  * @author  Leerang Song (leerang.song@samsung.com)
19  * @author  Wojciech Kosowicz (w.kosowicz@samsung.com)
20  * @version 1.0
21  * @brief    This file contains the declaration of certificate dao
22  */
23 #ifndef _CERTIFICATE_DAO_H_
24 #define _CERTIFICATE_DAO_H_
25
26 #include <dpl/db/thread_database_support.h>
27 #include <wrt-commons/certificate-dao/certificate_dao_types.h>
28 #include <dpl/wrt-dao-ro/common_dao_types.h>
29 #include <mutex>
30
31 namespace CertificateDB {
32 class CertificateDAO : public WrtDB::SQLiteDAOBase
33 {
34   public:
35     class Exception
36     {
37       public:
38         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
39         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
40         DECLARE_EXCEPTION_TYPE(Base, DataNotExist)
41     };
42
43     explicit CertificateDAO(const WrtDB::TizenPkgId &pkgName);
44     virtual ~CertificateDAO();
45     CertificateDataList getCertificateDataList();
46     Result getResult(const CertificateData &certificateData);
47     void setCertificateData(const CertificateData &certificateData,
48         const Result result);
49     void removeCertificateData(const CertificateData &certificateData);
50     void removeCertificateData(const Result result);
51
52   private:
53     std::mutex m_dbLock;
54     std::string m_certificateDBPath;
55     bool hasResult(const CertificateData &certificateData);
56 };
57
58 typedef std::shared_ptr<CertificateDAO> CertificateDAOPtr;
59 } // namespace CertificateDB
60
61 #endif // _CERTIFICATE_DAO_H_