aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp130
1 files changed, 89 insertions, 41 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 6d3f1bb..8038f4c 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -62,6 +62,9 @@ const char kKeyHeightPixel[] = "height_pixel";
const char kKeyWidthMm[] = "width_mm";
const char kKeyHeightMm[] = "height_mm";
+static const std::string task_allocate = "allocate"
+static const std::string task_release = "release"
+
static AllocateRequestList allocate_list;
namespace {
@@ -348,6 +351,33 @@ void App::layout_commit() {
this->display->flush();
}
+void App::do_allocate_window_resource(unsigned sequence_number){
+ do {
+ // TODO: Tasks will be changed according to policy manager result
+ // do task(onTransition (activate))
+ }while (!allocate_list.requestFinished())
+
+ // lm_.updateLayout(jobj);
+ // TODO: emit syncDraw with application
+ do{
+ client->emit_syncdraw(role);
+ }while (!allocate_list.requestFinished());
+
+ // is this needed?
+ //allocate_list.setAllocated(sequence_number);
+
+ if(timer_ev_src != nullptr){
+ // firsttime set into sd_event
+ int ret = sd_event_add_time(afb_daemon_get_event_loop(), &timer_ev_src,
+ CLOCK_BOOTTIME, time(NULL) + TIME_OUT, 0, processTimerHandler, this);
+ }
+ else{
+ // update timer limitation after second time
+ sd_event_source_set_time(timer_ev_src, time(NULL) + TIME_OUT);
+ sd_event_source_set_enabled(timer_ev_src, SD_EVENT_ONESHOT);
+ }
+}
+
void App::api_activate_surface(char const *appid, char const *drawing_name, char const *drawing_area, const reply_func &reply) {
ST();
@@ -357,30 +387,49 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
auto const &surface_id = this->lookup_id(drawing_name);
std::string role = std::string(drawing_name);
- // newState = checkPolicy(role);
+ std::string area = std::string(drawing_area);
+
const WMClient* client = allocate_list.loopUpClient(appid);
+ if(!client){
+ reply("%d doesn't request 'requestSurface' yet", appid);
+ return;
+ }
+
+ // json_object* newState = checkPolicy(role);
+ /* The following error check is not necessary because main.cpp will reject the message form not registered object
if(client != nullptr){
reply("client is not registered");
return;
- }
- auto const &surface_id_tmp = client->surfaceID(role);
+ } */
+
+ // get surfaceID from role
+ /* auto const &surface_id_tmp = client->surfaceID(role);
auto const &layer_id_tmp = client->layerID();
if(!surface_id_tmp && !layer_id_tmp){
reply("invalid window manager client");
HMI_DEBUG("appid:%s, requested_role:%s, surfaceID:%d in layer %d",
appid, role, surface_id_tmp, layer_id_tmp);
- }
+ } */
/*
* Queueing Phase
*/
- static unsigned ++sequence_number;
unsigned current = allocate_list.curerntSequenceNumber();
+ unsigned requested_num = getSequenceNumber(appid, role, area);
+ if(requested_num != 0){
+ HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", appid, role, area);
+ reply("already requested");
+ return;
+ }
+
+ static unsigned ++sequence_number;
+ HMI_SEQ_DEBUG(sequence_number, "%s start sequence with %s, %s", appid, role, area);
if(sequence_number != current){
// Add request, then invoked after the previous task is finished
- allocate_list.addAllocateRequest(client, sequence_number, tasks);
+ allocate_list.addAllocateRequest(client, sequence_number, task_allocate);
+ HMI_SEQ_DEBUG(sequence_number, "request is accepted");
reply(nullptr);
return;
}
@@ -388,27 +437,7 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
/*
* Do allocate tasks
*/
- do {
- // TODO: Tasks will be changed according to policy manager result
- // do task(onTransition (activate))
- }while (!allocate_list.requestFinished())
-
- // lm_.updateLayout(jobj);
- // TODO: emit syncDraw with application
- do{
- client->emit_syncdraw(role);
- }while (!allocate_list.requestFinished());
-
- if(timer_ev_src != nullptr){
- // firsttime set into sd_event
- int ret = sd_event_add_time(afb_daemon_get_event_loop(), &timer_ev_src,
- CLOCK_BOOTTIME, time(NULL) + TIME_OUT, 0, processTimerHandler, this);
- }
- else{
- // update timer limitation after second time
- sd_event_source_set_time(timer_ev_src, time(NULL) + TIME_OUT);
- sd_event_source_set_enabled(timer_ev_src, SD_EVENT_ONESHOT);
- }
+ this->do_allocate_window_resource(sequence_number);
if (!surface_id)
{
@@ -559,7 +588,7 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
}
}
-void App::api_deactivate_surface(char const *drawing_name, const reply_func &reply) {
+void App::api_deactivate_surface(char const *appid, char const *drawing_name, const reply_func &reply) {
ST();
auto const &surface_id = this->lookup_id(drawing_name);
WMClient* client = allocate_list.lookupClient(appid);
@@ -663,31 +692,50 @@ void App::check_flushdraw(int surface_id) {
}
}
-void App::api_enddraw(char const *drawing_name) {
- unsigned request_seq = allocate_list.searchAllocatingApp(appid);
+void App::do_enddraw(unsigned sequence_number){
+ HMI_SEQ_INFO(sequence_number, "do endDraw");
+ do{
+ // make visible application
+ }while(!allocate_list.requestFinished());
+
+ HMI_SEQ_INFO(sequence_number, "emit flushDraw");
+ do{
+ // emit flush Draw
+ //emitFlushDrawToAll(&allocate_list, request_seq);
+ // emit status change event
+ }while(!allocate_list.requestFinished());
+}
+
+void App::api_enddraw(char const *appid, char const *drawing_name) {
+ unsigned request_seq = allocate_list.lookUpAllocatingApp(appid);
unsigned current_seq = allocate_list.currentSequence();
if(current_seq != request_seq){
if(request_seq == 0){
- HMI_ERROR("[req_num:%d] You don't have Window Resource", request_seq);
+ HMI_ERROR("You don't have Window Resource");
}
else{
- HMI_ERROR("[req_num:%d] unknown error. Application may not obey the sequence manner. please call endDraw after syncDraw");
+ HMI_ERROR("wm", "unknown error. Application may not obey the sequence manner. please call endDraw after syncDraw");
}
return;
}
- allocate_list.allocate(appid, request_seq);
+
+ std::string role = drawing_name;
+ std::string area = drawing_area;
+ allocate_list.setEndDrawFinished(request_seq, role);
+
if(allocate_list.endDrawFullfilled(request_seq)){
// do task for endDraw
- do{
- // visible application
- }while(false);
- do{
- // emit flush Draw
- allocate_list.resetRequest(request_seq);
- }while(false);
+ this->do_enddraw(request_seq);
+ allocate_list.removeRequest(request_seq);
+ HMI_SEQ_INFO(request_seq, "Finish sequence");
+ allocate_list.setCurrentSequence(request_seq + 1);
+ if(allocate_list.haveRequest()){
+ this->process_request();
+ }
}
else{
- // wait other apps call endDraw
+ HMI_SEQ_INFO(request_seq, "Wait other App call endDraw");
+ return;
}
for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
auto n = this->lookup_name(this->pending_end_draw[i]);