ScummVM API documentation
networkreadstream-android.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_NETWORKING_HTTP_ANDROID_NETWORKREADSTREAM_ANDROID_H
23#define BACKENDS_NETWORKING_HTTP_ANDROID_NETWORKREADSTREAM_ANDROID_H
24
25#include <jni.h>
26
27#include "backends/networking/http/networkreadstream.h"
28#include "common/memstream.h"
29
30namespace Networking {
31
33 friend class NetJNI;
34private:
35 static void gotHeaders(JNIEnv *env, jobject obj, jlong nativePointer, jobjectArray headers);
36 static void gotData(JNIEnv *env, jobject obj, jlong nativePointer, jbyteArray data, jint size, jint totalSize);
37 static void finished_(JNIEnv *env, jobject obj, jlong nativePointer, jint errorCode, jstring errorMsg);
38
39 void resetStream(JNIEnv *env);
40 void finished(int errorCode, const Common::String &errorMsg);
41 void setProgress(uint64 downloaded, uint64 total);
42
43 jobject _request;
44 Common::MemoryReadWriteStream _backingStream;
45
47 uint64 _downloaded;
48 uint64 _progressDownloaded, _progressTotal;
49 bool _requestComplete;
50 int _errorCode;
51 Common::String _errorMsg;
52public:
53 NetworkReadStreamAndroid(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading, bool usingPatch, bool keepAlive, long keepAliveIdle, long keepAliveInterval);
54
55 NetworkReadStreamAndroid(const char *url, RequestHeaders *headersList, const Common::HashMap<Common::String, Common::String> &formFields, const Common::HashMap<Common::String, Common::Path> &formFiles, bool keepAlive, long keepAliveIdle, long keepAliveInterval);
56
57 NetworkReadStreamAndroid(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post, bool keepAlive, long keepAliveIdle, long keepAliveInterval);
58
60
62 bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading = false, bool usingPatch = false) override;
64 bool reuse(
65 const char *url, RequestHeaders *headersList,
67 const Common::HashMap<Common::String, Common::Path> &formFiles) override;
69 bool reuse(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading = false, bool usingPatch = false, bool post = true) override;
70
71 long httpResponseCode() const override { return _errorCode; }
79 Common::HashMap<Common::String, Common::String> responseHeadersMap() const override { return _responseHeadersMap; }
80
81 bool hasError() const override { return _errorCode < 200 || _errorCode >= 300; }
82 const char *getError() const override { return _errorMsg.c_str(); }
83 double getProgress() const override;
84 uint32 read(void *dataPtr, uint32 dataSize) override;
85};
86
87} // End of namespace Networking
88
89#endif
Definition: memstream.h:283
Definition: str.h:59
Definition: jni.h:29
Definition: networkreadstream-android.h:32
Common::String currentLocation() const override
long httpResponseCode() const override
Definition: networkreadstream-android.h:71
double getProgress() const override
uint32 read(void *dataPtr, uint32 dataSize) override
bool reuse(const char *url, RequestHeaders *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles) override
Common::HashMap< Common::String, Common::String > responseHeadersMap() const override
Definition: networkreadstream-android.h:79
bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false) override
bool reuse(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true) override
Definition: networkreadstream.h:37