Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

add_subdirectory(tusclient)
add_subdirectory(ctus)
50 changes: 50 additions & 0 deletions lib/ctus/.cmake/ctus_sources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
set(CTUS_HEADERS
include/ctus/ctus.h
include/ctus/TusStatus.h
include/ctus/cache/CacheRepository.h
include/ctus/cache/ICacheManager.h
include/ctus/cache/TUSFile.h
include/ctus/chunk/FileChunker.h
include/ctus/chunk/IFileChunker.h
include/ctus/chunk/TUSChunk.h
include/ctus/chunk/utility/ChunkUtility.h
include/ctus/config.h
include/ctus/exceptions/TUSException.h
include/ctus/http/HttpClient.h
include/ctus/http/IHttpClient.h
include/ctus/http/Request.h
include/ctus/http/RequestTask.h
include/ctus/ctus.h
include/ctus/logging/GLoggingService.h
include/ctus/logging/ILogger.h
include/ctus/repository/IRepository.h
include/ctus/verifiers/IFileVerifier.h
include/ctus/verifiers/Md5Verifier.h
)

set(CTUS_SOURCES
src/ctus/TusClient.cpp
src/ctus/cache/CacheRepository.cpp
src/ctus/cache/TUSFile.cpp
src/ctus/chunk/FileChunker.cpp
src/ctus/chunk/TUSChunk.cpp
src/ctus/chunk/utility/ChunkUtility.cpp
src/ctus/http/HttpClient.cpp
src/ctus/http/Request.cpp
src/ctus/http/RequestTask.cpp
src/ctus/ctus.cpp
src/ctus/logging/GLoggingService.cpp
src/ctus/verifiers/Md5Verifier.cpp
)

set(CTUS_TEST_SOURCES
FileChunkerTest.cpp
TusClientTest.cpp
http/HttpClientTest.cpp
main.cpp
repository/CacheRepositoryTest.cpp
verifiers/FileVerifiersTest.cpp
)

set(CTUS_RESOURCES
)
1 change: 1 addition & 0 deletions lib/ctus/.cmake/sources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/ctus_sources.cmake)
43 changes: 43 additions & 0 deletions lib/ctus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Include common cmake scripts
include(${CMAKE_CURRENT_SOURCE_DIR}/.cmake/sources.cmake)
show_module_info(${CMAKE_CURRENT_LIST_DIR}/package.json)

# Configure build output directories for the target
configure_build(ctus)

# Create executable target
if(BUILD_SHARED_LIBS)
add_library(ctus SHARED ${CTUS_SOURCES} ${CTUS_HEADERS} ${CTUS_RESOURCES})
else()
add_library(ctus STATIC ${CTUS_SOURCES} ${CTUS_HEADERS} ${CTUS_RESOURCES})
endif()

# Include headers directory
target_include_directories(ctus PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/ctus>
$<INSTALL_INTERFACE:include/ctus>)

# Link libraries
target_link_libraries(ctus PUBLIC CURL::libcurl Boost::uuid Boost::lexical_cast nlohmann_json::nlohmann_json glog::glog fmt::fmt)
if(BUILD_SHARED_LIBS)
target_compile_definitions(ctus PRIVATE CTUS_EXPORTS)
target_compile_definitions(ctus PRIVATE CTUS_SHARED)
endif ()
# Enable testing if tests exist
include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
# Install target
configure_install(ctus)
#For destribution, we need to create a config file for the package
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_SOURCE_DIR}/cmake/ctusConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ctusConfig.cmake"
INSTALL_DESTINATION lib/cmake/ctus
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ctusConfig.cmake"
DESTINATION lib/cmake/ctus)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string>

#include "TusStatus.h"
#include "libtusclient.h"
#include "ctus.h"
#include "logging/ILogger.h"

