mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-16 20:14:19 +00:00
Use mintaka shared libraries (#1)
* Add libhv and test http client * Remove cpp-httplib * Update premake5.lua * Update client.cpp * Update premake5.lua * Add more windows libs * Use mintaka http client
This commit is contained in:
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/unix/unix_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_ANDROID
|
||||
#define TRIBUFU_ANDROID
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_MOBILE
|
||||
#define TRIBUFU_MOBILE
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef TRIBUFU_APPLE
|
||||
#define TRIBUFU_APPLE
|
||||
#endif
|
||||
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#define DLLIMPORT __attribute__((visibility("default")))
|
@ -1,7 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/defines.h>
|
||||
#include <tribufu/platform.h>
|
||||
#include <tribufu/std.h>
|
@ -2,7 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/base.h>
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
const char *VERSION = "0.0.4";
|
||||
|
||||
@ -13,6 +13,7 @@ namespace tribufu
|
||||
private:
|
||||
uint64_t id;
|
||||
std::string secret;
|
||||
HttpClient http;
|
||||
|
||||
public:
|
||||
TribufuClient(uint64_t id, const std::string &secret);
|
||||
@ -22,5 +23,7 @@ namespace tribufu
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
void get_token();
|
||||
};
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef EXTERN_C
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C extern "C"
|
||||
#define TRIBUFU_CPP
|
||||
#else
|
||||
#define EXTERN_C
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Declare Enum
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define TRIBUFU_ENUM_START(name) enum class name {
|
||||
#define TRIBUFU_ENUM_END(name) }
|
||||
|
||||
#else
|
||||
|
||||
#define TRIBUFU_ENUM_START(name) typedef enum name {
|
||||
#define TRIBUFU_ENUM_END } name
|
||||
|
||||
#endif
|
||||
|
||||
#define TRIBUFU_DECLARE_ENUM(name, ...) TRIBUFU_ENUM_START(name) __VA_ARGS__ TRIBUFU_ENUM_END
|
||||
|
||||
// Declare Struct
|
||||
|
||||
#define TRIBUFU_PASTE(...) __VA_ARGS__
|
||||
|
||||
#define TRIBUFU_DECLARE_STRUCT(name, body) \
|
||||
EXTERN_C typedef struct name \
|
||||
{ \
|
||||
TRIBUFU_PASTE body \
|
||||
} name
|
||||
|
||||
// Experimental
|
||||
|
||||
#define TRIBUFU_CLASS(...)
|
||||
#define TRIBUFU_STRUCT(...)
|
||||
#define TRIBUFU_ENUM(...)
|
||||
#define TRIBUFU_FUNCTION(...)
|
||||
#define TRIBUFU_PROPERTY(...)
|
||||
|
||||
// Import/Export API
|
||||
|
||||
#define NATIVE_API EXTERN_C
|
||||
|
||||
#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
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/unix/unix_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_FREEBSD
|
||||
#define TRIBUFU_FREEBSD
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_DESKTOP
|
||||
#define TRIBUFU_DESKTOP
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/apple/apple_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_IOS
|
||||
#define TRIBUFU_IOS
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_MOBILE
|
||||
#define TRIBUFU_MOBILE
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/unix/unix_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_LINUX
|
||||
#define TRIBUFU_LINUX
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_DESKTOP
|
||||
#define TRIBUFU_DESKTOP
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/apple/apple_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_MAC
|
||||
#define TRIBUFU_MAC
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_DESKTOP
|
||||
#define TRIBUFU_DESKTOP
|
||||
#endif
|
18
include/tribufu/macros.h
Normal file
18
include/tribufu/macros.h
Normal file
@ -0,0 +1,18 @@
|
||||
// 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
|
@ -1,14 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef TRIBUFU_MSVC
|
||||
#define TRIBUFU_MSVC
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_MICROSOFT
|
||||
#define TRIBUFU_MICROSOFT
|
||||
#endif
|
||||
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#define DLLIMPORT __declspec(dllimport)
|
5
include/tribufu/native.h
Normal file
5
include/tribufu/native.h
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
127
include/tribufu/oauth2.h
Normal file
127
include/tribufu/oauth2.h
Normal file
@ -0,0 +1,127 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
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();
|
||||
};
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <tribufu/windows/windows_platform.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <tribufu/mac/mac_platform.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <tribufu/linux/linux_platform.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <tribufu/freebsd/freebsd_platform.h>
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <tribufu/android/android_platform.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
// #include <TargetConditionals.h>
|
||||
#ifdef TARGET_OS_IPHONE
|
||||
#include <tribufu/ios/ios_platform.h>
|
||||
#endif
|
||||
#endif
|
13
include/tribufu/prelude.h
Normal file
13
include/tribufu/prelude.h
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mintaka/framework.h>
|
||||
#include <tribufu/macros.h>
|
||||
#include <tribufu/native.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
|
||||
using namespace mintaka;
|
||||
|
||||
#endif
|
27
include/tribufu/servers/server.h
Normal file
27
include/tribufu/servers/server.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
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();
|
||||
};
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef TRIBUFU_UNIX
|
||||
#define TRIBUFU_UNIX
|
||||
#endif
|
||||
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#define DLLIMPORT __attribute__((visibility("default")))
|
46
include/tribufu/users/profile.h
Normal file
46
include/tribufu/users/profile.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
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();
|
||||
};
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/msvc/msvc_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_UWP
|
||||
#define TRIBUFU_UWP
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/msvc/msvc_platform.h>
|
||||
|
||||
#ifndef TRIBUFU_WINDOWS
|
||||
#define TRIBUFU_WINDOWS
|
||||
#endif
|
||||
|
||||
#ifndef TRIBUFU_DESKTOP
|
||||
#define TRIBUFU_DESKTOP
|
||||
#endif
|
Reference in New Issue
Block a user