From 5dd90202be32681314ac3fa006050c6150305fac Mon Sep 17 00:00:00 2001 From: Guilherme Werner Date: Wed, 6 Mar 2024 18:48:14 -0300 Subject: [PATCH] Remove mintaka submodule --- .gitmodules | 3 --- Cargo.toml | 1 - include/tribufu/api.h | 8 +------- include/tribufu/client.h | 4 +--- include/tribufu/json.h | 11 +++++++++++ include/tribufu/oauth2.h | 14 ++++++++++---- include/tribufu/platform.h | 21 +++++++++++++++++++++ include/tribufu/prelude.h | 9 ++------- include/tribufu/server.h | 4 +--- scripts/premake.bat | 2 +- scripts/premake.sh | 4 ++-- src/oauth2.cpp | 16 ++++++++++++---- src/options.cpp | 6 ++++-- src/server.cpp | 3 ++- vendor/Mintaka | 1 - 15 files changed, 68 insertions(+), 39 deletions(-) create mode 100644 include/tribufu/json.h create mode 100644 include/tribufu/platform.h delete mode 160000 vendor/Mintaka diff --git a/.gitmodules b/.gitmodules index 644d939f..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "vendor/Mintaka"] - path = vendor/Mintaka - url = https://github.com/Tribufu/Mintaka diff --git a/Cargo.toml b/Cargo.toml index a9d6fdb0..28a2c53e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,3 @@ crate-type = ["staticlib"] path = "src/lib.rs" [dependencies] -mintaka-native = { path = "./vendor/Mintaka/src/native" } diff --git a/include/tribufu/api.h b/include/tribufu/api.h index d073559c..e85e8560 100644 --- a/include/tribufu/api.h +++ b/include/tribufu/api.h @@ -2,8 +2,8 @@ #pragma once -#include #include +#include namespace tribufu { @@ -15,19 +15,13 @@ namespace tribufu private: std::string base_url; TribufuApiOptions options; - HttpClient http; public: TribufuApi(); - TribufuApi(std::string api_key); - TribufuApi(TribufuApiOptions options); - ~TribufuApi(); - static TribufuApi from_env(); - static TribufuApi from_env(std::string prefix); }; } diff --git a/include/tribufu/client.h b/include/tribufu/client.h index d44dc340..3d773971 100644 --- a/include/tribufu/client.h +++ b/include/tribufu/client.h @@ -2,8 +2,8 @@ #pragma once -#include #include +#include namespace tribufu { @@ -15,9 +15,7 @@ namespace tribufu public: TribufuClient(uint64_t id, const std::string &secret); - ~TribufuClient(); - uint64_t &get_client_id(); }; } diff --git a/include/tribufu/json.h b/include/tribufu/json.h new file mode 100644 index 00000000..add3e3bb --- /dev/null +++ b/include/tribufu/json.h @@ -0,0 +1,11 @@ +// Copyright (c) Tribufu. All Rights Reserved. + +#pragma once + +#include +#include + +#ifdef TRIBUFU_CPP +#include +using json = nlohmann::json; +#endif diff --git a/include/tribufu/oauth2.h b/include/tribufu/oauth2.h index bc4510cd..a13003c7 100644 --- a/include/tribufu/oauth2.h +++ b/include/tribufu/oauth2.h @@ -61,7 +61,8 @@ namespace tribufu public: OAuth2AuthorizeRequest(); - OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &scope, const std::string &state); + OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, + const std::string &redirect_uri, const std::string &scope, const std::string &state); ~OAuth2AuthorizeRequest(); }; @@ -87,7 +88,8 @@ namespace tribufu public: OAuth2ErrorResponse(); - OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, const std::string &error_uri, const std::string &state); + OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, + const std::string &error_uri, const std::string &state); ~OAuth2ErrorResponse(); }; @@ -105,7 +107,9 @@ namespace tribufu public: OAuth2TokenRequest(); - OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, const std::string &username, const std::string &password); + OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, + const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, + const std::string &username, const std::string &password); ~OAuth2TokenRequest(); }; @@ -121,7 +125,9 @@ namespace tribufu public: OAuth2TokenResponse(); - OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, const std::string &refresh_token, const std::string &scope, const std::string &state, uint64_t expires_in); + OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, + const std::string &refresh_token, const std::string &scope, const std::string &state, + uint64_t expires_in); ~OAuth2TokenResponse(); }; } diff --git a/include/tribufu/platform.h b/include/tribufu/platform.h new file mode 100644 index 00000000..7aeeccce --- /dev/null +++ b/include/tribufu/platform.h @@ -0,0 +1,21 @@ +// Copyright (c) Tribufu. All Rights Reserved. + +#pragma once + +#ifdef _WIN32 +#ifndef DLLEXPORT +#define DLLEXPORT __declspec(dllexport) +#endif +#ifndef DLLIMPORT +#define DLLIMPORT __declspec(dllimport) +#endif +#endif + +#ifdef __MACH__ || __APPLE__ || __linux__ || __FreeBSD__ || __ANDROID__ +#ifndef DLLEXPORT +#define DLLEXPORT __attribute__((visibility("default"))) +#endif +#ifndef DLLIMPORT +#define DLLIMPORT __attribute__((visibility("default"))) +#endif +#endif diff --git a/include/tribufu/prelude.h b/include/tribufu/prelude.h index f0e5634e..16649115 100644 --- a/include/tribufu/prelude.h +++ b/include/tribufu/prelude.h @@ -2,12 +2,7 @@ #pragma once -#include +#include #include #include - -#ifdef TRIBUFU_CPP - -using namespace mintaka; - -#endif +#include diff --git a/include/tribufu/server.h b/include/tribufu/server.h index f83d91e2..d67e0cbd 100644 --- a/include/tribufu/server.h +++ b/include/tribufu/server.h @@ -2,8 +2,8 @@ #pragma once -#include #include +#include namespace tribufu { @@ -14,9 +14,7 @@ namespace tribufu public: TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret); - ~TribufuServer(); - uint64_t &get_server_id(); }; } diff --git a/scripts/premake.bat b/scripts/premake.bat index 0a16272f..5488708a 100644 --- a/scripts/premake.bat +++ b/scripts/premake.bat @@ -1,3 +1,3 @@ @echo off -call .\vendor\Mintaka\vendor\premake-core\windows\premake5.exe vs2022 +call .\vendor\premake-core\windows\premake5.exe vs2022 diff --git a/scripts/premake.sh b/scripts/premake.sh index f1e09cba..3fb5e5e4 100644 --- a/scripts/premake.sh +++ b/scripts/premake.sh @@ -2,9 +2,9 @@ if [ "$(expr substr $(uname -s) 1 5)" = "Linux" ] then - ./vendor/Mintaka/vendor/premake-core/linux/premake5 gmake2 + ./vendor/premake-core/linux/premake5 gmake2 elif [ "$(uname)" = "Darwin" ] then - ./vendor/Mintaka/vendor/premake-core/mac/premake5 xcode4 + ./vendor/premake-core/mac/premake5 xcode4 fi diff --git a/src/oauth2.cpp b/src/oauth2.cpp index 7bd0ed58..d40ca2c2 100644 --- a/src/oauth2.cpp +++ b/src/oauth2.cpp @@ -8,7 +8,9 @@ namespace tribufu { } - OAuth2AuthorizeRequest::OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &scope, const std::string &state) + OAuth2AuthorizeRequest::OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, + const std::string &client_secret, const std::string &redirect_uri, + const std::string &scope, const std::string &state) { this->response_type = response_type; this->client_id = client_id; @@ -40,7 +42,8 @@ namespace tribufu { } - OAuth2ErrorResponse::OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, const std::string &error_uri, const std::string &state) + OAuth2ErrorResponse::OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, + const std::string &error_uri, const std::string &state) { this->error = error; this->error_description = error_description; @@ -56,7 +59,10 @@ namespace tribufu { } - OAuth2TokenRequest::OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, const std::string &username, const std::string &password) + OAuth2TokenRequest::OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, + const std::string &client_secret, const std::string &redirect_uri, + const std::string &code, const std::string &refresh_token, + const std::string &username, const std::string &password) { this->grant_type = grant_type; this->client_id = client_id; @@ -76,7 +82,9 @@ namespace tribufu { } - OAuth2TokenResponse::OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, const std::string &refresh_token, const std::string &scope, const std::string &state, uint64_t expires_in) + OAuth2TokenResponse::OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, + const std::string &refresh_token, const std::string &scope, + const std::string &state, uint64_t expires_in) { this->token_type = token_type; this->access_token = access_token; diff --git a/src/options.cpp b/src/options.cpp index 3558fdd8..0b9e847d 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -12,11 +12,13 @@ namespace tribufu { } - TribufuApiOptions::TribufuApiOptions(std::string access_token, std::string refresh_token, float expires_in) : TribufuApiOptions(nullptr, access_token, refresh_token, expires_in) + TribufuApiOptions::TribufuApiOptions(std::string access_token, std::string refresh_token, float expires_in) + : TribufuApiOptions(nullptr, access_token, refresh_token, expires_in) { } - TribufuApiOptions::TribufuApiOptions(std::string api_key, std::string access_token, std::string refresh_token, float expires_in) + TribufuApiOptions::TribufuApiOptions(std::string api_key, std::string access_token, std::string refresh_token, + float expires_in) { this->api_key = api_key; this->access_token = access_token; diff --git a/src/server.cpp b/src/server.cpp index 52a0cca2..9fb3e9a5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4,7 +4,8 @@ namespace tribufu { - TribufuServer::TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret) : TribufuClient(client_id, client_secret) + TribufuServer::TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret) + : TribufuClient(client_id, client_secret) { this->server_id = server_id; } diff --git a/vendor/Mintaka b/vendor/Mintaka deleted file mode 160000 index 6733b056..00000000 --- a/vendor/Mintaka +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6733b056f633d02af586d881776e82363cdc9ca7