Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/application/discord/application_manager.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/application/discord/application_manager.cpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/application/discord/application_manager.cpp')
-rw-r--r--source/application/discord/application_manager.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/source/application/discord/application_manager.cpp b/source/application/discord/application_manager.cpp
new file mode 100644
index 0000000..f5a06d3
--- /dev/null
+++ b/source/application/discord/application_manager.cpp
@@ -0,0 +1,63 @@
+#if !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "application_manager.h"
+
+#include "core.h"
+
+#include <cstring>
+#include <memory>
+
+namespace discord {
+
+void ApplicationManager::ValidateOrExit(std::function<void(Result)> callback)
+{
+ static auto wrapper = [](void* callbackData, EDiscordResult result) -> void {
+ std::unique_ptr<std::function<void(Result)>> cb(
+ reinterpret_cast<std::function<void(Result)>*>(callbackData));
+ if (!cb || !(*cb)) {
+ return;
+ }
+ (*cb)(static_cast<Result>(result));
+ };
+ std::unique_ptr<std::function<void(Result)>> cb{};
+ cb.reset(new std::function<void(Result)>(std::move(callback)));
+ internal_->validate_or_exit(internal_, cb.release(), wrapper);
+}
+
+void ApplicationManager::GetCurrentLocale(char locale[128])
+{
+ if (!locale) {
+ return;
+ }
+
+ internal_->get_current_locale(internal_, reinterpret_cast<DiscordLocale*>(locale));
+}
+
+void ApplicationManager::GetCurrentBranch(char branch[4096])
+{
+ if (!branch) {
+ return;
+ }
+
+ internal_->get_current_branch(internal_, reinterpret_cast<DiscordBranch*>(branch));
+}
+
+void ApplicationManager::GetOAuth2Token(std::function<void(Result, OAuth2Token const&)> callback)
+{
+ static auto wrapper =
+ [](void* callbackData, EDiscordResult result, DiscordOAuth2Token* oauth2Token) -> void {
+ std::unique_ptr<std::function<void(Result, OAuth2Token const&)>> cb(
+ reinterpret_cast<std::function<void(Result, OAuth2Token const&)>*>(callbackData));
+ if (!cb || !(*cb)) {
+ return;
+ }
+ (*cb)(static_cast<Result>(result), *reinterpret_cast<OAuth2Token const*>(oauth2Token));
+ };
+ std::unique_ptr<std::function<void(Result, OAuth2Token const&)>> cb{};
+ cb.reset(new std::function<void(Result, OAuth2Token const&)>(std::move(callback)));
+ internal_->get_oauth2_token(internal_, cb.release(), wrapper);
+}
+
+} // namespace discord