List:Commits« Previous MessageNext Message »
From:Iggy Galarza Date:June 30 2011 3:35pm
Subject:bzr commit into wex-installer-1.0 branch (iggy:535) Bug#61156
View as plain text  
#At file:///C:/src/bzr.mysql/wex/installer/ based on revid:iggy@stripped

  535 Iggy Galarza	2011-06-30
      Bug #61156 - Added functionality to verify that the command-line client shortcut uses the proper defaults file.

    modified:
      StandardPlugins/Properties/Resources.Designer.cs
      StandardPlugins/Properties/Resources.resx
      StandardPlugins/Server/ConfigurationController.cs
      StandardPlugins/StandardPlugins.csproj
=== modified file 'StandardPlugins/Properties/Resources.Designer.cs'
--- a/StandardPlugins/Properties/Resources.Designer.cs	2011-06-23 20:56:05 +0000
+++ b/StandardPlugins/Properties/Resources.Designer.cs	2011-06-30 15:35:39 +0000
@@ -326,6 +326,33 @@ namespace WexInstaller.Plugins.Propertie
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Adding firewall rule failed..
+        /// </summary>
+        internal static string ServerConfigEventFirewallSettingFailed {
+            get {
+                return ResourceManager.GetString("ServerConfigEventFirewallSettingFailed", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Adding firewall rule for {0} on port {1}..
+        /// </summary>
+        internal static string ServerConfigEventFirewallSettingInfo {
+            get {
+                return ResourceManager.GetString("ServerConfigEventFirewallSettingInfo", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Adding firewall rule was successful..
+        /// </summary>
+        internal static string ServerConfigEventFirewallSettingSucceeded {
+            get {
+                return ResourceManager.GetString("ServerConfigEventFirewallSettingSucceeded", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Failed to process template..
         /// </summary>
         internal static string ServerConfigEventProcessTemplateError {
@@ -380,83 +407,83 @@ namespace WexInstaller.Plugins.Propertie
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Failed to start service..
+        ///   Looks up a localized string similar to Failed to verify command-line client shortcut..
         /// </summary>
-        internal static string ServerConfigEventStartServiceError {
+        internal static string ServerConfigEventShortcutError {
             get {
-                return ResourceManager.GetString("ServerConfigEventStartServiceError", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventShortcutError", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Attempting to start service..
+        ///   Looks up a localized string similar to Attempting to verify command-line client shortcut..
         /// </summary>
-        internal static string ServerConfigEventStartServiceInfo {
+        internal static string ServerConfigEventShortcutInfo {
             get {
-                return ResourceManager.GetString("ServerConfigEventStartServiceInfo", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventShortcutInfo", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Started service..
+        ///   Looks up a localized string similar to Verified command-line client shortcut..
         /// </summary>
-        internal static string ServerConfigEventStartServiceSuccess {
+        internal static string ServerConfigEventShortcutSucceeded {
             get {
-                return ResourceManager.GetString("ServerConfigEventStartServiceSuccess", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventShortcutSucceeded", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Unable to find a valid template..
+        ///   Looks up a localized string similar to Failed to start service..
         /// </summary>
-        internal static string ServerConfigEventValidTemplateError {
+        internal static string ServerConfigEventStartServiceError {
             get {
-                return ResourceManager.GetString("ServerConfigEventValidTemplateError", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventStartServiceError", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Looking for valid template.
+        ///   Looks up a localized string similar to Attempting to start service..
         /// </summary>
-        internal static string ServerConfigEventValidTemplateInfo {
+        internal static string ServerConfigEventStartServiceInfo {
             get {
-                return ResourceManager.GetString("ServerConfigEventValidTemplateInfo", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventStartServiceInfo", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Found valid template..
+        ///   Looks up a localized string similar to Started service..
         /// </summary>
-        internal static string ServerConfigEventValidTemplateSuccess {
+        internal static string ServerConfigEventStartServiceSuccess {
             get {
-                return ResourceManager.GetString("ServerConfigEventValidTemplateSuccess", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventStartServiceSuccess", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Adding firewall rule failed..
+        ///   Looks up a localized string similar to Unable to find a valid template..
         /// </summary>
-        internal static string ServerConfigFirewallSettingFailed {
+        internal static string ServerConfigEventValidTemplateError {
             get {
-                return ResourceManager.GetString("ServerConfigFirewallSettingFailed", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventValidTemplateError", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Adding firewall rule for {0} on port {1}..
+        ///   Looks up a localized string similar to Looking for valid template.
         /// </summary>
-        internal static string ServerConfigFirewallSettingInfo {
+        internal static string ServerConfigEventValidTemplateInfo {
             get {
-                return ResourceManager.GetString("ServerConfigFirewallSettingInfo", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventValidTemplateInfo", resourceCulture);
             }
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Adding firewall rule was successful..
+        ///   Looks up a localized string similar to Found valid template..
         /// </summary>
-        internal static string ServerConfigFirewallSettingSucceeded {
+        internal static string ServerConfigEventValidTemplateSuccess {
             get {
-                return ResourceManager.GetString("ServerConfigFirewallSettingSucceeded", resourceCulture);
+                return ResourceManager.GetString("ServerConfigEventValidTemplateSuccess", resourceCulture);
             }
         }
         

=== modified file 'StandardPlugins/Properties/Resources.resx'
--- a/StandardPlugins/Properties/Resources.resx	2011-06-23 20:56:05 +0000
+++ b/StandardPlugins/Properties/Resources.resx	2011-06-30 15:35:39 +0000
@@ -265,13 +265,13 @@
   <data name="config_win_integration" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\config_win_integration.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
-  <data name="ServerConfigFirewallSettingInfo" xml:space="preserve">
+  <data name="ServerConfigEventFirewallSettingInfo" xml:space="preserve">
     <value>Adding firewall rule for {0} on port {1}.</value>
   </data>
-  <data name="ServerConfigFirewallSettingFailed" xml:space="preserve">
+  <data name="ServerConfigEventFirewallSettingFailed" xml:space="preserve">
     <value>Adding firewall rule failed.</value>
   </data>
-  <data name="ServerConfigFirewallSettingSucceeded" xml:space="preserve">
+  <data name="ServerConfigEventFirewallSettingSucceeded" xml:space="preserve">
     <value>Adding firewall rule was successful.</value>
   </data>
   <data name="ConfigErrorCouldNotOpenDatabase" xml:space="preserve">
@@ -280,4 +280,13 @@
   <data name="ConfigErrorInstallingSampleDatabase" xml:space="preserve">
     <value>Error installing sample database. The error is:\n\t{0}</value>
   </data>
+  <data name="ServerConfigEventShortcutError" xml:space="preserve">
+    <value>Failed to verify command-line client shortcut.</value>
+  </data>
+  <data name="ServerConfigEventShortcutInfo" xml:space="preserve">
+    <value>Attempting to verify command-line client shortcut.</value>
+  </data>
+  <data name="ServerConfigEventShortcutSucceeded" xml:space="preserve">
+    <value>Verified command-line client shortcut.</value>
+  </data>
 </root>
\ No newline at end of file

=== modified file 'StandardPlugins/Server/ConfigurationController.cs'
--- a/StandardPlugins/Server/ConfigurationController.cs	2011-06-23 20:56:05 +0000
+++ b/StandardPlugins/Server/ConfigurationController.cs	2011-06-30 15:35:39 +0000
@@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
 using System.Windows.Forms;
 using System.ServiceProcess;
 
-using NetFwTypeLib;
+using Shell32;
 using MySql.Data.MySqlClient;
 
 using WexInstaller.Core;
@@ -86,6 +86,7 @@ namespace WexInstaller.Plugins
             if (Template.EnableNetworking)
               CreateFirewallRule();
             ProcessSecuritySettings();
+            ProcessStartMenuLink();
           }
         }
       }
@@ -212,13 +213,19 @@ namespace WexInstaller.Plugins
       Initialize(true);
     }
 
+    private int CurrentPercent(int step)
+    {
+      double cp = step * 100 / 15;
+      return (int) Math.Round(cp);
+    }
+
     private bool ProcessTemplate()
     {
-      ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventValidTemplateInfo, 9);
+      ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventValidTemplateInfo, CurrentPercent(1));
 
       if (Template.IsValid)
       {
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventValidTemplateSuccess, 18);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventValidTemplateSuccess, CurrentPercent(2));
 
         switch (ServerInstallType)
         {
@@ -246,9 +253,9 @@ namespace WexInstaller.Plugins
         if (EnableTCPIP)
           Template.Port = Port.ToString();
 
-        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventProcessTemplateInfo, 27);
+        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventProcessTemplateInfo, CurrentPercent(3));
         Template.ProcessTemplate();
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventProcessTemplateSuccess, 36);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventProcessTemplateSuccess, CurrentPercent(4));
         processedTemplate = true;
       }
       else
@@ -270,21 +277,21 @@ namespace WexInstaller.Plugins
         bool doUpdate = ScManager.ServiceExists(ServiceName);
 
         // Make sure an existing server uses the new configuration file, then restart it.
-        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventConfigureServiceInfo, 45);
+        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventConfigureServiceInfo, CurrentPercent(5));
         if (doUpdate)
           ScManager.Update(ServiceName, String.Format("\"{0}bin\\mysqld\" --defaults-file=\"{1}\" {2}",
             Template.BaseDir, Template.ConfigurationFile, ServiceName));
         else
           ScManager.Add(ServiceName, ServiceName,
             String.Format("\"{0}bin\\mysqld\" --defaults-file=\"{1}\" {2}", Template.BaseDir, Template.ConfigurationFile, ServiceName));
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventConfigureServiceSuccess, 54);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventConfigureServiceSuccess, CurrentPercent(6));
 
-        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventStartServiceInfo, 63);
+        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventStartServiceInfo, CurrentPercent(7));
         if (doUpdate)
           ScManager.Restart(ServiceName);
         else
           ScManager.Start(ServiceName);
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventStartServiceSuccess, 72);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventStartServiceSuccess, CurrentPercent(8));
 
         processedService = true;
       }
@@ -301,7 +308,7 @@ namespace WexInstaller.Plugins
     {
       try
       {
-        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventSecuritySettingsInfo, 99);
+        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventSecuritySettingsInfo, CurrentPercent(11));
 
         // Set root password.
         MySqlCommand cmd = new MySqlCommand();
@@ -316,7 +323,7 @@ namespace WexInstaller.Plugins
         cmd.CommandText = "FLUSH PRIVILEGES";
         cmd.ExecuteNonQuery();
         cmd.Connection.Close();
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventSecuritySettingsSuccess, 100);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventSecuritySettingsSuccess, CurrentPercent(12));
 
         processedSecuritySettings = true;
       }
@@ -330,6 +337,53 @@ namespace WexInstaller.Plugins
       return processedSecuritySettings;
     }
 
+    private bool ProcessStartMenuLink()
+    {
+      bool greatSuccess = false;
+
+      ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventShortcutInfo, CurrentPercent(13));
+
+      try
+      {
+        Shell shell = new ShellClass();
+        string mysqlStartMenu = String.Format("{0}\\Programs\\MySQL\\{1}",
+                                              ((Folder2)shell.NameSpace(ShellSpecialFolderConstants.ssfCOMMONSTARTMENU)).Self.Path,
+                                              Owner.ProductSubPath);
+        Folder folder = shell.NameSpace(mysqlStartMenu);
+        ShellLinkObject link = null;
+
+        foreach (Shell32.FolderItem fi in folder.Items())
+        {
+          if (fi.IsLink && fi.Name.Contains("Command Line Client"))
+          {
+            link = (ShellLinkObject)fi.GetLink;
+
+            String arguments = link.Arguments;
+            if (arguments.Contains("defaults-file"))
+            {
+              // Make sure that the link is pointing to the newly created config file.
+              int targetArgIndex = arguments.IndexOf("=", arguments.IndexOf("defaults-file")) + 1;
+              String defaultsFileArg = arguments.Substring(targetArgIndex, arguments.IndexOf("\"", targetArgIndex) - targetArgIndex);
+              if (defaultsFileArg != Template.ConfigurationFile)
+              {
+                link.Arguments = arguments.Replace(defaultsFileArg, Template.ConfigurationFile);
+                link.Save();
+              }
+              ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventShortcutSucceeded, CurrentPercent(14));
+            }
+            break;
+          }
+        }
+      }
+      catch
+      {
+        greatSuccess = false;
+        ReportStatus(ConfigurationEventType.Info, Properties.Resources.ServerConfigEventShortcutError, 100);
+      }
+
+      return greatSuccess;
+    }
+
     private bool RunNetShellProcess(string action, string port, string serviceName)
     {
       bool greatSuccess = false;
@@ -395,12 +449,12 @@ namespace WexInstaller.Plugins
       }
       ReportConfigStatus(new ConfigurationEventArgs(eventType, "FIREWALL_RULE"));
       */
-      ReportStatus(ConfigurationEventType.Info, string.Format(Properties.Resources.ServerConfigFirewallSettingInfo, ServiceName, Port), 81);
+      ReportStatus(ConfigurationEventType.Info, string.Format(Properties.Resources.ServerConfigEventFirewallSettingInfo, ServiceName, Port), CurrentPercent(9));
 
       if (RunNetShellProcess("add", Port.ToString(), ServiceName))
-        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigFirewallSettingSucceeded, 90);
+        ReportStatus(ConfigurationEventType.Success, Properties.Resources.ServerConfigEventFirewallSettingSucceeded, CurrentPercent(10));
       else
-        ReportError(Properties.Resources.ServerConfigFirewallSettingSucceeded);
+        ReportError(Properties.Resources.ServerConfigEventFirewallSettingFailed);
     }
 
     private void RemoveFirewallRule()

=== modified file 'StandardPlugins/StandardPlugins.csproj'
--- a/StandardPlugins/StandardPlugins.csproj	2011-06-24 14:46:06 +0000
+++ b/StandardPlugins/StandardPlugins.csproj	2011-06-30 15:35:39 +0000
@@ -142,8 +142,8 @@
     <None Include="Resources\config_win_integration.png" />
   </ItemGroup>
   <ItemGroup>
-    <COMReference Include="NetFwTypeLib">
-      <Guid>{58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08}</Guid>
+    <COMReference Include="Shell32">
+      <Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
       <VersionMajor>1</VersionMajor>
       <VersionMinor>0</VersionMinor>
       <Lcid>0</Lcid>


Attachment: [text/bzr-bundle] bzr/iggy@mysql.com-20110630153539-mrdealz3j0mwleu5.bundle
Thread
bzr commit into wex-installer-1.0 branch (iggy:535) Bug#61156Iggy Galarza4 Jul