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 
29 namespace Networking {
30 
32  friend class NetJNI;
33 private:
34  static void gotHeaders(JNIEnv *env, jobject obj, jlong nativePointer, jobjectArray headers);
35  static void gotData(JNIEnv *env, jobject obj, jlong nativePointer, jbyteArray data, jint size, jint totalSize);
36  static void finished_(JNIEnv *env, jobject obj, jlong nativePointer, jint errorCode, jstring errorMsg);
37 
38  void resetStream(JNIEnv *env);
39  void finished(int errorCode, const Common::String &errorMsg);
40 
41  jobject _request;
42 
44  uint64 _downloaded;
45  int _errorCode;
46  Common::String _errorMsg;
47 public:
48  NetworkReadStreamAndroid(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading, bool usingPatch, bool keepAlive, long keepAliveIdle, long keepAliveInterval);
49 
50  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);
51 
52  NetworkReadStreamAndroid(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post, bool keepAlive, long keepAliveIdle, long keepAliveInterval);
53 
54  ~NetworkReadStreamAndroid() override;
55 
57  bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading = false, bool usingPatch = false) override;
59  bool reuse(
60  const char *url, RequestHeaders *headersList,
62  const Common::HashMap<Common::String, Common::Path> &formFiles) override;
64  bool reuse(const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading = false, bool usingPatch = false, bool post = true) override;
65 
66  long httpResponseCode() const override { return _errorCode; }
67  Common::String currentLocation() const override;
74  Common::HashMap<Common::String, Common::String> responseHeadersMap() const override { return _responseHeadersMap; }
75 
76  bool hasError() const override { return _errorCode < 200 || _errorCode >= 300; }
77  const char *getError() const override { return _errorMsg.c_str(); }
78 };
79 
80 } // End of namespace Networking
81 
82 #endif
Definition: networkreadstream-android.h:31
Definition: str.h:59
bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false) override
Definition: scummvmcloud.h:32
long httpResponseCode() const override
Definition: networkreadstream-android.h:66
Common::HashMap< Common::String, Common::String > responseHeadersMap() const override
Definition: networkreadstream-android.h:74
Definition: jni.h:29
Definition: networkreadstream.h:37
Common::String currentLocation() const override