diff options
Diffstat (limited to 'src/messagehandler.cc')
-rw-r--r-- | src/messagehandler.cc | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/messagehandler.cc b/src/messagehandler.cc index cdc7246..a394f08 100644 --- a/src/messagehandler.cc +++ b/src/messagehandler.cc @@ -86,8 +86,51 @@ MessageList handle_msg(MessageList msgList, clientid_t wsi) { { INFO(messagehandler, "Handling move command\n"); try { - m.nodes = task_manager.moveTask(m.move.id, m.move.parentid); - outmsgs.push_back(m); + task_t removetask = task_manager.task(m.move.id); + TaskIdListPair tilpair = task_manager.moveTask(m.move.id, m.move.parentid); + task_t createtask = task_manager.task(m.move.id); + + /* + TaskIdList commonAncestors; + TaskIdList removeAncestors; + TaskIdList createAncestors; + + // find command ancestors and fill ancestors for remove command + for(TaskIdList::iterator it_remove = tilpair.first.begin(); + it_remove != tilpair.first.end(); it_remove++) { + taskid_t removeid = *it; + bool common = false; + for(TaskIdList::iterator it_create = tilpair.second.begin(); + it_create = != tilpair.second.end(); it_create++) { + taskid_t createid = *id; + if(removeid == createid) { + commandAncestors.push_back(removeid); + common = true; + } + } + if(!common) { + removeAncestors.push_back(removeid); + } + } + + // fill ancestors for create command + for(TaskIdList::iterator it_create = tilpair.second.begin(); + it_create = != tilpair.second.end(); it_create++) { + taskid_t createid = *id; + if(removeid == createid) { + commandAncestors.push_back(removeid); + common = true; + } + } + */ + + message_t removemsg = create_msg_remove(removetask); + removemsg.nodes = tilpair.first; + message_t createmsg = create_msg_create(createtask); + createmsg.nodes = tilpair.second; + + outmsgs.push_back(removemsg); + outmsgs.push_back(createmsg); } catch (std::exception& e) { DEBUG(messagehandler, "Error moving task\n"); |