mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
710d99ef4d
When a source file contains an explicit include with a filename following the "moc_<actual-filename>.cpp" pattern, then CMake's AUTOMOC generation tool will recognize the matching pair and generate the replacement header file and add the required include directory entries. For all files which do contain Q_OBJECT or similar declarations but do not have an explicit include directive, the global mocs_compilation.cpp file will still be generated (which groups all "missing" generated headers). The larger this global file is, the more expensive incremental compilation will be as this file (and all its contained generated headers) will be re-generated regardless of whether actual changes occurred.
88 lines
1.7 KiB
C++
88 lines
1.7 KiB
C++
#include "moc_auth-base.cpp"
|
|
#include "window-basic-main.hpp"
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
struct AuthInfo {
|
|
Auth::Def def;
|
|
Auth::create_cb create;
|
|
};
|
|
|
|
static std::vector<AuthInfo> authDefs;
|
|
|
|
void Auth::RegisterAuth(const Def &d, create_cb create)
|
|
{
|
|
AuthInfo info = {d, create};
|
|
authDefs.push_back(info);
|
|
}
|
|
|
|
std::shared_ptr<Auth> Auth::Create(const std::string &service)
|
|
{
|
|
for (auto &a : authDefs) {
|
|
if (service.find(a.def.service) != std::string::npos) {
|
|
return a.create();
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
Auth::Type Auth::AuthType(const std::string &service)
|
|
{
|
|
for (auto &a : authDefs) {
|
|
if (service.find(a.def.service) != std::string::npos) {
|
|
return a.def.type;
|
|
}
|
|
}
|
|
|
|
return Type::None;
|
|
}
|
|
|
|
bool Auth::External(const std::string &service)
|
|
{
|
|
for (auto &a : authDefs) {
|
|
if (service.find(a.def.service) != std::string::npos) {
|
|
return a.def.externalOAuth;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void Auth::Load()
|
|
{
|
|
OBSBasic *main = OBSBasic::Get();
|
|
const char *typeStr = config_get_string(main->Config(), "Auth", "Type");
|
|
if (!typeStr)
|
|
typeStr = "";
|
|
|
|
main->auth = Create(typeStr);
|
|
if (main->auth) {
|
|
if (main->auth->LoadInternal()) {
|
|
main->auth->LoadUI();
|
|
main->SetBroadcastFlowEnabled(
|
|
main->auth->broadcastFlow());
|
|
}
|
|
} else {
|
|
main->SetBroadcastFlowEnabled(false);
|
|
}
|
|
}
|
|
|
|
void Auth::Save()
|
|
{
|
|
OBSBasic *main = OBSBasic::Get();
|
|
Auth *auth = main->auth.get();
|
|
if (!auth) {
|
|
if (config_has_user_value(main->Config(), "Auth", "Type")) {
|
|
config_remove_value(main->Config(), "Auth", "Type");
|
|
config_save_safe(main->Config(), "tmp", nullptr);
|
|
}
|
|
return;
|
|
}
|
|
|
|
config_set_string(main->Config(), "Auth", "Type", auth->service());
|
|
auth->SaveInternal();
|
|
config_save_safe(main->Config(), "tmp", nullptr);
|
|
}
|