[Nmailserver-commits] SF.net SVN: nmailserver: [191] NMail/trunk
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-05-09 12:56:43
|
Revision: 191
http://svn.sourceforge.net/nmailserver/?rev=191&view=rev
Author: tmyroadctfig
Date: 2007-05-09 05:56:42 -0700 (Wed, 09 May 2007)
Log Message:
-----------
Added ACLs to most local store functions. Some work on setup wizard.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.Designer.cs
NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.cs
NMail/trunk/NMail.SetupWizard/LocalStoreConfigPanel.cs
NMail/trunk/NMail.SetupWizard/NMail.SetupWizard.csproj
NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs
NMail/trunk/NMail.sln
Removed Paths:
-------------
NMail/trunk/NMail.SetupWizard/MySqlHelper.cs
Modified: NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -31,6 +31,21 @@
/// <summary>
/// The right to create a new mail domain.
/// </summary>
- CreateMailDomain = 8
+ CreateMailDomain = 8,
+
+ /// <summary>
+ /// The right to view mail domains.
+ /// </summary>
+ ViewMailDomains = 16,
+
+ /// <summary>
+ /// The right to alter mail domains.
+ /// </summary>
+ UpdateMailDomain = 32,
+
+ /// <summary>
+ /// The right to delete mail domains.
+ /// </summary>
+ DeleteMailDomain = 64
}
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -566,7 +566,7 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace);
+ void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<UserGroupAdminPrivilege> ace);
/// <summary>
/// Removes any ACE associated with the given identifier.
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -1044,7 +1044,7 @@
return LocalStoreData.GetUsers();
}
- return List<LocalStoreUser>();
+ return new List<LocalStoreUser>();
}
public void CreateUser(IAuthenticationToken authToken, LocalStoreUser user) {
@@ -1246,19 +1246,25 @@
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The mail domains.</returns>
public IList<MailDomain> GetMailDomains(IAuthenticationToken authToken) {
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ViewMailDomains)) {
+ return this.LocalStoreData.GetMailDomains();
+ }
- // TODO: check acls
- return this.LocalStoreData.GetMailDomains();
+ return new List<MailDomain>();
}
+
/// <summary>
/// Creates a new mail domain for the given host.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomain">The mail domain to create.</param>
public void CreateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain) {
- // TODO: check ACLs
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.CreateMailDomain)) {
+ this.LocalStoreData.CreateMailDomain(mailDomain);
- this.LocalStoreData.CreateMailDomain(mailDomain);
+ } else {
+ throw new InvalidOperationException("Not permitted to create a mail domain.");
+ }
}
/// <summary>
@@ -1267,9 +1273,12 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomainId">The Id of the mail domain to delete.</param>
public void DeleteMailDomain(IAuthenticationToken authToken, int mailDomainId) {
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.DeleteMailDomain)) {
+ this.LocalStoreData.DeleteMailDomain(mailDomainId);
- // TODO: check acls
- this.LocalStoreData.DeleteMailDomain(mailDomainId);
+ } else {
+ throw new InvalidOperationException("Not permitted to delete a mail domain.");
+ }
}
/// <summary>
@@ -1278,9 +1287,12 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomain">The mail domain to update.</param>
public void UpdateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain) {
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.UpdateMailDomain)) {
+ this.LocalStoreData.UpdateMailDomain(mailDomain);
- // TODO: check acls
- this.LocalStoreData.UpdateMailDomain(mailDomain);
+ } else {
+ throw new InvalidOperationException("Not permitted to alter a mail domain.");
+ }
}
#endregion
@@ -1333,7 +1345,11 @@
/// <param name="user">The user trying to get the admin ACL.</param>
/// <returns>The ACL or null if insufficient privileges.</returns>
public GenericAcl<UserGroupAdminPrivilege> GetAdministrationAcl(IAuthenticationToken user) {
- throw new NotImplementedException();
+ if (hasSystemPrivilege(user.Username, SystemPrivilege.ViewSystemPrivileges)) {
+ return LocalStoreData.GetUserGroupAdminPrivilegeAcl();
+ }
+
+ return null;
}
/// <summary>
@@ -1342,8 +1358,13 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- public void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace) {
- throw new NotImplementedException();
+ public void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<UserGroupAdminPrivilege> ace) {
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ModifySystemPrivileges)) {
+ LocalStoreData.SetUserGroupAdminPrivilegeAce(ace);
+
+ } else {
+ throw new InvalidOperationException("Not permitted to alter administration ACL.");
+ }
}
/// <summary>
@@ -1352,7 +1373,12 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="identifier">The identifier to remove from the ACL.</param>
public void RemoveAdministrationAce(IAuthenticationToken authToken, string identifier) {
- throw new NotImplementedException();
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ModifySystemPrivileges)) {
+ LocalStoreData.RemoveUserGroupAdminPrivilegeAce(identifier);
+
+ } else {
+ throw new InvalidOperationException("Not permitted to alter administration ACL.");
+ }
}
#endregion
Modified: NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.Designer.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.Designer.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.Designer.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -23,15 +23,11 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
- this.descriptionTextBox = new System.Windows.Forms.TextBox();
- this.hostname = new System.Windows.Forms.TextBox();
- this.username = new System.Windows.Forms.TextBox();
- this.password = new System.Windows.Forms.TextBox();
- this.createDbUserCheckBox = new System.Windows.Forms.CheckBox();
- this.autoPassCheckBox = new System.Windows.Forms.CheckBox();
- this.hostLbl = new System.Windows.Forms.Label();
- this.usernameLbl = new System.Windows.Forms.Label();
- this.passwordLbl = new System.Windows.Forms.Label();
+ this.descriptionTextBox = new System.Windows.Forms.RichTextBox();
+ this.spoolHibernateTextBox = new System.Windows.Forms.TextBox();
+ this.localStoreHibernateTextBox = new System.Windows.Forms.TextBox();
+ this.spoolLabel = new System.Windows.Forms.Label();
+ this.localStoreLabel = new System.Windows.Forms.Label();
this.mainPanel.SuspendLayout();
this.SuspendLayout();
//
@@ -42,14 +38,10 @@
//
// mainPanel
//
- this.mainPanel.Controls.Add(this.passwordLbl);
- this.mainPanel.Controls.Add(this.usernameLbl);
- this.mainPanel.Controls.Add(this.autoPassCheckBox);
- this.mainPanel.Controls.Add(this.hostLbl);
- this.mainPanel.Controls.Add(this.password);
- this.mainPanel.Controls.Add(this.createDbUserCheckBox);
- this.mainPanel.Controls.Add(this.username);
- this.mainPanel.Controls.Add(this.hostname);
+ this.mainPanel.Controls.Add(this.localStoreLabel);
+ this.mainPanel.Controls.Add(this.spoolLabel);
+ this.mainPanel.Controls.Add(this.localStoreHibernateTextBox);
+ this.mainPanel.Controls.Add(this.spoolHibernateTextBox);
this.mainPanel.Controls.Add(this.descriptionTextBox);
this.mainPanel.Size = new System.Drawing.Size(357, 273);
//
@@ -58,92 +50,54 @@
this.descriptionTextBox.BackColor = System.Drawing.Color.White;
this.descriptionTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.descriptionTextBox.Location = new System.Drawing.Point(8, 8);
- this.descriptionTextBox.Multiline = true;
this.descriptionTextBox.Name = "descriptionTextBox";
this.descriptionTextBox.ReadOnly = true;
this.descriptionTextBox.Size = new System.Drawing.Size(343, 40);
this.descriptionTextBox.TabIndex = 2;
this.descriptionTextBox.TabStop = false;
- this.descriptionTextBox.Text = "Enter the details of the database to use for the SMTP spool and local store data." +
- "";
+ this.descriptionTextBox.Text = "Enter the details of the databases to use for the SMTP spool and local store data" +
+ ". See the NHibernate website (http://www.hibernate.org/361.html) for more detail" +
+ "s.";
+ this.descriptionTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.descriptionTextBox_LinkClicked);
//
- // hostname
+ // spoolHibernateTextBox
//
- this.hostname.Location = new System.Drawing.Point(127, 70);
- this.hostname.Name = "hostname";
- this.hostname.Size = new System.Drawing.Size(176, 20);
- this.hostname.TabIndex = 3;
- this.hostname.Text = "127.0.0.1";
+ this.spoolHibernateTextBox.AcceptsReturn = true;
+ this.spoolHibernateTextBox.AcceptsTab = true;
+ this.spoolHibernateTextBox.Location = new System.Drawing.Point(8, 77);
+ this.spoolHibernateTextBox.Multiline = true;
+ this.spoolHibernateTextBox.Name = "spoolHibernateTextBox";
+ this.spoolHibernateTextBox.Size = new System.Drawing.Size(338, 77);
+ this.spoolHibernateTextBox.TabIndex = 3;
//
- // username
+ // localStoreHibernateTextBox
//
- this.username.Location = new System.Drawing.Point(127, 119);
- this.username.Name = "username";
- this.username.Size = new System.Drawing.Size(176, 20);
- this.username.TabIndex = 5;
- this.username.Text = "NMail";
+ this.localStoreHibernateTextBox.AcceptsReturn = true;
+ this.localStoreHibernateTextBox.AcceptsTab = true;
+ this.localStoreHibernateTextBox.Location = new System.Drawing.Point(6, 188);
+ this.localStoreHibernateTextBox.Multiline = true;
+ this.localStoreHibernateTextBox.Name = "localStoreHibernateTextBox";
+ this.localStoreHibernateTextBox.Size = new System.Drawing.Size(338, 77);
+ this.localStoreHibernateTextBox.TabIndex = 4;
//
- // password
+ // spoolLabel
//
- this.password.Enabled = false;
- this.password.Location = new System.Drawing.Point(127, 191);
- this.password.Name = "password";
- this.password.PasswordChar = '*';
- this.password.Size = new System.Drawing.Size(176, 20);
- this.password.TabIndex = 7;
+ this.spoolLabel.AutoSize = true;
+ this.spoolLabel.Location = new System.Drawing.Point(6, 61);
+ this.spoolLabel.Name = "spoolLabel";
+ this.spoolLabel.Size = new System.Drawing.Size(37, 13);
+ this.spoolLabel.TabIndex = 5;
+ this.spoolLabel.Text = "Spool:";
//
- // createDbUserCheckBox
+ // localStoreLabel
//
- this.createDbUserCheckBox.AutoSize = true;
- this.createDbUserCheckBox.Checked = true;
- this.createDbUserCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
- this.createDbUserCheckBox.Location = new System.Drawing.Point(127, 145);
- this.createDbUserCheckBox.Name = "createDbUserCheckBox";
- this.createDbUserCheckBox.Size = new System.Drawing.Size(159, 17);
- this.createDbUserCheckBox.TabIndex = 8;
- this.createDbUserCheckBox.Text = "Create a new database user";
- this.createDbUserCheckBox.UseVisualStyleBackColor = true;
- this.createDbUserCheckBox.CheckedChanged += new System.EventHandler(this.createDbUserCheckBox_CheckedChanged);
+ this.localStoreLabel.AutoSize = true;
+ this.localStoreLabel.Location = new System.Drawing.Point(5, 172);
+ this.localStoreLabel.Name = "localStoreLabel";
+ this.localStoreLabel.Size = new System.Drawing.Size(64, 13);
+ this.localStoreLabel.TabIndex = 6;
+ this.localStoreLabel.Text = "Local Store:";
//
- // autoPassCheckBox
- //
- this.autoPassCheckBox.AutoSize = true;
- this.autoPassCheckBox.Checked = true;
- this.autoPassCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
- this.autoPassCheckBox.Location = new System.Drawing.Point(127, 168);
- this.autoPassCheckBox.Name = "autoPassCheckBox";
- this.autoPassCheckBox.Size = new System.Drawing.Size(141, 17);
- this.autoPassCheckBox.TabIndex = 6;
- this.autoPassCheckBox.Text = "Auto generate password";
- this.autoPassCheckBox.UseVisualStyleBackColor = true;
- //
- // hostLbl
- //
- this.hostLbl.AutoSize = true;
- this.hostLbl.Location = new System.Drawing.Point(42, 73);
- this.hostLbl.Name = "hostLbl";
- this.hostLbl.Size = new System.Drawing.Size(79, 13);
- this.hostLbl.TabIndex = 7;
- this.hostLbl.Text = "Database host:";
- //
- // usernameLbl
- //
- this.usernameLbl.AutoSize = true;
- this.usernameLbl.Location = new System.Drawing.Point(42, 122);
- this.usernameLbl.Name = "usernameLbl";
- this.usernameLbl.Size = new System.Drawing.Size(79, 13);
- this.usernameLbl.TabIndex = 8;
- this.usernameLbl.Text = "Database user:";
- //
- // passwordLbl
- //
- this.passwordLbl.AutoSize = true;
- this.passwordLbl.Location = new System.Drawing.Point(17, 194);
- this.passwordLbl.Name = "passwordLbl";
- this.passwordLbl.Size = new System.Drawing.Size(104, 13);
- this.passwordLbl.TabIndex = 9;
- this.passwordLbl.Text = "Database password:";
- //
// DatabaseConfigPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -158,14 +112,10 @@
#endregion
- private System.Windows.Forms.TextBox descriptionTextBox;
- private System.Windows.Forms.TextBox username;
- private System.Windows.Forms.TextBox hostname;
- private System.Windows.Forms.CheckBox autoPassCheckBox;
- private System.Windows.Forms.Label hostLbl;
- private System.Windows.Forms.TextBox password;
- private System.Windows.Forms.CheckBox createDbUserCheckBox;
- private System.Windows.Forms.Label usernameLbl;
- private System.Windows.Forms.Label passwordLbl;
+ private System.Windows.Forms.RichTextBox descriptionTextBox;
+ private System.Windows.Forms.TextBox spoolHibernateTextBox;
+ private System.Windows.Forms.TextBox localStoreHibernateTextBox;
+ private System.Windows.Forms.Label localStoreLabel;
+ private System.Windows.Forms.Label spoolLabel;
}
}
Modified: NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/DatabaseConfigPanel.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -23,9 +23,6 @@
using System.Text;
using System.Windows.Forms;
-using NMail.SpoolData.MySql.Configuration;
-using NMail.LocalStoreData.MySql.Configuration;
-
namespace NMail.SetupWizard {
public partial class DatabaseConfigPanel : BasePanel {
public DatabaseConfigPanel(BaseForm baseForm, SmtpSubSysConfigPanel smtpConfigPanel, LocalStoreConfigPanel localStoreConfigPanel, BasePanel previous) : base(baseForm) {
@@ -36,139 +33,52 @@
this.PreviousPanel = previous;
this.NextPanel = new ServiceConfigPanel(this.BaseForm, this);
- // TODO: load config
-
- // Make a random password
- this.password.Text = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
- this.password.Text = this.password.Text.Replace("=", "a");
- this.password.Text = this.password.Text.Replace("+", "b");
- this.password.Text = this.password.Text.Replace("/", "c");
-
- this.createDbUserTask = new Task("Create a new database user.", new TaskDelegate(createDbUser));
-
- this.grantDbUserPrivsTask = new Task("Grant privileges to the database user.", new TaskDelegate(grantDbPrivileges));
+ loadConfiguration();
}
private LocalStoreConfigPanel localStoreConfigPanel;
private SmtpSubSysConfigPanel smtpConfigPanel;
- private Task createDbUserTask;
-
- private Task grantDbUserPrivsTask;
-
/// <summary>
- /// The code that attempts to create a new database user.
- /// </summary>
- /// <param name="message">A message if an error occurs.</param>
- /// <returns>The result of the attempt to create the database user.</returns>
- private TaskResult createDbUser(out string message) {
- try {
- MySqlHelper.DatabaseHost = this.DatabaseHost;
- MySqlHelper.CreateUser(this.DatabaseUsername, this.DatabasePassword);
- message = null;
- return TaskResult.Ok;
-
- } catch (Exception e) {
- message = "Error creating database user: " + e.Message;
- return TaskResult.Error;
- }
- }
-
- /// <summary>
- /// Grants the database user the required privileges to the database.
- /// </summary>
- /// <param name="message">A message if an error occurs.</param>
- /// <returns>The result of the attempt to grant the privileges.</returns>
- private TaskResult grantDbPrivileges(out string message) {
- try {
- string dbUser = this.DatabaseUsername + "@'%'";
- MySqlHelper.DatabaseHost = this.DatabaseHost;
- MySqlHelper.GrantPrivileges(dbUser, "mysql.proc", "SELECT"); // TODO: remove for MySql connector 1.0.8 and higher
- MySqlHelper.GrantPrivileges(dbUser, "NMailSpool.*", "INSERT,SELECT,UPDATE,DELETE,EXECUTE");
- MySqlHelper.GrantPrivileges(dbUser, "NMailLocalStore.*", "INSERT,SELECT,UPDATE,DELETE,EXECUTE");
-
- message = null;
- return TaskResult.Ok;
-
- } catch (Exception e) {
- message = "Error granting privileges to database user: " + e.Message;
- return TaskResult.Error;
- }
- }
-
- /// <summary>
- /// Gets the database host.
- /// </summary>
- public string DatabaseHost {
- get {
- return this.hostname.Text;
- }
- }
-
- /// <summary>
- /// Gets the database password.
- /// </summary>
- public string DatabasePassword {
- get {
- return this.password.Text;
- }
- }
-
- /// <summary>
- /// Gets the database username.
- /// </summary>
- public string DatabaseUsername {
- get {
- return this.username.Text;
- }
- }
-
- /// <summary>
/// Stores the settings into the configuration objects.
/// </summary>
private void storeConfiguration() {
if (this.smtpConfigPanel.SmtpSubSystemEnabled) {
// Ensure our config sections are there
- MySqlSpoolDataConfiguration.AddToConfigFile();
+ NMail.SpoolData.NHibernate.Configuration.AddToConfigFile();
- MySqlSpoolDataConfiguration msdc = MySqlSpoolDataConfiguration.Current;
+ NMail.SpoolData.NHibernate.Configuration nhsdc = NMail.SpoolData.NHibernate.Configuration.Current;
- // Save the connection string
- msdc.ConnectionString = string.Format(
- "Host={0};Password={1};Uid={2};Database=NMailSpool",
- this.hostname.Text,
- this.password.Text,
- this.username.Text);
-
+ // TODO: save filename to config, save file
+ throw new NotImplementedException();
+
} else {
// Remove the configuration
- MySqlSpoolDataConfiguration.RemoveFromConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.RemoveFromConfigFile();
}
if (this.localStoreConfigPanel.LocalStoreSubSystemEnabled) {
// Ensure our config sections are there
- MySqlLocalStoreDataConfiguration.AddToConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.AddToConfigFile();
- MySqlLocalStoreDataConfiguration mlsdc = MySqlLocalStoreDataConfiguration.Current;
+ NMail.LocalStoreData.NHibernate.Configuration nhlsdc = NMail.LocalStoreData.NHibernate.Configuration.Current;
- // Save the connection string
- mlsdc.ConnectionString = string.Format(
- "Host={0};Password={1};Uid={2};Database=NMailLocalStore",
- this.hostname.Text,
- this.password.Text,
- this.username.Text);
+ // TODO: save filename to config, save file
+ throw new NotImplementedException();
} else {
// Remove the configuration
- MySqlLocalStoreDataConfiguration.RemoveFromConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.RemoveFromConfigFile();
}
}
private void loadConfiguration() {
- MySqlSpoolDataConfiguration msdc = MySqlSpoolDataConfiguration.Current;
+ NMail.LocalStoreData.NHibernate.Configuration nhlsdc = NMail.LocalStoreData.NHibernate.Configuration.Current;
+ NMail.SpoolData.NHibernate.Configuration nhsdc = NMail.SpoolData.NHibernate.Configuration.Current;
// TODO: Populate the widgets with the current config
+ throw new NotImplementedException();
}
protected override void OnNextButtonClick() {
@@ -179,33 +89,12 @@
MessageBox.Show(this, e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
-
- if (this.createDbUserCheckBox.Checked && !this.BaseForm.Tasks.Contains(this.createDbUserTask)) {
- int makeTablesIndex = this.smtpConfigPanel.MakeSpoolTablesTaskIndex;
-
- if (makeTablesIndex == -1) {
- this.BaseForm.Tasks.Add(this.createDbUserTask);
- this.BaseForm.Tasks.Add(this.grantDbUserPrivsTask);
- } else {
- // Insert the create user task before the make spool tables task
- this.BaseForm.Tasks.Insert(makeTablesIndex, this.createDbUserTask);
- this.BaseForm.Tasks.Insert(makeTablesIndex + 1, this.grantDbUserPrivsTask);
- }
- }
base.OnNextButtonClick();
}
- protected override void OnBackButtonClick() {
- this.BaseForm.Tasks.Remove(this.createDbUserTask);
- this.BaseForm.Tasks.Remove(this.grantDbUserPrivsTask);
-
- base.OnBackButtonClick();
+ private void descriptionTextBox_LinkClicked(object sender, LinkClickedEventArgs e) {
+ System.Diagnostics.Process.Start(e.LinkText);
}
-
- private void createDbUserCheckBox_CheckedChanged(object sender, EventArgs e) {
- this.autoPassCheckBox.Enabled = this.createDbUserCheckBox.Checked;
- this.password.Enabled = this.createDbUserCheckBox.Checked && !this.autoPassCheckBox.Checked;
- }
}
}
Modified: NMail/trunk/NMail.SetupWizard/LocalStoreConfigPanel.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/LocalStoreConfigPanel.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/LocalStoreConfigPanel.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -28,8 +28,7 @@
using NMail.DataTypes;
using NMail.Helper;
using NMail.ImapService.Configuration;
-using NMail.LocalStoreData.MySql;
-using NMail.LocalStoreData.MySql.Configuration;
+using NMail.LocalStoreData.NHibernate;
namespace NMail.SetupWizard {
public partial class LocalStoreConfigPanel : BasePanel {
@@ -41,7 +40,7 @@
// If any of these are present consider it all enabled
if (ImapServiceConfiguration.ConfigurationPresent
- || MySqlLocalStoreDataConfiguration.ConfigurationPresent) {
+ || NMail.LocalStoreData.NHibernate.Configuration.ConfigurationPresent) {
this.enableLocalStoreSubSysBox.Checked = true;
@@ -50,7 +49,7 @@
// Ensure the rest are there
ImapServiceConfiguration.AddToConfigFile();
- MySqlLocalStoreDataConfiguration.AddToConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.AddToConfigFile();
}
if (this.enableLocalStoreSubSysBox.Checked) {
@@ -81,7 +80,7 @@
/// <returns>The result of the attempt to create the tables.</returns>
private TaskResult makeStoreTables(out string message) {
try {
- MySqlHelper.RunScript("MySqlLocalStore.sql");
+ NMailConfiguration.Current.LocalStoreData.ReinstallSchema();
message = null;
return TaskResult.Ok;
@@ -120,10 +119,10 @@
if (this.enableLocalStoreSubSysBox.Checked) {
// Ensure our config sections are there
ImapServiceConfiguration.AddToConfigFile();
- MySqlLocalStoreDataConfiguration.AddToConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.AddToConfigFile();
ImapServiceConfiguration isc = ImapServiceConfiguration.Current;
- MySqlLocalStoreDataConfiguration mlsdc = MySqlLocalStoreDataConfiguration.Current;
+ NMail.LocalStoreData.NHibernate.Configuration nhc = NMail.LocalStoreData.NHibernate.Configuration.Current;
// Ensure the IMAP service is in the list of services
bool foundImapService = false;
@@ -165,14 +164,14 @@
if (!foundLocalStoreData) {
NamedServiceElement service = new NamedServiceElement();
service.Name = "LocalStoreData";
- service.ObjectType = typeof(MySqlLocalStoreData);
+ service.ObjectType = typeof(NMail.LocalStoreData.NHibernate.NHibernateLocalStoreData);
nc.NamedServiceDetails.Add(service);
}
if (!foundAuthProvider) {
NamedServiceElement service = new NamedServiceElement();
service.Name = "AuthProvider";
- service.ObjectType = typeof(MySqlAuthProvider);
+ service.ObjectType = typeof(NMail.LocalStoreData.NHibernate.NHibernateAuthProvider);
nc.NamedServiceDetails.Add(service);
}
@@ -197,7 +196,7 @@
} else {
// Remove the configuration
ImapServiceConfiguration.RemoveFromConfigFile();
- MySqlLocalStoreDataConfiguration.RemoveFromConfigFile();
+ NMail.LocalStoreData.NHibernate.Configuration.RemoveFromConfigFile();
// Ensure the IMAP service is not in the list of services
for (int i = 0; i < nc.ServiceDetails.Count; i++) {
@@ -225,7 +224,7 @@
private void loadConfiguration() {
ImapServiceConfiguration isc = ImapServiceConfiguration.Current;
- MySqlLocalStoreDataConfiguration mlsdc = MySqlLocalStoreDataConfiguration.Current;
+ NMail.LocalStoreData.NHibernate.Configuration nhc = NMail.LocalStoreData.NHibernate.Configuration.Current;
// Populate the widgets with the current config
this.visibleHostTextBox.Text = isc.VisibleHost.ToString();
Deleted: NMail/trunk/NMail.SetupWizard/MySqlHelper.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/MySqlHelper.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/MySqlHelper.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -1,133 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Windows.Forms;
-
-using MySql.Data.MySqlClient;
-
-namespace NMail.SetupWizard {
- public static class MySqlHelper {
-
- private static PasswordDialog passwordDialog = new PasswordDialog();
-
- static MySqlHelper() {
- Username = "root";
- Password = string.Empty;
- DatabaseHost = "localhost";
- }
-
- private static string host;
-
- /// <summary>
- /// The host that the helper will connect to.
- /// </summary>
- public static string DatabaseHost {
- get {
- return host;
- }
- set {
- host = value;
- passwordDialog.ConnectionLabel = "Connecting to MySql on " + host;
- }
- }
-
- /// <summary>
- /// The username to connect with.
- /// </summary>
- public static string Username {
- get {
- return passwordDialog.Username;
- }
- set {
- passwordDialog.Username = value;
- }
- }
-
- /// <summary>
- /// The password to connect with.
- /// </summary>
- public static string Password {
- get {
- return passwordDialog.Password;
- }
- set {
- passwordDialog.Password = value;
- }
- }
-
- private static MySqlConnection GetConnection() {
- while (true) {
- MySqlConnection cnn = new MySqlConnection();
- cnn.ConnectionString = string.Format(
- "Host={0};Database=mysql;Username={1};Password={2}",
- DatabaseHost,
- Username,
- Password);
-
- try {
- cnn.Open();
- return cnn;
-
- } catch (MySqlException) { }
-
- DialogResult dialogResult = passwordDialog.ShowDialog();
-
- if (dialogResult == DialogResult.Cancel) {
- throw new InvalidOperationException("MySql login cancelled by user.");
- }
- }
- }
-
- public static void CreateDatabase(string databaseName) {
- MySqlConnection cnn = GetConnection();
-
- MySqlCommand cmd = cnn.CreateCommand();
- cmd.CommandText = "CREATE DATABASE ?Database";
- cmd.Parameters.Add("?Database", databaseName);
-
- cmd.ExecuteNonQuery();
- }
-
- /// <summary>
- /// Grants privileges on a database to a user.
- /// </summary>
- /// <remarks><b>WARNING:</b> The strings used in this function are not
- /// checked for SQL injection attacks. Only use input from a trusted
- /// source!</remarks>
- public static void GrantPrivileges(string username, string database, string privileges) {
- MySqlConnection cnn = GetConnection();
-
- string cmdText = string.Format("GRANT {0} ON {1} TO {2}", privileges, database, username);
-
- MySqlCommand cmd = cnn.CreateCommand();
- cmd.CommandText = cmdText;
-
- cmd.ExecuteNonQuery();
- }
-
- public static void CreateUser(string username, string password) {
- MySqlConnection cnn = GetConnection();
-
- MySqlCommand cmd = cnn.CreateCommand();
- cmd.CommandText = "CREATE USER ?User IDENTIFIED BY ?Password";
- cmd.Parameters.Add("?User", username);
- cmd.Parameters.Add("?Password", password);
-
- cmd.ExecuteNonQuery();
- }
-
- public static void RunScript(string scriptFile) {
- FileStream fs = File.Open(scriptFile, FileMode.Open);
- StreamReader reader = new StreamReader(fs);
- string scriptData = reader.ReadToEnd();
-
- MySqlConnection cnn = GetConnection();
- MySqlCommand cmd = cnn.CreateCommand();
-
- cmd.CommandText = scriptData;
-
- cmd.ExecuteNonQuery();
- }
- }
-}
Modified: NMail/trunk/NMail.SetupWizard/NMail.SetupWizard.csproj
===================================================================
--- NMail/trunk/NMail.SetupWizard/NMail.SetupWizard.csproj 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/NMail.SetupWizard.csproj 2007-05-09 12:56:42 UTC (rev 191)
@@ -28,10 +28,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="MySql.Data, Version=1.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\MySql.Data.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
@@ -78,7 +74,6 @@
<Compile Include="LocalStoreConfigPanel.Designer.cs">
<DependentUpon>LocalStoreConfigPanel.cs</DependentUpon>
</Compile>
- <Compile Include="MySqlHelper.cs" />
<Compile Include="PasswordDialog.cs">
<SubType>Form</SubType>
</Compile>
@@ -175,9 +170,9 @@
<Project>{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}</Project>
<Name>NMail.ImapService</Name>
</ProjectReference>
- <ProjectReference Include="..\NMail.LocalStoreData.MySql\NMail.LocalStoreData.MySql.csproj">
- <Project>{90B33C2B-F945-478A-BBA0-4F66EF78B870}</Project>
- <Name>NMail.LocalStoreData.MySql</Name>
+ <ProjectReference Include="..\NMail.LocalStoreData.NHibernate\NMail.LocalStoreData.NHibernate.csproj">
+ <Project>{72F7E307-F0A9-4750-9ED5-5A1F97725A11}</Project>
+ <Name>NMail.LocalStoreData.NHibernate</Name>
</ProjectReference>
<ProjectReference Include="..\NMail.LocalStore\NMail.LocalStore.csproj">
<Project>{488A8890-EEE1-4ACC-9B35-3DDBE8E70D1D}</Project>
@@ -195,9 +190,9 @@
<Project>{AEFF4DA8-7243-44C2-8223-69035380B042}</Project>
<Name>NMail.SmtpService</Name>
</ProjectReference>
- <ProjectReference Include="..\NMail.SpoolData.MySql\NMail.SpoolData.MySql.csproj">
- <Project>{68D6D57F-02CC-419F-8D69-3B479A1BFBED}</Project>
- <Name>NMail.SpoolData.MySql</Name>
+ <ProjectReference Include="..\NMail.SpoolData.NHibernate\NMail.SpoolData.NHibernate.csproj">
+ <Project>{A5EAEF38-D326-40B0-A51F-8A96D0621EEC}</Project>
+ <Name>NMail.SpoolData.NHibernate</Name>
</ProjectReference>
<ProjectReference Include="..\NMail.SpoolFilter\NMail.SpoolFilter.csproj">
<Project>{1C585C54-6FE4-47F5-9A1F-8437F412DCF5}</Project>
@@ -233,7 +228,7 @@
</Target>
-->
<PropertyGroup>
- <PostBuildEvent>copy /y "$(SolutionDir)NMail.SpoolData.MySql\*.sql" "$(ProjectDir)$(OutDir)"
-copy /y "$(SolutionDir)NMail.LocalStoreData.MySql\*.sql" "$(ProjectDir)$(OutDir)"</PostBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
Modified: NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs 2007-05-09 12:56:42 UTC (rev 191)
@@ -28,7 +28,6 @@
using NMail.MessageRouter.Configuration;
using NMail.SmtpClient.Configuration;
using NMail.SmtpService.Configuration;
-using NMail.SpoolData.MySql;
using NMail.SpoolFilter.Configuration;
using NMail.SpoolService.Configuration;
@@ -86,7 +85,7 @@
/// <returns>The result of the attempt to create the tables.</returns>
private TaskResult makeSpoolTables(out string message) {
try {
- MySqlHelper.RunScript("MySqlSpoolData.sql");
+ NMailConfiguration.Current.SpoolData.ReinstallSchema();
message = null;
return TaskResult.Ok;
@@ -180,7 +179,7 @@
if (!foundSpoolData) {
NamedServiceElement service = new NamedServiceElement();
service.Name = "SpoolData";
- service.ObjectType = typeof(MySqlSpoolData);
+ service.ObjectType = typeof(NMail.SpoolData.NHibernate.NHibernateSpoolData);
nc.NamedServiceDetails.Add(service);
}
Modified: NMail/trunk/NMail.sln
===================================================================
--- NMail/trunk/NMail.sln 2007-05-08 13:20:38 UTC (rev 190)
+++ NMail/trunk/NMail.sln 2007-05-09 12:56:42 UTC (rev 191)
@@ -34,8 +34,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.UnitTests", "NMail.UnitTests\NMail.UnitTests.csproj", "{ED0957A8-FB7C-496B-8301-7A15842A3F01}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.Administration.Console", "NMail.Administration.Console\NMail.Administration.Console.csproj", "{93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.PostInstall", "NMail.PostInstall\NMail.PostInstall.csproj", "{906413B5-1C7D-4072-B5CF-FDCED1F6CA7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.SetupWizard", "NMail.SetupWizard\NMail.SetupWizard.csproj", "{DDE40B82-A5D9-4BE4-997B-C7EF3FFF5EBD}"
@@ -48,8 +46,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.LocalStoreData.NHibernate", "NMail.LocalStoreData.NHibernate\NMail.LocalStoreData.NHibernate.csproj", "{72F7E307-F0A9-4750-9ED5-5A1F97725A11}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.SpoolData.MySql", "NMail.SpoolData.MySql\NMail.SpoolData.MySql.csproj", "{68D6D57F-02CC-419F-8D69-3B479A1BFBED}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -194,14 +190,6 @@
{ED0957A8-FB7C-496B-8301-7A15842A3F01}.Release|Any CPU.Build.0 = Release|Any CPU
{ED0957A8-FB7C-496B-8301-7A15842A3F01}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
{ED0957A8-FB7C-496B-8301-7A15842A3F01}.Release2005|Any CPU.Build.0 = Release|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Debug2005|Any CPU.Build.0 = Debug|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Release|Any CPU.Build.0 = Release|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
- {93F9B202-EB30-4FF8-B10F-BD45FD3B7E9F}.Release2005|Any CPU.Build.0 = Release|Any CPU
{906413B5-1C7D-4072-B5CF-FDCED1F6CA7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{906413B5-1C7D-4072-B5CF-FDCED1F6CA7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{906413B5-1C7D-4072-B5CF-FDCED1F6CA7C}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
@@ -250,14 +238,6 @@
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Release|Any CPU.Build.0 = Release|Any CPU
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Release2005|Any CPU.Build.0 = Release|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Debug2005|Any CPU.Build.0 = Debug|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Release|Any CPU.Build.0 = Release|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
- {68D6D57F-02CC-419F-8D69-3B479A1BFBED}.Release2005|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|