From e6246a9306567f5646d3bc1971a1c5c4cf8f4f54 Mon Sep 17 00:00:00 2001 From: Lenny McLennington Date: Mon, 20 Dec 2021 02:41:08 +0000 Subject: Move MSA Client ID to the same place as the others MSA Client ID has been moved to CMakeLists.txt, and defaults to the Client ID for the PolyMC application. Removed secrets/notsecrets library, replace with (temporary?) program_info subdirectory. --- .gitignore | 2 + CMakeLists.txt | 16 +- README.md | 2 +- buildconfig/BuildConfig.cpp.in | 1 + buildconfig/BuildConfig.h | 5 + launcher/Application.cpp | 6 - launcher/Application.h | 2 - launcher/CMakeLists.txt | 2 +- launcher/minecraft/auth/steps/MSAStep.cpp | 3 +- launcher/ui/instanceview/InstanceView.cpp | 9 - launcher/ui/pages/global/AccountListPage.cpp | 4 +- notsecrets/CMakeLists.txt | 18 -- notsecrets/Launcher.icns | Bin 304757 -> 0 bytes notsecrets/Launcher.ico | Bin 102134 -> 0 bytes notsecrets/Launcher.manifest | 31 --- notsecrets/README.md | 13 -- notsecrets/Secrets.cpp | 40 ---- notsecrets/Secrets.h | 8 - notsecrets/genicons.sh | 18 -- notsecrets/launcher.rc | 29 --- notsecrets/logo.qrc | 8 - notsecrets/logo.svg | 271 --------------------------- program_info/CMakeLists.txt | 13 ++ program_info/Launcher.icns | Bin 0 -> 304757 bytes program_info/Launcher.ico | Bin 0 -> 102134 bytes program_info/Launcher.manifest | 31 +++ program_info/README.md | 5 + program_info/genicons.sh | 18 ++ program_info/launcher.rc | 29 +++ program_info/logo.qrc | 8 + program_info/logo.svg | 271 +++++++++++++++++++++++++++ 31 files changed, 394 insertions(+), 469 deletions(-) delete mode 100644 notsecrets/CMakeLists.txt delete mode 100644 notsecrets/Launcher.icns delete mode 100644 notsecrets/Launcher.ico delete mode 100644 notsecrets/Launcher.manifest delete mode 100644 notsecrets/README.md delete mode 100644 notsecrets/Secrets.cpp delete mode 100644 notsecrets/Secrets.h delete mode 100755 notsecrets/genicons.sh delete mode 100644 notsecrets/launcher.rc delete mode 100644 notsecrets/logo.qrc delete mode 100644 notsecrets/logo.svg create mode 100644 program_info/CMakeLists.txt create mode 100644 program_info/Launcher.icns create mode 100644 program_info/Launcher.ico create mode 100644 program_info/Launcher.manifest create mode 100644 program_info/README.md create mode 100755 program_info/genicons.sh create mode 100644 program_info/launcher.rc create mode 100644 program_info/logo.qrc create mode 100644 program_info/logo.svg diff --git a/.gitignore b/.gitignore index 69dda72c..d73f9f22 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ tags branding/ secrets/ run/ + +.cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8417be93..b7018d1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,10 +79,13 @@ set(Launcher_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application") # Google analytics ID -set(Launcher_ANALYTICS_ID "UA-87731965-2" CACHE STRING "ID you can get from Google analytics") +set(Launcher_ANALYTICS_ID "" CACHE STRING "ID you can get from Google analytics") + +# MSA Client ID +set(Launcher_MSA_CLIENT_ID "17b47edd-c884-4997-926d-9e7f9a6b4647" CACHE STRING "Client ID you can get from Microsoft Identity Platform when you register an application") # Bug tracker URL -set(Launcher_BUG_TRACKER_URL "" CACHE STRING "URL for the bug tracker.") +set(Launcher_BUG_TRACKER_URL "https://github.com/PolyMC/PolyMC/issues" CACHE STRING "URL for the bug tracker.") # Discord URL set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") @@ -90,9 +93,6 @@ set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") # Subreddit URL set(Launcher_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.") -# Use the secrets library or a public stub? -option(Launcher_EMBED_SECRETS "Determines whether to embed secrets. Secrets are separate and non-public." OFF) - #### Check the current Git commit and branch include(GetGitRevisionDescription) get_git_head_revision(Launcher_GIT_REFSPEC Launcher_GIT_COMMIT) @@ -131,11 +131,7 @@ endif() ####################################### Secrets ####################################### -if(Launcher_EMBED_SECRETS) - add_subdirectory(secrets) -else() - add_subdirectory(notsecrets) -endif() +add_subdirectory(program_info) ####################################### Install layout ####################################### diff --git a/README.md b/README.md index 9c485604..4c78e08c 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ This is a **fork** of the MultiMC Launcher and not endorsed by MultiMC. The Poly - [ ] Packaging for Linux--Any help packaging for your favorite distro is appreciated! - [ ] Packaging for MacOS/Windows - [ ] Stop relying on MultiMC-Hosted metadata services -- [ ] Long-term solution for the MSA client ID issue - [ ] Remove references to MultiMC - [ ] Meson +- [x] Long-term solution for the MSA client ID issue - [x] Figure out a way to switch to GPL. ## Packages diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 9e449aec..66cb0f17 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -45,6 +45,7 @@ Config::Config() NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@"; PASTE_EE_KEY = "@Launcher_PASTE_EE_API_KEY@"; IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@"; + MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@"; META_URL = "@Launcher_META_URL@"; BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@"; diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index ac05f288..2d847f94 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -79,6 +79,11 @@ public: * Client ID you can get from Imgur when you register an application */ QString IMGUR_CLIENT_ID; + + /** + * Client ID you can get from Microsoft Identity Platform when you register an application + */ + QString MSA_CLIENT_ID; /** * Metadata repository URL prefix diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 72ed5e5a..0d7eeaef 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -76,8 +76,6 @@ #include #include -#include - #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -1559,10 +1557,6 @@ void Application::on_windowClose() } } -QString Application::msaClientId() const { - return Secrets::getMSAClientID('-'); -} - void Application::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password) { // Set the application proxy settings. diff --git a/launcher/Application.h b/launcher/Application.h index 1b2a2b60..982e22e3 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -104,8 +104,6 @@ public: return m_accounts; } - QString msaClientId() const; - Status status() const { return m_status; } diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 2dfc78b5..fceca8e2 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -935,7 +935,7 @@ target_link_libraries(Launcher_logic ganalytics ) -target_link_libraries(Launcher_logic secrets) +target_link_libraries(Launcher_logic) add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${LAUNCHER_RCS}) target_link_libraries(${Launcher_Name} Launcher_logic) diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index be711f7e..bc10aa4e 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -2,6 +2,7 @@ #include +#include "BuildConfig.h" #include "minecraft/auth/AuthRequest.h" #include "minecraft/auth/Parsers.h" @@ -13,7 +14,7 @@ using Activity = Katabasis::Activity; MSAStep::MSAStep(AccountData* data, Action action) : AuthStep(data), m_action(action) { OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; - opts.clientIdentifier = APPLICATION->msaClientId(); + opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 1f044866..25aec1ab 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -835,15 +835,6 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio if(group_index < 0) return current; - auto real_group = m_groups[group_index]; - int beginning_row = 0; - for(auto group: m_groups) - { - if(group == real_group) - break; - beginning_row += group->numRows(); - } - QPair pos = cat->positionOf(current); int column = pos.first; int row = pos.second; diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index d3eb2655..87fcac86 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -37,8 +37,6 @@ #include "BuildConfig.h" -#include "Secrets.h" - AccountListPage::AccountListPage(QWidget *parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { @@ -74,7 +72,7 @@ AccountListPage::AccountListPage(QWidget *parent) updateButtonStates(); // Xbox authentication won't work without a client identifier, so disable the button if it is missing - ui->actionAddMicrosoft->setVisible(Secrets::hasMSAClientID()); + ui->actionAddMicrosoft->setVisible(BuildConfig.MSA_CLIENT_ID.size() != 0); } AccountListPage::~AccountListPage() diff --git a/notsecrets/CMakeLists.txt b/notsecrets/CMakeLists.txt deleted file mode 100644 index 00b132a3..00000000 --- a/notsecrets/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_library(secrets STATIC Secrets.cpp Secrets.h) -target_link_libraries(secrets Qt5::Core) -target_compile_definitions(secrets PUBLIC -DEMBED_SECRETS) -target_include_directories(secrets PUBLIC .) - -set(Launcher_CommonName "PolyMC") - -set(Launcher_Copyright "MultiMC Contributors" PARENT_SCOPE) -set(Launcher_Domain "multimc.org" PARENT_SCOPE) -set(Launcher_Name "${Launcher_CommonName}" PARENT_SCOPE) -set(Launcher_DisplayName "${Launcher_CommonName} 5" PARENT_SCOPE) -set(Launcher_UserAgent "${Launcher_CommonName}/5.0" PARENT_SCOPE) -set(Launcher_ConfigFile "polymc.cfg" PARENT_SCOPE) -set(Launcher_Git "https://github.com/MultiMC/Launcher" PARENT_SCOPE) - -set(Launcher_Branding_ICNS "notsecrets/Launcher.icns" PARENT_SCOPE) -set(Launcher_Branding_WindowsRC "notsecrets/launcher.rc" PARENT_SCOPE) -set(Launcher_Branding_LogoQRC "notsecrets/logo.qrc" PARENT_SCOPE) diff --git a/notsecrets/Launcher.icns b/notsecrets/Launcher.icns deleted file mode 100644 index 951b74fc..00000000 Binary files a/notsecrets/Launcher.icns and /dev/null differ diff --git a/notsecrets/Launcher.ico b/notsecrets/Launcher.ico deleted file mode 100644 index 9308958f..00000000 Binary files a/notsecrets/Launcher.ico and /dev/null differ diff --git a/notsecrets/Launcher.manifest b/notsecrets/Launcher.manifest deleted file mode 100644 index 0ee781ee..00000000 --- a/notsecrets/Launcher.manifest +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - Custom Minecraft launcher for managing multiple installs. - - - - - - - - - - - - - - - diff --git a/notsecrets/README.md b/notsecrets/README.md deleted file mode 100644 index dcc67699..00000000 --- a/notsecrets/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# PolyMC (Not) Secrets - -This is a dummy implementation of PolyMC's _Secrets_ library, used to store private information needed for: -- Application name and logo (and branding in general) -- Various URLs and API endpoints -- Your Microsoft Identity Platform client ID. **This is required to use Microsoft accounts to play!** - - If omitted, adding Microsoft accounts will be completely disabled. - -## MultiMC development - -In its current state, the `notsecrets` library is suitable for PolyMC code contributions. - -All you have to do is add the Microsoft client ID. See `Secrets.cpp` for details. diff --git a/notsecrets/Secrets.cpp b/notsecrets/Secrets.cpp deleted file mode 100644 index 6d2444a2..00000000 --- a/notsecrets/Secrets.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Secrets.h" - -#include -#include - -namespace { - -/* - * This is the MSA client ID. It is confidential and should not be reused. - * You can obtain one for yourself by using azure app registration: - * https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app - * - * The app registration should: - * - Be only for personal accounts. - * - Not have any redirect URI. - * - Not have any platform. - * - Have no credentials. - * - No certificates. - * - No client secrets. - * - Enable 'Live SDK support' for access to XBox APIs. - * - Enable 'public client flows' for OAuth2 device flow. - * - * By putting one in here, you accept the terms and conditions for using the MS Identity Plaform and assume all responsibilities associated with it. - * See: https://docs.microsoft.com/en-us/legal/microsoft-identity-platform/terms-of-use - * - * If you intend to base your own launcher on this code, take care and customize this to obfuscate the client ID, so it cannot be trivially found by casual attackers. - */ - -QString MSAClientID = ""; -} - -namespace Secrets { -bool hasMSAClientID() { - return !MSAClientID.isEmpty(); -} - -QString getMSAClientID(uint8_t separator) { - return MSAClientID; -} -} diff --git a/notsecrets/Secrets.h b/notsecrets/Secrets.h deleted file mode 100644 index 6872b68e..00000000 --- a/notsecrets/Secrets.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -#include - -namespace Secrets { -bool hasMSAClientID(); -QString getMSAClientID(uint8_t separator); -} diff --git a/notsecrets/genicons.sh b/notsecrets/genicons.sh deleted file mode 100755 index e6f704f9..00000000 --- a/notsecrets/genicons.sh +++ /dev/null @@ -1,18 +0,0 @@ -#/bin/bash - -inkscape -w 16 -h 16 -o logo_16.png logo.svg -inkscape -w 24 -h 24 -o logo_24.png logo.svg -inkscape -w 32 -h 32 -o logo_32.png logo.svg -inkscape -w 48 -h 48 -o logo_48.png logo.svg -inkscape -w 64 -h 64 -o logo_64.png logo.svg -inkscape -w 128 -h 128 -o logo_128.png logo.svg - -convert logo_128.png logo_64.png logo_48.png logo_32.png logo_24.png logo_16.png Launcher.ico - -inkscape -w 256 -h 256 -o logo_256.png logo.svg -inkscape -w 512 -h 512 -o logo_512.png logo.svg -inkscape -w 1024 -h 1024 -o logo_1024.png logo.svg - -png2icns Launcher.icns logo_1024.png logo_512.png logo_256.png logo_128.png logo_32.png logo_16.png - -rm -f logo_*.png diff --git a/notsecrets/launcher.rc b/notsecrets/launcher.rc deleted file mode 100644 index f84104fb..00000000 --- a/notsecrets/launcher.rc +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include - -IDI_ICON1 ICON DISCARDABLE "Launcher.ico" -1 RT_MANIFEST "Launcher.manifest" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,0,0,0 -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_APP -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "MultiMC Contributors" - VALUE "FileDescription", "A Minecraft Launcher" - VALUE "FileVersion", "1.0.0.0" - VALUE "ProductName", "Launcher" - VALUE "ProductVersion", "5" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0000, 0x04b0 // Unicode - END -END diff --git a/notsecrets/logo.qrc b/notsecrets/logo.qrc deleted file mode 100644 index f1da6fe6..00000000 --- a/notsecrets/logo.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - - logo.svg - - - - diff --git a/notsecrets/logo.svg b/notsecrets/logo.svg deleted file mode 100644 index a1c8e439..00000000 --- a/notsecrets/logo.svg +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/program_info/CMakeLists.txt b/program_info/CMakeLists.txt new file mode 100644 index 00000000..f418f8b2 --- /dev/null +++ b/program_info/CMakeLists.txt @@ -0,0 +1,13 @@ +set(Launcher_CommonName "PolyMC") + +set(Launcher_Copyright "PolyMC Contributors" PARENT_SCOPE) +set(Launcher_Domain "github.com/PolyMC" PARENT_SCOPE) +set(Launcher_Name "${Launcher_CommonName}" PARENT_SCOPE) +set(Launcher_DisplayName "${Launcher_CommonName} 5" PARENT_SCOPE) +set(Launcher_UserAgent "${Launcher_CommonName}/5.0" PARENT_SCOPE) +set(Launcher_ConfigFile "polymc.cfg" PARENT_SCOPE) +set(Launcher_Git "https://github.com/PolyMC/Launcher" PARENT_SCOPE) + +set(Launcher_Branding_ICNS "program_info/Launcher.icns" PARENT_SCOPE) +set(Launcher_Branding_WindowsRC "program_info/launcher.rc" PARENT_SCOPE) +set(Launcher_Branding_LogoQRC "program_info/logo.qrc" PARENT_SCOPE) diff --git a/program_info/Launcher.icns b/program_info/Launcher.icns new file mode 100644 index 00000000..951b74fc Binary files /dev/null and b/program_info/Launcher.icns differ diff --git a/program_info/Launcher.ico b/program_info/Launcher.ico new file mode 100644 index 00000000..9308958f Binary files /dev/null and b/program_info/Launcher.ico differ diff --git a/program_info/Launcher.manifest b/program_info/Launcher.manifest new file mode 100644 index 00000000..0ee781ee --- /dev/null +++ b/program_info/Launcher.manifest @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + Custom Minecraft launcher for managing multiple installs. + + + + + + + + + + + + + + + diff --git a/program_info/README.md b/program_info/README.md new file mode 100644 index 00000000..01c4d02b --- /dev/null +++ b/program_info/README.md @@ -0,0 +1,5 @@ +# PolyMC Program Info + +This is PolyMC's program info which contains information about: +- Application name and logo (and branding in general) +- Various URLs and API endpoints diff --git a/program_info/genicons.sh b/program_info/genicons.sh new file mode 100755 index 00000000..e6f704f9 --- /dev/null +++ b/program_info/genicons.sh @@ -0,0 +1,18 @@ +#/bin/bash + +inkscape -w 16 -h 16 -o logo_16.png logo.svg +inkscape -w 24 -h 24 -o logo_24.png logo.svg +inkscape -w 32 -h 32 -o logo_32.png logo.svg +inkscape -w 48 -h 48 -o logo_48.png logo.svg +inkscape -w 64 -h 64 -o logo_64.png logo.svg +inkscape -w 128 -h 128 -o logo_128.png logo.svg + +convert logo_128.png logo_64.png logo_48.png logo_32.png logo_24.png logo_16.png Launcher.ico + +inkscape -w 256 -h 256 -o logo_256.png logo.svg +inkscape -w 512 -h 512 -o logo_512.png logo.svg +inkscape -w 1024 -h 1024 -o logo_1024.png logo.svg + +png2icns Launcher.icns logo_1024.png logo_512.png logo_256.png logo_128.png logo_32.png logo_16.png + +rm -f logo_*.png diff --git a/program_info/launcher.rc b/program_info/launcher.rc new file mode 100644 index 00000000..f84104fb --- /dev/null +++ b/program_info/launcher.rc @@ -0,0 +1,29 @@ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include + +IDI_ICON1 ICON DISCARDABLE "Launcher.ico" +1 RT_MANIFEST "Launcher.manifest" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,0,0,0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "CompanyName", "MultiMC Contributors" + VALUE "FileDescription", "A Minecraft Launcher" + VALUE "FileVersion", "1.0.0.0" + VALUE "ProductName", "Launcher" + VALUE "ProductVersion", "5" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0000, 0x04b0 // Unicode + END +END diff --git a/program_info/logo.qrc b/program_info/logo.qrc new file mode 100644 index 00000000..f1da6fe6 --- /dev/null +++ b/program_info/logo.qrc @@ -0,0 +1,8 @@ + + + + logo.svg + + + + diff --git a/program_info/logo.svg b/program_info/logo.svg new file mode 100644 index 00000000..a1c8e439 --- /dev/null +++ b/program_info/logo.svg @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + -- cgit