From f4c41ec5c005f9093dd03bd1a52f7d67087ce219 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 10 Apr 2024 22:54:31 +0300 Subject: triage#170 Fix 'Clear log' button having incorrect state 1. onClear should clear file even if in 'don't log' state. 2. When chat isn't logging, check presence of old log by checking file. --- indra/newview/llfloaterpreference.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index b65d727948..35fcc9e1b1 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1917,7 +1917,21 @@ void LLFloaterPreference::selectChatPanel() void LLFloaterPreference::changed() { - getChild("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0); + if (LLConversationLog::instance().getIsLoggingEnabled()) + { + getChild("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0); + } + else + { + // onClearLog clears list, then notifies changed() and only then clears file, + // so check presence of conversations before checking file, file will cleared later. + llstat st; + bool has_logs = LLConversationLog::instance().getConversations().size() > 0 + && LLFile::stat(LLConversationLog::instance().getFileName(), &st) == 0 + && S_ISREG(st.st_mode) + && st.st_size > 0; + getChild("clear_log")->setEnabled(has_logs); + } // set 'enable' property for 'Delete transcripts...' button updateDeleteTranscriptsButton(); -- cgit v1.2.3 From afcc64cb073eef83f07313bb5f3a0b364d4b6933 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 31 Jul 2025 23:54:39 +0800 Subject: Rich Presence support using Discord Social SDK (#4457) * Rich Presence support using Discord Social SDK Download DiscordSocialSdk-1.4.9649.zip from https://discord.com/developers/applications/1394782217405862001/social-sdk/downloads Add -DUSE_DISCORD:BOOL=ON to your cmake line. The Discord app needs to be set to be a public client in the OAuth2 tab. All Discord-related code are contained within one file, llstartup.cpp, and other classes access it through some opaque layer, static functions, otherwise we'd get these "duplicate symbol" linking errors. * Move Discord-related code to llappviewer.cpp The doFrame is the one called over and over again, so running the Discord callbacks from there shouldn't have one extra function overhead, while running the Discord initialisation is only once so it's much more okay to have the extra function overhead there. * panel_preferences_privacy tabs Add tab and checkboxes for discord social SDK integration options to panel_preferences_privacy.xml * Shorten Discord-related local variable names * Connect to Discord now through privacy tab Now the access token is saved the way passwords are saved, but without a username, so we can have some persistence without having to implement an OAuth2 backend server cause we would have to store those tokens there anyway still, and it's just simpler to not go that way. Discord Social SDK doesn't have a helper for sending code to a custom server anyway, that we would have to have some asynchronous HTTP requestor ready. Show location check button gets enabled only when Discord integration is enabled, though it's not functioning yet. * Location for Discord Rich Presence Activity State I was going to use LLAgentUI::buildLocationString but there's no location format that shows only region and coords without having to have the parcel name empty, so I copied buildLocationString implementation in the case of LOCATION_FORMAT_NO_MATURITY but when the parcel name is empty. I had to make updateDiscordActivity check agent's ID and the existence of agent avatar pointer first before trying to set Activity Details or State, cause I like the "Show location" button be checkable not only after online when both the ID & pointer will have existed. I think this way is simpler than programmatically enabling the "Show location" button after the user is logged in. I put a trigger to Activity update somewhere after the user is logged in for now, not yet after a TP. The elapsed time gets reset whenever Activity is updated for now, but I'll try to make elapsed time extended instead. No Party for now, because I couldn't find a way to make a Party shown without showing its CurrentSize (I could still get away not showing its MaxSize by setting it to 0), so the State (location) is shown above the elapsed time, not on the right of it. I'll try to figure out to get some representative numbers for its CurrentSize & MaxSize next. Also no privacy on hiding the username for now, until the UI is ready. * Update Rich Presence location on region change I had to find a spot in source code where it doesn't cause a crash (it did in LLAgent::setRegion), but I'm not removing the one in llstartup.cpp because on login, the one in llviewermessage.cpp gets only the placeholder coords (10, 10, 10). * Show display name too on Discord Rich Presence Avatar name cache can be used right away upon login now after I moved the update call to the end of PRECACHE section in llstartup. * Show Discord Rich Presence Activity Party By setting CurrentSize to the number of people within chat radius, and MaxSize to the number of people within near range. * Call updateDiscordActivity too in Discord init so when the user enables the integration after being logged in, the init can show the name and location right away. * Discord Rich Presence: Hide name & connect to llappviewer.cpp Add option to show/hide avatar name in privacy panel & connect rich presense directly to llappviewer.cpp * Discord time elapsed not reset on region change Time elapses right after viewer launch even before login. Plus parameter name change in header to make it the same as in implementation. * Cache bool setting retrievals in updateDiscordActivity As suggested by Andrey Kleschev. getBOOL and getF32 are expensive, so using `static LLCachedControl<>` is the way to do it in llappviewer.cpp. * Check Discord creds existence before getting token as suggested by Andrey Kleshchev, anticipating external factors such as user moving settings from another PC. * Tracy visibility for looped Discord function calls As suggested by Andrey Kleshchev. They likely can get pricey so they need to be visible in the profiler. * Discord-related error handling/logging plus delay saving Discord credentials to only after the access token is successfully updated on Discord, and try to disconnect from Discord when the integration gets disabled regardless whether there are credentials to delete or not and whether there's an access token to revoke or not. * Use getAvatars already called for Discord Party numbers so we don't have to make any extra getAvatars calls just for this, as it's pricy in crowds, and we'll just be piggybacking `updateSpeakerList` and `updateNearbyList`. * Assemble Discord Activity Details only once by saving it to a static global string for reuse. * Remove updateDiscordActivity call in startup loop The State field (region & coords) is updated well enough without it now. * Rename handleDiscordSocial to toggleDiscordIntegration * Update Discord Activity only when integration is enabled No need to check setting for the status change callback one, because getting there would need to be connected to Discord first, which in turn needs the integration to be enabled first. --------- Co-authored-by: Secret Foxtail --- indra/newview/llfloaterpreference.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index fdac390e8a..2a6360cef8 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -366,6 +366,11 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.ClearLog", boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance())); mCommitCallbackRegistrar.add("Pref.DeleteTranscripts", boost::bind(&LLFloaterPreference::onDeleteTranscripts, this)); mCommitCallbackRegistrar.add("UpdateFilter", boost::bind(&LLFloaterPreference::onUpdateFilterTerm, this, false)); // Hook up for filtering +#ifdef LL_DISCORD + gSavedSettings.getControl("EnableDiscord")->getCommitSignal()->connect(boost::bind(&LLAppViewer::toggleDiscordIntegration, _2)); + gSavedSettings.getControl("ShowDiscordActivityDetails")->getCommitSignal()->connect(boost::bind(&LLAppViewer::updateDiscordActivity)); + gSavedSettings.getControl("ShowDiscordActivityState")->getCommitSignal()->connect(boost::bind(&LLAppViewer::updateDiscordActivity)); +#endif } void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type ) -- cgit v1.2.3 From 61d53a8731a0d10e94c4c366c31598b3f12198e1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 4 Aug 2025 22:40:13 +0300 Subject: #4470 Plug in Discord SDK package --- indra/newview/llfloaterpreference.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 2a6360cef8..c84728248c 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -528,6 +528,10 @@ bool LLFloaterPreference::postBuild() getChild("language_combobox")->add("System default", LLSD("default"), ADD_TOP, true); } +#ifndef LL_DISCORD + getChild("privacy_tab_container")->childDisable("privacy_preferences_discord"); +#endif + return true; } -- cgit v1.2.3 From 93a66b47645755d8811d3420f772c1a606b53d40 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 6 Aug 2025 22:34:28 +0300 Subject: #4470 Hide discord panel when set to build without discord --- indra/newview/llfloaterpreference.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index fff005872c..9fb9c6346e 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -529,7 +529,8 @@ bool LLFloaterPreference::postBuild() } #ifndef LL_DISCORD - getChild("privacy_tab_container")->childDisable("privacy_preferences_discord"); + LLPanel* panel = getChild("privacy_preferences_discord"); + getChild("privacy_tab_container")->removeTabPanel(panel); #endif return true; -- cgit v1.2.3