diff --git a/android/jni/CMakeLists.txt b/android/jni/CMakeLists.txt index ee104e6758..31d4ff673b 100644 --- a/android/jni/CMakeLists.txt +++ b/android/jni/CMakeLists.txt @@ -71,6 +71,7 @@ set( com/mapswithme/opengl/androidoglcontextfactory.cpp com/mapswithme/opengl/gl3stub.c com/mapswithme/platform/HttpThread.cpp + com/mapswithme/platform/HttpUploader.cpp com/mapswithme/platform/GuiThread.cpp com/mapswithme/platform/Language.cpp com/mapswithme/platform/MarketingService.cpp diff --git a/android/jni/com/mapswithme/platform/HttpUploader.cpp b/android/jni/com/mapswithme/platform/HttpUploader.cpp new file mode 100644 index 0000000000..12fce40b41 --- /dev/null +++ b/android/jni/com/mapswithme/platform/HttpUploader.cpp @@ -0,0 +1,12 @@ +#include "platform/http_uploader.hpp" + +#include "base/assert.hpp" + +namespace platform +{ +void HttpUploader::Upload() const +{ + // Dummy implementation. + CHECK(m_callback, ()); +} +} // namespace platform diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index ee7ee539bb..4383357720 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -23,6 +23,7 @@ set( http_request.cpp http_request.hpp http_thread_callback.hpp + http_uploader.hpp local_country_file.cpp local_country_file.hpp local_country_file_utils.cpp @@ -57,6 +58,7 @@ if(${PLATFORM_IPHONE}) http_thread_apple.h http_thread_apple.mm http_client_apple.mm + http_uploader_apple.mm marketing_service_ios.mm platform_ios.mm platform_unix_impl.cpp @@ -88,6 +90,7 @@ else() # neither iPhone nor Android http_client_curl.cpp http_thread_qt.cpp http_thread_qt.hpp + http_uploader_dummy.cpp marketing_service_dummy.cpp platform_win.cpp secure_storage_dummy.cpp @@ -101,6 +104,7 @@ else() # neither iPhone nor Android http_client_apple.mm http_thread_apple.h http_thread_apple.mm + http_uploader_apple.mm marketing_service_dummy.cpp platform_mac.mm platform_unix_impl.cpp @@ -115,6 +119,7 @@ else() # neither iPhone nor Android http_client_curl.cpp http_thread_qt.cpp http_thread_qt.hpp + http_uploader_dummy.cpp marketing_service_dummy.cpp platform_linux.cpp platform_unix_impl.cpp diff --git a/platform/http_uploader.hpp b/platform/http_uploader.hpp new file mode 100644 index 0000000000..9379a65556 --- /dev/null +++ b/platform/http_uploader.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include + +namespace platform +{ +class HttpUploader +{ +public: + using ResultCallback = std::function; + + void SetMethod(std::string const & method) { m_method = method; } + void SetUrl(std::string const & url) { m_url = url; } + void SetParams(std::map const & params) { m_params = params; } + void SetHeaders(std::map const & headers) { m_headers = headers; } + void SetFileKey(std::string const & fileKey) { m_fileKey = fileKey; } + void SetFilename(std::string const & filename) { m_filename = filename; } + void SetCallback(ResultCallback const & callback) { m_callback = callback; } + + void Upload() const; + +private: + std::string m_method = "POST"; + std::string m_url; + std::map m_params; + std::map m_headers; + std::string m_fileKey = "file"; + std::string m_filename; + ResultCallback m_callback; +}; +} // namespace platform diff --git a/platform/http_uploader_apple.mm b/platform/http_uploader_apple.mm new file mode 100644 index 0000000000..12fce40b41 --- /dev/null +++ b/platform/http_uploader_apple.mm @@ -0,0 +1,12 @@ +#include "platform/http_uploader.hpp" + +#include "base/assert.hpp" + +namespace platform +{ +void HttpUploader::Upload() const +{ + // Dummy implementation. + CHECK(m_callback, ()); +} +} // namespace platform diff --git a/platform/http_uploader_dummy.cpp b/platform/http_uploader_dummy.cpp new file mode 100644 index 0000000000..12fce40b41 --- /dev/null +++ b/platform/http_uploader_dummy.cpp @@ -0,0 +1,12 @@ +#include "platform/http_uploader.hpp" + +#include "base/assert.hpp" + +namespace platform +{ +void HttpUploader::Upload() const +{ + // Dummy implementation. + CHECK(m_callback, ()); +} +} // namespace platform diff --git a/xcode/platform/platform.xcodeproj/project.pbxproj b/xcode/platform/platform.xcodeproj/project.pbxproj index 42021237e8..6323fd3a3d 100644 --- a/xcode/platform/platform.xcodeproj/project.pbxproj +++ b/xcode/platform/platform.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 34C624BE1DABCCD100510300 /* socket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34C624BC1DABCCD100510300 /* socket.hpp */; }; 3D30587D1D8320E4004AC712 /* http_client.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D30587B1D8320E4004AC712 /* http_client.hpp */; }; 3D30587F1D880910004AC712 /* http_client_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D30587E1D880910004AC712 /* http_client_apple.mm */; }; + 3D318A062021DD8B007B2607 /* http_uploader_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D318A042021DD8A007B2607 /* http_uploader_apple.mm */; }; + 3D318A072021DD8B007B2607 /* http_uploader.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D318A052021DD8B007B2607 /* http_uploader.hpp */; }; 3D78156E1F3A14090068B6AC /* gui_thread_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D78156B1F3A14090068B6AC /* gui_thread_apple.mm */; }; 3D78156F1F3A14090068B6AC /* gui_thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D78156C1F3A14090068B6AC /* gui_thread.hpp */; }; 3D78157D1F3D8A0A0068B6AC /* safe_callback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D78157C1F3D8A0A0068B6AC /* safe_callback.hpp */; }; @@ -121,6 +123,8 @@ 34F558341DBF273C00A4FC11 /* common-release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "common-release.xcconfig"; path = "../common-release.xcconfig"; sourceTree = ""; }; 3D30587B1D8320E4004AC712 /* http_client.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = http_client.hpp; sourceTree = ""; }; 3D30587E1D880910004AC712 /* http_client_apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = http_client_apple.mm; sourceTree = ""; }; + 3D318A042021DD8A007B2607 /* http_uploader_apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = http_uploader_apple.mm; sourceTree = ""; }; + 3D318A052021DD8B007B2607 /* http_uploader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = http_uploader.hpp; sourceTree = ""; }; 3D78156B1F3A14090068B6AC /* gui_thread_apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = gui_thread_apple.mm; sourceTree = ""; }; 3D78156C1F3A14090068B6AC /* gui_thread.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = gui_thread.hpp; sourceTree = ""; }; 3D78157C1F3D8A0A0068B6AC /* safe_callback.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = safe_callback.hpp; sourceTree = ""; }; @@ -336,6 +340,8 @@ 6753437A1A3F5CF500A0A8C3 /* platform */ = { isa = PBXGroup; children = ( + 3D318A042021DD8A007B2607 /* http_uploader_apple.mm */, + 3D318A052021DD8B007B2607 /* http_uploader.hpp */, 451E329F1F73A8B000964C9F /* secure_storage.hpp */, 451E329D1F73A8B000964C9F /* secure_storage_ios.mm */, 451E329E1F73A8B000964C9F /* secure_storage_qt.cpp */, @@ -475,6 +481,7 @@ 3D30587D1D8320E4004AC712 /* http_client.hpp in Headers */, 56EB1EDD1C6B6E6C0022D831 /* file_logging.hpp in Headers */, F6DF735B1EC9EAE700D8BA0B /* string_storage_base.hpp in Headers */, + 3D318A072021DD8B007B2607 /* http_uploader.hpp in Headers */, 6741250D1B4C00CC00A3E828 /* local_country_file_utils.hpp in Headers */, 675343DA1A3F5D5A00A0A8C3 /* wifi_info.hpp in Headers */, 671C62071AE9014C00076BD0 /* measurement_utils.hpp in Headers */, @@ -620,6 +627,7 @@ 56EB1EDE1C6B6E6C0022D831 /* mwm_traits.cpp in Sources */, 3D30587F1D880910004AC712 /* http_client_apple.mm in Sources */, F6DF73581EC9EAE700D8BA0B /* string_storage_base.cpp in Sources */, + 3D318A062021DD8B007B2607 /* http_uploader_apple.mm in Sources */, 3D78156E1F3A14090068B6AC /* gui_thread_apple.mm in Sources */, 67247FFD1C60BD6500EDE56A /* writable_dir_changer.cpp in Sources */, 34513AFB1DCB37C100471BDA /* marketing_service.cpp in Sources */,