11use std:: path:: { Path , PathBuf } ;
22
3+ /// Display label shown in the Windows context menu submenu header.
4+ const CONTEXT_MENU_LABEL : & str = if cfg ! ( feature = "web-server" ) {
5+ "RClone Manager Headless"
6+ } else {
7+ "RClone Manager"
8+ } ;
9+
10+ /// Registry sub-key name — must differ between desktop and headless so both can coexist.
11+ const REGISTRY_KEY : & str = if cfg ! ( feature = "web-server" ) {
12+ "RCloneManagerHeadless"
13+ } else {
14+ "RCloneManager"
15+ } ;
16+
317struct WindowsPaths {
418 send_to : PathBuf ,
519}
@@ -25,13 +39,13 @@ fn register_context_menu_entry(
2539 icon_path : & str ,
2640 command : & str ,
2741) -> Result < ( ) , String > {
28- let parent_path = format ! ( r"{root_path}\shell\RCloneManager " ) ;
42+ let parent_path = format ! ( r"{root_path}\shell\{REGISTRY_KEY} " ) ;
2943
3044 let ( parent_key, _) = hkcu
3145 . create_subkey ( & parent_path)
3246 . map_err ( |e| format ! ( "Failed creating registry key '{parent_path}': {e}" ) ) ?;
3347 parent_key
34- . set_value ( "MUIVerb" , & "RClone Manager" )
48+ . set_value ( "MUIVerb" , & CONTEXT_MENU_LABEL )
3549 . map_err ( |e| format ! ( "Failed creating registry key '{parent_path}': {e}" ) ) ?;
3650 parent_key
3751 . set_value ( "Icon" , & icon_path)
@@ -61,7 +75,7 @@ fn register_context_menu_entry(
6175fn unregister_context_menu_entry ( hkcu : & winreg:: RegKey , root_path : & str , name : & str ) {
6276 use winreg:: enums:: KEY_ALL_ACCESS ;
6377
64- let parent_path = format ! ( r"{root_path}\shell\RCloneManager " ) ;
78+ let parent_path = format ! ( r"{root_path}\shell\{REGISTRY_KEY} " ) ;
6579 let Ok ( parent_key) = hkcu. open_subkey_with_flags ( & parent_path, KEY_ALL_ACCESS ) else {
6680 return ;
6781 } ;
@@ -74,7 +88,7 @@ fn unregister_context_menu_entry(hkcu: &winreg::RegKey, root_path: &str, name: &
7488 if shell_key. enum_keys ( ) . count ( ) == 0 {
7589 drop ( shell_key) ;
7690 drop ( parent_key) ;
77- let _ = hkcu. delete_subkey_all ( & parent_path ) ;
91+ let _ = hkcu. delete_subkey_all ( format ! ( r"{root_path}\shell\{REGISTRY_KEY}" ) ) ;
7892 }
7993}
8094
@@ -189,7 +203,7 @@ pub fn is_registered(name: &str) -> Result<bool, String> {
189203 let hkcu = RegKey :: predef ( HKEY_CURRENT_USER ) ;
190204
191205 let registered_under = |root_path : & str | {
192- hkcu. open_subkey ( format ! ( r"{root_path}\shell\RCloneManager \shell\{name}" ) )
206+ hkcu. open_subkey ( format ! ( r"{root_path}\shell\{REGISTRY_KEY} \shell\{name}" ) )
193207 . is_ok ( )
194208 } ;
195209
0 commit comments