summaryrefslogtreecommitdiff
path: root/src/messageparser.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-05-04 11:47:09 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2012-05-04 11:47:09 +0200
commit5523263c6ca0782979394ba25c1679801bf5fe99 (patch)
tree6a4fc5ee9fe02bbbbda9b205f0b1e322ef2ead92 /src/messageparser.cc
parentcd715b0c0cb84f082967dc0ce4e504074ee0484c (diff)
parentc90f21d1d5526f87035fcf34ad40feb3348558c6 (diff)
Fix bad task type.
Diffstat (limited to 'src/messageparser.cc')
-rw-r--r--src/messageparser.cc64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/messageparser.cc b/src/messageparser.cc
index 3b19b86..b3fc173 100644
--- a/src/messageparser.cc
+++ b/src/messageparser.cc
@@ -110,8 +110,8 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
if(t[0] == "observe") m.cmd = cmd::observe;
else if(t[0] == "unobserve") m.cmd = cmd::unobserve;
- else if(t[0] == "add") m.cmd = cmd::add;
-// else if(t[0] == "del") m.cmd = cmd::del;
+ else if(t[0] == "create") m.cmd = cmd::create;
+ else if(t[0] == "remove") m.cmd = cmd::remove;
else if(t[0] == "move") m.cmd = cmd::move;
else if(t[0] == "update") m.cmd = cmd::update;
else m.cmd = cmd::error;
@@ -135,25 +135,22 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
m.unobserve.id = atoi(t[1].c_str());
break;
}
- case cmd::add: {
- if(t.size() != 3+1) {
+ case cmd::create: {
+ if(t.size() != 1+1) {
+ printf("Wrong number of parameters\n");
+ continue;
+ }
+ m.create.parentid = atoi(t[1].c_str());
+ break;
+ }
+ case cmd::remove: {
+ if(t.size() != 1+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.parentid = atoi(t[3].c_str());
- printf("addcmd: %s %s %d\n", m.add.title, m.add.desc, m.add.parentid);
+ m.remove.id = atoi(t[1].c_str());
break;
}
-// case cmd::del: {
-// if(t.size() != 1+1) {
-// printf("Wrong number of parameters\n");
-// continue;
-// }
-// m.del.id = atoi(t[1].c_str());
-// break;
-// }
case cmd::move: {
if(t.size() != 2+1) {
printf("Wrong number of parameters\n");
@@ -164,13 +161,12 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
break;
}
case cmd::update: {
- if(t.size() != 3+1) {
+ if(t.size() != 2+1) {
printf("Wrong number of parameters\n");
continue;
}
m.update.id = atoi(t[1].c_str());
sprintf(m.update.title, "%s", t[2].c_str());
- sprintf(m.update.desc, "%s", t[3].c_str());
break;
}
default:
@@ -195,24 +191,22 @@ MessageList parse_msg(std::string data) {
std::string msg_tostring(message_t m) {
char* buf = NULL;
switch(m.cmd) {
- case cmd::add: {
- asprintf(&buf, "add %d \"%s\" \"%s\" %d;",
- m.add.id,
- m.add.title, m.add.desc,
- m.add.parentid);
+ case cmd::create: {
+ asprintf(&buf, "create %d %d;",
+ m.create.id,
+ m.create.parentid);
+ break;
+ }
+ case cmd::remove: {
+ asprintf(&buf, "remove %d;", m.remove.id);
break;
}
-// case cmd::del: {
-// asprintf(&buf, "del %d;", m.del.id);
-// break;
-// }
case cmd::move: {
asprintf(&buf, "move %d %d;", m.move.id, m.move.parentid);
break;
}
case cmd::update: {
- //todo
- asprintf(&buf, "update %d \"%s\" \"%s\";", m.update.id, m.update.title, m.update.desc);
+ asprintf(&buf, "update %d \"%s\";", m.update.id, m.update.title);
break;
};
default:
@@ -230,8 +224,8 @@ std::string msg_tostring(message_t m) {
message_t create_msg_create(task_t t) {
message_t m;
- m.cmd = cmd::add;
- m.add.id = t.id;
+ m.cmd = cmd::create;
+ m.create.id = t.id;
return m;
}
@@ -239,10 +233,16 @@ message_t create_msg_update(task_t t) {
message_t m;
m.cmd = cmd::update;
m.update.id = t.id;
- sprintf(m.add.title, "%s", t.title.c_str());
+ sprintf(m.update.title, "%s", t.title.c_str());
return m;
}
+message_t create_msg_remove(task_t t) {
+ message_t m;
+ m.cmd = cmd::remove;
+ m.remove.id = t.id;
+ return m;
+}
#ifdef TEST_MSGPARSER
//Additional dependency files