Add the 'privilege' parameter to popup response callback
[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  * @brief       The declaration of ApiInterfaceImpl.
21  */
22
23 #pragma once
24
25 #include <map>
26 #include <memory>
27 #include <set>
28
29 #include <ApiInterface.h>
30 #include <PopupCallbackClosure.h>
31 #include <StatusCallbackClosure.h>
32
33 #include <client-channel.h>
34
35 #include <askuser-notification-client.h>
36
37 namespace AskUser {
38
39 namespace Client {
40
41 class ApiInterfaceImpl : public ApiInterface {
42 public:
43     explicit ApiInterfaceImpl(const StatusCallbackClosure &closure);
44     ApiInterfaceImpl(const ApiInterfaceImpl& orig) = delete;
45     virtual ~ApiInterfaceImpl();
46
47     ApiInterface &operator=(const ApiInterfaceImpl& orig) = delete;
48
49     virtual int process(int fd, int events);
50     virtual askuser_check_result checkPrivilege(const std::string &privilege);
51     virtual RequestId popupRequest(const PopupCallbackClosure &closure,
52                                    const std::string &privilege);
53     virtual bool popupRequestInProgress(const std::string &privilege) const;
54
55     void updateConnection(Protocol::ConnectionFd fd, int mask);
56     void popupResponse(Protocol::RequestId id, int response);
57
58 private:
59     void respondToAllRequests(askuser_call_cause cause, askuser_popup_result result);
60
61     StatusCallbackClosure m_statusClosure;
62     std::unique_ptr<Protocol::ClientChannel> m_channel;
63     std::map<RequestId, PopupCallbackClosure> m_popupClosures;
64     std::set<std::string> m_requestedPrivileges;
65 };
66
67 } // namespace Client
68
69 } // namespace AskUser
70