From 6f6bd04d77336927f344b1fd4b02880286aebdcb Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 4 May 2012 15:09:49 +0200 Subject: Deliver id of newly created task to caller (MessageHandler) through taskid_t pointer. --- src/messagehandler.cc | 4 +++- src/taskmanager.cc | 4 ++-- 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); } -- cgit v1.2.3