6 #include "gestured_invocation_manager.h"
11 #define LOG_TAG "GESTURE_INVOCATION"
13 static const int MAX_INVOCATION_ID = 1000000;
15 static std::map<int, GDBusMethodInvocation*> g_invocation_map;
16 static int g_last_id = -1;
18 int gestureInvocationManagerInit()
20 LOGD("Initialize invocation manager");
22 g_invocation_map.clear();
27 int gestureInvocationManagerAdd(GDBusMethodInvocation* invocation)
29 if (NULL == invocation) {
30 LOGE("Invalid parameter");
34 LOGD("Add new invocation handle");
36 for (int i = g_last_id + 1; i != g_last_id; i = (i + 1) % MAX_INVOCATION_ID) {
37 if (g_invocation_map.find(i) == g_invocation_map.end()) {
45 LOGE("Invocation map is full");
49 g_invocation_map.insert({g_last_id, invocation});
54 GDBusMethodInvocation* gestureInvocationManagerGet(int invocation_id)
56 LOGD("Find invocation handle. ID(%d)", invocation_id);
57 auto iter = g_invocation_map.find(invocation_id);
58 if (iter == g_invocation_map.end()) {
59 LOGE("There is no handle");
66 bool gestureInvocationManagerRemove(int invocation_id)
68 LOGD("Remove invocation handle. ID(%d)", invocation_id);
69 g_invocation_map.erase(invocation_id);