|
@@ -33,6 +33,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
execmap["getdata"] = &CmdMan::cmdGetdata;
|
|
execmap["getdata"] = &CmdMan::cmdGetdata;
|
|
execmap["listdata"] = &CmdMan::cmdListdata;
|
|
execmap["listdata"] = &CmdMan::cmdListdata;
|
|
execmap["head"] = &CmdMan::cmdHead;
|
|
execmap["head"] = &CmdMan::cmdHead;
|
|
|
|
+ execmap["deletefile"] = &CmdMan::cmdDeletefile;
|
|
execmap["deleteme"] = &CmdMan::cmdDeleteme;
|
|
execmap["deleteme"] = &CmdMan::cmdDeleteme;
|
|
execmap["keyfile"] = &CmdMan::cmdKeyfile;
|
|
execmap["keyfile"] = &CmdMan::cmdKeyfile;
|
|
execmap["closekey"] = &CmdMan::cmdClosekey;
|
|
execmap["closekey"] = &CmdMan::cmdClosekey;
|
|
@@ -47,6 +48,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
helpmap["head"] = descHead;
|
|
helpmap["head"] = descHead;
|
|
helpmap["login"] = descLogin;
|
|
helpmap["login"] = descLogin;
|
|
helpmap["signup"] = descSignup;
|
|
helpmap["signup"] = descSignup;
|
|
|
|
+ helpmap["deletefile"] = descDeletefile;
|
|
helpmap["deleteme"] = descDeleteme;
|
|
helpmap["deleteme"] = descDeleteme;
|
|
helpmap["keyfile"] = descKeyfile;
|
|
helpmap["keyfile"] = descKeyfile;
|
|
helpmap["closekey"] = descClosekey;
|
|
helpmap["closekey"] = descClosekey;
|
|
@@ -64,6 +66,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
handlemap["signup"] = &CmdMan::handleSignup;
|
|
handlemap["signup"] = &CmdMan::handleSignup;
|
|
handlemap["listdata"] = &CmdMan::handleListdata;
|
|
handlemap["listdata"] = &CmdMan::handleListdata;
|
|
handlemap["head"] = &CmdMan::handleHead;
|
|
handlemap["head"] = &CmdMan::handleHead;
|
|
|
|
+ handlemap["deletefile"] = &CmdMan::handleDeletefile;
|
|
handlemap["deleteme"] = &CmdMan::handleDeleteme;
|
|
handlemap["deleteme"] = &CmdMan::handleDeleteme;
|
|
|
|
|
|
debugprintfunc = dpf;
|
|
debugprintfunc = dpf;
|
|
@@ -254,6 +257,25 @@ CmdMan::CmdRet CmdMan::cmdHead(vector<string> args) {
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+CmdMan::CmdRet CmdMan::cmdDeletefile(vector<string> args) {
|
|
|
|
+ CmdRet retval;
|
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
|
+ Json::Value root;
|
|
|
|
+ root["command"] = "deletefile";
|
|
|
|
+
|
|
|
|
+ if (args.size() < 1) {
|
|
|
|
+ retval.type = error;
|
|
|
|
+ root["accept"] = false;
|
|
|
|
+ root["error"] = "not enough arguments, at least 1 argument required";
|
|
|
|
+ } else {
|
|
|
|
+ root["file"] = args[0];
|
|
|
|
+ retval.type = send;
|
|
|
|
+ }
|
|
|
|
+ retval.msg = root;
|
|
|
|
+
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " using command \"" + cmd + "\" with arguments [ ");
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " using command \"" + cmd + "\" with arguments [ ");
|
|
@@ -760,6 +782,26 @@ CmdMan::CmdRet CmdMan::handleHead(Json::Value root) {
|
|
output["command"] = "head";
|
|
output["command"] = "head";
|
|
output["file"] = root["file"];
|
|
output["file"] = root["file"];
|
|
output["error"] = "Server reports: " + root["error"].asString();
|
|
output["error"] = "Server reports: " + root["error"].asString();
|
|
|
|
+ output["accept"] = false;
|
|
|
|
+ retval.type = error;
|
|
|
|
+ retval.msg = output;
|
|
|
|
+ } else {
|
|
|
|
+ retval.type = print;
|
|
|
|
+ retval.msg = root;
|
|
|
|
+ }
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+CmdMan::CmdRet CmdMan::handleDeletefile(Json::Value root) {
|
|
|
|
+ CmdRet retval;
|
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
|
+
|
|
|
|
+ if (!root["accept"].asBool()) {
|
|
|
|
+ Json::Value output;
|
|
|
|
+ output["command"] = "deletefile";
|
|
|
|
+ output["file"] = root["file"];
|
|
|
|
+ output["error"] = "Server reports: " + root["error"].asString();
|
|
|
|
+ output["accept"] = false;
|
|
retval.type = error;
|
|
retval.type = error;
|
|
retval.msg = output;
|
|
retval.msg = output;
|
|
} else {
|
|
} else {
|