#ifndef CMDMAN_H #define CMDMAN_H #include "fileman.h" #include #include #include #include using std::string; using std::vector; using std::map; class CmdMan { public: enum rettype { notsend, send, error, startlist, stoplist, close, seton }; struct CmdRet { rettype type; string msg; }; CmdMan(FileMan &fm); ~CmdMan(); // execute cmd with optional argument args, returns answer string // if cmd unknown, returns error string CmdRet execute(string cmd, vector args); CmdRet handle(Json::Value root); Json::CharReader* reader; private: Json::StreamWriterBuilder wbuilder; string jsonerror; FileMan &fileman; map)> execmap; map helpmap; map handlemap; bool dologin, doversion; /* execute command descriptions and methods go here */ const string descHelp = "print available commands"; CmdRet cmdHelp(vector args); const string descStatus = "request status from server"; CmdRet cmdStatus(vector args); const string descDisconnect = "disconnect from server"; CmdRet cmdDisconnect(vector args); const string descPut = "upload file to server and add to queue"; CmdRet cmdPut(vector args); const string descGet = "retrieve file from server"; CmdRet cmdGet(vector args); const string descList = "list files available on server"; CmdRet cmdList(vector args); /* internal execute commands */ CmdRet cmdVersion(vector args); CmdRet cmdLogin(vector args); /* handle commands go here */ CmdRet handleStatus(Json::Value); CmdRet handleClose(Json::Value); CmdRet handlePut(Json::Value); CmdRet handleGet(Json::Value); CmdRet handleList(Json::Value); CmdRet handleVersion(Json::Value); CmdRet handleLogin(Json::Value); }; #endif