summaryrefslogtreecommitdiff
path: root/src/msgparser.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2012-03-10 14:56:34 +0100
committerJonas Suhr Christensen <jsc@umbraculum.org>2012-03-10 14:56:34 +0100
commit39396a2660150770c3fd14aac8b4be0dcbae8497 (patch)
treeec1604a37725de1dfafade10bb4cb24d89e6322c /src/msgparser.cc
parent0f00f525e5c4da9f5a96cd35c3cdad50f84b51d9 (diff)
Added new task hierarchy based protocol.
Drag and drop works somehow - maybe some weirdness in html5 drag and drop.
Diffstat (limited to 'src/msgparser.cc')
-rw-r--r--src/msgparser.cc36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/msgparser.cc b/src/msgparser.cc
index 1ea2f31..f3bafe1 100644
--- a/src/msgparser.cc
+++ b/src/msgparser.cc
@@ -32,6 +32,7 @@
#include <list>
#include <vector>
+/*
inline void parse_add(msg_t& m, std::string data) {
int offset = 0;
std::string title = data.substr(offset, data.find(' ', offset) - offset);
@@ -73,6 +74,7 @@ inline void parse_move(msg_t& m, std::string data) {
m.move.x = x;
m.move.y = y;
}
+*/
MsgVector parse_msg(std::string data) {
@@ -165,14 +167,15 @@ MsgVector parse_msg(std::string data) {
switch(m.cmd) {
case cmd::add: {
- if(t.size() != 4+1) {
+ if(t.size() != 3+1) {
printf("Wrong number of parameters\n");
continue;
}
sprintf(m.add.title, "%s", t[1].c_str());
sprintf(m.add.desc, "%s", t[2].c_str());
- m.add.x = atoi(t[3].c_str());
- m.add.y = atoi(t[4].c_str());
+ m.add.parent_id = atoi(t[3].c_str());
+// m.add.x = atoi(t[3].c_str());
+// m.add.y = atoi(t[4].c_str());
// printf("addcmd: %s %s %d %d\n", m.add.title, m.add.desc, m.add.x, m.add.y);
break;
}
@@ -185,13 +188,14 @@ MsgVector parse_msg(std::string data) {
break;
}
case cmd::move: {
- if(t.size() != 3+1) {
+ if(t.size() != 2+1) {
printf("Wrong number of parameters\n");
continue;
}
m.move.id = atoi(t[1].c_str());
- m.move.x = atoi(t[2].c_str());
- m.move.y = atoi(t[3].c_str());
+ m.move.parent_id = atoi(t[2].c_str());
+// m.move.x = atoi(t[2].c_str());
+// m.move.y = atoi(t[3].c_str());
break;
}
case cmd::update: {
@@ -217,8 +221,9 @@ msg_t create_msg(cmd::cmd_t type, task_t t) {
switch(type) {
case cmd::add: {
m.add.id = t.id;
- m.add.x = t.x;
- m.add.y = t.y;
+ m.add.parent_id = t.parent_id;
+// m.add.x = t.x;
+// m.add.y = t.y;
// m.add.title = t.title.c_str();
// m.add.desc = t.desc.c_str();
snprintf(m.add.title, sizeof(m.add.title), "%s", t.title.c_str());
@@ -231,8 +236,9 @@ msg_t create_msg(cmd::cmd_t type, task_t t) {
}
case cmd::move: {
m.move.id = t.id;
- m.move.x = t.x;
- m.move.y = t.y;
+// m.move.x = t.x;
+// m.move.y = t.y;
+ m.move.parent_id = t.parent_id;
break;
}
case cmd::update: {
@@ -258,10 +264,14 @@ std::string msg_tostring(msg_t m) {
case cmd::add: {
// printf("msg: %d, %d, %d, %s, %s\n", m.add.id, m.add.x, m.add.y, m.add.title, m.add.desc);
// snprintf(buf, BUF_SIZE, "add %d %s %s %d %d;",
- asprintf(&buf, "add %d \"%s\" \"%s\" %d %d;",
+// asprintf(&buf, "add %d \"%s\" \"%s\" %d %d;",
+// m.add.id,
+// m.add.title, m.add.desc,
+// m.add.x, m.add.y);
+ asprintf(&buf, "add %d \"%s\" \"%s\" %d;",
m.add.id,
m.add.title, m.add.desc,
- m.add.x, m.add.y);
+ m.add.parent_id);
break;
}
case cmd::del: {
@@ -271,7 +281,7 @@ std::string msg_tostring(msg_t m) {
}
case cmd::move: {
// snprintf(buf, BUF_SIZE, "move %d %d %d;", m.move.id, m.move.x, m.move.y);
- asprintf(&buf, "move %d %d %d;", m.move.id, m.move.x, m.move.y);
+ asprintf(&buf, "move %d %d;", m.move.id, m.move.parent_id);
break;
}
case cmd::update: {