summaryrefslogtreecommitdiff
path: root/src/muniad.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-02-23 15:17:24 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-02-23 15:17:24 +0100
commit07e31be1298ab2df9b7b1442a2b5979c74820674 (patch)
tree4c9f31ea224ea61b5230ab8ddc136d7336882dfb /src/muniad.cc
parent3cbbce9bbe2e63554d253bca8c313e27a16c9b12 (diff)
Move 'em boxes...
Diffstat (limited to 'src/muniad.cc')
-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") {