Modification about smack label of db file belong to process.
[platform/framework/web/wrt-security.git] / mockups / communication_client_mock.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  * @author      Tomasz Swierczek (t.swierczek@samsung.com)
18  * @version     1.0
19  * @brief       DBus client mockup class.
20  */
21
22 #ifndef WRT_MOCKUPS_DBUS_CLIENT_MOCK_H_
23 #define WRT_MOCKUPS_DBUS_CLIENT_MOCK_H_
24
25 #include <dpl/exception.h>
26 #include <dpl/assert.h>
27
28 #include <string>
29 #include <vector>
30 #include "ace_server_api.h"
31 #include "popup_response_server_api.h"
32
33 namespace WrtSecurity {
34 namespace Communication {
35
36 /*
37  * This class is a mockup implementation for some methods called
38  * with DBus::Client.
39  */
40
41 class Client
42 {
43
44   public:
45     class Exception
46     {
47       public:
48         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
49         DECLARE_EXCEPTION_TYPE(Base, SecurityCommunicationClientException)
50     };
51
52     Client(std::string /*interfaceName*/)
53     {
54     }
55
56     // ACE server api check access method
57     void call(const std::string &methodName,
58               int,
59               const std::string&,
60               const std::string&,
61               const std::vector<std::string>&,
62               const std::vector<std::string>&,
63               const std::string&,
64               int* outArg)
65     {
66         if (methodName == WrtSecurity::AceServerApi::CHECK_ACCESS_METHOD()) {
67             Assert(NULL != outArg);
68             *outArg = m_checkAccessResult;
69             return;
70         }
71     }
72
73     void call(const std::string &methodName,
74                   bool,
75                   int,
76                   int,
77                   const std::string&,
78                   const std::string&,
79                   const std::vector<std::string>&,
80                   const std::vector<std::string>&,
81                   const std::string&,
82                   bool* outArg)
83     {
84         if (methodName == WrtSecurity::PopupServerApi::VALIDATION_METHOD()) {
85             Assert(NULL != outArg);
86             *outArg = m_validationResult;
87             return;
88         }
89     }
90
91
92     ~Client()
93     {
94     }
95
96     static void setCheckAccessResult(int value)
97     {
98         m_checkAccessResult = value;
99     }
100
101     static void setValidationResult(bool value)
102     {
103         m_validationResult = value;
104     }
105
106   private:
107     static int m_checkAccessResult;
108     static bool m_validationResult;
109 };
110
111 } // namespace DBus
112 }
113
114 #endif // WRT_MOCKUPS_DBUS_CLIENT_MOCK_H_