ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

request.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef BACKENDS_NETWORKING_CURL_REQUEST_H
00024 #define BACKENDS_NETWORKING_CURL_REQUEST_H
00025 
00026 #include "common/callback.h"
00027 #include "common/scummsys.h"
00028 #include "common/str.h"
00029 
00030 namespace Networking {
00031 
00032 class Request;
00033 
00048 template<typename T> struct Response {
00049     Request *request;
00050     T value;
00051 
00052     Response(Request *rq, T v) : request(rq), value(v) {}
00053 };
00054 
00074 struct ErrorResponse {
00075     Request *request;
00076     bool interrupted;
00077     bool failed;
00078     Common::String response;
00079     long httpResponseCode;
00080 
00081     ErrorResponse(Request *rq);
00082     ErrorResponse(Request *rq, bool interrupt, bool failure, Common::String resp, long httpCode);
00083 };
00084 
00085 typedef Response<void *> DataReponse;
00086 typedef Common::BaseCallback<DataReponse> *DataCallback;
00087 typedef Common::BaseCallback<ErrorResponse> *ErrorCallback;
00088 
00113 enum RequestState {
00114     PROCESSING,
00115     PAUSED,
00116     RETRY,
00117     FINISHED
00118 };
00119 
00120 class Request {
00121 protected:
00129     DataCallback _callback;
00130 
00136     ErrorCallback _errorCallback;
00137 
00146     RequestState _state;
00147 
00149     uint32 _retryInSeconds;
00150 
00152     virtual void finishError(ErrorResponse error);
00153 
00155     virtual void finishSuccess();
00156 
00157 public:
00158     Request(DataCallback cb, ErrorCallback ecb);
00159     virtual ~Request();
00160 
00162     virtual void handle() = 0;
00163 
00165     virtual void handleRetry();
00166 
00168     virtual void restart() = 0;
00169 
00171     virtual void pause();
00172 
00178     virtual void finish();
00179 
00181     virtual void retry(uint32 seconds);
00182 
00184     RequestState state() const;
00185 
00198     virtual Common::String date() const;
00199 };
00200 
00201 } // End of namespace Networking
00202 
00203 #endif


Generated on Sat May 18 2019 05:01:18 for ResidualVM by doxygen 1.7.1
curved edge   curved edge