aboutsummaryrefslogtreecommitdiffstats
path: root/src/wm-client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wm-client.cpp')
-rw-r--r--src/wm-client.cpp57
1 files changed, 47 insertions, 10 deletions
diff --git a/src/wm-client.cpp b/src/wm-client.cpp
index b568817..2d440e6 100644
--- a/src/wm-client.cpp
+++ b/src/wm-client.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <json-c/json.h>
#include "wm-client.hpp"
#include "hmi-debug.h"
@@ -25,13 +26,16 @@ using std::vector;
namespace wm
{
-
const vector<string> wm_events = {
// Private event for applications
"syncDraw", "flushDraw", "visible", "invisible", "active", "inactive", "error"};
+const vector<string> error_description = {
+ "unknown-error"};
static const char key_drawing_name[] = "drawing_name";
static const char key_role[] = "role";
+static const char key_err[] = "error";
+static const char key_err_desc[] = "error_description";
WMClient::WMClient(const string &appid, unsigned layerID, unsigned surfaceID, const string &role)
: layer(layerID),
@@ -77,15 +81,18 @@ string WMClient::appID()
return this->id;
}
-unsigned WMClient::surfaceID(const string &role){
- if(0 == role2surface.count(role)){
+unsigned WMClient::surfaceID(const string &role)
+{
+ if (0 == role2surface.count(role))
+ {
HMI_WARNING("wm", "invalid role");
return INVALID_SURFACE_ID;
}
return role2surface.at(role);
}
-unsigned WMClient::layerID(){
+unsigned WMClient::layerID()
+{
return layer;
}
@@ -97,18 +104,21 @@ void WMClient::registerLayer(unsigned layerID)
bool WMClient::addSurface(const string &role, unsigned surface)
{
HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface);
- if(0 != role2surface.count(role)){
+ if (0 != role2surface.count(role))
+ {
HMI_NOTICE("wm", "override surfaceID %d with %d", role2surface[role], surface);
}
role2surface[role] = surface;
return true;
}
-bool WMClient::removeSurfaceIfExist(unsigned surfaceID){
+bool WMClient::removeSurfaceIfExist(unsigned surfaceID)
+{
bool ret = false;
for (auto &x : role2surface)
{
- if(surfaceID == x.second){
+ if (surfaceID == x.second)
+ {
role2surface.erase(x.first);
ret = true;
break;
@@ -117,7 +127,8 @@ bool WMClient::removeSurfaceIfExist(unsigned surfaceID){
return ret;
}
-bool WMClient::removeRole(const string& role){
+bool WMClient::removeRole(const string &role)
+{
bool ret = false;
if (role2surface.count(role) != 0)
{
@@ -127,10 +138,36 @@ bool WMClient::removeRole(const string& role){
return ret;
}
-void WMClient::dumpInfo(){
+bool WMClient::subscribe(afb_req req, const string &evname)
+{
+ int ret = afb_req_subscribe(req, event_list[evname]);
+ if (ret)
+ {
+ return false;
+ }
+ return true;
+}
+
+void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
+{
+ json_object *j = json_object_new_object();
+ json_object_object_add(j, key_err, json_object_new_int(ev));
+ json_object_object_add(j, key_err_desc, json_object_new_string(error_description[ev].c_str()));
+ HMI_DEBUG("wm", "error: %d, description:%s", ev, error_description[ev].c_str());
+
+ int ret = afb_event_push(this->event_list[key_err], j);
+ if (ret != 0)
+ {
+ HMI_DEBUG("wm", "afb_event_push failed: %m");
+ }
+}
+
+void WMClient::dumpInfo()
+{
DUMP("APPID : %s", id.c_str());
DUMP(" LAYER : %d", layer);
- for(const auto& x : role2surface){
+ for (const auto &x : role2surface)
+ {
DUMP(" ROLE : %s , SURFACE : %d", x.first.c_str(), x.second);
}
}