|
@@ -33,6 +33,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
execmap["getdata"] = &CmdMan::cmdGetdata;
|
|
|
execmap["listdata"] = &CmdMan::cmdListdata;
|
|
|
execmap["head"] = &CmdMan::cmdHead;
|
|
|
+ execmap["deleteme"] = &CmdMan::cmdDeleteme;
|
|
|
|
|
|
/* initialize description map */
|
|
|
helpmap["help"] = descHelp;
|
|
@@ -44,6 +45,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
helpmap["head"] = descHead;
|
|
|
helpmap["login"] = descLogin;
|
|
|
helpmap["signup"] = descSignup;
|
|
|
+ helpmap["deleteme"] = descDeleteme;
|
|
|
|
|
|
/* initialize handle command map */
|
|
|
handlemap["status"] = &CmdMan::handleStatus;
|
|
@@ -58,6 +60,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
handlemap["signup"] = &CmdMan::handleSignup;
|
|
|
handlemap["listdata"] = &CmdMan::handleListdata;
|
|
|
handlemap["head"] = &CmdMan::handleHead;
|
|
|
+ handlemap["deleteme"] = &CmdMan::handleDeleteme;
|
|
|
|
|
|
debugprintfunc = dpf;
|
|
|
}
|
|
@@ -289,6 +292,26 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
return (this->*(execmap[cmd]))(args);
|
|
|
}
|
|
|
|
|
|
+CmdMan::CmdRet CmdMan::cmdDeleteme(vector<string> args) {
|
|
|
+ CmdRet retval;
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
+ Json::Value root;
|
|
|
+
|
|
|
+ root["command"] = "deleteme";
|
|
|
+
|
|
|
+ if (args.size() < 1) {
|
|
|
+ retval.type = error;
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "not enough arguments, at least 1 argument required";
|
|
|
+ } else {
|
|
|
+ retval.type = send;
|
|
|
+ root["pass"] = args[0];
|
|
|
+ }
|
|
|
+ retval.msg = root;
|
|
|
+
|
|
|
+ return retval;
|
|
|
+}
|
|
|
+
|
|
|
/* login and signup commands */
|
|
|
CmdMan::CmdRet CmdMan::cmdLogin(vector<string> args) {
|
|
|
CmdRet retval;
|
|
@@ -408,9 +431,12 @@ CmdMan::CmdRet CmdMan::handleStatus(Json::Value root) {
|
|
|
|
|
|
CmdMan::CmdRet CmdMan::handleClose(Json::Value root) {
|
|
|
CmdRet retval;
|
|
|
+ Json::Value output;
|
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
- retval.type = close;
|
|
|
- retval.msg = root;
|
|
|
+ output["command"] = "disconnect";
|
|
|
+ output["accept"] = true;
|
|
|
+ retval.type = close | print;
|
|
|
+ retval.msg = output;
|
|
|
|
|
|
return retval;
|
|
|
}
|
|
@@ -716,6 +742,18 @@ CmdMan::CmdRet CmdMan::handleHead(Json::Value root) {
|
|
|
retval.type = print;
|
|
|
retval.msg = root;
|
|
|
}
|
|
|
+ return retval;
|
|
|
+}
|
|
|
|
|
|
+CmdMan::CmdRet CmdMan::handleDeleteme(Json::Value root) {
|
|
|
+ CmdRet retval;
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
+
|
|
|
+ if (!root["accept"].asBool()) {
|
|
|
+ retval.type = error;
|
|
|
+ } else {
|
|
|
+ retval.type = close | print;
|
|
|
+ }
|
|
|
+ retval.msg = root;
|
|
|
return retval;
|
|
|
}
|