From 07e31be1298ab2df9b7b1442a2b5979c74820674 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 23 Feb 2012 15:17:24 +0100 Subject: Move 'em boxes... --- src/muniad.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/muniad.cc') 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") { -- cgit v1.2.3