Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prototyped version lookup for installed application items.

Refactored error handling for XML errors to pave the way for validation of the applist.
  • Loading branch information...
commit 4aa0b85211ee55f54eee56c32172a3cb1275256f 1 parent 3adcc98
@zacr zacr authored
View
6 Changelog.txt
@@ -1,7 +1,9 @@
+- Prototype version lookup for installed applist items.
+- Add ability to parse empty XML elements. Slightly refactor XML error message collection. Add stubs for applist validation.
- Small error dialog on startup if your environment vars are bad in some way; keeps installpad from bombing out silently
- Added ability to edit an applications details by double clicking on it. (Craig Reynolds)
-- refactored unit tests, embedded /data as a resource so the unit test dl can be run from anywhere (Zac Ruiz)
-- helper methods for zip class (contains(), hasRootFolder()) (Zac Ruiz)
+- Refactored unit tests, embedded /data as a resource so the unit test dl can be run from anywhere (Zac Ruiz)
+- Helper methods for zip class (contains(), hasRootFolder()) (Zac Ruiz)
- Create a root folder for the zip if it doesn't have one, instead of extracting tons of files to c:\program files (Zac Ruiz)
- Bugfix: If there is an error writing our applist back to disk, backup the original file and then restore it so it is not lost (Craig Reynolds)
- Turned on double buffering for the ApplicationListItem control. Makes resizing a little faster.
View
7 InstallPad.csproj
@@ -37,11 +37,15 @@
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
+ <Reference Include="System.Management" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="src\ApplicationItemOptions.cs" />
+ <Compile Include="src\InstallationOptions.cs" />
+ <Compile Include="src\Persistable.cs" />
<Compile Include="Settings.cs" />
<Compile Include="src\about\AboutDialog.cs">
<SubType>Form</SubType>
@@ -85,7 +89,7 @@
<DependentUpon>AppListErrorDialog.cs</DependentUpon>
</Compile>
<Compile Include="src\ControlList.cs">
- <SubType>Component</SubType>
+ <SubType>UserControl</SubType>
</Compile>
<Compile Include="src\ControlList.Designer.cs">
<DependentUpon>ControlList.cs</DependentUpon>
@@ -171,6 +175,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
+ <Compile Include="src\ProxyOptions.cs" />
<Compile Include="src\RemoteVersionChecker.cs" />
<Compile Include="src\Zip.cs" />
</ItemGroup>
View
4 src/ApplicationDialog.cs
@@ -247,7 +247,9 @@ public void ModifyApplicationItemFromDialog(ApplicationItem item)
item.Options.DownloadLatestVersion = this.DownloadLatestVersion;
item.Options.SilentInstall = this.SilentInstall;
item.Options.InstallerArguments = this.InstallerArguments;
- item.Options.Checked = this.Checked;
+ item.Options.Checked = this.Checked;
+
+ item.DetectVersion();
// Setting InstallationRoot is disabled for now until the rules are decided.
// Could allow setting Options, but probably wouldn't want to allow setting
View
255 src/ApplicationItem.cs
@@ -14,13 +14,15 @@
using System.Text;
using System.Xml;
+using Microsoft.Win32;
+
namespace InstallPad
{
/// <summary>
/// An application item describes an application - its name, filename, and download options.
/// It can also attempt to check and find the latest version of the application online.
/// </summary>
- public class ApplicationItem
+ public class ApplicationItem : Persistable
{
string name;
@@ -118,6 +120,58 @@ public string Version
set { version = value; }
}
+ string detectedVersion = string.Empty;
+ public string DetectedVersion
+ {
+ get { return detectedVersion; }
+ }
+
+ public bool DetectVersion()
+ {
+ RegistryKey UninstallKey = Registry.LocalMachine;
+ UninstallKey = UninstallKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);
+
+ try
+ {
+ // Iterate subkeys... each subkey is an installed package
+ foreach (string subkeyname in UninstallKey.GetSubKeyNames())
+ {
+ RegistryKey pkg = Registry.LocalMachine;
+ pkg = UninstallKey.OpenSubKey(subkeyname, true);
+
+ try
+ {
+ string displayname = pkg.GetValue("DisplayName").ToString();
+
+ if (displayname.Contains(name) || name.Contains(displayname))
+ {
+ try
+ {
+ detectedVersion = "v"+pkg.GetValue("DisplayVersion").ToString();
+ return true;
+ }
+ catch
+ {
+ detectedVersion = "found but not found";
+ }
+ }
+ }
+ catch
+ {
+ }
+ finally
+ {
+ pkg.Close();
+ }
+ }
+ }
+ finally
+ {
+ UninstallKey.Close();
+ }
+ return false;
+ }
+
ApplicationItemOptions options = new ApplicationItemOptions();
public ApplicationItemOptions Options
@@ -292,7 +346,7 @@ private static bool IsDigit(char c)
}
#region Xml methods
- public static ApplicationItem FromXml(XmlReader reader, List<string> errors)
+ public static ApplicationItem FromXml(XmlReader reader)
{
ApplicationItem item = new ApplicationItem();
@@ -303,36 +357,49 @@ public static ApplicationItem FromXml(XmlReader reader, List<string> errors)
case XmlNodeType.Element:
if (reader.Name == "Name")
{
- item.Name = reader.ReadString();
- reader.ReadEndElement();
+ if (reader.IsEmptyElement == false)
+ {
+ item.Name = reader.ReadString();
+ reader.ReadEndElement();
+ }
}
else if (reader.Name == "FileUrl")
{
- item.DownloadUrl = reader.ReadString();
- reader.ReadEndElement();
+ if (reader.IsEmptyElement == false)
+ {
+ item.DownloadUrl = reader.ReadString();
+ reader.ReadEndElement();
+ }
}
else if (reader.Name == "Comment")
{
- item.Comment = reader.ReadString();
- reader.ReadEndElement();
+ if (reader.IsEmptyElement == false)
+ {
+ item.Comment = reader.ReadString();
+ reader.ReadEndElement();
+ }
}
else if (reader.Name == "Options")
{
- item.Options = ApplicationItemOptions.FromXml(reader, errors);
+ item.Options = ApplicationItemOptions.FromXml(reader);
+ item.XmlErrors.AddRange(item.options.XmlErrors);
}
-
else
{
- errors.Add(
+ item.XmlErrors.Add(
String.Format("Unrecognized element in an application: \"{0}\"", reader.Name));
}
break;
case XmlNodeType.EndElement:
- if (reader.Name=="Application")
+ if (reader.Name == "Application")
+ {
+ item.DetectVersion();
return item;
+ }
break;
}
}
+ item.DetectVersion();
return item;
}
@@ -340,176 +407,24 @@ public void WriteXml(XmlWriter writer)
{
writer.WriteStartElement("Application");
writer.WriteElementString("Name", this.Name);
- writer.WriteElementString("FileUrl", this.DownloadUrl);
+ writer.WriteElementString("FileUrl", this.DownloadUrl);
if (this.Comment != null && this.Comment.Length > 0)
+ {
writer.WriteElementString("Comment", this.Comment);
+ }
this.Options.WriteXml(writer);
writer.WriteEndElement();
}
#endregion
- }
- public class ApplicationItemOptions
- {
- #region XML methods
- public static ApplicationItemOptions FromXml(XmlReader reader, List<string> errors)
+ #region Persistable
+ public override bool Validate()
{
- ApplicationItemOptions options = new ApplicationItemOptions();
-
- // If this is an empty option element then don't read further
- if (reader.IsEmptyElement)
- return options;
-
- while (reader.Read())
- {
- switch (reader.NodeType)
- {
- case XmlNodeType.Element:
- if (reader.Name == "DownloadLatestVersion")
- {
- options.DownloadLatestVersion = true;
- }
- else if (reader.Name == "SilentInstall")
- {
- options.SilentInstall = true;
- }
- else if (reader.Name == "PostInstallScript")
- {
- options.PostInstallScript = reader.ReadString().Trim();
- reader.ReadEndElement();
- }
- else if (reader.Name == "InstallationRoot")
- {
- options.InstallationRoot = reader.ReadString();
- reader.ReadEndElement();
- }
- else if (reader.Name == "AlternateFileUrl")
- {
- options.AlternateFileUrls.Add(reader.ReadString());
- reader.ReadEndElement();
- }
- else if (reader.Name == "InstallerArguments")
- {
- options.InstallerArguments = reader.ReadString();
- reader.ReadEndElement();
- }
- else if (reader.Name == "Checked")
- {
- bool value=true;
- try
- {
- value = bool.Parse(reader.ReadString());
- }
- catch (Exception)
- {
- }
- options.Checked = value;
- }
-
-
- else
- errors.Add(String.Format("Unrecognized application option: \"{0}\"", reader.Name));
-
- break;
- case XmlNodeType.EndElement:
- // Only stop reading when we've hit the end of the Options element
- if (reader.Name == "Options")
- return options;
- break;
- }
- }
- return options;
- }
- public void WriteXml(XmlWriter writer)
- {
- // Only write if there is an option set. This could be more elegant.
- if ((InstallerArguments != null && InstallerArguments.Length > 0) ||
- (PostInstallScript != null && PostInstallScript.Length > 0) ||
- this.SilentInstall || this.DownloadLatestVersion || !this.Checked)
- {
-
- writer.WriteStartElement("Options");
- if (this.DownloadLatestVersion)
- writer.WriteElementString("DownloadLatestVersion", "");
- if (this.SilentInstall)
- writer.WriteElementString("SilentInstall", "");
-
- if (InstallerArguments != null && InstallerArguments.Length > 0)
- writer.WriteElementString("InstallerArguments", this.InstallerArguments);
- if (PostInstallScript != null && PostInstallScript.Length > 0)
- writer.WriteElementString("PostInstallScript", this.PostInstallScript);
- if (InstallationRoot.Length > 0)
- writer.WriteElementString("InstallationRoot", this.InstallationRoot);
- foreach (string s in AlternateFileUrls)
- {
- if (s.Length > 0)
- writer.WriteElementString("AlternateFileUrl", s);
- }
- if (Checked==false)
- writer.WriteElementString("Checked", "false");
-
- writer.WriteEndElement();
- }
+ return true;
}
#endregion
-
- /// <summary>
- /// You can specify in the applist whether this application should be checked by default
- /// </summary>
- private bool checkEnabled = true;
-
- public bool Checked
- {
- get { return checkEnabled; }
- set { checkEnabled = value; }
- }
-
- private bool downloadLatestVersion=false;
-
- public bool DownloadLatestVersion
- {
- get { return downloadLatestVersion; }
- set { downloadLatestVersion = value; }
- }
-
- private bool silentInstall = false;
- public bool SilentInstall
- {
- get { return silentInstall; }
- set { silentInstall = value; }
- }
- private string installerArguments=null;
-
- public string InstallerArguments
- {
- get { return installerArguments; }
- set { installerArguments = value; }
- }
- private string postInstallScript=null;
-
- public string PostInstallScript
- {
- get { return postInstallScript; }
- set { postInstallScript = value; }
- }
-
- private string installationRoot = string.Empty;
-
- public string InstallationRoot
- {
- get { return installationRoot; }
- set { installationRoot = value; }
- }
-
- private List<string> alternateFileUrls = new List<string>();
-
- public List<string> AlternateFileUrls
- {
- get { return alternateFileUrls; }
- set { alternateFileUrls = value; }
- }
}
}
View
195 src/ApplicationItemOptions.cs
@@ -0,0 +1,195 @@
+//
+// Author: Phil Crosby
+//
+
+// Copyright (C) 2006 Phil Crosby
+// Permission is granted to use, copy, modify, and merge copies
+// of this software for personal use. Permission is not granted
+// to use or change this software for commercial use or commercial
+// redistribution. Permission is not granted to use, modify or
+// distribute this software internally within a corporation.
+
+using System;
+using System.Xml;
+using System.Collections.Generic;
+
+namespace InstallPad
+{
+ public class ApplicationItemOptions : Persistable
+ {
+ #region XML methods
+ public static ApplicationItemOptions FromXml(XmlReader reader)
+ {
+ ApplicationItemOptions options = new ApplicationItemOptions();
+
+ // If this is an empty option element then don't read further
+ if (reader.IsEmptyElement)
+ return options;
+
+ while (reader.Read())
+ {
+ switch (reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ if (reader.Name == "DownloadLatestVersion")
+ {
+ options.DownloadLatestVersion = true;
+ }
+ else if (reader.Name == "SilentInstall")
+ {
+ options.SilentInstall = true;
+ }
+ else if (reader.Name == "PostInstallScript")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.PostInstallScript = reader.ReadString().Trim();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "InstallationRoot")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.InstallationRoot = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "AlternateFileUrl")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.AlternateFileUrls.Add(reader.ReadString());
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "InstallerArguments")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.InstallerArguments = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "Checked")
+ {
+ bool value = true;
+ try
+ {
+ value = bool.Parse(reader.ReadString());
+ }
+ catch (Exception)
+ {
+ }
+ options.Checked = value;
+ }
+ else
+ options.XmlErrors.Add(String.Format("Unrecognized application option: \"{0}\"", reader.Name));
+
+ break;
+ case XmlNodeType.EndElement:
+ // Only stop reading when we've hit the end of the Options element
+ if (reader.Name == "Options")
+ return options;
+ break;
+ }
+ }
+ return options;
+ }
+ public void WriteXml(XmlWriter writer)
+ {
+ // Only write if there is an option set. This could be more elegant.
+ if ((InstallerArguments != null && InstallerArguments.Length > 0) ||
+ (PostInstallScript != null && PostInstallScript.Length > 0) ||
+ this.SilentInstall || this.DownloadLatestVersion || !this.Checked)
+ {
+
+ writer.WriteStartElement("Options");
+ if (this.DownloadLatestVersion)
+ writer.WriteElementString("DownloadLatestVersion", "");
+ if (this.SilentInstall)
+ writer.WriteElementString("SilentInstall", "");
+
+ if (InstallerArguments != null && InstallerArguments.Length > 0)
+ writer.WriteElementString("InstallerArguments", this.InstallerArguments);
+ if (PostInstallScript != null && PostInstallScript.Length > 0)
+ writer.WriteElementString("PostInstallScript", this.PostInstallScript);
+ if (InstallationRoot.Length > 0)
+ writer.WriteElementString("InstallationRoot", this.InstallationRoot);
+ foreach (string s in AlternateFileUrls)
+ {
+ if (s.Length > 0)
+ writer.WriteElementString("AlternateFileUrl", s);
+ }
+ if (Checked == false)
+ writer.WriteElementString("Checked", "false");
+
+ writer.WriteEndElement();
+ }
+ }
+ #endregion
+
+ /// <summary>
+ /// You can specify in the applist whether this application should be checked by default
+ /// </summary>
+ private bool checkEnabled = true;
+
+ public bool Checked
+ {
+ get { return checkEnabled; }
+ set { checkEnabled = value; }
+ }
+
+ private bool downloadLatestVersion = false;
+
+ public bool DownloadLatestVersion
+ {
+ get { return downloadLatestVersion; }
+ set { downloadLatestVersion = value; }
+ }
+
+ private bool silentInstall = false;
+ public bool SilentInstall
+ {
+ get { return silentInstall; }
+ set { silentInstall = value; }
+ }
+ private string installerArguments = null;
+
+ public string InstallerArguments
+ {
+ get { return installerArguments; }
+ set { installerArguments = value; }
+ }
+ private string postInstallScript = null;
+
+ public string PostInstallScript
+ {
+ get { return postInstallScript; }
+ set { postInstallScript = value; }
+ }
+
+ private string installationRoot = string.Empty;
+
+ public string InstallationRoot
+ {
+ get { return installationRoot; }
+ set { installationRoot = value; }
+ }
+
+ private List<string> alternateFileUrls = new List<string>();
+
+ public List<string> AlternateFileUrls
+ {
+ get { return alternateFileUrls; }
+ set { alternateFileUrls = value; }
+ }
+
+ #region Persistable
+ public override bool Validate()
+ {
+ return true;
+ }
+ #endregion
+ }
+}
View
245 src/ApplicationList.cs
@@ -18,11 +18,10 @@
namespace InstallPad
{
- class ApplicationList
+ class ApplicationList : Persistable
{
private ApplicationList() { }
private List<ApplicationItem> applicationItems = new List<ApplicationItem>();
- private List<string> errors = new List<string>();
private string fileName;
/// <summary>
@@ -34,12 +33,6 @@ public string FileName
set { fileName = value; }
}
- public List<string> Errors
- {
- get { return errors; }
- set { errors = value; }
- }
-
public List<ApplicationItem> ApplicationItems
{
get { return applicationItems; }
@@ -177,11 +170,20 @@ private static ApplicationList FromXml(XmlReader reader)
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name.Equals("Application") && !reader.IsEmptyElement)
- list.applicationItems.Add(ApplicationItem.FromXml(reader, list.errors));
+ {
+ ApplicationItem ai = ApplicationItem.FromXml(reader);
+ list.XmlErrors.AddRange(ai.XmlErrors);
+ list.applicationItems.Add(ai);
+ }
else if (reader.Name.Equals("InstallationOptions") && !reader.IsEmptyElement)
- list.installationOptions = InstallationOptions.FromXml(reader, list.errors);
+ {
+ list.installationOptions = InstallationOptions.FromXml(reader);
+ list.XmlErrors.AddRange(list.installationOptions.XmlErrors);
+ }
else
- list.errors.Add(String.Format("Unrecognized element: \"{0}\"", reader.Name));
+ {
+ list.XmlErrors.Add(String.Format("Unrecognized element: \"{0}\"", reader.Name));
+ }
}
}
return list;
@@ -195,226 +197,11 @@ private void WriteXml(XmlWriter writer)
writer.WriteEndElement();
}
#endregion
- }
-
- public class InstallationOptions
- {
- private bool installInOrder = false;
-
- public bool InstallInOrder
- {
- get { return installInOrder; }
- set { installInOrder = value; }
- }
-
- private bool silentInstall = false;
-
- public bool SilentInstall
- {
- get { return silentInstall; }
- set { silentInstall = value; }
- }
-
- private int simultaneousDownloads = 2;
-
- public int SimultaneousDownloads
- {
- get { return simultaneousDownloads; }
- set { simultaneousDownloads = value; }
- }
-
- private ProxyOptions proxyOptions = null;
-
- public ProxyOptions ProxyOptions
- {
- get { return proxyOptions; }
- set { proxyOptions = value; }
- }
-
- private string installationRoot = string.Empty;
-
- public string InstallationRoot
- {
- get { return installationRoot; }
- set { installationRoot = value; }
- }
-
- private string alternateDownloadLocation = string.Empty;
-
- public string AlternateDownloadLocation
- {
- get { return alternateDownloadLocation; }
- set { alternateDownloadLocation = value; }
- }
-
- #region XML methods
- public static InstallationOptions FromXml(XmlReader reader, List<String> errors)
- {
- InstallationOptions options = new InstallationOptions();
- while (reader.Read())
- {
- switch (reader.NodeType)
- {
- case XmlNodeType.Element:
- if (reader.Name == "InstallInOrder")
- options.InstallInOrder = true;
- else if (reader.Name == "Proxy")
- {
- options.ProxyOptions = ProxyOptions.FromXml(reader, errors);
- }
- else if (reader.Name == "SilentInstall")
- {
- options.SilentInstall = true;
- }
- else if (reader.Name == "SimultaneousDownloads")
- {
- options.SimultaneousDownloads = int.Parse(reader.ReadString());
- reader.ReadEndElement();
- }
- else if (reader.Name == "InstallationRoot")
- {
- options.InstallationRoot = reader.ReadString();
- reader.ReadEndElement();
- }
- else if (reader.Name == "AlternateDownloadLocation")
- {
- options.AlternateDownloadLocation = reader.ReadString();
- reader.ReadEndElement();
- }
- else
- errors.Add(
- String.Format("Unrecognized installation option: \"{0}\"", reader.Name));
- break;
-
- case XmlNodeType.EndElement:
- // Only stop reading when we've hit the end of the InstallationOptions element
- if (reader.Name == "InstallationOptions")
- return options;
- break;
- }
-
- }
- return options;
- }
- public void WriteXml(XmlWriter writer)
- {
- writer.WriteStartElement("InstallationOptions");
- if (this.InstallInOrder)
- writer.WriteElementString("InstallInOrder", "");
- if (this.SilentInstall)
- writer.WriteElementString("SilentInstall", "");
- if (this.proxyOptions != null)
- this.proxyOptions.WriteXml(writer);
- if (this.installationRoot != string.Empty)
- writer.WriteElementString("InstallationRoot", this.InstallationRoot);
- if (this.alternateDownloadLocation != string.Empty)
- writer.WriteElementString("AlternateDownloadLocation", this.AlternateDownloadLocation);
-
- writer.WriteElementString("SimultaneousDownloads", this.SimultaneousDownloads.ToString());
-
- writer.WriteEndElement();
- }
- #endregion
- }
-
- public class ProxyOptions
- {
- private string address = null;
- public string Address
+ #region Persistable
+ public override bool Validate()
{
- get { return address; }
- set { address = value; }
- }
- private string username = null;
-
- public string Username
- {
- get { return username; }
- set { username = value; }
- }
- private string password = null;
-
- public string Password
- {
- get { return password; }
- set { password = value; }
- }
-
- public System.Net.WebProxy ProxyFromOptions()
- {
- System.Net.WebProxy proxy = new System.Net.WebProxy();
- Uri addressUri = null;
-
- // Try and create this URi from the address given in the file. It can fail if it's
- // malformed, or it can fail if they specify an IP without http://.
- if (!Uri.TryCreate(address, UriKind.Absolute, out addressUri))
- {
- // Try and create it again, appending http:// this time (rooting it)
- if (!Uri.TryCreate("http://" + address, UriKind.Absolute, out addressUri))
- {
- // Could not understand the URL. Exception case.
- return null;
- }
- }
-
- proxy.Address = addressUri;
- if (this.username == null || this.password == null)
- proxy.UseDefaultCredentials = true;
- else
- proxy.Credentials = new System.Net.NetworkCredential(this.username, this.password);
- return proxy;
- }
-
- #region XML methods
- public static ProxyOptions FromXml(XmlReader reader, List<String> errors)
- {
- ProxyOptions options = new ProxyOptions();
- while (reader.Read())
- {
- switch (reader.NodeType)
- {
- case XmlNodeType.Element:
- if (reader.Name == "Address")
- {
- options.Address = reader.ReadString();
- reader.ReadEndElement();
- }
- else if (reader.Name == "Username")
- {
- options.Username = reader.ReadString();
- reader.ReadEndElement();
- }
- else if (reader.Name == "Password")
- {
- options.Password = reader.ReadString();
- reader.ReadEndElement();
- }
- else
- errors.Add(
- String.Format("Unrecognized proxy option: \"{0}\"", reader.Name));
- break;
-
- case XmlNodeType.EndElement:
- // Only stop reading when we've hit the end of the InstallationOptions element
- if (reader.Name == "Proxy")
- return options;
- break;
- }
-
- }
- return options;
- }
- public void WriteXml(XmlWriter writer)
- {
- writer.WriteStartElement("Proxy");
- if (this.Address != null)
- writer.WriteElementString("Address", this.Address);
- if (this.Username != null)
- writer.WriteElementString("Username", this.Username);
- if (this.Password != null)
- writer.WriteElementString("Password", this.Password);
- writer.WriteEndElement();
+ return true;
}
#endregion
}
View
14 src/ApplicationListItem.Designer.cs
@@ -47,6 +47,7 @@ private void InitializeComponent()
this.checkboxEnabled = new System.Windows.Forms.CheckBox();
this.labelProgress = new System.Windows.Forms.Label();
this.toolTipComment = new System.Windows.Forms.ToolTip(this.components);
+ this.labelVersion = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// labelName
@@ -120,10 +121,20 @@ private void InitializeComponent()
this.labelProgress.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.labelProgress.Visible = false;
//
+ // labelVersion
+ //
+ this.labelVersion.AutoSize = true;
+ this.labelVersion.Location = new System.Drawing.Point(153, 16);
+ this.labelVersion.Name = "labelVersion";
+ this.labelVersion.Size = new System.Drawing.Size(13, 13);
+ this.labelVersion.TabIndex = 8;
+ this.labelVersion.Text = "v";
+ //
// ApplicationListItem
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.labelVersion);
this.Controls.Add(this.labelProgress);
this.Controls.Add(this.checkboxEnabled);
this.Controls.Add(this.labelStatus);
@@ -147,6 +158,7 @@ private void InitializeComponent()
private System.Windows.Forms.Label labelStatus;
private System.Windows.Forms.CheckBox checkboxEnabled;
private System.Windows.Forms.Label labelProgress;
- private System.Windows.Forms.ToolTip toolTipComment;
+ private System.Windows.Forms.ToolTip toolTipComment;
+ private System.Windows.Forms.Label labelVersion;
}
}
View
1  src/ApplicationListItem.cs
@@ -60,6 +60,7 @@ public ApplicationItem ApplicationItem
{
application = value;
this.labelName.Text = this.application.Name;
+ this.labelVersion.Text = this.application.DetectedVersion;
this.toolTipComment.SetToolTip(this, this.application.Comment);
}
}
View
4 src/InstallPad.cs
@@ -339,10 +339,10 @@ private void LoadApplicationList(string filename)
SetControlsEnabled(true);
// Show errors, if we had any in loading
- if (appList.Errors.Count > 0)
+ if (appList.XmlErrors.Count > 0)
{
errorDialog = new AppListErrorDialog();
- foreach (string error in appList.Errors)
+ foreach (string error in appList.XmlErrors)
errorDialog.ErrorText += error + System.Environment.NewLine;
// Show the "encountered errors" label
View
154 src/InstallationOptions.cs
@@ -0,0 +1,154 @@
+//
+// Author: Phil Crosby
+//
+
+// Copyright (C) 2006 Phil Crosby
+// Permission is granted to use, copy, modify, and merge copies
+// of this software for personal use. Permission is not granted
+// to use or change this software for commercial use or commercial
+// redistribution. Permission is not granted to use, modify or
+// distribute this software internally within a corporation.
+
+using System;
+using System.Xml;
+using System.Collections.Generic;
+
+namespace InstallPad
+{
+ public class InstallationOptions : Persistable
+ {
+ private bool installInOrder = false;
+
+ public bool InstallInOrder
+ {
+ get { return installInOrder; }
+ set { installInOrder = value; }
+ }
+
+ private bool silentInstall = false;
+
+ public bool SilentInstall
+ {
+ get { return silentInstall; }
+ set { silentInstall = value; }
+ }
+
+ private int simultaneousDownloads = 2;
+
+ public int SimultaneousDownloads
+ {
+ get { return simultaneousDownloads; }
+ set { simultaneousDownloads = value; }
+ }
+
+ private ProxyOptions proxyOptions = null;
+
+ public ProxyOptions ProxyOptions
+ {
+ get { return proxyOptions; }
+ set { proxyOptions = value; }
+ }
+
+ private string installationRoot = string.Empty;
+
+ public string InstallationRoot
+ {
+ get { return installationRoot; }
+ set { installationRoot = value; }
+ }
+
+ private string alternateDownloadLocation = string.Empty;
+
+ public string AlternateDownloadLocation
+ {
+ get { return alternateDownloadLocation; }
+ set { alternateDownloadLocation = value; }
+ }
+
+ #region XML methods
+ public static InstallationOptions FromXml(XmlReader reader)
+ {
+ InstallationOptions options = new InstallationOptions();
+ while (reader.Read())
+ {
+ switch (reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ if (reader.Name == "InstallInOrder")
+ options.InstallInOrder = true;
+ else if (reader.Name == "Proxy")
+ {
+ options.ProxyOptions = ProxyOptions.FromXml(reader);
+ options.XmlErrors.AddRange(options.ProxyOptions.XmlErrors);
+ }
+ else if (reader.Name == "SilentInstall")
+ {
+ options.SilentInstall = true;
+ }
+ else if (reader.Name == "SimultaneousDownloads")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.SimultaneousDownloads = int.Parse(reader.ReadString());
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "InstallationRoot")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.InstallationRoot = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "AlternateDownloadLocation")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.AlternateDownloadLocation = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else
+ options.XmlErrors.Add(
+ String.Format("Unrecognized installation option: \"{0}\"", reader.Name));
+ break;
+
+ case XmlNodeType.EndElement:
+ // Only stop reading when we've hit the end of the InstallationOptions element
+ if (reader.Name == "InstallationOptions")
+ return options;
+ break;
+ }
+
+ }
+ return options;
+ }
+ public void WriteXml(XmlWriter writer)
+ {
+ writer.WriteStartElement("InstallationOptions");
+ if (this.InstallInOrder)
+ writer.WriteElementString("InstallInOrder", "");
+ if (this.SilentInstall)
+ writer.WriteElementString("SilentInstall", "");
+ if (this.proxyOptions != null)
+ this.proxyOptions.WriteXml(writer);
+ if (this.installationRoot != string.Empty)
+ writer.WriteElementString("InstallationRoot", this.InstallationRoot);
+ if (this.alternateDownloadLocation != string.Empty)
+ writer.WriteElementString("AlternateDownloadLocation", this.AlternateDownloadLocation);
+
+ writer.WriteElementString("SimultaneousDownloads", this.SimultaneousDownloads.ToString());
+
+ writer.WriteEndElement();
+ }
+ #endregion
+
+ #region Persistable
+ public override bool Validate()
+ {
+ return true;
+ }
+ #endregion
+ }
+}
View
35 src/Persistable.cs
@@ -0,0 +1,35 @@
+//
+// Author: Phil Crosby
+//
+
+// Copyright (C) 2006 Phil Crosby
+// Permission is granted to use, copy, modify, and merge copies
+// of this software for personal use. Permission is not granted
+// to use or change this software for commercial use or commercial
+// redistribution. Permission is not granted to use, modify or
+// distribute this software internally within a corporation.
+
+using System;
+using System.Text;
+using System.Collections.Generic;
+
+namespace InstallPad
+{
+ public abstract class Persistable
+ {
+ private List<string> m_xmlErrors = new List<string>();
+ private List<string> m_appErrors = new List<string>();
+
+ public List<string> XmlErrors
+ {
+ get { return m_xmlErrors; }
+ }
+
+ public List<string> AppErrors
+ {
+ get { return m_appErrors; }
+ }
+
+ public abstract bool Validate();
+ }
+}
View
135 src/ProxyOptions.cs
@@ -0,0 +1,135 @@
+//
+// Author: Phil Crosby
+//
+
+// Copyright (C) 2006 Phil Crosby
+// Permission is granted to use, copy, modify, and merge copies
+// of this software for personal use. Permission is not granted
+// to use or change this software for commercial use or commercial
+// redistribution. Permission is not granted to use, modify or
+// distribute this software internally within a corporation.
+
+using System;
+using System.Xml;
+using System.Collections.Generic;
+
+namespace InstallPad
+{
+ public class ProxyOptions : Persistable
+ {
+ private string address = null;
+
+ public string Address
+ {
+ get { return address; }
+ set { address = value; }
+ }
+ private string username = null;
+
+ public string Username
+ {
+ get { return username; }
+ set { username = value; }
+ }
+ private string password = null;
+
+ public string Password
+ {
+ get { return password; }
+ set { password = value; }
+ }
+
+ public System.Net.WebProxy ProxyFromOptions()
+ {
+ System.Net.WebProxy proxy = new System.Net.WebProxy();
+ Uri addressUri = null;
+
+ // Try and create this URi from the address given in the file. It can fail if it's
+ // malformed, or it can fail if they specify an IP without http://.
+ if (!Uri.TryCreate(address, UriKind.Absolute, out addressUri))
+ {
+ // Try and create it again, appending http:// this time (rooting it)
+ if (!Uri.TryCreate("http://" + address, UriKind.Absolute, out addressUri))
+ {
+ // Could not understand the URL. Exception case.
+ return null;
+ }
+ }
+
+ proxy.Address = addressUri;
+ if (this.username == null || this.password == null)
+ proxy.UseDefaultCredentials = true;
+ else
+ proxy.Credentials = new System.Net.NetworkCredential(this.username, this.password);
+ return proxy;
+ }
+
+ #region XML methods
+ public static ProxyOptions FromXml(XmlReader reader)
+ {
+ ProxyOptions options = new ProxyOptions();
+ while (reader.Read())
+ {
+ switch (reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ if (reader.Name == "Address")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.Address = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "Username")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.Username = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else if (reader.Name == "Password")
+ {
+ if (reader.IsEmptyElement == false)
+ {
+ options.Password = reader.ReadString();
+ reader.ReadEndElement();
+ }
+ }
+ else
+ options.XmlErrors.Add(
+ String.Format("Unrecognized proxy option: \"{0}\"", reader.Name));
+ break;
+
+ case XmlNodeType.EndElement:
+ // Only stop reading when we've hit the end of the InstallationOptions element
+ if (reader.Name == "Proxy")
+ return options;
+ break;
+ }
+
+ }
+ return options;
+ }
+ public void WriteXml(XmlWriter writer)
+ {
+ writer.WriteStartElement("Proxy");
+ if (this.Address != null)
+ writer.WriteElementString("Address", this.Address);
+ if (this.Username != null)
+ writer.WriteElementString("Username", this.Username);
+ if (this.Password != null)
+ writer.WriteElementString("Password", this.Password);
+ writer.WriteEndElement();
+ }
+ #endregion
+
+ #region Persistable
+ public override bool Validate()
+ {
+ return true;
+ }
+ #endregion
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.