Move HTTP related code into new NLWEB library

feature/pre-code-move
kaetemi 5 years ago
parent 1cf2a792ae
commit 76e0e9c105

@ -291,6 +291,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
###
OPTION(WITH_NET "Build NLNET" ON )
OPTION(WITH_3D "Build NL3D" ON )
OPTION(WITH_WEB "Build WEB" ON )
OPTION(WITH_GUI "Build GUI" ON )
OPTION(WITH_PACS "Build NLPACS" ON )
OPTION(WITH_GEORGES "Build NLGEORGES" ON )

@ -4,6 +4,10 @@ IF(WITH_3D)
SUBDIRS(3d)
ENDIF()
IF(WITH_WEB OR WITH_GUI)
ADD_SUBDIRECTORY(web)
ENDIF()
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF()

@ -0,0 +1,2 @@
FILE(GLOB HEADERS *.h)
INSTALL(FILES ${HEADERS} DESTINATION include/nel/web COMPONENT headers)

@ -22,7 +22,7 @@
// forward declaration to avoid curl.h inclusion everywhere
typedef void CURL;
namespace NLMISC
namespace NLWEB
{
class CCurlCertificates
{

@ -20,7 +20,7 @@
#include "nel/misc/types_nl.h"
#include <string>
namespace NLMISC
namespace NLWEB
{
/**

@ -14,15 +14,15 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NLMISC_HTTP_PACKAGE_PROVIDER_H
#define NLMISC_HTTP_PACKAGE_PROVIDER_H
#ifndef NLWEB_HTTP_PACKAGE_PROVIDER_H
#define NLWEB_HTTP_PACKAGE_PROVIDER_H
#include <nel/misc/types_nl.h>
#include <nel/misc/i_streamed_package_provider.h>
namespace NLMISC {
namespace NLWEB {
class CHttpPackageProvider : public IStreamedPackageProvider
class CHttpPackageProvider : public NLMISC::IStreamedPackageProvider
{
public:
CHttpPackageProvider();
@ -31,7 +31,7 @@ public:
/// Download a file. This call is blocking
/// filePath: [out] ex. /games/nel/stream/00/00/000000000..
/// hash: [in]
virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name) NL_OVERRIDE;
virtual bool getFile(std::string &filePath, const NLMISC::CHashKey &hash, const std::string &name) NL_OVERRIDE;
public:
/// Set storage path (ex. stream/)
@ -45,6 +45,6 @@ public:
} /* namespace NLMISC */
#endif /* #ifndef NLMISC_STREAMED_PACKAGE_MANAGER_H */
#endif /* #ifndef NLWEB_HTTP_PACKAGE_PROVIDER_H */
/* end of file */

@ -4,6 +4,10 @@ IF(WITH_3D)
ADD_SUBDIRECTORY(3d)
ENDIF()
IF(WITH_WEB OR WITH_GUI)
ADD_SUBDIRECTORY(web)
ENDIF()
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF()

@ -8,7 +8,7 @@ NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES})
TARGET_LINK_LIBRARIES(nelgui nelmisc nelweb nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES})
NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI")
NL_ADD_RUNTIME_FLAGS(nelgui)

@ -47,7 +47,7 @@
#include "nel/gui/url_parser.h"
#include "nel/gui/http_cache.h"
#include "nel/gui/http_hsts.h"
#include "nel/misc/curl_certificates.h"
#include "nel/web/curl_certificates.h"
#include "nel/gui/html_parser.h"
#include "nel/gui/html_element.h"
#include "nel/gui/css_style.h"
@ -550,7 +550,7 @@ namespace NLGUI
if (toLower(download.url.substr(0, 8)) == "https://")
{
// if supported, use custom SSL context function to load certificates
CCurlCertificates::useCertificates(curl);
NLWEB::CCurlCertificates::useCertificates(curl);
}
download.data = new CCurlWWWData(curl, download.url);
@ -3823,7 +3823,7 @@ namespace NLGUI
if (toLower(url.substr(0, 8)) == "https://")
{
// if supported, use custom SSL context function to load certificates
CCurlCertificates::useCertificates(curl);
NLWEB::CCurlCertificates::useCertificates(curl);
}
// do not follow redirects, we have own handler

@ -212,16 +212,16 @@ IF(UNIX)
ENDIF()
INCLUDE_DIRECTORIES(../../3rdparty)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} config_file)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file)
TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} nel_sevenzip)
TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY} nel_sevenzip)
NL_DEFAULT_PROPS(nelmisc "NeL, Library: NeL Misc")
NL_ADD_RUNTIME_FLAGS(nelmisc)
NL_ADD_LIB_SUFFIX(nelmisc)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS})
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(nelmisc ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.h ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.cpp)

