Simplify the drive name shown in the Explorer sidebar#498
Open
RyanEwen wants to merge 1 commit into
Open
Conversation
The daemon registers each sync root in the navigation pane as "SeaDrive - <user>(<server>)". Two problems with that: the space between the user name and the parenthesized server host is missing, and when there is only one account the whole suffix carries no information. Fix the missing space in getDisplayName(), and relabel the sidebar entry to the plain brand name when a single sync root is registered, keeping the account suffix only when multiple accounts need to be told apart. Explorer reads the sidebar label from the default value of HKCU\Software\Classes\CLSID\<NamespaceCLSID>, which is per-user writable, so the label can be rewritten there without elevation (the SyncRootManager entry itself is under HKLM and is owned by the daemon). Since the daemon registers sync roots asynchronously after the seafile_add_account rpc, the rewrite is retried a few times after accounts are added or removed.
Author
|
@feiniks sorry to bug but it looks like you're the one who usually handles PRs around here based on commit history. Hoping to get my PRs looked at :) |
Contributor
|
Hello @RyanEwen , Hiding the user information when only one account is signed in is a good idea. However, with the current implementation, there isn't a better way to update the display name. In particular, when a second account is added, the display name of the first account also needs to be updated. Since this would typically require modifying the Windows Registry, we don't plan to change this behavior for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
The sync root currently appears in the Explorer navigation pane as
SeaDrive - Ryan Ewen(seafile.example.com). Two changes:getDisplayName()now returnsName (host)instead ofName(host), so the registered label readsSeaDrive - Ryan Ewen (seafile.example.com).SeaDrive. With two or more accounts, each entry keeps its fullSeaDrive - Name (host)label so they can be told apart. Labels self-correct when accounts are added or removed.Note: this contains a workaround for daemon behavior
The seadrive daemon always registers the sync root as
SeaDrive - <display name>, where only<display name>comes from the GUI (viaseafile_add_account). There is no way to get a plainSeaDrivelabel through the RPC alone — passing an empty display name would presumably leave a danglingSeaDrive -.So the single-account case is handled by rewriting the label after the daemon registers it: Explorer reads the sidebar label from the default value of
HKCU\Software\Classes\CLSID\<NamespaceCLSID>(per-user writable, unlike theSyncRootManagerentry under HKLM), and the newRegElement::setSyncRootSidebarLabel()overwrites that value. Because the daemon registers sync roots asynchronously after the RPC returns, the rewrite is retried a few times (2s/10s/30s) after accounts are added/removed and on every daemon start.If the daemon were changed to use the GUI-provided display name verbatim (i.e. not force the
"SeaDrive - "prefix, letting the GUI passSeaDriveorSeaDrive - Name (host)as the full label), the registry rewrite, the retry timers, andAccountManager::updateSyncRootSidebarLabels()could all be deleted — the GUI would simply pass the right label inseafile_add_account.Changes
src/rpc/rpc-client.cpp: space fix ingetDisplayName(), now also declared in the header for reusesrc/utils/registry.{h,cpp}:collectSyncRootManagerIds()andsetSyncRootSidebarLabel()helperssrc/account-mgr.{h,cpp}:updateSyncRootSidebarLabels()computes the desired label per account; scheduled with retries from account add/removesrc/seadrive-gui.cpp: labels refreshed on daemon start/restart