Browse Source

Get the handler command line from the registry so it can be parsed to get the current settings.

Douglas Thrift 9 years ago
parent
commit
e09311d8eb

+ 5 - 4
ssh-handler/HandlerSettingsBox.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  */
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 
 public partial class HandlerSettingsBox : GroupBox
 {
     private Handler handler;
 
-    public HandlerSettingsBox(Handler handler)
+    public HandlerSettingsBox(Handler handler, IEnumerable<string> options)
     {
         InitializeComponent();
 
@@ -36,13 +37,13 @@ public partial class HandlerSettingsBox : GroupBox
             switch (setting.type)
             {
             case SettingType.OptionalExecutable:
-                SettingsPanel.Children.Add(new OptionalExecutablePanel(setting));
+                SettingsPanel.Children.Add(new OptionalExecutablePanel(setting, options));
                 break;
             case SettingType.OptionalYesNoExecutable:
-                SettingsPanel.Children.Add(new OptionalYesNoExecutablePanel(setting));
+                SettingsPanel.Children.Add(new OptionalYesNoExecutablePanel(setting, options));
                 break;
             case SettingType.OptionalYesNoDirectory:
-                SettingsPanel.Children.Add(new OptionalYesNoDirectoryPanel(setting));
+                SettingsPanel.Children.Add(new OptionalYesNoDirectoryPanel(setting, options));
                 break;
             }
     }

+ 2 - 1
ssh-handler/OptionalExecutablePanel.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  */
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 
 public partial class OptionalExecutablePanel : StackPanel
 {
     private Setting setting;
 
-    public OptionalExecutablePanel(Setting setting)
+    public OptionalExecutablePanel(Setting setting, IEnumerable<string> options)
     {
         InitializeComponent();
 

+ 2 - 1
ssh-handler/OptionalYesNoDirectoryPanel.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  */
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 
 public partial class OptionalYesNoDirectoryPanel : StackPanel
 {
     private Setting setting;
 
-    public OptionalYesNoDirectoryPanel(Setting setting)
+    public OptionalYesNoDirectoryPanel(Setting setting, IEnumerable<string> options)
     {
         InitializeComponent();
 

+ 2 - 1
ssh-handler/OptionalYesNoExecutablePanel.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  */
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 
 public partial class OptionalYesNoExecutablePanel : StackPanel
 {
     private Setting setting;
 
-    public OptionalYesNoExecutablePanel(Setting setting)
+    public OptionalYesNoExecutablePanel(Setting setting, IEnumerable<string> options)
     {
         InitializeComponent();
 

+ 17 - 1
ssh-handler/SettingsDialog.xaml.cs

@@ -21,9 +21,11 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Linq;
 using System.Reflection;
 using System.Windows;
 using System.Windows.Controls;
+using Microsoft.Win32;
 
 public partial class SettingsDialog : Window
 {
@@ -31,8 +33,22 @@ public partial class SettingsDialog : Window
     {
         InitializeComponent();
 
+        IEnumerable<string> options = new string[0];
+
+        using (RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Default), key = baseKey.OpenSubKey(@"ssh\shell\open\command"))
+            if (key != null)
+            {
+                string command = (string)key.GetValue(null);
+                if (!string.IsNullOrWhiteSpace(command))
+                {
+                    var args = Shell32.CommandLineToArgv(command);
+
+                    options = args.Skip(1).TakeWhile(arg => arg != "%1");
+                }
+            }
+
         foreach (Handler handler in handlers)
-            SettingsPanel.Children.Add(new HandlerSettingsBox(handler));
+            SettingsPanel.Children.Add(new HandlerSettingsBox(handler, options));
     }
 
     private void OkButton_Click(object sender, RoutedEventArgs e)