summaryrefslogtreecommitdiff
path: root/src/client/Client.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-06 23:45:24 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-06 23:45:24 (GMT)
commitbbfbb81086897d50b67bf1494ac150eb607add72 (patch)
tree80bab3ddb1f62f847f12947bc81fac2c091669b8 /src/client/Client.cpp
parent8f8de875c6f7a68a3e47252a8653abb72fd398c1 (diff)
downloadpowder-bbfbb81086897d50b67bf1494ac150eb607add72.zip
powder-bbfbb81086897d50b67bf1494ac150eb607add72.tar.gz
Confirmation Dialogue, Save selection and multi-delete
Diffstat (limited to 'src/client/Client.cpp')
-rw-r--r--src/client/Client.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 4b7ef95..b748005 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -432,6 +432,58 @@ LoginStatus Client::Login(string username, string password, User & user)
return LoginError;
}
+RequestStatus Client::DeleteSave(int saveID)
+{
+ lastError = "";
+ std::vector<string> * tags = NULL;
+ std::stringstream urlStream;
+ char * data = NULL;
+ int dataStatus, dataLength;
+ urlStream << "http://" << SERVER << "/Browse/Delete.json?ID=" << saveID;
+ if(authUser.ID)
+ {
+ std::stringstream userIDStream;
+ userIDStream << authUser.ID;
+ data = http_auth_get((char *)urlStream.str().c_str(), (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
+ }
+ else
+ {
+ lastError = "Not authenticated";
+ return RequestFailure;
+ }
+ if(dataStatus == 200 && data)
+ {
+ try
+ {
+ std::istringstream dataStream(data);
+ json::Object objDocument;
+ json::Reader::Read(objDocument, dataStream);
+
+ int status = ((json::Number)objDocument["Status"]).Value();
+
+ if(status!=1)
+ goto failure;
+ }
+ catch (json::Exception &e)
+ {
+ lastError = "Could not read response";
+ goto failure;
+ }
+ }
+ else
+ {
+ lastError = http_ret_text(dataStatus);
+ goto failure;
+ }
+ if(data)
+ free(data);
+ return RequestOkay;
+failure:
+ if(data)
+ free(data);
+ return RequestFailure;
+}
+
Save * Client::GetSave(int saveID, int saveDate)
{
lastError = "";