diff options
| -rw-r--r-- | indra/newview/llappviewer.cpp | 44 | ||||
| -rw-r--r-- | indra/newview/llappviewer.h | 5 | ||||
| -rw-r--r-- | indra/newview/llstartup.cpp | 44 | ||||
| -rw-r--r-- | indra/newview/llstartup.h | 5 | ||||
| -rw-r--r-- | indra/newview/llviewermenu.cpp | 3 | 
5 files changed, 51 insertions, 50 deletions
| diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 419d2cb842..d70287ac83 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -278,6 +278,12 @@ using namespace LL;  #pragma warning (disable:4702)  #endif +#ifdef LL_DISCORD +#define DISCORDPP_IMPLEMENTATION +#include <discordpp.h> +static std::shared_ptr<discordpp::Client> gDiscordClient; +#endif +  static LLAppViewerListener sAppViewerListener(LLAppViewer::instance);  ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor @@ -1349,7 +1355,7 @@ bool LLAppViewer::doFrame()      TimePoint fpsLimitFrameStartTime = std::chrono::steady_clock::now();  #ifdef LL_DISCORD -    LLStartUp::runDiscordCallbacks(); +    discordpp::RunCallbacks();  #endif      LL_RECORD_BLOCK_TIME(FTM_FRAME); @@ -5911,3 +5917,39 @@ void LLAppViewer::metricsSend(bool enable_reporting)      // resolution in time.      gViewerAssetStats->restart();  } + +#ifdef LL_DISCORD + +void LLAppViewer::initDiscordSocial() +{ +        gDiscordClient = std::make_shared<discordpp::Client>(); +        gDiscordClient->SetStatusChangedCallback([](discordpp::Client::Status status, discordpp::Client::Error, int32_t) { +            if (status == discordpp::Client::Status::Ready) { +                discordpp::Activity activity; +                activity.SetType(discordpp::ActivityTypes::Playing); +                gDiscordClient->UpdateRichPresence(activity, [](discordpp::ClientResult) {}); +            } +        }); +} + +void LLAppViewer::handleDiscordSocial() +{ +    static const uint64_t DISCORD_APPLICATION_ID = 1393451183741599796; +    discordpp::AuthorizationArgs discordAuthArgs{}; +    discordAuthArgs.SetClientId(DISCORD_APPLICATION_ID); +    discordAuthArgs.SetScopes(discordpp::Client::GetDefaultPresenceScopes()); +    auto discordCodeVerifier = gDiscordClient->CreateAuthorizationCodeVerifier(); +    discordAuthArgs.SetCodeChallenge(discordCodeVerifier.Challenge()); +    gDiscordClient->Authorize(discordAuthArgs, [discordCodeVerifier](auto result, auto code, auto redirectUri) { +        if (result.Successful()) { +            gDiscordClient->GetToken(DISCORD_APPLICATION_ID, code, discordCodeVerifier.Verifier(), redirectUri, [](discordpp::ClientResult result, std::string accessToken, std::string, discordpp::AuthorizationTokenType, int32_t, std::string) { +                gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [](discordpp::ClientResult result) { +                    if (result.Successful()) +                        gDiscordClient->Connect(); +                    }); +            }); +        } +    }); +} + +#endif diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 3da0246ccf..dc10738249 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -250,6 +250,11 @@ public:      // Note: mQuitRequested can be aborted by user.      void outOfMemorySoftQuit(); +#ifdef LL_DISCORD +    static void initDiscordSocial(); +    static void handleDiscordSocial(); +#endif +  protected:      virtual bool initWindow(); // Initialize the viewer's window.      virtual void initLoggingAndGetLastDuration(); // Initialize log files, logging system diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 834b99555e..8d010553a0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -217,12 +217,6 @@  #include "fsfloatersearch.h" -#ifdef LL_DISCORD -#define DISCORDPP_IMPLEMENTATION -#include <discordpp.h> -static std::shared_ptr<discordpp::Client> gDiscordClient; -#endif -  //  // exported globals  // @@ -758,14 +752,7 @@ bool idle_startup()          }  #ifdef LL_DISCORD -        gDiscordClient = std::make_shared<discordpp::Client>(); -        gDiscordClient->SetStatusChangedCallback([](discordpp::Client::Status status, discordpp::Client::Error, int32_t) { -            if (status == discordpp::Client::Status::Ready) { -                discordpp::Activity activity; -                activity.SetType(discordpp::ActivityTypes::Playing); -                gDiscordClient->UpdateRichPresence(activity, [](discordpp::ClientResult) {}); -            } -        }); +        LLAppViewer::initDiscordSocial();  #endif          // @@ -3447,35 +3434,6 @@ bool LLStartUp::startLLProxy()      return proxy_ok;  } -#ifdef LL_DISCORD - -void LLStartUp::runDiscordCallbacks() -{ -    discordpp::RunCallbacks(); -} - -void LLStartUp::handleDiscordSocial() -{ -    static const uint64_t DISCORD_APPLICATION_ID = 1393451183741599796; -    discordpp::AuthorizationArgs discordAuthArgs{}; -    discordAuthArgs.SetClientId(DISCORD_APPLICATION_ID); -    discordAuthArgs.SetScopes(discordpp::Client::GetDefaultPresenceScopes()); -    auto discordCodeVerifier = gDiscordClient->CreateAuthorizationCodeVerifier(); -    discordAuthArgs.SetCodeChallenge(discordCodeVerifier.Challenge()); -    gDiscordClient->Authorize(discordAuthArgs, [discordCodeVerifier](auto result, auto code, auto redirectUri) { -        if (result.Successful()) { -            gDiscordClient->GetToken(DISCORD_APPLICATION_ID, code, discordCodeVerifier.Verifier(), redirectUri, [](discordpp::ClientResult result, std::string accessToken, std::string, discordpp::AuthorizationTokenType, int32_t, std::string) { -                gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [](discordpp::ClientResult result) { -                    if (result.Successful()) -                        gDiscordClient->Connect(); -                    }); -            }); -        } -    }); -} - -#endif -  bool login_alert_done(const LLSD& notification, const LLSD& response)  {      LLPanelLogin::giveFocus(); diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index cf1d38bb18..c07926facb 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -129,11 +129,6 @@ public:      static LLViewerStats::PhaseMap& getPhases() { return *sPhases; } -#ifdef LL_DISCORD -    static void runDiscordCallbacks(); -    static void handleDiscordSocial(); -#endif -  private:      friend class LLStartupListener;      static LLSLURL sStartSLURL; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4383fc87e5..2c022d0a4c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -144,6 +144,7 @@  #include "llwindow.h"  #include "llpathfindingmanager.h"  #include "llstartup.h" +#include "llappviewer.h"  #include "boost/unordered_map.hpp"  #include <boost/regex.hpp>  #include <boost/algorithm/string.hpp> @@ -8945,7 +8946,7 @@ void handle_report_bug(const LLSD& param)  #ifdef LL_DISCORD  void handle_discord_social(const LLSD& param)  { -    LLStartUp::handleDiscordSocial(); +    LLAppViewer::handleDiscordSocial();  }  #endif | 
