Revision: 67
http://svn.sourceforge.net/nmailserver/?rev=67&view=rev
Author: tmyroadctfig
Date: 2006-10-31 01:22:41 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
Work on installer and post install program.
Modified Paths:
--------------
NMail/branches/luke-dev/Installer/NMail-installer.build
NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj
NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.Designer.cs
NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs
Added Paths:
-----------
NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs
Property Changed:
----------------
NMail/branches/luke-dev/NMail.PostInstall/
Modified: NMail/branches/luke-dev/Installer/NMail-installer.build
===================================================================
--- NMail/branches/luke-dev/Installer/NMail-installer.build 2006-10-24 12:21:38 UTC (rev 66)
+++ NMail/branches/luke-dev/Installer/NMail-installer.build 2006-10-31 09:22:41 UTC (rev 67)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<project name="nant" default="package">
<!-- default configuration -->
- <property name="project.config" value="Debug" />
+ <property name="project.config" value="Release" />
<property name="current.build.defines" value="" />
<target name="Debug" description="Packages up a 'debug' build into an installer">
@@ -72,6 +72,7 @@
<!-- Compile the installer package -->
<exec program="candle" verbose="true">
+ <arg value="-nologo" />
<arg value="-out" />
<arg>
<path>
@@ -84,6 +85,7 @@
<!-- Link the installer package -->
<exec program="light">
<!-- TODO: add a date and revision number into the installer name -->
+ <arg value="-nologo" />
<arg value="-out" />
<arg><path><pathelement file="${output.dir}/NMail-${project.config}-${build.date}.msi" /></path></arg>
Property changes on: NMail/branches/luke-dev/NMail.PostInstall
___________________________________________________________________
Name: svn:ignore
- obj
bin
+ obj
bin
NMail.PostInstall.csproj.user
Added: NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs (rev 0)
+++ NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs 2006-10-31 09:22:41 UTC (rev 67)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2004-2006 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+using System.Windows.Forms;
+
+using Microsoft.Win32;
+
+using NMail.SmtpService;
+
+namespace NMail.PostInstall {
+
+ public class CustomAction {
+
+
+ }
+}
Modified: NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj 2006-10-24 12:21:38 UTC (rev 66)
+++ NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj 2006-10-31 09:22:41 UTC (rev 67)
@@ -36,6 +36,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="CustomAction.cs" />
<Compile Include="PostInstallForm.cs">
<SubType>Form</SubType>
</Compile>
Modified: NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.Designer.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.Designer.cs 2006-10-24 12:21:38 UTC (rev 66)
+++ NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.Designer.cs 2006-10-31 09:22:41 UTC (rev 67)
@@ -23,25 +23,25 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
- this.label1 = new System.Windows.Forms.Label();
+ this.messageLbl = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
- this.label1.AutoSize = true;
- this.label1.Dock = System.Windows.Forms.DockStyle.Top;
- this.label1.Location = new System.Drawing.Point(0, 0);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(141, 13);
- this.label1.TabIndex = 0;
- this.label1.Text = "Performing post install setup.";
+ this.messageLbl.AutoSize = true;
+ this.messageLbl.Dock = System.Windows.Forms.DockStyle.Top;
+ this.messageLbl.Location = new System.Drawing.Point(0, 0);
+ this.messageLbl.Name = "label1";
+ this.messageLbl.Size = new System.Drawing.Size(141, 13);
+ this.messageLbl.TabIndex = 0;
+ this.messageLbl.Text = "Performing post install setup.";
//
// PostInstallForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(251, 17);
- this.Controls.Add(this.label1);
+ this.Controls.Add(this.messageLbl);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
@@ -55,7 +55,7 @@
#endregion
- private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label messageLbl;
}
}
Modified: NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs 2006-10-24 12:21:38 UTC (rev 66)
+++ NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs 2006-10-31 09:22:41 UTC (rev 67)
@@ -25,6 +25,8 @@
using System.Threading;
using System.Windows.Forms;
+using Microsoft.Win32;
+
using NMail.SmtpService;
namespace NMail.PostInstall {
@@ -32,15 +34,22 @@
public PostInstallForm() {
InitializeComponent();
- ThreadPool.QueueUserWorkItem(new WaitCallback(SetupSmtpServiceCounters), null);
+ if (NMailInstalled()) {
+ this.messageLbl.Text = "Performing final uninstall steps.";
+ ThreadPool.QueueUserWorkItem(new WaitCallback(Uninstall), null);
+ } else {
+ ThreadPool.QueueUserWorkItem(new WaitCallback(Install), null);
+ }
}
- private void SetupSmtpServiceCounters(object unused) {
+ private void DeleteSmtpServiceCounters() {
if (PerformanceCounterCategory.Exists(SmtpService.SmtpService.PerfCounterCategory)) {
// Remove any old performance counters if they are present
PerformanceCounterCategory.Delete(SmtpService.SmtpService.PerfCounterCategory);
}
+ }
+ private void SetupSmtpServiceCounters() {
CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
// Number of connections received
@@ -56,12 +65,114 @@
"Performance counters for NMail's SMTP service.",
PerformanceCounterCategoryType.SingleInstance,
ccdc);
+ }
- Application.Exit();
+ private bool NMailInstalled() {
+ RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", false);
+
+ // Check for the NMail key
+ RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, false);
+
+ if (nmailKey == null) {
+ return false;
+ }
+
+ // Check for the NMail Server key
+ RegistryKey nmailSeverKey = nmailKey.OpenSubKey(NMailServerKey, false);
+
+ bool installed = (nmailSeverKey != null);
+
+ nmailKey.Close();
+ if (nmailSeverKey != null) {
+ nmailSeverKey.Close();
+ }
+
+ return installed;
}
+ private void SetupNMailRegistryKeys() {
+ RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
+
+ // Create for the NMail key
+ RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, true);
+
+ if (nmailKey == null) {
+ nmailKey = softwareKey.CreateSubKey(NMailKey);
+ }
+
+ // Create for the NMail Server key
+ RegistryKey nmailSeverKey = nmailKey.OpenSubKey(NMailServerKey, false);
+
+ if (nmailSeverKey == null) {
+ nmailSeverKey = nmailKey.CreateSubKey(NMailServerKey);
+ }
+
+ nmailKey.Close();
+ nmailSeverKey.Close();
+ }
+
+ private void DeleteNMailRegistryKeys() {
+ RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
+
+ // Get the key for the NMail
+ RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, true);
+
+ if (nmailKey != null) {
+ nmailKey.DeleteSubKeyTree(NMailServerKey);
+ nmailKey.Close();
+ }
+
+ // Try to delete the top level key (will fail if other sub-keys are present)
+ softwareKey.DeleteSubKey(NMailKey, false);
+ }
+
+ public void Install(object unused) {
+ try {
+ DeleteSmtpServiceCounters();
+
+ DeleteNMailRegistryKeys();
+
+ SetupNMailRegistryKeys();
+
+ SetupSmtpServiceCounters();
+
+ Application.Exit();
+
+ } catch (Exception e) {
+ ShowErrorBox("Error performing install: " + e.Message);
+ }
+ }
+
+ public void Uninstall(object unused) {
+ try {
+ DeleteSmtpServiceCounters();
+
+ DeleteNMailRegistryKeys();
+
+ Application.Exit();
+
+ } catch (Exception e) {
+ ShowErrorBox("Error performing uninstall: " + e.Message);
+ }
+ }
+
+ private void ShowErrorBox(object o) {
+ if (this.InvokeRequired) {
+ object[] args = { o };
+ this.Invoke(new WaitCallback(ShowErrorBox), args);
+ return;
+ }
+
+ string message = o as string;
+ MessageBox.Show(null, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
protected override void OnClosing(CancelEventArgs e) {
e.Cancel = true;
}
+
+ public const string NMailKey = "NMail";
+
+ public const string NMailServerKey = "NMail Server 1.0";
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|