summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-05-04 15:09:49 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2012-05-04 15:09:49 +0200
commit6f6bd04d77336927f344b1fd4b02880286aebdcb (patch)
tree81dc7a7b06375a802430b92e66cc6692d216693b
parent055a527dd8103e35bf76ea04373f5c31ab03200f (diff)
Deliver id of newly created task to caller (MessageHandler) through taskid_t pointer.
-rw-r--r--src/messagehandler.cc4
-rw-r--r--src/taskmanager.cc4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/messagehandler.cc b/src/messagehandler.cc
index 0b63da1..8217bde 100644
--- a/src/messagehandler.cc
+++ b/src/messagehandler.cc
@@ -48,7 +48,9 @@ MessageList handle_msg(MessageList msgList, clientid_t wsi) {
{
INFO(messagehandler, "Handling create command\n");
try {
- m.nodes = task_manager.createTask(m.create.parentid);
+ taskid_t id;
+ m.nodes = task_manager.createTask(m.create.parentid, &id);
+ m.create.id = id;
outmsgs.push_back(m);
}
catch (std::exception& e) {
diff --git a/src/taskmanager.cc b/src/taskmanager.cc
index 479299c..2dda0e0 100644
--- a/src/taskmanager.cc
+++ b/src/taskmanager.cc
@@ -120,7 +120,7 @@ TaskIdList TaskManager::updateTask(taskid_t id, task_t t)
return affectedTasks;
}
-TaskIdList TaskManager::createTask(taskid_t parentid)
+TaskIdList TaskManager::createTask(taskid_t parentid, taskid_t *pid)
throw (std::exception) {
TaskIdList affectedTasks;
@@ -128,8 +128,8 @@ TaskIdList TaskManager::createTask(taskid_t parentid)
taskid_t id = createId();
t.title = "";
t.id = id;
+ if(pid) *pid = id;
-// printf("Created node with id %d\n", t.id);
try {
affectedTasks = tree.insertAsChild(parentid, id, t);
}