2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef _ATSPI_ACCESSIBLE_WATCHER_H_
19 #define _ATSPI_ACCESSIBLE_WATCHER_H_
21 #include "AccessibleNode.h"
22 #include "AccessibleWatcher.h"
23 #include "AtspiAccessibleApplication.h"
25 #include <atspi/atspi.h>
28 #include <shared_mutex>
35 using namespace Aurum;
37 namespace AurumInternal {
42 * @brief WindowActivateInfoType enum class.
46 enum class WindowActivateInfoType {
47 DEFAULT_LABEL_ENALBED = 0x00,
48 DEFAULT_LABEL_ENALBED_WITHOUT_WINDOW = 0x01,
49 DEFAULT_LABEL_DISABLED = 0x02,
56 * @brief IAtspiEvents Interface
65 virtual ~IAtspiEvents() {}
71 virtual void onObjectDefunct(AtspiAccessible *node) = 0;
77 * @class AtspiAccessibleWatcher
81 * @brief Class that communicates with the atspi sever and generates an event,
82 * and generates a node that matches with atspi node.
84 class AtspiAccessibleWatcher : public AccessibleWatcher, public IAtspiEvents {
86 AtspiAccessibleWatcher();
87 virtual ~AtspiAccessibleWatcher();
91 * @copydoc @AccessibleWatcher::getApplicationCount()
93 virtual int getApplicationCount(void) const override;
96 * @copydoc @AccessibleWatcher::getApplicationAt()
98 virtual std::shared_ptr<AccessibleApplication> getApplicationAt(int index) const override;
101 * @copydoc @AccessibleWatcher::getApplications()
103 virtual std::vector<std::shared_ptr<AccessibleApplication>> getApplications(void) const override;
106 * @copydoc @AccessibleWatcher::executeAndWaitForEvents()
108 virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override;
111 * @copydoc @AccessibleWatcher::getActiveAppMap()
113 virtual std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> getActiveAppMap(void) override;
117 * @brief Listen atspi events.
119 * @param[in] event AtspiEvent
120 * @param[in] watcher @AtspiAccessibleWatcher
124 static void onAtspiEvents(AtspiEvent *event, void *watcher);
127 * @brief Notifies when object defunct.
129 * @param[in] node @AtspiAccessible
133 void onObjectDefunct(AtspiAccessible *node) override;
136 * @brief AtspiEvent listener.
138 * @param[in] event AtspiEvent
139 * @param[in] user_data data for event by user
143 static void onEventListener(AtspiEvent *event, void *user_data);
145 /** Private methods for Mock Test **/
146 bool removeFromActivatedList(AtspiAccessible *node);
147 bool addToActivatedList(AtspiAccessible *node);
148 bool removeFromWindowSet(AtspiAccessible *node);
149 bool addToWindowSet(AtspiAccessible *node);
150 void addEventListener(AtspiEventListener *listener, A11yEvent type);
151 void removeEventListener(AtspiEventListener *listener, A11yEvent type);
154 GDBusProxy *mDbusProxy;
155 std::list<AtspiAccessible *> mActivatedWindowList;
156 std::list<AtspiAccessible *> mActivatedApplicationList;
157 std::set<AtspiAccessible *> mWindowSet;
158 std::map<AtspiAccessible *, std::shared_ptr<AccessibleApplication>> mActiveAppMap;
159 static GThread *mEventThread;
160 static std::vector<std::shared_ptr<A11yEventInfo>> mEventQueue;
161 static std::mutex mMutex;