Change API in applist
[apps/agl-service-windowmanager.git] / src / applist.cpp
index 462a0d8..d0082dd 100644 (file)
@@ -53,7 +53,7 @@ void AppList::removeClient(const string &appid)
     this->app2client.erase(appid);
 }
 
-bool AppList::contains(const string &appid)
+bool AppList::contains(const string &appid) const
 {
     auto result = this->app2client.find(appid);
     return (this->app2client.end() != result) ? true : false;
@@ -83,18 +83,18 @@ shared_ptr<WMClient> AppList::lookUpClient(const string &appid)
     return this->app2client.at(appid);
 }
 
-int AppList::countClient()
+int AppList::countClient() const
 {
     return this->app2client.size();
 }
 
-unsigned AppList::currentRequestNumber()
+unsigned AppList::currentRequestNumber() const
 {
     return this->current_req;
 }
 
 // Is this function necessary ?
-unsigned AppList::getRequestNumber(const string &appid)
+unsigned AppList::getRequestNumber(const string &appid) const
 {
     for (const auto &x : this->req_list)
     {
@@ -122,36 +122,36 @@ unsigned AppList::addAllocateRequest(WMRequest req)
     return req.req_num; // return 1; if you test time_expire
 }
 
-bool AppList::requestFinished()
+struct WMTrigger AppList::getRequest(unsigned req_num, bool *found)
 {
-    return this->req_list.empty();
-}
-
-struct WMTrigger AppList::getRequest(unsigned req_num)
-{
-    for (auto &x : this->req_list)
+    *found = false;
+    for (const auto &x : this->req_list)
     {
         if (req_num == x.req_num)
         {
+            *found = true;
             return x.trigger;
         }
     }
+    return WMTrigger{"", "", "", Task::TASK_INVALID};
 }
 
-const vector<struct WMAction> &AppList::getActions(unsigned req_num)
+const vector<struct WMAction> &AppList::getActions(unsigned req_num, bool* found)
 {
+    *found = false;
     for (auto &x : this->req_list)
     {
         if (req_num == x.req_num)
         {
+            *found = true;
             return x.sync_draw_req;
         }
     }
 }
 
-bool AppList::setAction(unsigned req_num, const struct WMAction &action)
+WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
 {
-    bool result = false;
+    WMError result = WMError::FAIL;
     for (auto &x : this->req_list)
     {
         if (req_num != x.req_num)
@@ -159,7 +159,7 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action)
             continue;
         }
         x.sync_draw_req.push_back(action);
-        result = true;
+        result = WMError::SUCCESS;
         break;
     }
 
@@ -173,9 +173,9 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action)
  * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true.
  * This function doesn't support actions for focus yet.
  */
-bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
+WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible)
 {
-    bool result = false;
+    WMError result = WMError::NOT_REGISTERED;
     for (auto &x : req_list)
     {
         if (req_num != x.req_num)
@@ -186,7 +186,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol
         WMAction action{appid, role, area, visible, edraw_f};
 
         x.sync_draw_req.push_back(action);
-        result = true;
+        result = WMError::SUCCESS;
         break;
     }
     return result;
@@ -269,7 +269,7 @@ void AppList::next()
     }
 }
 
-bool AppList::haveRequest()
+bool AppList::haveRequest() const
 {
     return !this->req_list.empty();
 }