summaryrefslogtreecommitdiff
path: root/src/messagehandler.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2012-05-17 12:10:57 +0200
committerJonas Suhr Christensen <jsc@umbraculum.org>2012-05-17 12:10:57 +0200
commit69f1a4dfc0d3a7a1462d87a31b11197a638c5746 (patch)
treeeb4be65262797896b928ab01bd5d1b12644cbe1b /src/messagehandler.cc
parent2b542db3b553e73bdd58f54f657776715fd5472d (diff)
parentc2def65a701a973cde305d8c221d01beeb33eb84 (diff)
Merge branch 'master' of https://git.oftal.dk/munia
Conflicts: src/taskmanager.cc
Diffstat (limited to 'src/messagehandler.cc')
-rw-r--r--src/messagehandler.cc47
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");