lxcpp: fix cgroup unit tests
[platform/core/security/vasum.git] / server / input-monitor.hpp
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Jan Olszak <j.olszak@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18
19 /**
20  * @file
21  * @author  Jan Olszak (j.olszak@samsung.com)
22  * @brief   C++ wrapper for glib input monitor
23  */
24
25 #ifndef SERVER_INPUT_MONITOR_HPP
26 #define SERVER_INPUT_MONITOR_HPP
27
28 #include "input-monitor-config.hpp"
29 #include "ipc/epoll/event-poll.hpp"
30
31 #include <linux/input.h>
32 #include <sys/time.h>
33
34 #include <string>
35 #include <list>
36 #include <mutex>
37
38
39 namespace vasum {
40
41 class ZonesManager;
42
43 class InputMonitor {
44 public:
45     InputMonitor(ipc::epoll::EventPoll& eventPoll,
46                  const InputConfig& inputConfig,
47                  ZonesManager* zonesManager);
48     ~InputMonitor();
49
50     void start();
51     void stop();
52 private:
53     typedef std::mutex Mutex;
54
55     InputConfig mConfig;
56     ZonesManager* mZonesManager;
57     int mFd;
58     ipc::epoll::EventPoll& mEventPoll;
59     std::list<struct timeval> mEventTimes;
60     std::string mDevicePath;
61     Mutex mMutex;
62
63     std::string getDevicePath() const;
64     void setHandler(const std::string& devicePath);
65     void handleInternal(int fd, ipc::epoll::Events events);
66     void leaveDevice();
67     bool isExpectedEventSequence(const struct input_event&);
68 };
69
70 } // namespace vasum
71
72
73 #endif // SERVER_INPUT_MONITOR_HPP