summaryrefslogtreecommitdiff
path: root/src/task_proto.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/task_proto.cc')
-rw-r--r--src/task_proto.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/task_proto.cc b/src/task_proto.cc
index 717ca3e..2312c9e 100644
--- a/src/task_proto.cc
+++ b/src/task_proto.cc
@@ -260,9 +260,33 @@ int callback_lws_task(struct libwebsocket_context * context,
printf("Moving task: %s\n", buf_str.c_str());
break;
}
- case cmd::update:
- printf("Update\n");
+ case cmd::update: {
+ printf("Updating %d\n", m.update.id);
+
+ bool id_found = false;
+ TaskList::iterator it;
+
+ task_t updated_task;
+ for(it = tasklist.begin(); it != tasklist.end(); it++) {
+ task_t &t = *it;
+ if(t.id == m.update.id) {
+ id_found = true;
+ t.title = m.update.title;
+ t.desc = m.update.desc;
+ updated_task = t;
+ break;
+ }
+ }
+
+ if(!id_found) {
+ printf("\t!!!Could not locate task with id %d\n", m.update.id);
+ }
+
+ buf_str = msg_tostring(create_msg(cmd::update, updated_task));
+ printf("Updating task: %s\n", buf_str.c_str());
+
break;
+ }
default:
printf("Wrong command :(\n");
break;