diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-03-30 11:37:01 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-03-30 11:37:01 +0200 |
commit | 91dad205b83319e00ea8060ca5a63de07b126c8f (patch) | |
tree | 6b64796359c459152502954b8015c33ece512cfa /src | |
parent | 9035d1358990d5e49c90605209d4e98c80263601 (diff) |
Add observe protocol in MessageParser.
Diffstat (limited to 'src')
-rw-r--r-- | src/messageparser.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/messageparser.h b/src/messageparser.h index 1559e86..b071dd8 100644 --- a/src/messageparser.h +++ b/src/messageparser.h @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** - * msgparser.h + * messageparser.h * * Fri Feb 24 14:59:34 CET 2012 * Copyright 2012 Jonas Suhr Christensen @@ -25,58 +25,77 @@ * along with Munia; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __MUNIA_MSGPARSER_H__ -#define __MUNIA_MSGPARSER_H__ +#ifndef __MUNIA_MESSAGEPARSER_H__ +#define __MUNIA_MESSAGEPARSER_H__ #include <list> #include <string> +#include "task.h" + namespace cmd { - enum cmd_t { + typedef enum { + observe, + unobserve, update, move, add, del, error - }; + } cmd_t; }; typedef struct { - int id; - int parentid; + taskid_t id; +} observe_t; + +typedef struct { + taskid_t id; +} unobserve_t; + +typedef struct { + taskid_t id; + taskid_t parent_id; char title[256]; char desc[256]; } add_t; + typedef struct { - int id; + taskid_t id; } del_t; + typedef struct { - int id; - int parentid; + taskid_t id; + taskid_t parent_id; } move_t; + typedef struct { - int id; + taskid_t id; char title[256]; char desc[256]; } update_t; -typedef struct msg_t { +typedef struct { cmd::cmd_t cmd; union { + observe_t observe; + unobserve_t unobserve; add_t add; del_t del; move_t move; update_t update; }; -} msg_types; +} message_t; + + +typedef std::list<message_t> MessageList; -typedef std::list<msg_t> MsgList; +MessageList parse_msg(std::string msg); -MsgList parse_msg(std::string msg); +message_t create_msg(cmd::cmd_t type, task_t task); +std::string msg_tostring(message_t msg); -//msg_t create_msg(cmd::cmd_t msg_type, task_t task); -std::string msg_tostring(msg_t msg); -#endif/*__MUNIA_MSGPARSER_H__*/ +#endif/*__MUNIA_MESSAGEPARSER_H__*/ |