2726a7675a310ed660a7cce590eb6da20225c983
[platform/core/security/askuser.git] / src / client / impl / ApiInterfaceImpl.h
1 /*
2  *  Copyright (c) 2017 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 /**
18  * @file        ApiInterfaceImpl.h
19  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
20  * @version     1.0
21  * @brief       The declaration of ApiInterfaceImpl.
22  */
23
24 #pragma once
25
26 #include <memory>
27
28 #include <ApiInterface.h>
29 #include <PopupCallbackClosure.h>
30 #include <StatusCallbackClosure.h>
31
32 #include <askuser-notification/ask-user-client-channel.h>
33
34 #include <askuser-notification-client.h>
35
36 namespace AskUser {
37
38 namespace Client {
39
40 class ApiInterfaceImpl : public ApiInterface {
41 public:
42     ApiInterfaceImpl(const StatusCallbackClosure &closure);
43     ApiInterfaceImpl(const ApiInterfaceImpl& orig) = delete;
44     virtual ~ApiInterfaceImpl();
45
46     ApiInterface &operator=(const ApiInterfaceImpl& orig) = delete;
47
48     virtual int process(int fd, int events);
49     virtual askuser_check_result checkPrivilege(const std::string &privilege);
50     virtual RequestId popupRequest(const PopupCallbackClosure &closure,
51                                    const std::string &privilege);
52
53     void updateConnection(Protocol::ConnectionFd fd, int mask);
54     void popupResponse(Protocol::RequestId id, int response);
55
56 private:
57     StatusCallbackClosure m_statusClosure;
58     std::unique_ptr<Protocol::ClientChannel> m_channel;
59     std::map<RequestId, PopupCallbackClosure> m_callbacks;
60 };
61
62 } // namespace Client
63
64 } // namespace AskUser
65