Skip to content

Commit

Permalink
feat(core): add HttpServer
Browse files Browse the repository at this point in the history
Includes cpp-httplib v0.5.6.
  • Loading branch information
trollixx committed Feb 25, 2020
1 parent 58b9276 commit 090f527
Show file tree
Hide file tree
Showing 6 changed files with 4,970 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ add_library(Core STATIC
applicationsingleton.cpp
extractor.cpp
filemanager.cpp
httpserver.cpp
networkaccessmanager.cpp
settings.cpp

# Show headers without .cpp in Qt Creator.
httplib.h
)

target_link_libraries(Core Registry Ui)
Expand All @@ -15,3 +19,10 @@ target_link_libraries(Core Qt5::Network Qt5::WebKit Qt5::Widgets)
find_package(LibArchive REQUIRED)
include_directories(${LibArchive_INCLUDE_DIRS})
target_link_libraries(Core ${LibArchive_LIBRARIES})

# Required by cpp-httplib.
if(NOT WIN32)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Core Threads::Threads)
endif()
7 changes: 7 additions & 0 deletions src/libs/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "extractor.h"
#include "filemanager.h"
#include "httpserver.h"
#include "networkaccessmanager.h"
#include "settings.h"

Expand Down Expand Up @@ -63,6 +64,7 @@ Application::Application(QObject *parent)
m_networkManager = new NetworkAccessManager(this);

m_fileManager = new FileManager(this);
m_httpServer = new HttpServer(this);

// Extractor setup
m_extractorThread = new QThread(this);
Expand Down Expand Up @@ -134,6 +136,11 @@ FileManager *Application::fileManager() const
return m_fileManager;
}

HttpServer *Application::httpServer() const
{
return m_httpServer;
}

QString Application::cacheLocation()
{
#ifndef PORTABLE_BUILD
Expand Down
3 changes: 3 additions & 0 deletions src/libs/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace Core {

class Extractor;
class FileManager;
class HttpServer;
class Settings;

class Application final : public QObject
Expand All @@ -64,6 +65,7 @@ class Application final : public QObject

Registry::DocsetRegistry *docsetRegistry();
FileManager *fileManager() const;
HttpServer *httpServer() const;

static QString cacheLocation();
static QString configLocation();
Expand Down Expand Up @@ -96,6 +98,7 @@ private slots:
QNetworkAccessManager *m_networkManager = nullptr;

FileManager *m_fileManager = nullptr;
HttpServer *m_httpServer = nullptr;

QThread *m_extractorThread = nullptr;
Extractor *m_extractor = nullptr;
Expand Down
Loading

0 comments on commit 090f527

Please sign in to comment.