@ -0,0 +1,28 @@
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../include/nel/web/*.h)
SOURCE_GROUP("" FILES ${SRC} ${HEADERS})
NL_TARGET_LIB(nelweb ${HEADERS} ${SRC})
INCLUDE_DIRECTORIES(../../3rdparty)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(nelweb ${LIBXML2_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} nelmisc nel_sevenzip)
NL_DEFAULT_PROPS(nelweb "NeL, Library: NeL Web")
NL_ADD_RUNTIME_FLAGS(nelweb)
NL_ADD_LIB_SUFFIX(nelweb)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS})
IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(nelweb ${CMAKE_CURRENT_SOURCE_DIR}/stdweb.h ${CMAKE_CURRENT_SOURCE_DIR}/stdweb.cpp)
ENDIF()
NL_GEN_PC(nel-web.pc)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelweb LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries)
ENDIF()

@ -14,26 +14,14 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdmisc.h"
#include <nel/misc/curl_certificates.h>
#include "stdweb.h"
#include <nel/web/curl_certificates.h>
#include <nel/misc/common.h>
#include <nel/misc/debug.h>
#include <nel/misc/path.h>
#include <nel/misc/file.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <curl/curl.h>
#ifdef NL_OS_WINDOWS
#include <wincrypt.h>
#ifdef X509_NAME
#undef X509_NAME
#endif
#endif
// for compatibility with older versions
#ifndef CURL_AT_LEAST_VERSION
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
@ -44,12 +32,13 @@
using namespace std;
using namespace NLMISC;
using namespace NLWEB;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC
namespace NLWEB
{
//
// x509CertList lifetime manager

@ -14,16 +14,15 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdmisc.h"
#include <nel/misc/http_client_curl.h>
#include <nel/misc/debug.h>
#include <curl/curl.h>
#include "stdweb.h"
#include <nel/web/http_client_curl.h>
#include <nel/misc/curl_certificates.h>
#include <nel/misc/debug.h>
#include <nel/web/curl_certificates.h>
using namespace NLMISC;
using namespace std;
using namespace NLMISC;
using namespace NLWEB;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
@ -31,7 +30,7 @@ using namespace std;
#define _Curl (CURL *)_CurlStruct
namespace NLMISC
namespace NLWEB
{
// Ugly CURL callback

@ -14,20 +14,21 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdmisc.h"
// 3rd Party includes
#include <curl/curl.h>
#include "stdweb.h"
#include <nel/web/http_package_provider.h>
// Project includes
#include <nel/misc/http_package_provider.h>
#include <nel/misc/streamed_package.h>
#include <nel/misc/file.h>
#include <nel/misc/path.h>
#include <nel/misc/seven_zip.h>
#include <nel/misc/sha1.h>
namespace NLMISC
using namespace std;
using namespace NLMISC;
using namespace NLWEB;
namespace NLWEB
{
CHttpPackageProvider::CHttpPackageProvider()

@ -0,0 +1,17 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdweb.h"

@ -0,0 +1,85 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_STDWEB_H
#define NL_STDWEB_H
#if defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <malloc.h>
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#elif defined(_MSC_VER)
#include <malloc.h>
#endif
#include <algorithm>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <nel/misc/types_nl.h>
#ifdef NL_OS_WINDOWS
# define WIN32_LEAN_AND_MEAN
# define _WIN32_WINDOWS 0x0500
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
# endif
# ifndef NL_COMP_MINGW
# define WINVER 0x0500
# define NOMINMAX
# endif
# include <WinSock2.h>
# include <Windows.h>
# include <wincrypt.h>
# ifdef X509_NAME
# undef X509_NAME
# endif
#endif
#include <libxml/parser.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <curl/curl.h>
#include <nel/misc/debug.h>
#endif // NL_STDWEB_H

@ -25,7 +25,7 @@ using namespace NLMISC;
// ***************************************************************************
// Data
NLMISC::CHttpPackageProvider *HttpPackageProvider = NULL;
NLWEB::CHttpPackageProvider *HttpPackageProvider = NULL;
// Main System
NL3D::UDriver *Driver = NULL; // The main 3D Driver

@ -28,7 +28,7 @@
// ***************************************************************************
namespace NLMISC
namespace NLWEB
{
class CHttpPackageProvider;
}
@ -84,7 +84,7 @@ const float ExtraZoneLoadingVision = 100.f;
// ***************************************************************************
// Data
extern NLMISC::CHttpPackageProvider *HttpPackageProvider; // Http provider from on-the-fly downloaded game data
extern NLWEB::CHttpPackageProvider *HttpPackageProvider; // Http provider from on-the-fly downloaded game data
// Main System
extern NL3D::UDriver *Driver; // The main 3D Driver

@ -35,7 +35,7 @@
#include "nel/misc/block_memory.h"
#include "nel/misc/system_utils.h"
#include "nel/misc/streamed_package_manager.h"
#include "nel/misc/http_package_provider.h"
#include "nel/web/http_package_provider.h"
#include "nel/misc/cmd_args.h"
// 3D Interface.
#include "nel/3d/bloom_effect.h"
@ -743,7 +743,7 @@ void initStreamedPackageManager(NLMISC::IProgressCallback &progress)
CStreamedPackageManager &spm = CStreamedPackageManager::getInstance();
nlassert(!spm.Provider); // If this asserts, init was called twice without release
nlassert(!HttpPackageProvider); // Idem
CHttpPackageProvider *hpp = new CHttpPackageProvider();
NLWEB::CHttpPackageProvider *hpp = new NLWEB::CHttpPackageProvider();
hpp->Path = ClientCfg.StreamedPackagePath;
for (uint i = 0; i < ClientCfg.StreamedPackageHosts.size(); i++)
hpp->Hosts.push_back(ClientCfg.StreamedPackageHosts[i]);

@ -28,7 +28,7 @@
#include "nel/misc/path.h"
#include "nel/misc/sheet_id.h"
#include "nel/misc/big_file.h"
#include "nel/misc/curl_certificates.h"
#include "nel/web/curl_certificates.h"
// 3D Interface.
#include "nel/3d/bloom_effect.h"
#include "nel/3d/u_driver.h"
@ -190,8 +190,8 @@ struct CStatThread : public NLMISC::IRunnable
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
if (url.length() > 8 && (url[4] == 's' || url[4] == 'S')) // 01234 https
{
NLMISC::CCurlCertificates::addCertificateFile("cacert.pem");
NLMISC::CCurlCertificates::useCertificates(curl);
NLWEB::CCurlCertificates::addCertificateFile("cacert.pem");
NLWEB::CCurlCertificates::useCertificates(curl);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
}

@ -30,7 +30,7 @@
#include "../connection.h"
#include <curl/curl.h>
#include "nel/misc/curl_certificates.h"
#include "nel/web/curl_certificates.h"
using namespace std;
using namespace NLMISC;
@ -188,7 +188,7 @@ public:
curl_easy_setopt(Curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, writeDataFromCurl);
NLMISC::CCurlCertificates::useCertificates(Curl);
NLWEB::CCurlCertificates::useCertificates(Curl);
}
~CWebigNotificationThread()

@ -113,7 +113,7 @@
#include "nel/gui/lua_helper.h"
using namespace NLGUI;
#include "nel/gui/lua_ihm.h"
#include "nel/misc/curl_certificates.h"
#include "nel/web/curl_certificates.h"
#include "lua_ihm_ryzom.h"
@ -480,7 +480,7 @@ CInterfaceManager::CInterfaceManager()
if (!ClientCfg.CurlCABundle.empty())
{
// specify custom CA certs, lookup will be made in this function
NLMISC::CCurlCertificates::addCertificateFile(ClientCfg.CurlCABundle);
NLWEB::CCurlCertificates::addCertificateFile(ClientCfg.CurlCABundle);
}
NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS );

@ -51,7 +51,7 @@
#include "global.h"
#include "input.h"
#include "nel/gui/libwww.h"
#include "nel/misc/http_client_curl.h"
#include "nel/web/http_client_curl.h"
#include "login_progress_post_thread.h"
#include "init.h"
@ -69,6 +69,7 @@ void ConnectToShard();
// ***************************************************************************
using namespace NLMISC;
using namespace NLWEB;
using namespace NLNET;
using namespace NL3D;
using namespace std;

@ -19,7 +19,7 @@
#define CL_LOGIN_H
#include <nel/misc/types_nl.h>
#include <nel/misc/http_client_curl.h>
#include <nel/web/http_client_curl.h>
#include <string>
#include <vector>
@ -74,7 +74,7 @@ extern sint32 ShardSelected;
/*
* HTTP client preconfigured to connect to the startup login host
*/
class CStartupHttpClient : public NLMISC::CCurlHttpClient
class CStartupHttpClient : public NLWEB::CCurlHttpClient
{
public:

@ -49,7 +49,7 @@
#include "nel/misc/i18n.h"
#include "nel/misc/cmd_args.h"
#include "nel/misc/seven_zip.h"
#include "nel/misc/curl_certificates.h"
#include "nel/web/curl_certificates.h"
#include "game_share/bg_downloader_msg.h"
@ -1431,8 +1431,8 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
curl_easy_setopt(curl, CURLOPT_URL, source.c_str());
if (source.length() > 8 && (source[4] == 's' || source[4] == 'S')) // 01234 https
{
NLMISC::CCurlCertificates::addCertificateFile("cacert.pem");
NLMISC::CCurlCertificates::useCertificates(curl);
NLWEB::CCurlCertificates::addCertificateFile("cacert.pem");
NLWEB::CCurlCertificates::useCertificates(curl);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
}

@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES(
TARGET_LINK_LIBRARIES(ryzom_client_patcher
nelmisc
nelweb
nelnet
ryzom_gameshare
nel_sevenzip

Loading…
Cancel
Save