diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-05-04 10:45:15 +0200 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-05-04 10:45:15 +0200 |
commit | d0bd8f44997150bcb06137258512654c75e79b49 (patch) | |
tree | 9057d2b5ec318f25b88868a7b715b46d800a98cf | |
parent | e2cf2ab253d32147e079a817f692f5c87b635c7e (diff) |
added create message functions
-rw-r--r-- | src/messageparser.cc | 42 | ||||
-rw-r--r-- | src/messageparser.h | 5 |
2 files changed, 33 insertions, 14 deletions
diff --git a/src/messageparser.cc b/src/messageparser.cc index e6d5e46..3b19b86 100644 --- a/src/messageparser.cc +++ b/src/messageparser.cc @@ -111,7 +111,7 @@ 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] == "del") m.cmd = cmd::del; else if(t[0] == "move") m.cmd = cmd::move; else if(t[0] == "update") m.cmd = cmd::update; else m.cmd = cmd::error; @@ -146,14 +146,14 @@ inline static void create_msg_list(MsgTokensList& msgTokensList, printf("addcmd: %s %s %d\n", m.add.title, m.add.desc, m.add.parentid); 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::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"); @@ -202,10 +202,10 @@ std::string msg_tostring(message_t m) { m.add.parentid); break; } - case cmd::del: { - asprintf(&buf, "del %d;", m.del.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; @@ -228,6 +228,22 @@ std::string msg_tostring(message_t m) { return r; } +message_t create_msg_create(task_t t) { + message_t m; + m.cmd = cmd::add; + m.add.id = t.id; + return m; +} + +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()); + return m; +} + + #ifdef TEST_MSGPARSER //Additional dependency files //deps: diff --git a/src/messageparser.h b/src/messageparser.h index 6483794..c768579 100644 --- a/src/messageparser.h +++ b/src/messageparser.h @@ -32,7 +32,10 @@ MessageList parse_msg(std::string msg); -message_t create_msg(cmd::cmd_t type, task_t task); +//message_t create_msg(cmd::cmd_t type, task_t task); std::string msg_tostring(message_t msg); +message_t create_msg_create(taskid_t task); +message_t create_msg_update(taskid_t task); + #endif/*__MUNIA_MESSAGEPARSER_H__*/ |