summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/muniad.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/muniad.cc b/src/muniad.cc
index e349e7c..9cb947c 100644
--- a/src/muniad.cc
+++ b/src/muniad.cc
@@ -358,15 +358,47 @@ static int callback_lws_mirror(struct libwebsocket_context * context,
break;
}
}
-
+
if(!id_found) {
printf("\t!!!Could not locate task with id %d\n", id);
}
buf_len = sprintf(buf, "del %d;", id);
printf("Deleting task: %s\n", buf);
+
} else if(cmd == "move") {
printf("Move\n");
+
+ int offset = cmd.length() + 1;
+ std::string s_id = data.substr(offset, data.find(' ', offset) - offset);
+ int id = atoi(s_id.c_str());
+ offset += s_id.length() + 1;
+ std::string x_str = data.substr(offset, data.find(' ', offset) - offset);
+ int x = atoi(x_str.c_str());
+ offset += x_str.length() + 1;
+ std::string y_str = data.substr(offset, data.find(' ', offset) - offset);
+ int y = atoi(y_str.c_str());
+
+ printf("Moving task with id %d to (%d,%d)\n", id, x, y);
+
+ bool id_found = false;
+ TaskList::iterator it;
+ for(it = tasklist.begin(); it != tasklist.end(); it++) {
+ struct task t = *it;
+ if(t.id == id) {
+ id_found = true;
+ t.x = x;
+ t.y = y;
+ break;
+ }
+ }
+
+ if(!id_found) {
+ printf("\t!!!Could not locate task with id %d\n", id);
+ }
+
+ buf_len = sprintf(buf, "move %d %d %d;", id, x, y);
+ printf("Moving task: %s\n", buf);
} else if(cmd == "update") {
printf("Update\n");
} else if(cmd == "d") {