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

request.cpp

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 #include "backends/networking/curl/request.h"
00024 
00025 namespace Networking {
00026 
00027 ErrorResponse::ErrorResponse(Request *rq):
00028     request(rq), interrupted(false), failed(true), response(""), httpResponseCode(-1) {}
00029 
00030 ErrorResponse::ErrorResponse(Request *rq, bool interrupt, bool failure, Common::String resp, long httpCode):
00031     request(rq), interrupted(interrupt), failed(failure), response(resp), httpResponseCode(httpCode) {}
00032 
00033 Request::Request(DataCallback cb, ErrorCallback ecb):
00034     _callback(cb), _errorCallback(ecb), _state(PROCESSING), _retryInSeconds(0) {}
00035 
00036 Request::~Request() {
00037     delete _callback;
00038     delete _errorCallback;
00039 }
00040 
00041 void Request::handleRetry() {
00042     if (_retryInSeconds > 0) {
00043         --_retryInSeconds;
00044     } else {
00045         _state = PROCESSING;
00046         restart();
00047     }
00048 }
00049 
00050 void Request::pause() { _state = PAUSED; }
00051 
00052 void Request::finish() {
00053     ErrorResponse error(this, true, false, "", -1);
00054     finishError(error);
00055 }
00056 
00057 void Request::retry(uint32 seconds) {
00058     _state = RETRY;
00059     _retryInSeconds = seconds;
00060 }
00061 
00062 RequestState Request::state() const { return _state; }
00063 
00064 Common::String Request::date() const { return ""; }
00065 
00066 void Request::finishError(ErrorResponse error) {
00067     _state = FINISHED;
00068     if (_errorCallback)
00069         (*_errorCallback)(error);
00070 }
00071 
00072 void Request::finishSuccess() { _state = FINISHED; }
00073 
00074 } // End of namespace Networking


Generated on Sat Mar 23 2019 05:02:00 for ResidualVM by doxygen 1.7.1
curved edge   curved edge