summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/messagehandler.cc2
-rw-r--r--src/messageparser.cc37
-rw-r--r--src/taskmanager.cc2
3 files changed, 29 insertions, 12 deletions
diff --git a/src/messagehandler.cc b/src/messagehandler.cc
index 361db34..fbe2237 100644
--- a/src/messagehandler.cc
+++ b/src/messagehandler.cc
@@ -48,7 +48,7 @@ MessageList handle_msg(MessageList msgList, clientid_t wsi) {
{
INFO(messagehandler, "Handling create command\n");
try {
- taskid_t id;
+ taskid_t id = m.create.id;
m.nodes = task_manager.createTask(m.create.parentid, &id);
m.create.id = id;
outmsgs.push_back(m);
diff --git a/src/messageparser.cc b/src/messageparser.cc
index 8f4cc16..1aba5ee 100644
--- a/src/messageparser.cc
+++ b/src/messageparser.cc
@@ -92,6 +92,20 @@ inline static void parse_into_msg_tokens(std::string& data,
tokenVector.clear();
}
}
+#include <map>
+static taskid_t baseid = 10000;
+static taskid_t getId(std::map<std::string, taskid_t> &sym, std::string token)
+{
+ bool isnumeric = true;
+ for(size_t i = 0; i < token.size(); i++) {
+ isnumeric &= (token[i] >= '0' && token[i] <= '9');
+ }
+
+ if(isnumeric) return atoi(token.c_str());
+
+ if(sym.find(token) == sym.end()) sym[token] = baseid++;
+ return sym[token];
+}
inline static void create_msg_list(MsgTokensList& msgTokensList,
MessageList& msgList,
@@ -101,6 +115,8 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
origin = 1;
}
+ std::map<std::string, taskid_t> sym;
+
MsgTokensList::iterator it_msg;
for(it_msg = msgTokensList.begin(); it_msg != msgTokensList.end(); it_msg++) {
TokenVector t = *it_msg;
@@ -130,7 +146,7 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
printf("Wrong number of parameters\n");
continue;
}
- m.observe.id = atoi(t[origin+1].c_str());
+ m.observe.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
break;
}
case cmd::unobserve: {
@@ -138,11 +154,11 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
printf("Wrong number of parameters\n");
continue;
}
- m.unobserve.id = atoi(t[origin+1].c_str());
+ m.unobserve.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
break;
}
case cmd::create: {
- if(!clientmode && t.size() != origin+1+1) {
+ if(!clientmode && t.size() != origin+1+2) {
printf("Wrong number of parameters\n");
continue;
}
@@ -151,11 +167,12 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
continue;
}
if(clientmode) {
- m.create.id = atoi(t[origin+1].c_str());
- m.create.parentid = atoi(t[origin+2].c_str());
+ m.create.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
+ m.create.parentid = getId(sym, t[origin+2]);// atoi(t[origin+2].c_str());
}
else {
- m.create.parentid = atoi(t[origin+1].c_str());
+ m.create.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
+ m.create.parentid = getId(sym, t[origin+2]);//atoi(t[origin+1].c_str());
}
break;
}
@@ -164,7 +181,7 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
printf("Wrong number of parameters\n");
continue;
}
- m.remove.id = atoi(t[origin+1].c_str());
+ m.remove.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
break;
}
case cmd::move: {
@@ -172,8 +189,8 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
printf("Wrong number of parameters\n");
continue;
}
- m.move.id = atoi(t[origin+1].c_str());
- m.move.parentid = atoi(t[origin+2].c_str());
+ m.move.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
+ m.move.parentid = getId(sym, t[origin+2]);//atoi(t[origin+2].c_str());
break;
}
case cmd::update: {
@@ -181,7 +198,7 @@ inline static void create_msg_list(MsgTokensList& msgTokensList,
printf("Wrong number of parameters\n");
continue;
}
- m.update.id = atoi(t[origin+1].c_str());
+ m.update.id = getId(sym, t[origin+1]);//atoi(t[origin+1].c_str());
sprintf(m.update.title, "%s", t[origin+2].c_str());
break;
}
diff --git a/src/taskmanager.cc b/src/taskmanager.cc
index c7cdb6d..41c1c8d 100644
--- a/src/taskmanager.cc
+++ b/src/taskmanager.cc
@@ -168,7 +168,7 @@ TaskIdList TaskManager::createTask(taskid_t parentid, taskid_t *pid)
TaskIdList affectedTasks;
task_t t;
- taskid_t id = createId();
+ taskid_t id = *pid;//createId();
t.title = "";
t.id = id;
if(pid) *pid = id;