diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index fc0f63cf..00000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,12 +0,0 @@ -# Shared - -[profile.dev] -lto = "off" - -[profile.release] -lto = "thin" - -# Windows - -[target.'cfg(target_os = "windows")'] -rustflags = ["-C", "target-feature=+crt-static"] diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 28a2c53e..00000000 --- a/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "tribufu-native" -version = "0.0.4" -description = "Tribufu Native" -repository = "https://github.com/Tribufu/TribufuNative" -authors = ["Tribufu "] -license = "Apache-2.0" -edition = "2021" -publish = false - -[lib] -name = "tribufu_native" -crate-type = ["staticlib"] -path = "src/lib.rs" - -[dependencies] diff --git a/config/cbindgen.toml b/config/cbindgen.toml deleted file mode 100644 index d0620c76..00000000 --- a/config/cbindgen.toml +++ /dev/null @@ -1,157 +0,0 @@ -language = "C" -header = "// Copyright (c) Tribufu. All Rights Reserved." -pragma_once = true -include_version = false -namespaces = [] -using_namespaces = [] -sys_includes = ["tribufu/prelude.h"] -includes = [] -no_includes = true -cpp_compat = false -braces = "NextLine" -line_length = 100 -tab_width = 4 -documentation = true -documentation_style = "doxy" -style = "tag" - -[defines] -"debug_assertions" = "TRIBUFU_DEVEL" -"not(debug_assertions)" = "TRIBUFU_RETAIL" -"panic = abort" = "TRIBUFU_PANIC_ABORT" -"panic = unwind" = "TRIBUFU_PANIC_UNWIND" -"proc_macro" = "TRIBUFU_PROC_MACRO" -"target_arch = aarch64" = "TRIBUFU_AARCH64" -"target_arch = arm" = "TRIBUFU_ARM" -"target_arch = armV7" = "TRIBUFU_ARMV7" -"target_arch = armv4t" = "TRIBUFU_ARMV4T" -"target_arch = armv6" = "TRIBUFU_ARMV6" -"target_arch = armv7a" = "TRIBUFU_ARMV7A" -"target_arch = armv7s" = "TRIBUFU_ARMV7S" -"target_arch = avr" = "TRIBUFU_AVR" -"target_arch = bpfeb" = "TRIBUFU_BPFEB" -"target_arch = bpfel" = "TRIBUFU_BPFEL" -"target_arch = hexagon" = "TRIBUFU_HEXAGON" -"target_arch = i386" = "TRIBUFU_I386" -"target_arch = i586" = "TRIBUFU_I586" -"target_arch = i686" = "TRIBUFU_I686" -"target_arch = m68k" = "TRIBUFU_M68K" -"target_arch = mips" = "TRIBUFU_MIPS" -"target_arch = mipsel" = "TRIBUFU_MIPSEL" -"target_arch = msp430" = "TRIBUFU_MSP430" -"target_arch = powerpc" = "TRIBUFU_POWERPC" -"target_arch = powerpc64" = "TRIBUFU_POWERPC64" -"target_arch = powerpc64l" = "TRIBUFU_POWERPC64L" -"target_arch = riscv32gc" = "TRIBUFU_RISCV32GC" -"target_arch = s390x" = "TRIBUFU_S390X" -"target_arch = sparc" = "TRIBUFU_SPARC" -"target_arch = sparc64" = "TRIBUFU_SPARC64" -"target_arch = thumbv4t" = "TRIBUFU_THUMBV4T" -"target_arch = thumbv7a" = "TRIBUFU_THUMBV7A" -"target_arch = thumbv7neon" = "TRIBUFU_THUMBV7NEON" -"target_arch = wasm32" = "TRIBUFU_WASM32" -"target_arch = wasm64" = "TRIBUFU_WASM64" -"target_arch = x86" = "TRIBUFU_X86" -"target_arch = x86_64" = "TRIBUFU_X86_64" -"target_endian = big" = "TRIBUFU_BIG_ENDIAN" -"target_endian = little" = "TRIBUFU_LITTLE_ENDIAN" -"target_env = gnu" = "TRIBUFU_GNU" -"target_env = msvc" = "TRIBUFU_MSVC" -"target_env = musl" = "TRIBUFU_MUSL" -"target_env = sgx" = "TRIBUFU_SGX" -"target_family = unix" = "TRIBUFU_UNIX" -"target_family = wasm" = "TRIBUFU_WASM" -"target_family = windows" = "TRIBUFU_MICROSOFT" -"target_feature = avx" = "TRIBUFU_AVX" -"target_feature = avx2" = "TRIBUFU_AVX2" -"target_feature = crt-static" = "TRIBUFU_CRTSTATIC" -"target_feature = rdrand" = "TRIBUFU_RDRAND" -"target_feature = sse" = "TRIBUFU_SSE" -"target_feature = sse2" = "TRIBUFU_SSE2" -"target_feature = sse4.1" = "TRIBUFU_SSE41" -"target_has_atomic = 128" = "TRIBUFU_ATOMIC_128" -"target_has_atomic = 16" = "TRIBUFU_ATOMIC_16" -"target_has_atomic = 32" = "TRIBUFU_ATOMIC_32" -"target_has_atomic = 64" = "TRIBUFU_ATOMIC_64" -"target_has_atomic = 8" = "TRIBUFU_ATOMIC_8" -"target_has_atomic = ptr" = "TRIBUFU_ATOMIC_PTR" -"target_os = android" = "TRIBUFU_ANDROID" -"target_os = dragonfly" = "TRIBUFU_DRAGONFLY" -"target_os = freebsd" = "TRIBUFU_FREEBSD" -"target_os = ios" = "TRIBUFU_IOS" -"target_os = linux" = "TRIBUFU_LINUX" -"target_os = macos" = "TRIBUFU_MACOS" -"target_os = netbsd" = "TRIBUFU_NETBSD" -"target_os = openbsd" = "TRIBUFU_OPENBSD" -"target_os = windows" = "TRIBUFU_WINDOWS" -"target_pointer_width = 16" = "TRIBUFU_POINTER_16" -"target_pointer_width = 32" = "TRIBUFU_POINTER_32" -"target_pointer_width = 64" = "TRIBUFU_POINTER_64" -"target_vendor = apple" = "TRIBUFU_APPLE" -"target_vendor = fortanix" = "TRIBUFU_FORTANIX" -"target_vendor = pc" = "TRIBUFU_MICROSOFT" -"target_vendor = unknown" = "TRIBUFU_UNKNOWN" - -[export] -include = [] -exclude = [] -item_types = ["enums", "structs", "typedefs", "functions"] -renaming_overrides_prefixing = false - -[layout] -packed = "PACKED" -aligned_n = "ALIGNED" - -[fn] -prefix = "NATIVE_API" -args = "horizontal" -must_use = "MUST_USE_FUNC" -no_return = "NO_RETURN" -rename_args = "None" -sort_by = "Name" - -[struct] -rename_fields = "None" -must_use = "MUST_USE_STRUCT" -derive_constructor = true -derive_eq = false -derive_neq = false -derive_lt = false -derive_lte = false -derive_gt = false -derive_gte = false - -[enum] -rename_variants = "None" -add_sentinel = false -prefix_with_name = false -enum_class = false -derive_helper_methods = false -derive_const_casts = false -derive_mut_casts = false -must_use = "MUST_USE_ENUM" -derive_tagged_enum_destructor = false -derive_tagged_enum_copy_constructor = false -derive_tagged_enum_copy_assignment = false -private_default_tagged_enum_constructor = false - -[const] -allow_static_const = true -allow_constexpr = false -sort_by = "Name" - -[macro_expansion] -bitflags = true - -[parse] -parse_deps = true -include = [] -exclude = [] -clean = false -extra_bindings = [] - -[parse.expand] -crates = [] -all_features = true -default_features = true -features = [] diff --git a/examples/main.cpp b/examples/main.cpp index 0e72dd53..1a6d89c5 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,11 +1,31 @@ // Copyright (c) Tribufu. All Rights Reserved. -#include -#include +#include using namespace tribufu; int main(int argc, char **argv) { + if (TribufuSdk::Initialize()) + { + std::cout << "Tribufu SDK initialized successfully!" << std::endl; + } + else + { + std::cout << "Failed to initialize Tribufu SDK!" << std::endl; + return 1; + } + + if (TribufuSdk::Ping()) + { + std::cout << "Tribufu SDK is online!" << std::endl; + } + else + { + std::cout << "Tribufu SDK is offline!" << std::endl; + } + + TribufuSdk::Shutdown(); + return 0; } diff --git a/examples/premake5.lua b/examples/premake5.lua index 50422b73..f661b406 100644 --- a/examples/premake5.lua +++ b/examples/premake5.lua @@ -7,8 +7,8 @@ project "example" cppdialect "C++20" - targetdir("../bin/%{cfg.platform:gsub('-', '/')}") - objdir("../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform:gsub('-', '/')}") + targetdir("../bin/%{cfg.platform}") + objdir("../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform}") files { @@ -19,13 +19,14 @@ project "example" includedirs { + "../../TribufuSdk/include", "../include", "../vendor/*/include", } libdirs { - "../bin/%{cfg.platform:gsub('-', '/')}", + "../bin/%{cfg.platform}", } -- Profile diff --git a/include/tribufu++/sdk.h b/include/tribufu++/sdk.h new file mode 100644 index 00000000..92d65ab5 --- /dev/null +++ b/include/tribufu++/sdk.h @@ -0,0 +1,20 @@ +// Copyright (c) Tribufu. All Rights Reserved. + +#pragma once + +#include + +namespace tribufu +{ + class TRIBUFU_API TribufuSdk + { + public: + static bool Initialize(); + static void Shutdown(); + static bool Ping(); + static void PingAsync(void *client_date, TribufuSdkPingCallback callback); + + private: + static void PingCallbackHandler(void *client_data, bool result); + }; +} diff --git a/include/tribufu.h b/include/tribufu.h deleted file mode 100644 index 70288c3a..00000000 --- a/include/tribufu.h +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include diff --git a/include/tribufu/api.h b/include/tribufu/api.h deleted file mode 100644 index e85e8560..00000000 --- a/include/tribufu/api.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -namespace tribufu -{ - static const char *VERSION = "0.0.4"; - static const char *API_URL = "https://api.tribufu.com"; - - class TRIBUFU_API TribufuApi - { - private: - std::string base_url; - TribufuApiOptions options; - - 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 deleted file mode 100644 index 3d773971..00000000 --- a/include/tribufu/client.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -namespace tribufu -{ - class TRIBUFU_API TribufuClient : public TribufuApi - { - private: - uint64_t client_id; - std::string client_secret; - - 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 deleted file mode 100644 index add3e3bb..00000000 --- a/include/tribufu/json.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -#ifdef TRIBUFU_CPP -#include -using json = nlohmann::json; -#endif diff --git a/include/tribufu/macros.h b/include/tribufu/macros.h deleted file mode 100644 index 704e0a97..00000000 --- a/include/tribufu/macros.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#ifdef __cplusplus -#define TRIBUFU_CPP -#endif - -#ifdef TRIBUFU_LIBRARY -#define TRIBUFU_API DLLEXPORT -#else -#define TRIBUFU_API DLLIMPORT -#endif - -// Macros Utils - -#define TRIBUFU_EXPAND_MACRO(x) x -#define TRIBUFU_STRINGIFY_MACRO(x) #x diff --git a/include/tribufu/native.h b/include/tribufu/native.h deleted file mode 100644 index f05bad5c..00000000 --- a/include/tribufu/native.h +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include diff --git a/include/tribufu/oauth2.h b/include/tribufu/oauth2.h deleted file mode 100644 index a13003c7..00000000 --- a/include/tribufu/oauth2.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include - -namespace tribufu -{ - enum class TRIBUFU_API OAuth2ResponseType - { - Code, - Token, - }; - - enum class TRIBUFU_API OAuth2ClientType - { - Confidential, - Public, - }; - - enum class TRIBUFU_API OAuth2TokenHintType - { - AccessToken, - RefreshToken, - }; - - enum class TRIBUFU_API OAuth2GrantType - { - AuthorizationCode, - ClientCredentials, - DeviceCode, - Password, - RefreshToken, - }; - - enum class TRIBUFU_API OAuth2AuthorizeError - { - AccessDenied, - InvalidRequest, - InvalidScope, - ServerError, - TemporarilyUnavailable, - UnauthorizedClient, - UnsupportedResponseType, - }; - - enum class TRIBUFU_API OAuth2TokenType - { - Bearer, - }; - - class TRIBUFU_API OAuth2AuthorizeRequest - { - private: - OAuth2ResponseType response_type; - uint64_t client_id; - std::string client_secret; - std::string redirect_uri; - std::string scope; - std::string state; - - 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(); - }; - - class TRIBUFU_API OAuth2CodeResponse - { - private: - std::string code; - std::string state; - - public: - OAuth2CodeResponse(); - OAuth2CodeResponse(const std::string &code, const std::string &state); - ~OAuth2CodeResponse(); - }; - - class TRIBUFU_API OAuth2ErrorResponse - { - private: - OAuth2AuthorizeError error; - std::string error_description; - std::string error_uri; - std::string state; - - public: - OAuth2ErrorResponse(); - OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, - const std::string &error_uri, const std::string &state); - ~OAuth2ErrorResponse(); - }; - - class TRIBUFU_API OAuth2TokenRequest - { - private: - OAuth2GrantType grant_type; - uint64_t client_id; - std::string client_secret; - std::string redirect_uri; - std::string code; - std::string refresh_token; - std::string username; - std::string password; - - 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(); - }; - - class TRIBUFU_API OAuth2TokenResponse - { - private: - OAuth2TokenType token_type; - std::string access_token; - std::string refresh_token; - std::string scope; - std::string state; - uint64_t expires_in; - - 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(); - }; -} diff --git a/include/tribufu/options.h b/include/tribufu/options.h deleted file mode 100644 index 6ab72f63..00000000 --- a/include/tribufu/options.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include - -namespace tribufu -{ - class TRIBUFU_API TribufuApiOptions - { - public: - std::string api_key; - std::string access_token; - std::string refresh_token; - float expires_in; - - public: - TribufuApiOptions(); - TribufuApiOptions(std::string api_key); - TribufuApiOptions(std::string access_token, std::string refresh_token, float expires_in); - TribufuApiOptions(std::string api_key, std::string access_token, std::string refresh_token, float expires_in); - ~TribufuApiOptions(); - }; -} diff --git a/include/tribufu/platform.h b/include/tribufu/platform.h deleted file mode 100644 index 7aeeccce..00000000 --- a/include/tribufu/platform.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index 2dcc44b4..00000000 --- a/include/tribufu/prelude.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include -#include -#include diff --git a/include/tribufu/server.h b/include/tribufu/server.h deleted file mode 100644 index d67e0cbd..00000000 --- a/include/tribufu/server.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -namespace tribufu -{ - class TRIBUFU_API TribufuServer : public TribufuClient - { - private: - uint64_t server_id; - - public: - TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret); - ~TribufuServer(); - uint64_t &get_server_id(); - }; -} diff --git a/include/tribufu/servers/server.h b/include/tribufu/servers/server.h deleted file mode 100644 index d44d3ae7..00000000 --- a/include/tribufu/servers/server.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -namespace tribufu -{ - class TRIBUFU_API Server - { - private: - uint64_t id; - std::string name; - std::string description; - std::string address; - uint16_t game_port; - uint16_t query_port; - uint64_t package_id; - - public: - Server(); - Server(json data); - ~Server(); - - json to_json(); - }; -} diff --git a/include/tribufu/std.h b/include/tribufu/std.h deleted file mode 100644 index 12fda2d6..00000000 --- a/include/tribufu/std.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include -#include -#include -#include - -#ifdef TRIBUFU_CPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif diff --git a/include/tribufu/users/profile.h b/include/tribufu/users/profile.h deleted file mode 100644 index 948e939f..00000000 --- a/include/tribufu/users/profile.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include - -namespace tribufu -{ - enum class UserType - { - User, - Bot, - Org, - }; - - class TRIBUFU_API Profile - { - private: - uint64_t id; - std::string uuid; - std::string name; - std::string display_name; - UserType type; - uint64_t public_flags; - bool verified; - uint32_t level; - double experience; - bool public_birthday; - double points; - std::string location; - std::string photo_url; - std::string banner_url; - std::string last_online; - std::string biography; - uint32_t view_count; - std::string created; - std::string updated; - - public: - Profile(); - Profile(json data); - ~Profile(); - - json to_json(); - }; -} diff --git a/premake5.lua b/premake5.lua index 5ba9b8ba..de1004d0 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,6 +1,6 @@ --- @diagnostic disable: undefined-global -workspace "tribufu" +workspace "tribufu_cpp" location "." configurations { "debug", "release" } diff --git a/scripts/msbuild.ps1 b/scripts/msbuild.ps1 index e2dc9159..bbe63ff5 100755 --- a/scripts/msbuild.ps1 +++ b/scripts/msbuild.ps1 @@ -1,8 +1,6 @@ #!/usr/bin/env pwsh echo "Building for windows-x86_64" -cargo build --package tribufu-native --target x86_64-pc-windows-msvc -New-Item "bin/windows/x86_64" -ItemType Directory -Force -Remove-Item -Path "bin/windows/x86_64/*" -Force -Copy-Item -Path "target/x86_64-pc-windows-msvc/debug/tribufu_native.lib" -Destination "bin/windows/x86_64" -Force +New-Item "bin/windows-x86_64" -ItemType Directory -Force +Remove-Item -Path "bin/windows-x86_64/*" -Force msbuild /p:Configuration="debug" /p:Platform="windows-x86_64" diff --git a/src/api.cpp b/src/api.cpp deleted file mode 100644 index 8aa3c226..00000000 --- a/src/api.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - TribufuApi::TribufuApi() - { - } - - TribufuApi::TribufuApi(std::string api_key) - { - this->options.api_key = api_key; - } - - TribufuApi::TribufuApi(TribufuApiOptions options) - { - this->options = options; - } - - TribufuApi::~TribufuApi() - { - } - - TribufuApi TribufuApi::from_env() - { - return TribufuApi::from_env(""); - } - - TribufuApi TribufuApi::from_env(std::string prefix) - { - std::string env_prefix = ""; - - if (prefix != "") - { - env_prefix = prefix + "_"; - } - - size_t required_size; - char api_key[64]; - - auto response = getenv_s(&required_size, api_key, sizeof(api_key), (env_prefix + "API_KEY").c_str()); - - if (response == 0 && required_size > 0) - { - return TribufuApi(api_key); - } - - return TribufuApi(); - } -} diff --git a/src/client.cpp b/src/client.cpp deleted file mode 100644 index 87eb2304..00000000 --- a/src/client.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - TribufuClient::TribufuClient(uint64_t client_id, const std::string &client_secret) : TribufuApi() - { - this->client_id = client_id; - this->client_secret = client_secret; - } - - TribufuClient::~TribufuClient() - { - } - - uint64_t &TribufuClient::get_client_id() - { - return this->client_id; - } - - /* - void TribufuClient::get_token() - { - try - { - std::string url = "https://api.tribufu.com/v1/servers"; - FHttpResponse response = this->http.get(url); - std::cout << "status_code: " << response.status_code << std::endl; - - if (response.body != nullptr) - { - json response_body = json::parse(response.body); - std::string json_str = response_body.dump(4); - std::cout << json_str << std::endl; - } - - mintaka_http_free_response(response); - } - catch (std::exception &e) - { - std::cout << "exception: " << e.what() << std::endl; - } - } - */ -} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 143a08f1..00000000 --- a/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. diff --git a/src/oauth2.cpp b/src/oauth2.cpp deleted file mode 100644 index d40ca2c2..00000000 --- a/src/oauth2.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - OAuth2AuthorizeRequest::OAuth2AuthorizeRequest() - { - } - - 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; - this->client_secret = client_secret; - this->redirect_uri = redirect_uri; - this->scope = scope; - this->state = state; - } - - OAuth2AuthorizeRequest::~OAuth2AuthorizeRequest() - { - } - - OAuth2CodeResponse::OAuth2CodeResponse() - { - } - - OAuth2CodeResponse::OAuth2CodeResponse(const std::string &code, const std::string &state) - { - this->code = code; - this->state = state; - } - - OAuth2CodeResponse::~OAuth2CodeResponse() - { - } - - OAuth2ErrorResponse::OAuth2ErrorResponse() - { - } - - 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; - this->error_uri = error_uri; - this->state = state; - } - - OAuth2ErrorResponse::~OAuth2ErrorResponse() - { - } - - OAuth2TokenRequest::OAuth2TokenRequest() - { - } - - 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; - this->client_secret = client_secret; - this->redirect_uri = redirect_uri; - this->code = code; - this->refresh_token = refresh_token; - this->username = username; - this->password = password; - } - - OAuth2TokenRequest::~OAuth2TokenRequest() - { - } - - OAuth2TokenResponse::OAuth2TokenResponse() - { - } - - 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; - this->refresh_token = refresh_token; - this->scope = scope; - this->state = state; - this->expires_in = expires_in; - } - - OAuth2TokenResponse::~OAuth2TokenResponse() - { - } -} diff --git a/src/options.cpp b/src/options.cpp deleted file mode 100644 index 0b9e847d..00000000 --- a/src/options.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - TribufuApiOptions::TribufuApiOptions() : TribufuApiOptions(nullptr, nullptr, nullptr, 0.0f) - { - } - - TribufuApiOptions::TribufuApiOptions(std::string api_key) : TribufuApiOptions(api_key, nullptr, nullptr, 0.0f) - { - } - - 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) - { - this->api_key = api_key; - this->access_token = access_token; - this->refresh_token = refresh_token; - this->expires_in = expires_in; - } - - TribufuApiOptions::~TribufuApiOptions() - { - } -} diff --git a/src/premake5.lua b/src/premake5.lua index 57c30cd3..199b9052 100644 --- a/src/premake5.lua +++ b/src/premake5.lua @@ -6,7 +6,7 @@ project "tribufu_cpp" cppdialect "C++20" - targetdir("../bin/%{cfg.platform:gsub('-', '/')}") + targetdir("../bin/%{cfg.platform}") objdir("../target/%{cfg.buildcfg}/%{cfg.platform}/%{prj.name}}") files @@ -24,6 +24,7 @@ project "tribufu_cpp" includedirs { + "../../TribufuSdk/include", "../include", "../vendor/*/include", "../vendor/*/vendor/*/include", @@ -31,8 +32,9 @@ project "tribufu_cpp" libdirs { - "../bin/%{cfg.platform:gsub('-', '/')}", - "../vendor/*/lib/%{cfg.platform:gsub('-', '/')}", + "../../TribufuSdk/bin/%{cfg.platform}", + "../bin/%{cfg.platform}", + "../vendor/*/lib/%{cfg.platform}", } -- Profile @@ -79,7 +81,7 @@ project "tribufu_cpp" links { - "tribufu_native.lib", + "tribufu_sdk.lib", } prelinkcommands @@ -88,6 +90,7 @@ project "tribufu_cpp" postbuildcommands { + "{COPYFILE} ../../TribufuSdk/bin/%{cfg.platform}/tribufu_sdk.dll ../bin/%{cfg.platform}", } filter { "platforms:mac-*" } @@ -108,7 +111,7 @@ project "tribufu_cpp" links { - "tribufu_native", + "tribufu_sdk", } prelinkcommands @@ -117,6 +120,7 @@ project "tribufu_cpp" postbuildcommands { + "{COPYFILE} ../../TribufuSdk/bin/%{cfg.platform}/libtribufu_sdk.dylib ../bin/%{cfg.platform}", } filter { "platforms:linux-*" } @@ -136,7 +140,7 @@ project "tribufu_cpp" links { - "tribufu_native", + "tribufu_sdk", } prelinkcommands @@ -145,6 +149,7 @@ project "tribufu_cpp" postbuildcommands { + "{COPYFILE} ../../TribufuSdk/bin/%{cfg.platform}/libtribufu_sdk.so ../bin/%{cfg.platform}", } filter { "platforms:android-*" } @@ -164,7 +169,7 @@ project "tribufu_cpp" links { - "tribufu_native", + "tribufu_sdk", } prelinkcommands @@ -173,6 +178,7 @@ project "tribufu_cpp" postbuildcommands { + "{COPYFILE} ../../TribufuSdk/bin/%{cfg.platform}/libtribufu_sdk.so ../bin/%{cfg.platform}", } filter { "platforms:ios-*" } @@ -193,7 +199,7 @@ project "tribufu_cpp" links { - "tribufu_native", + "tribufu_sdk", } prelinkcommands diff --git a/src/sdk.cpp b/src/sdk.cpp new file mode 100644 index 00000000..e9f39361 --- /dev/null +++ b/src/sdk.cpp @@ -0,0 +1,35 @@ +// Copyright (c) Tribufu. All Rights Reserved. + +#include + +namespace tribufu +{ + bool TribufuSdk::Initialize() + { + return tribufu_sdk_initialize(nullptr); + } + + void TribufuSdk::Shutdown() + { + tribufu_sdk_shutdown(); + } + + bool TribufuSdk::Ping() + { + std::promise promise; + std::future future = promise.get_future(); + PingAsync(static_cast(&promise), PingCallbackHandler); + return future.get(); + } + + void TribufuSdk::PingCallbackHandler(void *client_data, bool result) + { + std::promise *promise = static_cast *>(client_data); + promise->set_value(result); + } + + void TribufuSdk::PingAsync(void *client_data, TribufuSdkPingCallback callback) + { + tribufu_sdk_ping(client_data, callback); + } +} diff --git a/src/server.cpp b/src/server.cpp deleted file mode 100644 index 9fb3e9a5..00000000 --- a/src/server.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - 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; - } - - TribufuServer::~TribufuServer() - { - } - - uint64_t &TribufuServer::get_server_id() - { - return this->server_id; - } -} diff --git a/src/servers/server.cpp b/src/servers/server.cpp deleted file mode 100644 index 8ac357b4..00000000 --- a/src/servers/server.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - Server::Server() - { - } - - Server::Server(json data) - { - this->id = data["id"]; - this->name = data["name"]; - this->description = data["description"]; - this->address = data["address"]; - this->game_port = data["game_port"]; - this->query_port = data["query_port"]; - this->package_id = data["package_id"]; - } - - Server::~Server() - { - } - - json Server::to_json() - { - json data; - data["id"] = this->id; - data["name"] = this->name; - data["description"] = this->description; - data["address"] = this->address; - data["game_port"] = this->game_port; - data["query_port"] = this->query_port; - data["package_id"] = this->package_id; - return data; - } -} diff --git a/src/users/profile.cpp b/src/users/profile.cpp deleted file mode 100644 index 5b9a9bcd..00000000 --- a/src/users/profile.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include - -namespace tribufu -{ - Profile::Profile() - { - } - - Profile::Profile(json data) - { - this->id = data["id"]; - this->uuid = data["uuid"]; - this->name = data["name"]; - this->display_name = data["display_name"]; - this->type = data["type"]; - this->public_flags = data["public_flags"]; - this->verified = data["verified"]; - this->level = data["level"]; - this->experience = data["experience"]; - this->public_birthday = data["public_birthday"]; - this->points = data["points"]; - this->location = data["location"]; - this->photo_url = data["photo_url"]; - this->banner_url = data["banner_url"]; - this->last_online = data["last_online"]; - this->biography = data["biography"]; - this->view_count = data["view_count"]; - this->created = data["created"]; - this->updated = data["updated"]; - } - - Profile::~Profile() - { - } - - json Profile::to_json() - { - json data; - data["id"] = this->id; - data["uuid"] = this->uuid; - data["name"] = this->name; - data["display_name"] = this->display_name; - data["type"] = this->type; - data["public_flags"] = this->public_flags; - data["verified"] = this->verified; - data["level"] = this->level; - data["experience"] = this->experience; - data["public_birthday"] = this->public_birthday; - data["points"] = this->points; - data["location"] = this->location; - data["photo_url"] = this->photo_url; - data["banner_url"] = this->banner_url; - data["last_online"] = this->last_online; - data["biography"] = this->biography; - data["view_count"] = this->view_count; - data["created"] = this->created; - data["updated"] = this->updated; - return data; - } -}