diff --git a/include/openspace/engine/downloadengine.h b/include/openspace/engine/downloadmanager.h similarity index 83% rename from include/openspace/engine/downloadengine.h rename to include/openspace/engine/downloadmanager.h index 2ee3fad372..c72ef39c34 100644 --- a/include/openspace/engine/downloadengine.h +++ b/include/openspace/engine/downloadmanager.h @@ -22,26 +22,34 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __DOWNLOADENGINE_H__ -#define __DOWNLOADENGINE_H__ +#ifndef __DOWNLOADMANAGER_H__ +#define __DOWNLOADMANAGER_H__ +#include #include #include #include namespace openspace { -class DownloadEngine { +class DownloadManager : public ghoul::Singleton { public: - typedef std::function DownloadFinishedCallback; + typedef std::function DownloadFinishedCallback; - static bool downloadFile( + DownloadManager(std::string requestURL); + + bool downloadFile( const std::string& url, const ghoul::filesystem::File& file, DownloadFinishedCallback callback = DownloadFinishedCallback() ); + +private: + std::string _requestURL; }; +#define DlManager (openspace::DownloadManager::ref()) + } // namespace openspace -#endif // __DOWNLOADENGINE_H__ +#endif // __DOWNLOADMANAGER_H__ diff --git a/openspace.cfg b/openspace.cfg index 1fb1965c3e..d9325aa65b 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -53,6 +53,7 @@ return { Type = "text", File = "${BASE_PATH}/Properties.txt" }, + DownloadRequestURL = "http://openspace.itn.liu.se/request.cgi", RenderingMethod = "ABufferSingleLinked" -- On Windows and Unix -- RenderingMethod = "ABufferFrameBuffer" -- On Mac due to OpenGL 4.1 restrictions } \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 927c51df83..e63c0e4361 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/abuffer/abuffersinglelinked.cpp ${OPENSPACE_BASE_DIR}/src/abuffer/abuffervisualizer.cpp ${OPENSPACE_BASE_DIR}/src/engine/configurationmanager.cpp - ${OPENSPACE_BASE_DIR}/src/engine/downloadengine.cpp + ${OPENSPACE_BASE_DIR}/src/engine/downloadmanager.cpp ${OPENSPACE_BASE_DIR}/src/engine/logfactory.cpp ${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp @@ -96,7 +96,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffersinglelinked.h ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffervisualizer.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/configurationmanager.h - ${OPENSPACE_BASE_DIR}/include/openspace/engine/downloadengine.h + ${OPENSPACE_BASE_DIR}/include/openspace/engine/downloadmanager.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/logfactory.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h diff --git a/src/engine/downloadengine.cpp b/src/engine/downloadmanager.cpp similarity index 91% rename from src/engine/downloadengine.cpp rename to src/engine/downloadmanager.cpp index 7fb0a22fd0..023142cdfb 100644 --- a/src/engine/downloadengine.cpp +++ b/src/engine/downloadmanager.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include @@ -32,7 +32,7 @@ #endif namespace { - const std::string _loggerCat = "DownloadEngine"; + const std::string _loggerCat = "DownloadManager"; size_t writeData(void* ptr, size_t size, size_t nmemb, FILE* stream) { size_t written; @@ -43,7 +43,14 @@ namespace { namespace openspace { -bool DownloadEngine::downloadFile( +DownloadManager::DownloadManager(std::string requestURL) + : _requestURL(std::move(requestURL)) +{ + curl_global_init(CURL_GLOBAL_ALL); + // Check if URL is accessible +} + +bool DownloadManager::downloadFile( const std::string& url, const ghoul::filesystem::File& file, DownloadFinishedCallback callback) @@ -70,4 +77,5 @@ bool DownloadEngine::downloadFile( } } + } // namespace openspace diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 6d6b57e369..14f7c8d481 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -88,6 +88,7 @@ namespace { const std::string KeyRenderingMethod = "RenderingMethod"; const std::string DefaultRenderingMethod = "ABufferSingleLinked"; + const std::string KeyDownloadRequestURL = "DownloadRequestURL"; const std::string DefaultOpenGlVersion = "4.3"; @@ -301,8 +302,13 @@ bool OpenSpaceEngine::initialize() { SysCap.detectCapabilities(); SysCap.logCapabilities(); + std::string requestURL = ""; + bool success = configurationManager()->getValue(KeyDownloadRequestURL, requestURL); + if (success) + DownloadManager::initialize(requestURL); + // Load SPICE time kernel - bool success = loadSpiceKernels(); + success = loadSpiceKernels(); if (!success) return false; @@ -366,8 +372,8 @@ bool OpenSpaceEngine::initialize() { // Load a light and a monospaced font loadFonts(); - ghoul::filesystem::File f("d:/foo.txt"); - DownloadEngine::downloadFile("http://curl.haxx.se/libcurl/c/example.html", f); + //ghoul::filesystem::File f("d:/foo.txt"); + //DownloadEngine::downloadFile("http://curl.haxx.se/libcurl/c/example.html", f); _gui->initialize();