using std::string;
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace TUS {
* @brief The ITusClient class represents an interface for a client for
* uploading files using the TUS protocol.
*/
class EXPORT_LIBTUSCLIENT ITusClient {
class EXPORT_CTUS ITusClient {
public:
virtual ~ITusClient() = default;

Expand Down Expand Up @@ -96,7 +96,7 @@ namespace TUS {
* @brief The TusClient class represents a client for uploading files using the
* TUS protocol.
*/
class EXPORT_LIBTUSCLIENT TusClient : public ITusClient {
class EXPORT_CTUS TusClient : public ITusClient {
private:
using OnSuccessCallback = std::function<void(std::string, std::string)>;
using OnErrorCallback = std::function<void(std::string, std::string)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#ifndef INCLUDE_TUSSTATUS_H_
#define INCLUDE_TUSSTATUS_H_

#include "libtusclient.h"
#include "ctus.h"

namespace TUS {
enum class EXPORT_LIBTUSCLIENT TusStatus {
enum class EXPORT_CTUS TusStatus {
READY,
UPLOADING,
FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef INCLUDE_CACHE_CACHEREPOSITORY_H_
#define INCLUDE_CACHE_CACHEREPOSITORY_H_

#include "libtusclient.h"
#include "ctus.h"
#include "repository/IRepository.h"
#include "cache/TUSFile.h"

Expand All @@ -17,7 +17,7 @@ namespace TUS::Cache {
* The repository stores TUSFile objects in a cache file.
*/

class EXPORT_LIBTUSCLIENT CacheRepository : public Repository::IRepository<TUSFile> {
class EXPORT_CTUS CacheRepository : public Repository::IRepository<TUSFile> {
public:
explicit CacheRepository(std::string appName, bool clearCache = false);
static std::shared_ptr<CacheRepository> create(std::string appName, bool clearCache = false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <string>

#include "libtusclient.h"
#include "ctus.h"

namespace TUS {
class TUSFile;
Expand All @@ -22,7 +22,7 @@ namespace TUS {
* from the cache.
*/

class EXPORT_LIBTUSCLIENT ICacheManager {
class EXPORT_CTUS ICacheManager {
public:
virtual ~ICacheManager() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <nlohmann/json.hpp>
#include <boost/uuid/uuid.hpp>

#include "libtusclient.h"
#include "ctus.h"

namespace TUS::Cache {
/**
Expand All @@ -23,7 +23,7 @@ namespace TUS::Cache {
* the size of the full file and the application name that created the record.
* This class provides methods for storing and retrieving data from the cache.
*/
class EXPORT_LIBTUSCLIENT TUSFile {
class EXPORT_CTUS TUSFile {
public:
/**
* @brief Construct a new TUSFile object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "IFileChunker.h"
#include "verifiers/IFileVerifier.h"

#include "libtusclient.h"
#include "ctus.h"


using std::string;
Expand All @@ -28,7 +28,7 @@ namespace TUS::Chunk {
* To get the chunks, the loadChunks method must be called and you can get the chunks with the getChunks method,
* which returns a vector of TUSChunk objects.
*/
class EXPORT_LIBTUSCLIENT FileChunker : public IFileChunker<TUSChunk>, public FileVerifier::IFileVerifier {
class EXPORT_CTUS FileChunker : public IFileChunker<TUSChunk>, public FileVerifier::IFileVerifier {
private:
const string CHUNK_FILE_NAME_PREFIX = "_chunk_";
const string CHUNK_FILE_EXTENSION = ".bin";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vector>
#include <string>
#include <filesystem>
#include "libtusclient.h"
#include "ctus.h"

using std::string;
using std::filesystem::path;
Expand All @@ -25,7 +25,7 @@ namespace TUS::Chunk {
* and retrieve the total number of chunks.
*/
template<typename T>
class EXPORT_LIBTUSCLIENT IFileChunker {
class EXPORT_CTUS IFileChunker {
public:
virtual ~IFileChunker() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <vector>
#include <cstdint>
#include "libtusclient.h"
#include "ctus.h"


namespace TUS::Chunk {
Expand All @@ -19,7 +19,7 @@ namespace TUS::Chunk {
* This class represents a chunk of a TUS file. A chunk is a part of a file
* that is uploaded to the server in a single request.
*/
class EXPORT_LIBTUSCLIENT TUSChunk {
class EXPORT_CTUS TUSChunk {
public:
/**
* @brief Construct a TUSChunk object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#ifndef INCLUDE_CHUNK_UTILITY_CHUNKUTILITY_H_
#define INCLUDE_CHUNK_UTILITY_CHUNKUTILITY_H_
#include <cstdint>
#include "libtusclient.h"
#include "ctus.h"


namespace TUS::Chunk::Utility {
/**
* @brief The ChunkUtility class provides utility methods for working with chunks.
*/
class EXPORT_LIBTUSCLIENT ChunkUtility {
class EXPORT_CTUS ChunkUtility {
public:
/**
* @brief Get the chunk size in GB.
Expand Down
23 changes: 23 additions & 0 deletions lib/ctus/include/ctus/ctus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef INCLUDE_LIBTUSCLIENT_H_
#define INCLUDE_LIBTUSCLIENT_H_
#include <string>

constexpr auto TUS_PROTOCOL_VERSION = "1.0.0";
#if defined(CTUS_SHARED)
#if defined(_WIN32) || defined(__CYGWIN__)
#ifdef CTUS_EXPORTS
#define EXPORT_CTUS __declspec(dllexport)
#else
#define EXPORT_CTUS __declspec(dllimport)
#endif
#else
#ifdef CTUS_EXPORTS
#define EXPORT_CTUS __attribute__((visibility("default")))
#else
#define EXPORT_CTUS
#endif
#endif
#else
#define EXPORT_CTUS
#endif
#endif // INCLUDE_LIBTUSCLIENT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/
#include <stdexcept>
#include <string>
#include "libtusclient.h"
#include "ctus.h"


namespace TUS::Exceptions {
/**
* @brief Exception class for TUS client errors.
*/

class EXPORT_LIBTUSCLIENT TUSException : public std::runtime_error {
class EXPORT_CTUS TUSException : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
#include <memory>
#include <mutex>

#include "libtusclient.h"
#include "ctus.h"
#include "IHttpClient.h"
#include "http/RequestTask.h"
#include "logging/ILogger.h"
#include "Request.h"


namespace TUS::Http {
struct EXPORT_LIBTUSCLIENT Progress {
struct EXPORT_CTUS Progress {
char *data;
size_t size;
};

/**
* @brief Represents a HTTP client
*/
class EXPORT_LIBTUSCLIENT HttpClient : public IHttpClient {
class EXPORT_CTUS HttpClient : public IHttpClient {
public:
HttpClient();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is part of libtusclient, licensed under the MIT License.
* See the LICENSE file in the project root for more information.
*/
#include "libtusclient.h"
#include "ctus.h"
#include <list>
using std::list;
using std::string;
Expand All @@ -20,7 +20,7 @@ namespace TUS::Http {
* It provides methods for performing various HTTP methods such as GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS.
* It also provides a method for aborting a request.
*/
class EXPORT_LIBTUSCLIENT IHttpClient {
class EXPORT_CTUS IHttpClient {
public:
/**
* @brief Perform a GET request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
*/
#include <string>
#include <map>
#include "libtusclient.h"
#include "ctus.h"
#include <functional>
using std::string;
using std::map;
using std::function;


namespace TUS::Http {
enum class EXPORT_LIBTUSCLIENT HttpMethod {
enum class EXPORT_CTUS HttpMethod {
_GET,
_POST,
_PUT,
Expand All @@ -29,7 +29,7 @@ namespace TUS::Http {
/**
* @brief Represents a HTTP request
*/
class EXPORT_LIBTUSCLIENT Request {
class EXPORT_CTUS Request {
public:
using SuccessCallback = std::function<void(std::string header, std::string data)>;
using ErrorCallback = std::function<void(std::string header, std::string data)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include <curl/curl.h>

#include "Request.h"
#include "libtusclient.h"
#include "ctus.h"


namespace TUS::Http {
struct EXPORT_LIBTUSCLIENT RequestTask : public Request {
struct EXPORT_CTUS RequestTask : public Request {
CURL *curl;

RequestTask(const Request &request, CURL *curl);
Expand Down
Loading
Loading