nmailserver-commits Mailing List for NMail (Page 2)
Brought to you by:
dframpton-oss,
tmyroadctfig
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(13) |
Jun
(14) |
Jul
(8) |
Aug
|
Sep
|
Oct
(8) |
Nov
(22) |
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(21) |
Feb
(31) |
Mar
(24) |
Apr
(8) |
May
(23) |
Jun
(40) |
Jul
(14) |
Aug
(5) |
Sep
(7) |
Oct
(10) |
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tmy...@us...> - 2007-07-30 14:27:22
|
Revision: 262
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=262&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:27:23 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Added a metrics service.
Modified Paths:
--------------
NMail/trunk/NMail.sln
Added Paths:
-----------
NMail/trunk/NMail/DataTypes/Metrics/
NMail/trunk/NMail/DataTypes/Metrics/MetricAttribute.cs
NMail/trunk/NMail/DataTypes/Metrics/MetricType.cs
NMail/trunk/NMail.MetricsService/
NMail/trunk/NMail.MetricsService/Configuration/
NMail/trunk/NMail.MetricsService/Configuration/MetricsServiceConfiguration.cs
NMail/trunk/NMail.MetricsService/MetricDetails.cs
NMail/trunk/NMail.MetricsService/MetricsService.cs
NMail/trunk/NMail.MetricsService/NMail.MetricsService.csproj
NMail/trunk/NMail.MetricsService/Properties/
NMail/trunk/NMail.MetricsService/Properties/AssemblyInfo.cs
NMail/trunk/References/IKVM.AWT.WinForms.dll
NMail/trunk/References/IKVM.GNU.Classpath.dll
NMail/trunk/References/IKVM.Runtime.dll
NMail/trunk/References/ZedGraph.dll
NMail/trunk/References/rrd4j-2.0.5.dll
Added: NMail/trunk/NMail/DataTypes/Metrics/MetricAttribute.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Metrics/MetricAttribute.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Metrics/MetricAttribute.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Metrics {
+ /// <summary>
+ /// An attribute that marks properties as a metric that is monitored.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property, AllowMultiple=false)]
+ public class MetricAttribute : Attribute {
+
+ public MetricAttribute(string name, MetricType metricType) {
+ this.name = name;
+ this.metricType = metricType;
+ }
+
+ private string name;
+
+ /// <summary>
+ /// The name of the metric as displayed to the administrator.
+ /// </summary>
+ public string Name {
+ get { return name; }
+ }
+
+ private MetricType metricType;
+
+ /// <summary>
+ /// The type of this metric.
+ /// </summary>
+ public MetricType MetricType {
+ get { return metricType; }
+ }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Metrics/MetricType.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Metrics/MetricType.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Metrics/MetricType.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Metrics {
+ public enum MetricType {
+ Counter,
+
+ Gauge
+ }
+}
Added: NMail/trunk/NMail.MetricsService/Configuration/MetricsServiceConfiguration.cs
===================================================================
--- NMail/trunk/NMail.MetricsService/Configuration/MetricsServiceConfiguration.cs (rev 0)
+++ NMail/trunk/NMail.MetricsService/Configuration/MetricsServiceConfiguration.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2004-2007 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.Xml;
+using System.Configuration;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+
+namespace NMail.MetricsService.Configuration {
+ /// <summary>
+ /// Provides configuration for the metrics service.
+ /// </summary>
+ public class MetricsServiceConfiguration : ConfigurationSection {
+ /// <summary>
+ /// Adds a metrics service configuration section to the current config file.
+ /// </summary>
+ public static void AddToConfigFile() {
+ if (NMailConfigFile.Current.Sections["NMail.MetricsService"] == null) {
+ NMailConfigFile.Current.Sections.Add("NMail.MetricsService", new MetricsServiceConfiguration());
+ }
+ }
+
+ /// <summary>
+ /// Remove the config section from the config file.
+ /// </summary>
+ public static void RemoveFromConfigFile() {
+ if (NMailConfigFile.Current.Sections["NMail.MetricsService"] != null) {
+ NMailConfigFile.Current.Sections.Remove("NMail.MetricsService");
+ }
+ }
+
+ /// <summary>
+ /// Returns true if a metrics service configuration section exists in the current
+ /// configuration.
+ /// </summary>
+ public static bool ConfigurationPresent {
+ get {
+ return (NMailConfigFile.Current.Sections["NMail.MetricsService"] != null);
+ }
+ }
+
+ /// <summary>
+ /// The current configuration in use.
+ /// </summary>
+ public static MetricsServiceConfiguration Current {
+ get {
+ MetricsServiceConfiguration current;
+ current = (MetricsServiceConfiguration) NMailConfigFile.Current.GetSection("NMail.MetricsService");
+
+ if (current == null) {
+ throw new ConfigurationErrorsException("NMail Metrics Service configuration is missing");
+ }
+ return current;
+ }
+ }
+
+ /// <summary>
+ /// The period to wait between gathering metrics.
+ /// </summary>
+ [ConfigurationProperty("GatherWaitPeriod", DefaultValue = "0:05:0")]
+ public TimeSpan GatherWaitPeriod {
+ get {
+ return (TimeSpan) this["GatherWaitPeriod"];
+ }
+ set {
+ this["GatherWaitPeriod"] = value;
+ }
+ }
+ }
+}
Added: NMail/trunk/NMail.MetricsService/MetricDetails.cs
===================================================================
--- NMail/trunk/NMail.MetricsService/MetricDetails.cs (rev 0)
+++ NMail/trunk/NMail.MetricsService/MetricDetails.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.Reflection;
+using System.Text;
+
+using NMail.DataTypes.Metrics;
+
+namespace NMail.MetricsService {
+ /// <summary>
+ /// A class for holding metric details.
+ /// </summary>
+ public class MetricDetails {
+
+ private object objectInstance;
+
+ /// <summary>
+ /// The object to query the metrics from.
+ /// </summary>
+ public object ObjectInstance {
+ get { return objectInstance; }
+ set { objectInstance = value; }
+ }
+
+ private PropertyInfo propertyInfo;
+
+ /// <summary>
+ /// The property to query to get the metric.
+ /// </summary>
+ public PropertyInfo PropertyInfo {
+ get { return propertyInfo; }
+ set { propertyInfo = value; }
+ }
+
+ private MetricAttribute metric;
+
+ /// <summary>
+ /// The metric information.
+ /// </summary>
+ public MetricAttribute Metric {
+ get { return metric; }
+ set { metric = value; }
+ }
+ }
+}
Added: NMail/trunk/NMail.MetricsService/MetricsService.cs
===================================================================
--- NMail/trunk/NMail.MetricsService/MetricsService.cs (rev 0)
+++ NMail/trunk/NMail.MetricsService/MetricsService.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,307 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+
+using org.rrd4j;
+using org.rrd4j.core;
+
+using NMail.Configuration;
+using NMail.DataTypes.Metrics;
+using NMail.DataTypes.Service;
+using NMail.MetricsService.Configuration;
+using NMail.Server;
+
+namespace NMail.MetricsService {
+ /// <summary>
+ /// A service for periodically gathering and recording metrics from the running server.
+ /// </summary>
+ public class MetricsService : MarshalByRefObject, IService {
+
+ protected RrdDb rrdDb;
+
+ protected void SetupRrdDb() {
+ RrdDb.setDefaultFactory("FILE");
+
+ string rrdFilename = NMailServer.GetInstallDirectory() + Path.DirectorySeparatorChar + "NMail.rrd";
+ RrdDef rrdDef = new RrdDef(rrdFilename);
+
+ foreach (MetricDetails metricDetails in this.metrics) {
+ rrdDef.addDatasource(metricDetails.Metric.Name, DsType.COUNTER, 600, 0, Double.NaN);
+ }
+
+ rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 1, 600);
+ rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 6, 700);
+ rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 24, 775);
+ rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 288, 797);
+ rrdDef.addArchive(ConsolFun.MAX, 0.5, 1, 600);
+ rrdDef.addArchive(ConsolFun.MAX, 0.5, 6, 700);
+ rrdDef.addArchive(ConsolFun.MAX, 0.5, 24, 775);
+ rrdDef.addArchive(ConsolFun.MAX, 0.5, 288, 797);
+
+ this.rrdDb = new RrdDb(rrdDef);
+ }
+
+ protected void AddSample(string metricName, double value) {
+ Sample sample = this.rrdDb.createSample();
+ sample.setTime(Util.getTime());
+ sample.setValue(metricName, value);
+ sample.update();
+ }
+
+ protected List<MetricDetails> metrics = new List<MetricDetails>();
+
+ protected void PopulateMetricsForType(Type t, object instance) {
+ if (instance == null) {
+ // Can't get metrics off something that isn't there!
+ return;
+ }
+
+ // Check each property in the type
+ foreach (PropertyInfo propInfo in t.GetProperties()) {
+ // Look for metric attributes
+ MetricAttribute[] metricAttributes = (MetricAttribute[]) propInfo.GetCustomAttributes(typeof(MetricAttribute), true);
+
+ if (metricAttributes.Length > 0) {
+ // Save the metric into the list
+ MetricDetails metricDetails = new MetricDetails();
+ metricDetails.Metric = metricAttributes[0];
+ metricDetails.ObjectInstance = instance;
+ metricDetails.PropertyInfo = propInfo;
+ this.metrics.Add(metricDetails);
+ }
+ }
+ }
+
+ public IList<KeyValuePair<DateTime, double>> GetMetricValues(string metricName) {
+ FetchRequest request = this.rrdDb.createFetchRequest(ConsolFun.AVERAGE, Util.getTime() - 86400, Util.getTime());
+ FetchData fetchData = request.fetchData();
+
+ double[] values = fetchData.getValues(metricName);
+ long[] timestamps = fetchData.getTimestamps();
+ List<KeyValuePair<DateTime, double>> result = new List<KeyValuePair<DateTime, double>>();
+
+ for (int i = 0; i < timestamps.Length; i++) {
+ DateTime time = new DateTime(timestamps[i] * (long) Math.Pow(10, 7));
+ result.Add(new KeyValuePair<DateTime, double>(time, values[i]));
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// An event to signal a quit.
+ /// </summary>
+ ManualResetEvent quitEvent = new ManualResetEvent(true);
+
+ /// <summary>
+ /// A flag indicating if the service is running.
+ /// </summary>
+ bool running = false;
+
+ protected void GatherMetricsThread(object unused) {
+ // Flag that we're running
+ lock (this) {
+ running = true;
+ }
+
+ PopulateMetricsForType(typeof(NMail.DataTypes.Spool.ISpoolService), NMailConfiguration.Current.SpoolService);
+
+ SetupRrdDb();
+
+ while (this.running) {
+
+ // Wait until the next gathering period or quit
+ TimeSpan waitPeriod = MetricsServiceConfiguration.Current.GatherWaitPeriod;
+ bool quitSignalled = this.quitEvent.WaitOne(waitPeriod, true);
+
+ if (!quitSignalled) {
+
+ foreach (MetricDetails metricDetails in this.metrics) {
+ object val = metricDetails.PropertyInfo.GetGetMethod().Invoke(metricDetails.ObjectInstance, null);
+ AddSample(metricDetails.Metric.Name, Convert.ToDouble(val));
+ }
+
+ } else {
+ // Flag that we've quit
+ lock (this) {
+ running = false;
+ }
+ }
+ }
+ }
+
+ #region IService Members
+ /// <summary>
+ /// Initialise the service. All services are <b>Init</b>ialised before any services are <b>Start</b>ed.
+ /// </summary>
+ public void Init() { }
+
+ /// <summary>
+ /// Start the service.
+ /// </summary>
+ /// <exception cref="System.InvalidOperationException">
+ /// If Start() is called before Init().
+ /// </exception>
+ public void Start() {
+ lock (this) {
+ if (!this.Running) {
+ this.quitEvent.Reset();
+ ThreadPool.QueueUserWorkItem(new WaitCallback(GatherMetricsThread));
+
+ if (this.started != null) {
+ this.started(this, new EventArgs());
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Stop the service. It should be possible to resume the service with a subsequent call to Init and Start.
+ /// If you take too long (arbitrary) to Stop gracefully, then you may get an additional call to Stop
+ /// immediately on another thread, you must be able to handle this.
+ /// </summary>
+ public void Stop(bool runCurrentToCompletion) {
+ lock (this) {
+ if (this.Running) {
+ this.quitEvent.Set();
+
+ if (this.stopped != null) {
+ this.stopped(this, new EventArgs());
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Returns true if this service supports pausing processing without performing a complete shutdown.
+ /// </summary>
+ public bool SupportsPause {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// Pauses the service from processing but doesn't require a complete shutdown. E.g. a service may stop
+ /// accepting new connections or stop processing its work queue.
+ /// </summary>
+ /// <exception cref="System.InvalidOperationException">
+ /// If this service doesn't support pausing.
+ /// </exception>
+ public void Pause() {
+ throw new InvalidOperationException("Can't pause this service.");
+ }
+
+ /// <summary>
+ /// Continues processing following a pause command.
+ /// </summary>
+ /// <exception cref="System.InvalidOperationException">
+ /// If this service doesn't support pausing.
+ /// </exception>
+ public void Continue() {
+ throw new InvalidOperationException("Can't resume this service.");
+ }
+
+ /// <summary>
+ /// Reload the service configuration. This may recycle the service instance by stopping and discarding
+ /// the current IService and returning a new one.
+ /// </summary>
+ /// <remarks>
+ /// The service is <b>running</b> when this is called.
+ /// </remarks>
+ /// <exception cref="System.InvalidOperationException">
+ /// If this service is not running when this is called.
+ /// </exception>
+ public IService ReloadConfiguration() {
+ throw new InvalidOperationException("Can't reload configuration for this service.");
+ }
+
+ /// <summary>
+ /// Does this service support reloading configuration parameters on the fly?
+ /// </summary>
+ public bool AllowsReloadConfiguration {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// Is the service currently running?
+ /// </summary>
+ public bool Running {
+ get { return this.running; }
+ }
+
+ /// <summary>
+ /// The name of this service.
+ /// </summary>
+ public string Name {
+ get { return "Metrics Service"; }
+ }
+
+ /// <summary>
+ /// The description of this service.
+ /// </summary>
+ public string Description {
+ get { return "Periodically gathers and records metrics from the running server."; }
+ }
+
+ /// <summary>
+ /// A URL for details on this service.
+ /// </summary>
+ public Uri SupportUrl {
+ get { return new Uri("http://nmailserver.sf.net/support/services/metrics"); }
+ }
+
+ private event EventHandler started;
+
+ /// <summary>
+ /// The event triggered when the service has been started.
+ /// </summary>
+ /// <remarks>
+ /// Running should return true when this event is received.
+ /// </remarks>
+ public event EventHandler Started {
+ add {
+ this.started += value;
+ }
+ remove {
+ this.started -= value;
+ }
+ }
+
+ private event EventHandler stopped;
+
+ /// <summary>
+ /// The event triggered when the sevice has been stopped.
+ /// </summary>
+ /// <remarks>
+ /// Running should return false when this event is received.
+ /// </remarks>
+ public event EventHandler Stopped {
+ add {
+ this.stopped += value;
+ }
+ remove {
+ this.stopped -= value;
+ }
+ }
+ #endregion
+ }
+}
Added: NMail/trunk/NMail.MetricsService/NMail.MetricsService.csproj
===================================================================
--- NMail/trunk/NMail.MetricsService/NMail.MetricsService.csproj (rev 0)
+++ NMail/trunk/NMail.MetricsService/NMail.MetricsService.csproj 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,74 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{FD6E75CA-4BBC-41C6-A979-8816B74CD79E}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>NMail.MetricsService</RootNamespace>
+ <AssemblyName>NMail.MetricsService</AssemblyName>
+ <StartupObject>
+ </StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\References\NMail\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\References\NMail\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="IKVM.GNU.Classpath, Version=0.34.0.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\References\IKVM.GNU.Classpath.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.Runtime, Version=0.34.0.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\References\IKVM.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="rrd4j-2.0.5, Version=0.0.0.0, Culture=neutral">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\References\rrd4j-2.0.5.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Configuration\MetricsServiceConfiguration.cs" />
+ <Compile Include="MetricDetails.cs" />
+ <Compile Include="MetricsService.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\NMail.Server\NMail.Server.csproj">
+ <Project>{45123319-D913-4A92-BB67-C2C9E1A22A17}</Project>
+ <Name>NMail.Server</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\NMail\NMail.csproj">
+ <Project>{5A5A5012-B157-49B1-A35F-67EC9680112A}</Project>
+ <Name>NMail</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: NMail/trunk/NMail.MetricsService/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.MetricsService/Properties/AssemblyInfo.cs (rev 0)
+++ NMail/trunk/NMail.MetricsService/Properties/AssemblyInfo.cs 2007-07-30 14:27:23 UTC (rev 262)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004-2007 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.Reflection;
+using System.Runtime.CompilerServices;
+
+// General details
+[assembly: AssemblyTitle("NMail Metrics Service.")]
+[assembly: AssemblyVersion("1.1.*")]
+
+[assembly: AssemblyDescription("Provides a metrics gathering service implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2004-2007 Luke Quinane")]
+
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.sln
===================================================================
--- NMail/trunk/NMail.sln 2007-07-30 14:15:59 UTC (rev 261)
+++ NMail/trunk/NMail.sln 2007-07-30 14:27:23 UTC (rev 262)
@@ -52,6 +52,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.SurveyService", "NMail.SurveyService\NMail.SurveyService.csproj", "{11BFAF65-FA51-4245-8747-F4BA39D10FA3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.MetricsService", "NMail.MetricsService\NMail.MetricsService.csproj", "{FD6E75CA-4BBC-41C6-A979-8816B74CD79E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -268,6 +270,14 @@
{11BFAF65-FA51-4245-8747-F4BA39D10FA3}.Release|Any CPU.Build.0 = Release|Any CPU
{11BFAF65-FA51-4245-8747-F4BA39D10FA3}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
{11BFAF65-FA51-4245-8747-F4BA39D10FA3}.Release2005|Any CPU.Build.0 = Release|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Debug2005|Any CPU.Build.0 = Debug|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
+ {FD6E75CA-4BBC-41C6-A979-8816B74CD79E}.Release2005|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Added: NMail/trunk/References/IKVM.AWT.WinForms.dll
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/References/IKVM.AWT.WinForms.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: NMail/trunk/References/IKVM.GNU.Classpath.dll
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/References/IKVM.GNU.Classpath.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: NMail/trunk/References/IKVM.Runtime.dll
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/References/IKVM.Runtime.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: NMail/trunk/References/ZedGraph.dll
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/References/ZedGraph.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: NMail/trunk/References/rrd4j-2.0.5.dll
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/References/rrd4j-2.0.5.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:15:56
|
Revision: 261
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=261&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:15:59 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Removed performance counters.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Service/BaseService.cs
Modified: NMail/trunk/NMail/DataTypes/Service/BaseService.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Service/BaseService.cs 2007-07-30 14:15:10 UTC (rev 260)
+++ NMail/trunk/NMail/DataTypes/Service/BaseService.cs 2007-07-30 14:15:59 UTC (rev 261)
@@ -25,12 +25,11 @@
using log4net;
-using NMail.DataTypes;
using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.Metrics;
using NMail.Helper;
-// TODO: remove "#if !MONO" when perf counters are implemented in Mono
-
namespace NMail.DataTypes.Service {
/// <summary>
/// Provides a base class for services.
@@ -51,27 +50,13 @@
/// </summary>
private bool shutdown;
-#if !MONO
/// <summary>
- /// The performance counter for tracking the number of received connections.
- /// </summary>
- private PerformanceCounter connectionsReceived;
-#endif
-
- /// <summary>
/// Creates a new instance of the SMTP service.
/// </summary>
public BaseService() {
this.listenSockets = new List<TcpListener>();
this.sessionThreads = new List<Thread>();
this.shutdown = true;
-
-#if !MONO
- this.connectionsReceived = new PerformanceCounter(
- PerfCounterCategory,
- TotalConnectionsReceived,
- false);
-#endif
}
#region IService Members
@@ -186,13 +171,30 @@
}
#endregion
+ /// <summary>
+ /// The current number of active connections.
+ /// </summary>
+ [Metric("Connection count", MetricType.Gauge)]
public int ConnectionCount {
get {
return this.sessionThreads.Count;
}
}
+
+
+ private long connectionsReceived;
/// <summary>
+ /// The counter for tracking the number of received connections.
+ /// </summary>
+ [Metric("Connections Received", MetricType.Counter)]
+ public long ConnectionsReceived {
+ get {
+ return this.connectionsReceived;
+ }
+ }
+
+ /// <summary>
/// Handles incomming connections for an interface (IP address).
/// </summary>
/// <param name="o">The interface to listen for connections on.</param>
@@ -214,10 +216,9 @@
while (true) {
Socket client = socket.AcceptSocket();
-#if !MONO
- this.connectionsReceived.Increment();
-#endif
+ Interlocked.Increment(ref this.connectionsReceived);
+
lock (this) {
if (this.ConnectionCount < this.MaximumConnections) {
// Create a new session and thread to handle this connection
@@ -293,16 +294,5 @@
/// The reply to send when the server is busy.
/// </summary>
protected abstract string BusyReply { get; }
-
- /// <summary>
- /// The category the SMTP service uses for its performance counters.
- /// </summary>
- public abstract string PerfCounterCategory { get; }
-
- /// <summary>
- /// The name of the performance counter that tracks the total number of
- /// received connections.
- /// </summary>
- public const string TotalConnectionsReceived = "TotalConnectionsReceived";
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:15:44
|
Revision: 260
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=260&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:15:10 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Added extra spool management functions.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs
NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs
NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs
NMail/trunk/NMail.SpoolService/SpoolService.cs
Modified: NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs 2007-07-30 14:14:09 UTC (rev 259)
+++ NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs 2007-07-30 14:15:10 UTC (rev 260)
@@ -59,6 +59,12 @@
DeliveryBatch BeginDeliveryBatch(int messageLimit, int sizeLimit);
/// <summary>
+ /// Forces a delivery attempt for the given recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to force delivery for.</param>
+ DeliveryBatch ForceDeliveryAttempt(long recipientId);
+
+ /// <summary>
/// Either removes a recipient from a spool message or increments the number of
/// failed delivery attempts for the recipient. Also schedules the next delivery
/// attempt.
@@ -96,9 +102,51 @@
void SetFilterStatus(SmtpMessage message, bool filtered);
/// <summary>
+ /// Gets a message from a message Id.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to get.</param>
+ /// <returns>The message or null.</returns>
+ SmtpMessage GetMessage(Guid messageId);
+
+ /// <summary>
+ /// Gets a message recipient from a recipient Id.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to get.</param>
+ /// <returns>The recipient or null.</returns>
+ SmtpMessageRecipient GetMessageRecipient(long recipientId);
+
+ #region Spool Management
+ /// <summary>
/// Gets a list of message envelopes for messages currently in the spool.
/// </summary>
/// <returns>The list of envelopes.</returns>
IList<SpoolEnvelope> GetSpooledEnvelopes();
+
+ /// <summary>
+ /// Deletes a specific message recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to delete.</param>
+ void DeleteRecipient(long recipientId);
+
+ /// <summary>
+ /// Deletes a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to delete.</param>
+ void DeleteMessage(Guid messageId);
+
+ /// <summary>
+ /// Sets the filtered status for a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to set the status on.</param>
+ /// <param name="filtered">True if the message should be set as filtered.</param>
+ void SetFiltered(Guid messageId, bool filtered);
+
+ /// <summary>
+ /// Sets the next delivery attempt for a recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to set the next attempt for.</param>
+ /// <param name="deliveryAttempt">The next delivery attempt date/time.</param>
+ void SetNextDeliveryAttempt(long recipientId, DateTime deliveryAttempt);
+ #endregion
}
}
Modified: NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs 2007-07-30 14:14:09 UTC (rev 259)
+++ NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs 2007-07-30 14:15:10 UTC (rev 260)
@@ -19,6 +19,7 @@
using System.Collections.Generic;
using NMail.DataTypes;
+using NMail.DataTypes.Metrics;
using NMail.DataTypes.Service;
namespace NMail.DataTypes.Spool {
@@ -53,10 +54,60 @@
/// </summary>
void NotifyServiceThread();
+ #region Spool Management
/// <summary>
/// Gets a list of message envelopes for messages currently in the spool.
/// </summary>
/// <returns>The list of envelopes.</returns>
IList<SpoolEnvelope> GetSpooledEnvelopes();
+
+ /// <summary>
+ /// Deletes a specific message recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to delete.</param>
+ void DeleteRecipient(long recipientId);
+
+ /// <summary>
+ /// Deletes a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to delete.</param>
+ void DeleteMessage(Guid messageId);
+
+ /// <summary>
+ /// Rejects a specific message recipient causing a rejection message to be sent to the sender.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to reject.</param>
+ void RejectRecipient(long recipientId);
+
+ /// <summary>
+ /// Forces a delivery attempt for the given recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to force delivery for.</param>
+ void ForceDeliveryAttempt(long recipientId);
+
+ /// <summary>
+ /// Sets the filtered status for a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to set the status on.</param>
+ /// <param name="filtered">True if the message should be set as filtered.</param>
+ void SetFiltered(Guid messageId, bool filtered);
+
+ /// <summary>
+ /// Sets the next delivery attempt for a recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to set the next attempt for.</param>
+ /// <param name="deliveryAttempt">The next delivery attempt date/time.</param>
+ void SetNextDeliveryAttempt(long recipientId, DateTime deliveryAttempt);
+ #endregion
+
+ #region Metrics
+ /// <summary>
+ /// Gets the number of spooled messages.
+ /// </summary>
+ [Metric("Spooled Messages", MetricType.Counter)]
+ long SpooledMessages { get; }
+
+
+ #endregion
}
}
Modified: NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs 2007-07-30 14:14:09 UTC (rev 259)
+++ NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs 2007-07-30 14:15:10 UTC (rev 260)
@@ -212,6 +212,33 @@
}
#endregion
+ /// <summary>
+ /// Forces a delivery attempt for the given recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to force delivery for.</param>
+ public DeliveryBatch ForceDeliveryAttempt(long recipientId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ SmtpMessageRecipient recipient = session.Load<SmtpMessageRecipient>(recipientId);
+
+ if (recipient.InProgress) {
+ throw new InvalidOperationException("Recipient already in progress.");
+ }
+
+ // Flag the recipient as in progress
+ recipient.InProgress = true;
+ session.Update(recipient);
+
+ DeliveryBatch batch = new DeliveryBatch(recipient.Host);
+ batch.AddMessage(recipient.Message);
+
+ tx.Commit();
+ log.Debug("Delivery batch created, " + batch.GetMessages().Length + " messages.");
+ return batch;
+ }
+ }
+ }
+
#region Complete Delivery Attempt
/// <summary>
/// Either removes a recipient from a spool message or increments the number of
@@ -397,6 +424,117 @@
return result;
}
#endregion
+
+ /// <summary>
+ /// Gets a message from a message Id.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to get.</param>
+ /// <returns>The message or null.</returns>
+ public SmtpMessage GetMessage(Guid messageId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ // Load the message
+ return session.Get<SmtpMessage>(messageId);
+ }
+ }
+
+ /// <summary>
+ /// Gets a message recipient from a recipient Id.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to get.</param>
+ /// <returns>The recipient or null.</returns>
+ public SmtpMessageRecipient GetMessageRecipient(long recipientId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ // Load the message
+ return session.Get<SmtpMessageRecipient>(recipientId);
+ }
+ }
+
+ /// <summary>
+ /// Deletes a specific message recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to delete.</param>
+ public void DeleteRecipient(long recipientId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+
+ // Remove the recipient
+ SmtpMessageRecipient dbRecipient = session.Load<SmtpMessageRecipient>(recipientId);
+ dbRecipient.Message.Recipients.Remove(dbRecipient);
+ session.Update(dbRecipient.Message);
+ session.Delete(dbRecipient);
+
+ // Check if any recipients remain
+ if (dbRecipient.Message.Recipients.Count == 0) {
+ // No more recipients for the message, remove it
+ session.Delete(dbRecipient.Message);
+ }
+
+ // All good
+ tx.Commit();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Deletes a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to delete.</param>
+ public void DeleteMessage(Guid messageId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Delete the message
+ SmtpMessage message = session.Load<SmtpMessage>(messageId);
+ session.Delete(message);
+
+ // All good
+ tx.Commit();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Sets the filtered status for a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to set the status on.</param>
+ /// <param name="filtered">True if the message should be set as filtered.</param>
+ public void SetFiltered(Guid messageId, bool filtered) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+
+ // Update the message filtered status
+ SmtpMessage message = session.Load<SmtpMessage>(messageId);
+ message.Filtered = true;
+
+ if (filtered) {
+ // Set the next delivery attempt time
+ DateTime deliveryTime = DateTime.Now;
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
+ recipient.NextDeliveryAttempt = deliveryTime;
+ }
+ }
+
+ session.Update(message);
+ tx.Commit();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Sets the next delivery attempt for a recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to set the next attempt for.</param>
+ /// <param name="deliveryAttempt">The next delivery attempt date/time.</param>
+ public void SetNextDeliveryAttempt(long recipientId, DateTime deliveryAttempt) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Update the recipient details
+ SmtpMessageRecipient recipient = session.Load<SmtpMessageRecipient>(recipientId);
+ recipient.NextDeliveryAttempt = deliveryAttempt;
+ session.Update(recipient);
+ tx.Commit();
+ }
+ }
+ }
#endregion
}
}
Modified: NMail/trunk/NMail.SpoolService/SpoolService.cs
===================================================================
--- NMail/trunk/NMail.SpoolService/SpoolService.cs 2007-07-30 14:14:09 UTC (rev 259)
+++ NMail/trunk/NMail.SpoolService/SpoolService.cs 2007-07-30 14:15:10 UTC (rev 260)
@@ -46,26 +46,52 @@
}
#region ISpoolService Members
+ /// <summary>
+ /// Notifies the spool service of the result of the delivery attempt.
+ /// </summary>
+ /// <remarks>Note that this message may have some recipients removed.</remarks>
+ /// <param name="message">The message involved.</param>
+ /// <param name="result">The result of the delivery attempt.</param>
public void CompleteDeliveryAttempt(SmtpMessage message, DeliveryResult result) {
this.data.CompleteDeliveryAttempt(message, result);
+
// Ensure the service thread is awake
- if (result.Type == DeliveryResultType.TemporaryError)
+ if (result.Type == DeliveryResultType.TemporaryError) {
NotifyServiceThread();
+ }
}
- void NMail.DataTypes.Spool.ISpoolService.CompleteDeliveryAttempt(SmtpMessageRecipient recipient, DeliveryResult result) {
+ /// <summary>
+ /// Notifies the spool service of the result of the delivery attempt.
+ /// </summary>
+ /// <param name="recipient">The message and recipient involved.</param>
+ /// <param name="result">The result of the delivery attempt.</param>
+ public void CompleteDeliveryAttempt(SmtpMessageRecipient recipient, DeliveryResult result) {
this.data.CompleteDeliveryAttempt(recipient, result);
+
// Ensure the service thread is awake
- if (result.Type == DeliveryResultType.TemporaryError)
+ if (result.Type == DeliveryResultType.TemporaryError) {
NotifyServiceThread();
+ }
}
+ /// <summary>
+ /// Add a message to the spool. This method <b>must</b> throw an exception if the message could
+ /// not be spooled.
+ /// </summary>
+ /// <param name="message">The message to spool.</param>
public void SpoolMessage(SmtpMessage message) {
this.data.SpoolMessage(message);
+
+ Interlocked.Increment(ref this.spooledMessages);
+
// Ensure the filter thread is awake
NMailConfiguration.Current.SpoolFilter.NotifyFilterThread();
}
+ /// <summary>
+ /// Notifies the spool service thread that a message is waiting in the spool.
+ /// </summary>
public void NotifyServiceThread() {
Monitor.Enter(this);
Monitor.PulseAll(this);
@@ -79,6 +105,76 @@
public IList<SpoolEnvelope> GetSpooledEnvelopes() {
return this.data.GetSpooledEnvelopes();
}
+
+ /// <summary>
+ /// Deletes a specific message recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to delete.</param>
+ public void DeleteRecipient(long recipientId) {
+ this.data.DeleteRecipient(recipientId);
+ }
+
+ /// <summary>
+ /// Deletes a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to delete.</param>
+ public void DeleteMessage(Guid messageId) {
+ this.data.DeleteMessage(messageId);
+ }
+
+ /// <summary>
+ /// Rejects a specific message recipient causing a rejection message to be sent to the sender.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to reject.</param>
+ public void RejectRecipient(long recipientId) {
+ // Create a bounce message and spool it
+ SmtpMessageRecipient recipient = this.data.GetMessageRecipient(recipientId);
+ RecipientDeliveryResult result = new RecipientDeliveryResult(recipient, new DeliveryResult(DeliveryResultType.TemporaryError, "Message rejected by postmaster."));
+ SmtpMessage bounceMessage = NMailConfiguration.Current.Router.CreateBounceMessage(recipient.Message, result);
+ SpoolMessage(bounceMessage);
+
+ // Delete the recipient
+ this.data.DeleteRecipient(recipientId);
+ }
+
+ /// <summary>
+ /// Forces a delivery attempt for the given recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to force delivery for.</param>
+ public void ForceDeliveryAttempt(long recipientId) {
+ DeliveryBatch batch = this.data.ForceDeliveryAttempt(recipientId);
+ log.Debug("Queueing delivery batch for:[" + batch.Destination + "]");
+ this.pool.Queue(new NMailThreadStart(WorkerLoop), batch);
+ }
+
+ /// <summary>
+ /// Sets the filtered status for a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to set the status on.</param>
+ /// <param name="filtered">True if the message should be set as filtered.</param>
+ public void SetFiltered(Guid messageId, bool filtered) {
+ this.data.SetFiltered(messageId, filtered);
+ }
+
+ /// <summary>
+ /// Sets the next delivery attempt for a recipient.
+ /// </summary>
+ /// <param name="recipientId">The Id of the recipient to set the next attempt for.</param>
+ /// <param name="deliveryAttempt">The next delivery attempt date/time.</param>
+ public void SetNextDeliveryAttempt(long recipientId, DateTime deliveryAttempt) {
+ this.data.SetNextDeliveryAttempt(recipientId, deliveryAttempt);
+ }
+
+ private long spooledMessages = 0;
+
+ /// <summary>
+ /// Gets the number of spooled messages.
+ /// </summary>
+ public long SpooledMessages {
+ get {
+ return this.spooledMessages;
+ }
+ }
#endregion
#region IService Members
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:14:09
|
Revision: 259
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=259&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:14:09 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Added global exception handlers.
Modified Paths:
--------------
NMail/trunk/NMail.Server.Console/NMailConsoleServer.cs
NMail/trunk/NMail.Server.Service/NMailService.cs
Modified: NMail/trunk/NMail.Server.Console/NMailConsoleServer.cs
===================================================================
--- NMail/trunk/NMail.Server.Console/NMailConsoleServer.cs 2007-07-30 14:13:37 UTC (rev 258)
+++ NMail/trunk/NMail.Server.Console/NMailConsoleServer.cs 2007-07-30 14:14:09 UTC (rev 259)
@@ -42,48 +42,50 @@
// configure logging
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("logging.xml"));
-
- try {
- // output our platform details
- log.Debug("NMail Console Server version: [" + Assembly.GetExecutingAssembly().GetName().Version + "]");
- log.Debug("NMail Library version: [" + Assembly.GetAssembly(typeof(NMailConfiguration)).GetName().Version + "]");
- log.Debug("Platform: [" + Environment.OSVersion.Platform + "]");
- log.Debug("Version: [" + Environment.OSVersion.Version + "]");
- log.Debug("OS: [" + Environment.OSVersion.ToString() + "]");
- log.Debug("Environment: [" + Environment.Version.ToString() + "]");
- log.Debug("Current Dir: [" + Environment.CurrentDirectory + "]");
- NMailServer server = new NMailServer();
- RemoteAdministration ra = RemoteAdministration.GetInstance(server);
+ // Setup exception handler
+ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- // initialise the server
- server.Init();
+ // output our platform details
+ log.Debug("NMail Console Server version: [" + Assembly.GetExecutingAssembly().GetName().Version + "]");
+ log.Debug("NMail Library version: [" + Assembly.GetAssembly(typeof(NMailConfiguration)).GetName().Version + "]");
+ log.Debug("Platform: [" + Environment.OSVersion.Platform + "]");
+ log.Debug("Version: [" + Environment.OSVersion.Version + "]");
+ log.Debug("OS: [" + Environment.OSVersion.ToString() + "]");
+ log.Debug("Environment: [" + Environment.Version.ToString() + "]");
+ log.Debug("Current Dir: [" + Environment.CurrentDirectory + "]");
- // start the server
- server.Start();
+ NMailServer server = new NMailServer();
+ RemoteAdministration ra = RemoteAdministration.GetInstance(server);
- switch (Environment.OSVersion.Platform) {
- case PlatformID.Unix:
- // drop our root privileges
- MonoPrivileges.MonoPrivileges.SetUser(8);
- MonoPrivileges.MonoPrivileges.SetGroup(12);
- log.Debug("Current user id:" + MonoPrivileges.MonoPrivileges.GetUser());
- log.Debug("Current group id:" + MonoPrivileges.MonoPrivileges.GetGroup());
- break;
- }
+ // initialise the server
+ server.Init();
- // wait for line to be read (signalling a close)
- System.Console.ReadLine();
+ // start the server
+ server.Start();
- // stop services, waiting at most 20 seconds.
- server.Stop(true, TimeSpan.FromSeconds(20));
+ switch (Environment.OSVersion.Platform) {
+ case PlatformID.Unix:
+ // drop our root privileges
+ MonoPrivileges.MonoPrivileges.SetUser(8);
+ MonoPrivileges.MonoPrivileges.SetGroup(12);
+ log.Debug("Current user id:" + MonoPrivileges.MonoPrivileges.GetUser());
+ log.Debug("Current group id:" + MonoPrivileges.MonoPrivileges.GetGroup());
+ break;
+ }
- // Shutdown the remoting channel
- RemoteAdministration.ShutdownChannel();
+ // wait for line to be read (signalling a close)
+ System.Console.ReadLine();
- } catch (Exception e) {
- log.Fatal("Unhandled exception in NMail.", e);
- }
+ // stop services, waiting at most 20 seconds.
+ server.Stop(true, TimeSpan.FromSeconds(20));
+
+ // Shutdown the remoting channel
+ RemoteAdministration.ShutdownChannel();
}
+
+ static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
+ log.Fatal("Unhandled exception in NMail.", e.ExceptionObject as Exception);
+ }
}
}
Modified: NMail/trunk/NMail.Server.Service/NMailService.cs
===================================================================
--- NMail/trunk/NMail.Server.Service/NMailService.cs 2007-07-30 14:13:37 UTC (rev 258)
+++ NMail/trunk/NMail.Server.Service/NMailService.cs 2007-07-30 14:14:09 UTC (rev 259)
@@ -34,33 +34,31 @@
private static ILog log = LogManager.GetLogger(typeof(NMailService));
private NMailServer server;
-
+
public NMailService() {
- try {
- // Change the working directory from System32 to our install directory
- Environment.CurrentDirectory = NMailServer.GetInstallDirectory();
+ // Change the working directory from System32 to our install directory
+ Environment.CurrentDirectory = NMailServer.GetInstallDirectory();
- // output our platform details
- log.Debug("NMail Console Server version: [" + Assembly.GetExecutingAssembly().GetName().Version + "]");
- log.Debug("NMail Library version: [" + Assembly.GetAssembly(typeof(NMailConfiguration)).GetName().Version + "]");
- log.Debug("Platform: [" + Environment.OSVersion.Platform + "]");
- log.Debug("Version: [" + Environment.OSVersion.Version + "]");
- log.Debug("OS: [" + Environment.OSVersion.ToString() + "]");
- log.Debug("Environment: [" + Environment.Version.ToString() + "]");
- log.Debug("Current Dir: [" + Environment.CurrentDirectory + "]");
+ // output our platform details
+ log.Debug("NMail Console Server version: [" + Assembly.GetExecutingAssembly().GetName().Version + "]");
+ log.Debug("NMail Library version: [" + Assembly.GetAssembly(typeof(NMailConfiguration)).GetName().Version + "]");
+ log.Debug("Platform: [" + Environment.OSVersion.Platform + "]");
+ log.Debug("Version: [" + Environment.OSVersion.Version + "]");
+ log.Debug("OS: [" + Environment.OSVersion.ToString() + "]");
+ log.Debug("Environment: [" + Environment.Version.ToString() + "]");
+ log.Debug("Current Dir: [" + Environment.CurrentDirectory + "]");
- this.server = new NMailServer();
- RemoteAdministration ra = RemoteAdministration.GetInstance(this.server);
+ this.server = new NMailServer();
+ RemoteAdministration ra = RemoteAdministration.GetInstance(this.server);
- // initialise the server
- this.server.Init();
-
- } catch (Exception e) {
- log.Fatal("Unhandled exception in NMail.", e);
- throw e;
- }
+ // initialise the server
+ this.server.Init();
}
+ static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
+ log.Fatal("Unhandled exception in NMail.", e.ExceptionObject as Exception);
+ }
+
protected override void OnStart(string[] args) {
this.server.Start();
}
@@ -75,6 +73,9 @@
// configure logging
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("logging.xml"));
+
+ // Setup exception handler
+ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
ServiceBase.Run(new NMailService());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:13:35
|
Revision: 258
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=258&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:13:37 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Work towards fixing NTLM authentication.
Modified Paths:
--------------
NMail/trunk/NMail.ImapService/State/ConnectedState.cs
Modified: NMail/trunk/NMail.ImapService/State/ConnectedState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/ConnectedState.cs 2007-07-30 14:11:51 UTC (rev 257)
+++ NMail/trunk/NMail.ImapService/State/ConnectedState.cs 2007-07-30 14:13:37 UTC (rev 258)
@@ -143,7 +143,7 @@
// Check the hash against our copy
IHashAuthProvider authProvider = (IHashAuthProvider) NMailConfiguration.Current.AuthenticationProvider;
- IAuthenticationToken authToken = authProvider.Authenticate(type3Msg.Username, Convert.ToBase64String(type3Msg.NT));
+ IAuthenticationToken authToken = authProvider.Authenticate(type3Msg.Username, Convert.ToBase64String(type3Msg.NT), HashAuthType.Ntlm);
if (authToken != null) {
this.Session.AuthenticationToken = authToken;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:11:48
|
Revision: 257
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=257&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:11:51 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Fixed a defect in message templates.
Modified Paths:
--------------
NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs
Modified: NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs 2007-07-30 14:11:31 UTC (rev 256)
+++ NMail/trunk/NMail.SetupWizard/SmtpSubSysConfigPanel.cs 2007-07-30 14:11:51 UTC (rev 257)
@@ -229,8 +229,8 @@
ssc.ListenEndPoints.Add(endpoint);
// Save message router config
- mrc.WarningTemplate = "Warning.txt";
- mrc.BounceTemplate = "Bounce.txt";
+ mrc.WarningTemplateFile = "Warning.txt";
+ mrc.BounceTemplateFile = "Bounce.txt";
} else {
// Remove the configuration
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:11:31
|
Revision: 256
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=256&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:11:31 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Removed performance counters.
Modified Paths:
--------------
NMail/trunk/NMail.PostInstall/PostInstallForm.cs
NMail/trunk/NMail.PostInstall/Properties/AssemblyInfo.cs
NMail/trunk/NMail.SmtpService/SmtpService.cs
Modified: NMail/trunk/NMail.PostInstall/PostInstallForm.cs
===================================================================
--- NMail/trunk/NMail.PostInstall/PostInstallForm.cs 2007-07-30 14:10:27 UTC (rev 255)
+++ NMail/trunk/NMail.PostInstall/PostInstallForm.cs 2007-07-30 14:11:31 UTC (rev 256)
@@ -30,8 +30,6 @@
using NMail.SmtpService;
-// TODO: remove "#if !MONO" when perf counters are implemented in Mono
-
namespace NMail.PostInstall {
public partial class PostInstallForm : Form {
@@ -46,35 +44,6 @@
}
}
- private void DeleteSmtpServiceCounters() {
-#if !MONO
- if (PerformanceCounterCategory.Exists(SmtpService.SmtpService.SmtpPerfCounterCategory)) {
- // Remove any old performance counters if they are present
- PerformanceCounterCategory.Delete(SmtpService.SmtpService.SmtpPerfCounterCategory);
- }
-#endif
- }
-
- private void SetupSmtpServiceCounters() {
-#if !MONO
- CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
-
- // Number of connections received
- CounterCreationData cnnReceivedCounter = new CounterCreationData();
- cnnReceivedCounter.CounterType = PerformanceCounterType.NumberOfItems64;
- cnnReceivedCounter.CounterName = SmtpService.SmtpService.TotalConnectionsReceived;
- cnnReceivedCounter.CounterHelp = "The number of incoming connections received by the SMTP service.";
- ccdc.Add(cnnReceivedCounter);
-
- // Create the category with all the counters
- PerformanceCounterCategory.Create(
- SmtpService.SmtpService.SmtpPerfCounterCategory,
- "Performance counters for NMail's SMTP service.",
- PerformanceCounterCategoryType.SingleInstance,
- ccdc);
-#endif
- }
-
private bool NMailInstalled() {
return (GetInstallDirectory() != null);
}
@@ -85,7 +54,7 @@
/// <returns>The install location or null if an error occurs.</returns>
public string GetInstallDirectory() {
string installDirectory = null;
- RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(@"Software\NMail\NMail Server 1.0", false);
+ RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(@"Software\NMail\NMail Server 1.1", false);
if (nmailServerKey != null) {
installDirectory = nmailServerKey.GetValue("InstallDirectory") as string;
@@ -98,10 +67,6 @@
public void Install(object unused) {
try {
- DeleteSmtpServiceCounters();
-
- SetupSmtpServiceCounters();
-
ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = GetInstallDirectory();
psi.FileName = psi.WorkingDirectory + Path.DirectorySeparatorChar + "NMail.SetupWizard.exe";
@@ -116,7 +81,7 @@
public void Uninstall(object unused) {
try {
- DeleteSmtpServiceCounters();
+ // Nothing to do at the moment
} catch (Exception e) {
ShowErrorBox("Error performing uninstall: " + e.Message);
Modified: NMail/trunk/NMail.PostInstall/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.PostInstall/Properties/AssemblyInfo.cs 2007-07-30 14:10:27 UTC (rev 255)
+++ NMail/trunk/NMail.PostInstall/Properties/AssemblyInfo.cs 2007-07-30 14:11:31 UTC (rev 256)
@@ -1,33 +1,35 @@
-using System.Reflection;
+/*
+ * Copyright 2004-2007 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.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NMail.PostInstall")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.PostInstall")]
-[assembly: AssemblyCopyright("Copyright © 2006")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail Post-install Tools.")]
+[assembly: AssemblyVersion("1.1.*")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+[assembly: AssemblyDescription("Provides post-install setup for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2004-2007 Luke Quinane")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5c1a0117-3820-4cff-9de7-75ead9e2ffe1")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
Modified: NMail/trunk/NMail.SmtpService/SmtpService.cs
===================================================================
--- NMail/trunk/NMail.SmtpService/SmtpService.cs 2007-07-30 14:10:27 UTC (rev 255)
+++ NMail/trunk/NMail.SmtpService/SmtpService.cs 2007-07-30 14:11:31 UTC (rev 256)
@@ -88,16 +88,5 @@
return "421 Error - Server busy, try again later.\r\n";
}
}
-
- /// <summary>
- /// The category the SMTP service uses for its performance counters.
- /// </summary>
- public override string PerfCounterCategory {
- get {
- return SmtpPerfCounterCategory;
- }
- }
-
- public const string SmtpPerfCounterCategory = "NMail.SmtpService";
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:10:25
|
Revision: 255
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=255&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:10:27 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Fixed a defect in message templates. Added extra spool methods.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/AbstractMessageRouter.cs
NMail/trunk/NMail.MessageRouter/Configuration/MessageRouterConfiguration.cs
NMail/trunk/NMail.MessageRouter/MessageRouter.cs
Modified: NMail/trunk/NMail/DataTypes/AbstractMessageRouter.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/AbstractMessageRouter.cs 2007-07-30 14:07:38 UTC (rev 254)
+++ NMail/trunk/NMail/DataTypes/AbstractMessageRouter.cs 2007-07-30 14:10:27 UTC (rev 255)
@@ -81,20 +81,36 @@
/// </summary>
/// <param name="messageRecipient">The recipient to validate.</param>
/// <returns>The result of the request.</returns>
- abstract protected DeliveryResult ValidateRecipientInternal(SmtpMessageRecipient messageRecipient);
+ protected abstract DeliveryResult ValidateRecipientInternal(SmtpMessageRecipient messageRecipient);
/// <summary>
/// Spool a mail message.
/// </summary>
/// <param name="message">The message to be spooled.</param>
/// <returns>The result of the request.</returns>
- abstract public DeliveryResult SpoolMessage(SmtpMessage message);
+ public abstract DeliveryResult SpoolMessage(SmtpMessage message);
/// <summary>
/// Deliver a group of messages, including both connecting to remote SMTP
/// servers and the local store.
/// </summary>
/// <param name="batch">The batch of messages to deliver</param>
- abstract public void DeliverMessages(DeliveryBatch batch);
+ public abstract void DeliverMessages(DeliveryBatch batch);
+
+ /// <summary>
+ /// Creates a bouce message for the given recipient.
+ /// </summary>
+ /// <param name="message">The message that was being sent.</param>
+ /// <param name="deliveryResult">The recipient and result to create the bounce from.</param>
+ /// <returns>The message.</returns>
+ public abstract SmtpMessage CreateBounceMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult);
+
+ /// <summary>
+ /// Creates a warning message for the given recipient.
+ /// </summary>
+ /// <param name="message">The message that was being sent.</param>
+ /// <param name="deliveryResult">The recipient and result to create the warning from.</param>
+ /// <returns>The message.</returns>
+ public abstract SmtpMessage CreateWarningMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult);
}
}
Modified: NMail/trunk/NMail.MessageRouter/Configuration/MessageRouterConfiguration.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/Configuration/MessageRouterConfiguration.cs 2007-07-30 14:07:38 UTC (rev 254)
+++ NMail/trunk/NMail.MessageRouter/Configuration/MessageRouterConfiguration.cs 2007-07-30 14:10:27 UTC (rev 255)
@@ -113,29 +113,51 @@
}
/// <summary>
- /// TThe template to used to create a warning message.
+ /// The file containing the template to used to create a warning message.
/// </summary>
- [ConfigurationProperty("WarningTemplate", IsRequired = true)]
- public string WarningTemplate {
+ [ConfigurationProperty("WarningTemplateFile", IsRequired = true)]
+ public string WarningTemplateFile {
get {
- return (string) this["WarningTemplate"];
+ return (string) this["WarningTemplateFile"];
}
set {
- this["WarningTemplate"] = value;
+ this["WarningTemplateFile"] = value;
}
}
/// <summary>
- /// The template used to create bounce messages.
+ /// The file containing the template used to create bounce messages.
/// </summary>
- [ConfigurationProperty("BounceTemplate", IsRequired = true)]
- public string BounceTemplate {
+ [ConfigurationProperty("BounceTemplateFile", IsRequired = true)]
+ public string BounceTemplateFile {
get {
- return (string) this["BounceTemplate"];
+ return (string) this["BounceTemplateFile"];
}
set {
- this["BounceTemplate"] = value;
+ this["BounceTemplateFile"] = value;
}
}
+
+ /// <summary>
+ /// TThe template to used to create a warning message.
+ /// </summary>
+ public string WarningTemplate {
+ get {
+ using (StreamReader reader = new StreamReader(WarningTemplateFile)) {
+ return reader.ReadToEnd();
+ }
+ }
+ }
+
+ /// <summary>
+ /// The template used to create bounce messages.
+ /// </summary>
+ public string BounceTemplate {
+ get {
+ using (StreamReader reader = new StreamReader(BounceTemplateFile)) {
+ return reader.ReadToEnd();
+ }
+ }
+ }
}
}
Modified: NMail/trunk/NMail.MessageRouter/MessageRouter.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-07-30 14:07:38 UTC (rev 254)
+++ NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-07-30 14:10:27 UTC (rev 255)
@@ -164,7 +164,7 @@
/// <param name="message">The message that was being sent.</param>
/// <param name="deliveryResult">The recipient and result to create the bounce from.</param>
/// <returns>The message.</returns>
- public SmtpMessage CreateBounceMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult) {
+ public override SmtpMessage CreateBounceMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult) {
return CreateFailureMessage(Config.Current.BounceTemplate,
message,
message.Sender,
@@ -177,7 +177,7 @@
/// <param name="message">The message that was being sent.</param>
/// <param name="deliveryResult">The recipient and result to create the warning from.</param>
/// <returns>The message.</returns>
- public SmtpMessage CreateWarningMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult) {
+ public override SmtpMessage CreateWarningMessage(SmtpMessage message, RecipientDeliveryResult deliveryResult) {
return CreateFailureMessage(Config.Current.WarningTemplate,
message,
message.Sender,
@@ -195,7 +195,7 @@
public SmtpMessage CreateFailureMessage(string template, SmtpMessage message, EmailAddress sender, RecipientDeliveryResult deliveryResult) {
// Replace all the place holders
template = template.Replace("{FROM}",
- string.Format("\"Mail delivery system\" <postmaster@{0}", Config.Current.VisibleHost));
+ string.Format("\"Mail delivery system\" <postmaster@{0}>", Config.Current.VisibleHost));
template = template.Replace("{TO}", message.Sender.ToString(true));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:07:38
|
Revision: 254
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=254&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:07:38 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Some changes for MySQL.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-localstore-configuration.xml
NMail/trunk/NMail.SpoolData.NHibernate/hibernate-spool-configuration.xml
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml 2007-07-30 14:06:58 UTC (rev 253)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml 2007-07-30 14:07:38 UTC (rev 254)
@@ -24,7 +24,7 @@
<list name="AdditionalHosts" table="MailDomainHosts">
<key column="MailDomainId" />
<index column="ChildIndex" type="Int32" />
- <element column="Host" unique="true" type="Serializable" />
+ <element column="Host" type="Serializable" /> <!-- MySQL dialect can't hack this: unique="true" -->
</list>
<list name="MailboxMappings" table="MailDomainMailboxMappings">
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml 2007-07-30 14:06:58 UTC (rev 253)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml 2007-07-30 14:07:38 UTC (rev 254)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
- <class name="NMail.LocalStoreData.NHibernate.InternalStoreFolder" table="Folder">
+ <class name="NMail.LocalStoreData.NHibernate.InternalStoreFolder" table="t_Folder">
<id name="FolderId" type="Int32" unsaved-value="0">
<column name="FolderId" not-null="true"/>
<generator class="native" />
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-localstore-configuration.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-localstore-configuration.xml 2007-07-30 14:06:58 UTC (rev 253)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-localstore-configuration.xml 2007-07-30 14:07:38 UTC (rev 254)
@@ -2,9 +2,9 @@
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
- <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
- <property name="connection.connection_string">Data Source=127.0.0.1;Initial Catalog=NMailLocalStore;Integrated Security=True</property>
- <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
+ <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
+ <property name="connection.connection_string">Host=127.0.0.1;Database=NMailLocalStore;Uid=root;Password=bis6ocha</property>
+ <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="hibernate.query.substitutions">true 1, false 0</property>
</session-factory>
</hibernate-configuration>
Modified: NMail/trunk/NMail.SpoolData.NHibernate/hibernate-spool-configuration.xml
===================================================================
--- NMail/trunk/NMail.SpoolData.NHibernate/hibernate-spool-configuration.xml 2007-07-30 14:06:58 UTC (rev 253)
+++ NMail/trunk/NMail.SpoolData.NHibernate/hibernate-spool-configuration.xml 2007-07-30 14:07:38 UTC (rev 254)
@@ -2,9 +2,9 @@
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
- <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
- <property name="connection.connection_string">Data Source=127.0.0.1;Initial Catalog=NMailSpool;Integrated Security=True</property>
- <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
+ <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
+ <property name="connection.connection_string">Host=127.0.0.1;Database=NMailSpool;Uid=NMail;Password=moo</property>
+ <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="hibernate.query.substitutions">true 1, false 0</property>
</session-factory>
</hibernate-configuration>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:06:56
|
Revision: 253
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=253&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:06:58 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Fixed some defects in NHibernate xml.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalSystemAce.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalSystemAce.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalSystemAce.hbm.xml 2007-07-30 14:04:37 UTC (rev 252)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalSystemAce.hbm.xml 2007-07-30 14:06:58 UTC (rev 253)
@@ -7,11 +7,11 @@
<generator class="native" />
</id>
- <property name="Identifier" not-null="true" unique="true"/>
+ <property name="Identifier" not-null="true"/>
- <property name="AceType" not-null="true" unique="true"/>
+ <property name="AceType" not-null="true"/>
- <property name="Privilege" not-null="true" unique="true"/>
+ <property name="Privilege" not-null="true"/>
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml 2007-07-30 14:04:37 UTC (rev 252)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml 2007-07-30 14:06:58 UTC (rev 253)
@@ -7,11 +7,11 @@
<generator class="native" />
</id>
- <property name="Identifier" not-null="true" unique="true"/>
+ <property name="Identifier" not-null="true"/>
- <property name="AceType" not-null="true" unique="true"/>
+ <property name="AceType" not-null="true"/>
- <property name="Privilege" not-null="true" unique="true"/>
+ <property name="Privilege" not-null="true"/>
</class>
</hibernate-mapping>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 14:04:36
|
Revision: 252
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=252&view=rev
Author: tmyroadctfig
Date: 2007-07-30 07:04:37 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Added a memory class. Added new create folder overload.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs
NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs
NMail/trunk/NMail/DataTypes/Message/Message.cs
NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs
NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs
NMail/trunk/NMail/DataTypes/Message/MultipartMessageBody.cs
NMail/trunk/NMail/DataTypes/Message/SimpleMessageBody.cs
NMail/trunk/NMail/DataTypes/SmtpMessage.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.ImapService/State/ExamineState.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs
NMail/trunk/NMail.SmtpClient/SmtpClient.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageSizeTest1.cs
Added Paths:
-----------
NMail/trunk/NMail/DataTypes/Memory.cs
NMail/trunk/NMail.UnitTests/DataTypes/MemoryTests.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -103,6 +103,19 @@
/// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
/// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
/// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ void CreateFolder(IAuthenticationToken authToken, StoreFolder newFolder);
+
+ /// <summary>
+ /// Creates a new folder.
+ /// </summary>
+ /// <remarks>
+ /// It is a requirement of the local store that each new folder get an incremented Id number.
+ /// </remarks>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="newFolder">The folder to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
void CreateFolder(IAuthenticationToken authToken, string newFolder);
/// <summary>
@@ -265,8 +278,8 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the size from.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
- /// <returns>The message size in bytes or null if invalid folder or privileges.</returns>
- int? GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId);
+ /// <returns>The message size or null if invalid folder or privileges.</returns>
+ Memory GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Gets the headers for the message.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -220,8 +220,8 @@
/// </summary>
/// <param name="messageId">The Id of the message to get the size from.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
- /// <returns>The message size in bytes or null if non is found.</returns>
- int? GetMessageSize(int messageId, int folderId);
+ /// <returns>The message size or null if non is found.</returns>
+ Memory GetMessageSize(int messageId, int folderId);
/// <summary>
/// Gets the headers for the message.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -43,7 +43,7 @@
/// <param name="userFolderId">The Id of the user's nominal folder.</param>
/// <param name="quotaWarnLimit">The user's warning quota limit.</param>
/// <param name="quotaHardLimit">The user's hard quota limit.</param>
- public LocalStoreUser(string username, int userId, int userFolderId, int? quotaWarnLimit, int? quotaHardLimit) {
+ public LocalStoreUser(string username, int userId, int userFolderId, Memory quotaWarnLimit, Memory quotaHardLimit) {
this.username = username;
this.userId = userId;
this.userFolderId = userFolderId;
@@ -102,7 +102,7 @@
}
}
- private int? quotaHardLimit;
+ private Memory quotaHardLimit;
/// <summary>
/// The user's hard quota limit (null for no hard limit).
@@ -110,7 +110,7 @@
[Category("User Details")]
[Description("The user's hard quota.")]
[DisplayName("Hard Quota Limit")]
- public int? QuotaHardLimit {
+ public Memory QuotaHardLimit {
get {
return this.quotaHardLimit;
}
@@ -119,7 +119,7 @@
}
}
- private int? quotaWarnLimit;
+ private Memory quotaWarnLimit;
/// <summary>
/// The limit above which the user will recieve a warning (null for no warning).
@@ -127,7 +127,7 @@
[Category("User Details")]
[Description("The user's warning quota.")]
[DisplayName("Warning Quota Limit")]
- public int? QuotaWarnLimit {
+ public Memory QuotaWarnLimit {
get {
return this.quotaWarnLimit;
}
Added: NMail/trunk/NMail/DataTypes/Memory.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Memory.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Memory.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -0,0 +1,216 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes {
+ /// <summary>
+ /// Represents a unit of memory.
+ /// </summary>
+ [Serializable]
+ public class Memory {
+
+ /// <summary>
+ /// Creates a new instance from the given quantity.
+ /// </summary>
+ /// <param name="quantity">The quantity of memory to represent.</param>
+ public Memory(long quantity) {
+ this.memory = quantity;
+ }
+
+ /// <summary>
+ /// Creates a new instance from the given string.
+ /// </summary>
+ /// <param name="memoryStr">The quantity of memory to represent.</param>
+ public Memory(string memoryStr) {
+ int power = 0;
+ memoryStr = memoryStr.Trim().ToLower();
+
+ if (memoryStr.EndsWith("gb")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 2, 2);
+ power = 3;
+ } else if (memoryStr.EndsWith("g")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 1, 1);
+ power = 3;
+ } else if (memoryStr.EndsWith("mb")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 2, 2);
+ power = 2;
+ } else if (memoryStr.EndsWith("m")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 1, 1);
+ power = 2;
+ } else if (memoryStr.EndsWith("kb")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 2, 2);
+ power = 1;
+ } else if (memoryStr.EndsWith("k")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 1, 1);
+ power = 1;
+ } else if (memoryStr.EndsWith("b")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 1, 1);
+ power = 0;
+ } else if (memoryStr.EndsWith("bytes")) {
+ memoryStr = memoryStr.Remove(memoryStr.Length - 5, 5);
+ power = 0;
+ }
+
+ long memVal = Int64.Parse(memoryStr);
+
+ this.memory = memVal * (long) Math.Pow(OneKb, power);
+ }
+
+ public static Memory ParseNullable(string memoryStr) {
+ memoryStr = memoryStr.Trim().ToLower();
+
+ if (memoryStr == string.Empty || memoryStr == "null") {
+ return null;
+ } else {
+ return new Memory(memoryStr);
+ }
+ }
+
+ private long memory;
+
+ /// <summary>
+ /// The quantity of memory represented by this instance.
+ /// </summary>
+ public long Value {
+ get {
+ return this.memory;
+ }
+ }
+
+ /// <summary>
+ /// The memory in kilobytes.
+ /// </summary>
+ public double AsKiloBytes {
+ get {
+ return this.memory / OneKb;
+ }
+ }
+
+ /// <summary>
+ /// The memory in megabytes.
+ /// </summary>
+ public double AsMegaBytes {
+ get {
+ return this.memory / (OneKb * OneKb);
+ }
+ }
+
+ /// <summary>
+ /// The memory in gigabytes.
+ /// </summary>
+ public double AsGigaBytes {
+ get {
+ return this.memory / (OneKb * OneKb * OneKb);
+ }
+ }
+
+ #region ToString
+ /// <summary>
+ /// Converts the memory to a string.
+ /// </summary>
+ /// <returns>The memory as a string.</returns>
+ public override string ToString() {
+ if (this.memory > Math.Pow(OneKb, 3)) {
+ return string.Format("{0} Gb", (long) this.AsGigaBytes);
+
+ } else if (this.memory > Math.Pow(OneKb, 2)) {
+ return string.Format("{0} Mb", (long) this.AsMegaBytes);
+
+ } else if (this.memory > OneKb) {
+ return string.Format("{0} Kb", (long) this.AsKiloBytes);
+
+ } else {
+ return string.Format("{0} bytes", this.memory);
+ }
+ }
+
+ /// <summary>
+ /// Converts the memory to a string.
+ /// </summary>
+ /// <param name="format">The format to return the memory in.</param>
+ /// <returns>The memory as a string.</returns>
+ public string ToString(string format) {
+ if (format == "g") {
+ return string.Format("{0} Gb", this.AsGigaBytes);
+
+ } else if (format == "m") {
+ return string.Format("{0} Mb", (long) this.AsMegaBytes);
+
+ } else if (format == "k") {
+ return string.Format("{0} Kb", (long) this.AsKiloBytes);
+
+ } else if (format == "b") {
+ return string.Format("{0} bytes", this.memory);
+
+ } else if (format == "G") {
+ return string.Format("{0} G", this.AsGigaBytes);
+
+ } else if (format == "M") {
+ return string.Format("{0} M", (long) this.AsMegaBytes);
+
+ } else if (format == "K") {
+ return string.Format("{0} K", (long) this.AsKiloBytes);
+
+ } else if (format == "B") {
+ return string.Format("{0}", this.memory);
+
+ } else {
+ throw new FormatException("Invalid format string.");
+ }
+ }
+ #endregion
+
+ #region Operators
+
+ public static Memory operator +(Memory m1, Memory m2) {
+ return new Memory(m1.memory + m2.memory);
+ }
+
+ public static Memory operator +(Memory m1, int i) {
+ return new Memory(m1.memory + i);
+ }
+
+ public static Memory operator +(Memory m1, long l) {
+ return new Memory(m1.memory + l);
+ }
+
+ public static Memory operator -(Memory m1, Memory m2) {
+ return new Memory(m1.memory - m2.memory);
+ }
+
+ public static Memory operator -(Memory m1, int i) {
+ return new Memory(m1.memory - i);
+ }
+
+ public static Memory operator -(Memory m1, long l) {
+ return new Memory(m1.memory - l);
+ }
+
+ public static bool operator >(Memory m1, Memory m2) {
+ return m1.memory > m2.memory;
+ }
+
+ public static bool operator >(Memory m1, long l) {
+ return m1.memory > l;
+ }
+
+ public static bool operator <(Memory m1, Memory m2) {
+ return m1.memory < m2.memory;
+ }
+
+ public static bool operator <(Memory m1, long l) {
+ return m1.memory < l;
+ }
+ #endregion
+
+ /// <summary>
+ /// The value for one kilobyte.
+ /// </summary>
+ public const long OneKb = 1024;
+
+ /// <summary>
+ /// A memory unit zero in size.
+ /// </summary>
+ public static readonly Memory Zero = new Memory(0);
+ }
+}
Modified: NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -85,12 +85,12 @@
set { bodyCharacterCount = value; }
}
- private int size;
+ private Memory size;
/// <summary>
/// The size of this part in bytes.
/// </summary>
- public int Size {
+ public Memory Size {
get { return size; }
set { size = value; }
}
Modified: NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -30,6 +30,6 @@
/// <summary>
/// The size of the data in bytes.
/// </summary>
- int Size { get; }
+ Memory Size { get; }
}
}
Modified: NMail/trunk/NMail/DataTypes/Message/Message.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/Message.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/Message.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -176,7 +176,7 @@
/// <summary>
/// The size of the data in bytes.
/// </summary>
- public int Size {
+ public Memory Size {
get {
return this.body.Size;
}
Modified: NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -67,9 +67,9 @@
/// <summary>
/// The size of the data in bytes.
/// </summary>
- public virtual int Size {
+ public virtual Memory Size {
get {
- return this.data.Length;
+ return new Memory(this.data.Length);
}
}
Modified: NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -196,9 +196,9 @@
/// <summary>
/// Returns the size in bytes for the raw headers.
/// </summary>
- public int Size {
+ public Memory Size {
get {
- return this.rawHeaders.Length;
+ return new Memory(this.rawHeaders.Length);
}
}
Modified: NMail/trunk/NMail/DataTypes/Message/MultipartMessageBody.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/MultipartMessageBody.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/MultipartMessageBody.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -129,9 +129,9 @@
/// <summary>
/// The size of the data in bytes.
/// </summary>
- public int Size {
+ public Memory Size {
get {
- int size = this.headers.Size + Message.Terminator.Length;
+ Memory size = this.headers.Size + Message.Terminator.Length;
if (this.preamble != null) {
// Add the preamble size if present
@@ -163,7 +163,7 @@
/// </summary>
public ByteString BodyData {
get {
- ByteStringBuilder result = new ByteStringBuilder(Encoding.ASCII, this.Size);
+ ByteStringBuilder result = new ByteStringBuilder(Encoding.ASCII, (int) this.Size.Value);
if (this.preamble != null) {
result.Append(this.preamble.Data);
Modified: NMail/trunk/NMail/DataTypes/Message/SimpleMessageBody.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/SimpleMessageBody.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/Message/SimpleMessageBody.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -69,7 +69,7 @@
/// <summary>
/// The size of the data in bytes.
/// </summary>
- public override int Size {
+ public override Memory Size {
get {
return this.headers.Size + Message.Terminator.Length + this.data.Length;
}
Modified: NMail/trunk/NMail/DataTypes/SmtpMessage.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -117,8 +117,8 @@
/// <summary>
/// The size of the message in bytes.
/// </summary>
- public int MessageSize {
- get { return this.message.Size; }
+ public long MessageSize {
+ get { return this.message.Size.Value; }
private set { } // Hack: for NHibernate
}
Modified: NMail/trunk/NMail/NMail.csproj
===================================================================
--- NMail/trunk/NMail/NMail.csproj 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail/NMail.csproj 2007-07-30 14:04:37 UTC (rev 252)
@@ -150,6 +150,8 @@
<Compile Include="DataTypes\Classification.cs" />
<Compile Include="DataTypes\LatLong.cs" />
<Compile Include="DataTypes\Message\IMultipartMessageBody.cs" />
+ <Compile Include="DataTypes\Metrics\MetricAttribute.cs" />
+ <Compile Include="DataTypes\Metrics\MetricType.cs" />
<Compile Include="DataTypes\Service\BaseService.cs" />
<Compile Include="DataTypes\Service\BaseSession.cs" />
<Compile Include="DataTypes\Message\Envelope.cs" />
@@ -248,6 +250,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Helper\IPEndpointHelper.cs" />
+ <Compile Include="DataTypes\Memory.cs" />
<Compile Include="Helper\MessageHelper.cs">
<SubType>Code</SubType>
</Compile>
Modified: NMail/trunk/NMail.ImapService/State/ExamineState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -224,9 +224,9 @@
#region sendMessageSize
protected virtual void sendMessageSize(FetchResponse response, int messageUid) {
- int? messageSize = LocalStore.GetMessageSize(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
+ Memory messageSize = LocalStore.GetMessageSize(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
- if (messageSize.HasValue) {
+ if (messageSize != null) {
response.AppendResponseItem("RFC822.SIZE " + messageSize.Value);
}
}
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -355,6 +355,65 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="newFolder">The folder to create.</param>
/// <returns>The result of the create attempt.</returns>
+ public void CreateFolder(IAuthenticationToken authToken, StoreFolder newFolder) {
+ if (newFolder.Parent != null) {
+ StoreFolder parent = null;
+
+ // Get the parent folder
+ if (newFolder.ParentId.HasValue && newFolder.ParentId.Value != 0) {
+ parent = GetStoreFolder(authToken, newFolder.ParentId.Value);
+ } else {
+ Folder resolvedFolder = getResolvedFolder(authToken, newFolder.FullFolderName);
+ parent = GetStoreFolder(authToken, resolvedFolder.Parent.FullyQualifiedName);
+ }
+
+ if (parent != null) {
+ // Ensure the user has rights to get the message flags
+ if (hasFolderPrivilege(authToken.Username, parent.FolderId, StoreFolderPrivilege.CreateFolders)) {
+
+ // Get the user Id
+ LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
+ if (user == null) {
+ throw new InvalidOperationException("Can't get a user from the current username.");
+ }
+
+ // Ensure only administrators can create folders in someone else's name
+ if (!hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
+ newFolder.OwnerUserId = user.UserId;
+ }
+
+ // Create the mailbox
+ LocalStoreData.CreateFolder(newFolder);
+
+ // Create an ACL for the folder
+ GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(user.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
+ LocalStoreData.SetStoreFolderAce(newFolder.FolderId, ace);
+
+ } else {
+ // Don't have privileges to create the folder
+ throw new ArgumentException("Invalid folder Id.");
+ }
+
+ } else {
+ // Invalid parent folder
+ throw new ArgumentException("Invalid folder Id.");
+ }
+
+ } else {
+ // Currently can't create a folder without a parent
+ throw new ArgumentException("Invalid folder Id.");
+ }
+ }
+
+ /// <summary>
+ /// Creates a new folder.
+ /// </summary>
+ /// <remarks>
+ /// It is a requirement of the local store that each new folder get an incremented Id number.
+ /// </remarks>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="newFolder">The folder to create.</param>
+ /// <returns>The result of the create attempt.</returns>
public void CreateFolder(IAuthenticationToken authToken, string newFolder) {
Folder resolvedFolder = getResolvedFolder(authToken, newFolder);
@@ -845,8 +904,8 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the size from.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
- /// <returns>The message size in bytes or null if invalid folder or privileges.</returns>
- public int? GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId) {
+ /// <returns>The message size or null if invalid folder or privileges.</returns>
+ public Memory GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message size
if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -27,7 +27,7 @@
this.postamble = (multipartBody == null) ? null : multipartBody.Postamble;
this.mimeBoundary = (multipartBody == null) ? null : multipartBody.MimeBoundary;
- this.size = message.Size;
+ this.size = message.Size.Value;
if (this.mimeMessage) {
this.mimeParts = multipartBody.MimeParts;
@@ -64,9 +64,9 @@
set { this.mimeMessage = value; }
}
- private int size;
+ private long size;
- internal int Size {
+ internal long Size {
get { return size; }
set { size = value; }
}
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml 2007-07-30 14:04:37 UTC (rev 252)
@@ -12,9 +12,9 @@
<!-- TODO: ideally this would be a many-to-one relationship with StoreFolder -->
<property name="UserFolderId" />
- <property name="QuotaHardLimit" />
+ <property name="QuotaHardLimit" type="Serializable"/>
- <property name="QuotaWarnLimit" />
+ <property name="QuotaWarnLimit" type="Serializable"/>
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -756,15 +756,15 @@
/// </summary>
/// <param name="messageId">The Id of the message to get the size from.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
- /// <returns>The message size in bytes or null if non is found.</returns>
- public int? GetMessageSize(int messageId, int folderId) {
+ /// <returns>The message size or null if non is found.</returns>
+ public Memory GetMessageSize(int messageId, int folderId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
InternalMessage message = session.CreateCriteria(typeof(InternalMessage))
.Add(Expression.Eq("FolderId", folderId))
.Add(Expression.Eq("FolderMessageId", messageId))
.UniqueResult<InternalMessage>();
- return (message == null) ? null : (int?) message.Size;
+ return (message == null) ? null : new Memory(message.Size);
}
}
#endregion
Modified: NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -18,7 +18,7 @@
public BodyStructureSerializer(BodyStructure bodyStructure) {
this.headers = new MessageHeadersSerializer(bodyStructure.Headers);
- this.size = bodyStructure.Size;
+ this.size = bodyStructure.Size.Value;
foreach (BodyStructure child in bodyStructure) {
this.parts.Add(new BodyStructureSerializer(child));
@@ -32,9 +32,9 @@
set { headers = value; }
}
- private int size;
+ private long size;
- public int Size {
+ public long Size {
get { return size; }
set { size = value; }
}
Modified: NMail/trunk/NMail.SmtpClient/SmtpClient.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -416,7 +416,7 @@
private void SimpleSendData(SmtpMessage smtpMessage) {
this.connection.DataContents(smtpMessage.Message);
- int blocks = smtpMessage.Message.Size / 1024;
+ int blocks = (int) smtpMessage.Message.Size.AsKiloBytes;
blocks = (blocks > 0) ? blocks : 1;
this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
Added: NMail/trunk/NMail.UnitTests/DataTypes/MemoryTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/DataTypes/MemoryTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/DataTypes/MemoryTests.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+
+namespace NMail.UnitTests.DataTypes {
+ /// <summary>
+ /// Unit tests for the Memory class.
+ /// </summary>
+ [TestFixture]
+ public class MemoryTests {
+ /// <summary>
+ /// Tests the parsing of memory quantities.
+ /// </summary>
+ [Test]
+ public void CheckParsing() {
+ Memory m1 = null;
+
+ m1 = new Memory("1000");
+ Assert.AreEqual(1000, m1.Value);
+
+ m1 = new Memory("120 bytes");
+ Assert.AreEqual(120, m1.Value);
+
+ m1 = new Memory("150 b");
+ Assert.AreEqual(150, m1.Value);
+
+ m1 = new Memory("120bytes");
+ Assert.AreEqual(120, m1.Value);
+
+ m1 = new Memory("150b");
+ Assert.AreEqual(150, m1.Value);
+
+ m1 = new Memory("43Kb");
+ Assert.AreEqual(44032, m1.Value);
+
+ m1 = new Memory("43 Kb");
+ Assert.AreEqual(44032, m1.Value);
+
+ m1 = new Memory("43K");
+ Assert.AreEqual(44032, m1.Value);
+
+ m1 = new Memory("43 K");
+ Assert.AreEqual(44032, m1.Value);
+
+ m1 = new Memory("34Mb");
+ Assert.AreEqual(35651584, m1.Value);
+
+ m1 = new Memory("34 Mb");
+ Assert.AreEqual(35651584, m1.Value);
+
+ m1 = new Memory("34M");
+ Assert.AreEqual(35651584, m1.Value);
+
+ m1 = new Memory("34 M");
+ Assert.AreEqual(35651584, m1.Value);
+
+ m1 = new Memory("86Gb");
+ Assert.AreEqual(92341796864, m1.Value);
+
+ m1 = new Memory("86 Gb");
+ Assert.AreEqual(92341796864, m1.Value);
+
+ m1 = new Memory("86G");
+ Assert.AreEqual(92341796864, m1.Value);
+
+ m1 = new Memory("86 G");
+ Assert.AreEqual(92341796864, m1.Value);
+ }
+
+ /// <summary>
+ /// Tests the parsing of memory nullable quantities.
+ /// </summary>
+ [Test]
+ public void CheckNullParsing() {
+ Memory m1 = null;
+
+ m1 = Memory.ParseNullable("");
+ Assert.IsNull(m1);
+
+ m1 = Memory.ParseNullable("null");
+ Assert.IsNull(m1);
+
+ m1 = Memory.ParseNullable("120k");
+ Assert.IsNotNull(m1);
+ }
+
+ /// <summary>
+ /// Tests the "as" properties.
+ /// </summary>
+ [Test]
+ public void CheckAsProperties() {
+ Memory m1 = null;
+
+ m1 = new Memory("120k");
+ Assert.AreEqual(120, m1.AsKiloBytes);
+
+ m1 = new Memory("120m");
+ Assert.AreEqual(120, m1.AsMegaBytes);
+
+ m1 = new Memory("120g");
+ Assert.AreEqual(120, m1.AsGigaBytes);
+ }
+
+ /// <summary>
+ /// Tests the operator overloads.
+ /// </summary>
+ [Test]
+ public void CheckOperators() {
+ Memory m1 = null;
+ Memory m2 = null;
+ Memory m3 = null;
+
+ m1 = new Memory("12 b");
+ m2 = new Memory("11 b");
+ m3 = m1 + m2;
+ Assert.AreEqual(23, m3.Value);
+
+ m1 = new Memory("12 b");
+ int i = 15;
+ m3 = m1 + i;
+ Assert.AreEqual(27, m3.Value);
+
+ m1 = new Memory("12 b");
+ long l = 20;
+ m3 = m1 + l;
+ Assert.AreEqual(32, m3.Value);
+
+ m1 = new Memory(123);
+ m2 = new Memory(456);
+
+ Assert.IsTrue(m1 > 10);
+ Assert.IsFalse(m1 > 1000);
+
+ Assert.IsTrue(m2 > m1);
+ Assert.IsFalse(m1 > m2);
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageSizeTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageSizeTest1.cs 2007-07-30 13:56:42 UTC (rev 251)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageSizeTest1.cs 2007-07-30 14:04:37 UTC (rev 252)
@@ -31,10 +31,10 @@
int m1Uid = this.localStoreData.GetMessageId(1, user1.UserFolderId);
Assert.IsTrue(m1Uid > 0, "Valid message Id.");
- int? size1 = this.localStoreData.GetMessageSize(m1Uid, user1.UserFolderId);
+ Memory size1 = this.localStoreData.GetMessageSize(m1Uid, user1.UserFolderId);
Assert.IsNotNull(size1, "Valid size.");
- int? size2 = this.localStoreData.GetMessageSize(0, user1.UserFolderId);
+ Memory size2 = this.localStoreData.GetMessageSize(0, user1.UserFolderId);
Assert.IsNull(size2, "Invalid size.");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-07-30 13:56:41
|
Revision: 251
http://nmailserver.svn.sourceforge.net/nmailserver/?rev=251&view=rev
Author: tmyroadctfig
Date: 2007-07-30 06:56:42 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
Lots of work on NMail winforms administration tool.
Modified Paths:
--------------
NMail/trunk/NMail.Administration.WinForms/ExceptionDialog.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Groups/GroupManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Groups/GroupManager.cs
NMail/trunk/NMail.Administration.WinForms/Groups/GroupManager.resx
NMail/trunk/NMail.Administration.WinForms/MailDomain/MailDomainEditor.Designer.cs
NMail/trunk/NMail.Administration.WinForms/MailDomain/MailDomainEditor.cs
NMail/trunk/NMail.Administration.WinForms/MailDomain/MailDomainEditor.resx
NMail/trunk/NMail.Administration.WinForms/MailDomain/MailDomainManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/MailDomain/MailDomainManager.cs
NMail/trunk/NMail.Administration.WinForms/MainForm.cs
NMail/trunk/NMail.Administration.WinForms/NMail.Administration.WinForms.csproj
NMail/trunk/NMail.Administration.WinForms/Properties/AssemblyInfo.cs
NMail/trunk/NMail.Administration.WinForms/Spool/SmtpSpoolManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Spool/SmtpSpoolManager.cs
NMail/trunk/NMail.Administration.WinForms/Spool/SpoolMessageViewer.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Spool/SpoolMessageViewer.cs
NMail/trunk/NMail.Administration.WinForms/Spool/SpoolMessageViewer.resx
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.resx
NMail/trunk/NMail.Administration.WinForms/Users/UserManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserManager.cs
NMail/trunk/NMail.Icons/NMail.Icons.csproj
NMail/trunk/NMail.Icons/Properties/AssemblyInfo.cs
Added Paths:
-----------
NMail/trunk/NMail.Administration.WinForms/Folders/
NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.cs
NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.resx
NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.cs
NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.resx
NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.cs
NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.resx
NMail/trunk/NMail.Administration.WinForms/Groups/SelectGroupDialog.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Groups/SelectGroupDialog.cs
NMail/trunk/NMail.Administration.WinForms/Groups/SelectGroupDialog.resx
NMail/trunk/NMail.Administration.WinForms/MailDomain/AddHostDialog.Designer.cs
NMail/trunk/NMail.Administration.WinForms/MailDomain/AddHostDialog.cs
NMail/trunk/NMail.Administration.WinForms/MailDomain/AddHostDialog.resx
NMail/trunk/NMail.Administration.WinForms/Users/SelectUserDialog.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/SelectUserDialog.cs
NMail/trunk/NMail.Administration.WinForms/Users/SelectUserDialog.resx
NMail/trunk/NMail.Administration.WinForms/Users/SetPasswordForm.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/SetPasswordForm.cs
NMail/trunk/NMail.Administration.WinForms/Users/SetPasswordForm.resx
NMail/trunk/NMail.Icons/Resources/16x16/actions/add_group.png
NMail/trunk/NMail.Icons/Resources/16x16/actions/delete_group.png
NMail/trunk/NMail.Icons/Resources/16x16/actions/question.png
Modified: NMail/trunk/NMail.Administration.WinForms/ExceptionDialog.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/ExceptionDialog.Designer.cs 2007-06-26 12:47:19 UTC (rev 250)
+++ NMail/trunk/NMail.Administration.WinForms/ExceptionDialog.Designer.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -28,13 +28,19 @@
this.errorIcon = new System.Windows.Forms.PictureBox();
this.exitButton = new System.Windows.Forms.Button();
this.reportButton = new System.Windows.Forms.Button();
+ this.bottomPanel = new System.Windows.Forms.Panel();
+ this.rightBottomPanel = new System.Windows.Forms.Panel();
+ this.leftPanel = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize) (this.errorIcon)).BeginInit();
+ this.bottomPanel.SuspendLayout();
+ this.rightBottomPanel.SuspendLayout();
+ this.leftPanel.SuspendLayout();
this.SuspendLayout();
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.okButton.Location = new System.Drawing.Point(221, 125);
+ this.okButton.Location = new System.Drawing.Point(94, 8);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 0;
@@ -44,12 +50,13 @@
//
// exceptionDetailBox
//
- this.exceptionDetailBox.Location = new System.Drawing.Point(50, 12);
+ this.exceptionDetailBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.exceptionDetailBox.Location = new System.Drawing.Point(54, 0);
this.exceptionDetailBox.Multiline = true;
this.exceptionDetailBox.Name = "exceptionDetailBox";
this.exceptionDetailBox.ReadOnly = true;
this.exceptionDetailBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
- this.exceptionDetailBox.Size = new System.Drawing.Size(327, 107);
+ this.exceptionDetailBox.Size = new System.Drawing.Size(335, 105);
this.exceptionDetailBox.TabIndex = 1;
this.exceptionDetailBox.WordWrap = false;
//
@@ -63,7 +70,7 @@
//
// exitButton
//
- this.exitButton.Location = new System.Drawing.Point(302, 125);
+ this.exitButton.Location = new System.Drawing.Point(175, 8);
this.exitButton.Name = "exitButton";
this.exitButton.Size = new System.Drawing.Size(75, 23);
this.exitButton.TabIndex = 3;
@@ -73,7 +80,7 @@
//
// reportButton
//
- this.reportButton.Location = new System.Drawing.Point(140, 125);
+ this.reportButton.Location = new System.Drawing.Point(13, 8);
this.reportButton.Name = "reportButton";
this.reportButton.Size = new System.Drawing.Size(75, 23);
this.reportButton.TabIndex = 4;
@@ -82,26 +89,51 @@
this.reportButton.Visible = false;
this.reportButton.Click += new System.EventHandler(this.reportButton_Click);
//
+ // bottomPanel
+ //
+ this.bottomPanel.Controls.Add(this.rightBottomPanel);
+ this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.bottomPanel.Location = new System.Drawing.Point(0, 105);
+ this.bottomPanel.Name = "bottomPanel";
+ this.bottomPanel.Size = new System.Drawing.Size(389, 40);
+ this.bottomPanel.TabIndex = 5;
+ //
+ // rightBottomPanel
+ //
+ this.rightBottomPanel.Controls.Add(this.okButton);
+ this.rightBottomPanel.Controls.Add(this.exitButton);
+ this.rightBottomPanel.Controls.Add(this.reportButton);
+ this.rightBottomPanel.Dock = System.Windows.Forms.DockStyle.Right;
+ this.rightBottomPanel.Location = new System.Drawing.Point(128, 0);
+ this.rightBottomPanel.Name = "rightBottomPanel";
+ this.rightBottomPanel.Size = new System.Drawing.Size(261, 40);
+ this.rightBottomPanel.TabIndex = 0;
+ //
+ // leftPanel
+ //
+ this.leftPanel.Controls.Add(this.errorIcon);
+ this.leftPanel.Dock = System.Windows.Forms.DockStyle.Left;
+ this.leftPanel.Location = new System.Drawing.Point(0, 0);
+ this.leftPanel.Name = "leftPanel";
+ this.leftPanel.Size = new System.Drawing.Size(54, 105);
+ this.leftPanel.TabIndex = 6;
+ //
// ExceptionDialog
//
- this.AcceptButton = this.okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.okButton;
- this.ClientSize = new System.Drawing.Size(391, 159);
- this.Controls.Add(this.reportButton);
- this.Controls.Add(this.exitButton);
- this.Controls.Add(this.errorIcon);
+ this.ClientSize = new System.Drawing.Size(389, 145);
this.Controls.Add(this.exceptionDetailBox);
- this.Controls.Add(this.okButton);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
+ this.Controls.Add(this.leftPanel);
+ this.Controls.Add(this.bottomPanel);
this.Name = "ExceptionDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NMail Administration - Error";
((System.ComponentModel.ISupportInitialize) (this.errorIcon)).EndInit();
+ this.bottomPanel.ResumeLayout(false);
+ this.rightBottomPanel.ResumeLayout(false);
+ this.leftPanel.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -114,5 +146,8 @@
private System.Windows.Forms.PictureBox errorIcon;
private System.Windows.Forms.Button exitButton;
private System.Windows.Forms.Button reportButton;
+ private System.Windows.Forms.Panel bottomPanel;
+ private System.Windows.Forms.Panel rightBottomPanel;
+ private System.Windows.Forms.Panel leftPanel;
}
}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.Designer.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.Designer.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,93 @@
+namespace NMail.Administration.WinForms.Folders {
+ partial class FolderEditor {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.bottomPanel = new System.Windows.Forms.Panel();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.okButton = new System.Windows.Forms.Button();
+ this.folderPropertyGrid = new System.Windows.Forms.PropertyGrid();
+ this.bottomPanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // bottomPanel
+ //
+ this.bottomPanel.Controls.Add(this.cancelButton);
+ this.bottomPanel.Controls.Add(this.okButton);
+ this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.bottomPanel.Location = new System.Drawing.Point(0, 239);
+ this.bottomPanel.Name = "bottomPanel";
+ this.bottomPanel.Size = new System.Drawing.Size(292, 32);
+ this.bottomPanel.TabIndex = 0;
+ //
+ // cancelButton
+ //
+ this.cancelButton.Location = new System.Drawing.Point(93, 3);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 1;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // okButton
+ //
+ this.okButton.Location = new System.Drawing.Point(12, 3);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 0;
+ this.okButton.Text = "Ok";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // folderPropertyGrid
+ //
+ this.folderPropertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.folderPropertyGrid.Location = new System.Drawing.Point(0, 0);
+ this.folderPropertyGrid.Name = "folderPropertyGrid";
+ this.folderPropertyGrid.Size = new System.Drawing.Size(292, 239);
+ this.folderPropertyGrid.TabIndex = 1;
+ //
+ // FolderEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(292, 271);
+ this.Controls.Add(this.folderPropertyGrid);
+ this.Controls.Add(this.bottomPanel);
+ this.Name = "FolderEditor";
+ this.TabText = "Folder Editor";
+ this.Text = "Folder Editor";
+ this.bottomPanel.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel bottomPanel;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.PropertyGrid folderPropertyGrid;
+ }
+}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+using WeifenLuo.WinFormsUI.Docking;
+
+using NMail.Icons;
+
+namespace NMail.Administration.WinForms.Folders {
+ /// <summary>
+ /// A simple editor for folders.
+ /// </summary>
+ public partial class FolderEditor : DockContent {
+ public FolderEditor() {
+ InitializeComponent();
+
+ this.Folder = new NMail.DataTypes.LocalStore.StoreFolder();
+
+ //this.Icon = IconHelper.GetIcon("edit_user", "actions", IconSize.s16x16);
+ }
+
+ /// <summary>
+ /// The text on the OK button.
+ /// </summary>
+ public string OkButtonText {
+ get {
+ return this.okButton.Text;
+ }
+ set {
+ this.okButton.Text = value;
+ }
+ }
+
+ private NMail.DataTypes.LocalStore.StoreFolder folder;
+
+ /// <summary>
+ /// The folder displayed in the editor.
+ /// </summary>
+ public NMail.DataTypes.LocalStore.StoreFolder Folder {
+ get { return folder; }
+ set {
+ folder = value;
+ this.folderPropertyGrid.SelectedObject = folder;
+ }
+ }
+
+ private void okButton_Click(object sender, EventArgs e) {
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+ private void cancelButton_Click(object sender, EventArgs e) {
+ this.DialogResult = DialogResult.Cancel;
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.resx
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.resx (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderEditor.resx 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.Designer.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.Designer.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,191 @@
+namespace NMail.Administration.WinForms.Folders {
+ partial class FolderManager {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ this.bottomPanel = new System.Windows.Forms.Panel();
+ this.addFolderButton = new System.Windows.Forms.Button();
+ this.refreshButton = new System.Windows.Forms.Button();
+ this.folderListView = new System.Windows.Forms.ListView();
+ this.folderIdColumn = new System.Windows.Forms.ColumnHeader();
+ this.nameColumn = new System.Windows.Forms.ColumnHeader();
+ this.namespaceColumn = new System.Windows.Forms.ColumnHeader();
+ this.parentIdColumn = new System.Windows.Forms.ColumnHeader();
+ this.ownerColumn = new System.Windows.Forms.ColumnHeader();
+ this.imageList = new System.Windows.Forms.ImageList(this.components);
+ this.folderContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.addFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.editFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.deleteFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.bottomPanel.SuspendLayout();
+ this.folderContextMenu.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // bottomPanel
+ //
+ this.bottomPanel.Controls.Add(this.addFolderButton);
+ this.bottomPanel.Controls.Add(this.refreshButton);
+ this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.bottomPanel.Location = new System.Drawing.Point(0, 405);
+ this.bottomPanel.Name = "bottomPanel";
+ this.bottomPanel.Size = new System.Drawing.Size(631, 40);
+ this.bottomPanel.TabIndex = 0;
+ //
+ // addFolderButton
+ //
+ this.addFolderButton.Location = new System.Drawing.Point(159, 6);
+ this.addFolderButton.Name = "addFolderButton";
+ this.addFolderButton.Size = new System.Drawing.Size(75, 23);
+ this.addFolderButton.TabIndex = 1;
+ this.addFolderButton.Text = "Add Folder";
+ this.addFolderButton.UseVisualStyleBackColor = true;
+ this.addFolderButton.Click += new System.EventHandler(this.addFolderToolStripMenuItem_Click);
+ //
+ // refreshButton
+ //
+ this.refreshButton.Location = new System.Drawing.Point(12, 6);
+ this.refreshButton.Name = "refreshButton";
+ this.refreshButton.Size = new System.Drawing.Size(75, 23);
+ this.refreshButton.TabIndex = 0;
+ this.refreshButton.Text = "Refresh";
+ this.refreshButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.refreshButton.UseVisualStyleBackColor = true;
+ this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
+ //
+ // folderListView
+ //
+ this.folderListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.folderIdColumn,
+ this.nameColumn,
+ this.namespaceColumn,
+ this.parentIdColumn,
+ this.ownerColumn});
+ this.folderListView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.folderListView.FullRowSelect = true;
+ this.folderListView.GridLines = true;
+ this.folderListView.HideSelection = false;
+ this.folderListView.Location = new System.Drawing.Point(0, 0);
+ this.folderListView.MultiSelect = false;
+ this.folderListView.Name = "folderListView";
+ this.folderListView.Size = new System.Drawing.Size(631, 405);
+ this.folderListView.SmallImageList = this.imageList;
+ this.folderListView.TabIndex = 1;
+ this.folderListView.UseCompatibleStateImageBehavior = false;
+ this.folderListView.View = System.Windows.Forms.View.Details;
+ this.folderListView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.folderListView_MouseUp);
+ //
+ // folderIdColumn
+ //
+ this.folderIdColumn.Text = "Folder Id";
+ this.folderIdColumn.Width = 34;
+ //
+ // nameColumn
+ //
+ this.nameColumn.Text = "Name";
+ this.nameColumn.Width = 191;
+ //
+ // namespaceColumn
+ //
+ this.namespaceColumn.Text = "Namespace";
+ this.namespaceColumn.Width = 75;
+ //
+ // parentIdColumn
+ //
+ this.parentIdColumn.Text = "Parent Id";
+ this.parentIdColumn.Width = 47;
+ //
+ // ownerColumn
+ //
+ this.ownerColumn.Text = "Owner Id";
+ this.ownerColumn.Width = 43;
+ //
+ // imageList
+ //
+ this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.imageList.ImageSize = new System.Drawing.Size(16, 16);
+ this.imageList.TransparentColor = System.Drawing.Color.Transparent;
+ //
+ // folderContextMenu
+ //
+ this.folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.addFolderToolStripMenuItem,
+ this.editFolderToolStripMenuItem,
+ this.deleteFolderToolStripMenuItem});
+ this.folderContextMenu.Name = "folderContextMenu";
+ this.folderContextMenu.Size = new System.Drawing.Size(153, 92);
+ //
+ // addFolderToolStripMenuItem
+ //
+ this.addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem";
+ this.addFolderToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.addFolderToolStripMenuItem.Text = "Add Folder";
+ this.addFolderToolStripMenuItem.Click += new System.EventHandler(this.addFolderToolStripMenuItem_Click);
+ //
+ // editFolderToolStripMenuItem
+ //
+ this.editFolderToolStripMenuItem.Name = "editFolderToolStripMenuItem";
+ this.editFolderToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.editFolderToolStripMenuItem.Text = "Edit Folder";
+ this.editFolderToolStripMenuItem.Visible = false;
+ this.editFolderToolStripMenuItem.Click += new System.EventHandler(this.editFolderToolStripMenuItem_Click);
+ //
+ // deleteFolderToolStripMenuItem
+ //
+ this.deleteFolderToolStripMenuItem.Name = "deleteFolderToolStripMenuItem";
+ this.deleteFolderToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.deleteFolderToolStripMenuItem.Text = "Delete Folder";
+ this.deleteFolderToolStripMenuItem.Click += new System.EventHandler(this.deleteFolderToolStripMenuItem_Click);
+ //
+ // FolderManager
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.folderListView);
+ this.Controls.Add(this.bottomPanel);
+ this.Name = "FolderManager";
+ this.Size = new System.Drawing.Size(631, 445);
+ this.bottomPanel.ResumeLayout(false);
+ this.folderContextMenu.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel bottomPanel;
+ private System.Windows.Forms.Button refreshButton;
+ private System.Windows.Forms.ListView folderListView;
+ private System.Windows.Forms.ImageList imageList;
+ private System.Windows.Forms.ColumnHeader folderIdColumn;
+ private System.Windows.Forms.ColumnHeader nameColumn;
+ private System.Windows.Forms.ColumnHeader parentIdColumn;
+ private System.Windows.Forms.ColumnHeader namespaceColumn;
+ private System.Windows.Forms.ColumnHeader ownerColumn;
+ private System.Windows.Forms.ContextMenuStrip folderContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem addFolderToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem editFolderToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem deleteFolderToolStripMenuItem;
+ private System.Windows.Forms.Button addFolderButton;
+ }
+}
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+using NMail.Authentication;
+using NMail.DataTypes.LocalStore;
+using NMail.Icons;
+
+namespace NMail.Administration.WinForms.Folders {
+ /// <summary>
+ /// A control for managing folders.
+ /// </summary>
+ public partial class FolderManager : UserControl {
+
+ private MainForm mainForm;
+
+ public FolderManager(MainForm mainForm) {
+ InitializeComponent();
+
+ this.mainForm = mainForm;
+
+ // Setup icons
+ this.imageList.Images.Add(IconHelper.GetImage("folder", "actions", IconSize.s16x16));
+ this.refreshButton.Image = IconHelper.GetImage("recur", "actions", IconSize.s16x16);
+ }
+
+ private void refreshButton_Click(object sender, EventArgs e) {
+ try {
+ // Get a list of folders
+ ILocalStore localStore = this.mainForm.RemoteAdministration.NMailServer.LocalStore;
+ IAuthenticationProvider authProvider = this.mainForm.RemoteAdministration.NMailServer.AuthenticationProvider;
+ IList<StoreFolder> folders = localStore.GetFolders(this.mainForm.AuthenticationToken);
+
+ this.folderListView.Items.Clear();
+
+ // Add them to the list view
+ foreach (StoreFolder folder in folders) {
+ ListViewItem item = new FolderListViewItem(folder);
+
+ this.folderListView.Items.Add(item);
+ }
+
+ } catch (Exception ex) {
+ // Something bad :(
+ Program.ShowExceptionDialog(ex);
+ }
+ }
+
+ private void addFolderToolStripMenuItem_Click(object sender, EventArgs e) {
+ // Create a new editor and display it
+ FolderEditor editor = new FolderEditor();
+ editor.TabText = "Add Folder";
+ editor.OkButtonText = "Add";
+ this.mainForm.DockFloat(editor, new Size(320, 340));
+
+ // Add a handler for the editor's closing event
+ editor.FormClosing += delegate(object s, FormClosingEventArgs fea) {
+
+ if (editor.DialogResult == DialogResult.OK) {
+ // Attempt to add the folder
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+ this.mainForm.RemoteAdministration.NMailServer.LocalStore.CreateFolder(authToken, editor.Folder);
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of folders
+ refreshButton_Click(this, new EventArgs());
+ }
+ };
+ }
+
+ private void editFolderToolStripMenuItem_Click(object sender, EventArgs e) {
+ if (this.clickedItem != null) {
+ // Create a new editor and display it
+ FolderEditor editor = new FolderEditor();
+ editor.TabText = "Edit Folder";
+ editor.OkButtonText = "Update";
+ editor.Folder = this.clickedItem.Folder;
+ this.mainForm.DockFloat(editor, new Size(320, 340));
+
+ // Add a handler for the editor's closing event
+ editor.FormClosing += delegate(object s, FormClosingEventArgs fea) {
+
+ if (editor.DialogResult == DialogResult.OK) {
+ // Attempt to update the folder
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+ //this.mainForm.RemoteAdministration.NMailServer.LocalStore.UpdateFolder(authToken, editor.Folder);
+
+ throw new NotImplementedException("Currently can't update a folder.");
+
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of folders
+ refreshButton_Click(this, new EventArgs());
+ }
+ };
+ }
+ }
+
+ private void deleteFolderToolStripMenuItem_Click(object sender, EventArgs e) {
+ if (this.clickedItem != null) {
+ // Prompt the user to confirm deletion
+ DialogResult result = MessageBox.Show(
+ this,
+ string.Format("Really delete folder '{0}'?", this.clickedItem.Folder.FullFolderName),
+ "Confirm delete...",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2);
+
+ if (result == DialogResult.Yes) {
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+
+ // Attempt to delete the folder
+ this.mainForm.RemoteAdministration.NMailServer.LocalStore.DeleteFolder(authToken, this.clickedItem.Folder.FolderId);
+
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of folders
+ refreshButton_Click(this, new EventArgs());
+ }
+ }
+ }
+
+ private FolderListViewItem clickedItem;
+
+ private void folderListView_MouseUp(object sender, MouseEventArgs e) {
+ if (e.Button == MouseButtons.Right) {
+ // Get the item clicked on (if any)
+ this.clickedItem = this.folderListView.GetItemAt(e.X, e.Y) as FolderListViewItem;
+
+ // Update and show the context menu
+ updateContextMenu();
+ this.folderContextMenu.Show(Control.MousePosition, ToolStripDropDownDirection.BelowRight);
+ }
+ }
+
+ /// <summary>
+ /// Updates the context menu based on the item clicked on
+ /// </summary>
+ private void updateContextMenu() {
+ this.editFolderToolStripMenuItem.Enabled = (this.clickedItem != null);
+ this.deleteFolderToolStripMenuItem.Enabled = (this.clickedItem != null);
+ }
+ }
+
+ /// <summary>
+ /// A list view item for displaying folders.
+ /// </summary>
+ public class FolderListViewItem : ListViewItem {
+
+ public FolderListViewItem(StoreFolder folder) {
+ this.folder = folder;
+
+ this.SubItems[0] = new ListViewSubItem(this, folder.FolderId.ToString());
+ this.SubItems.Add(new ListViewSubItem(this, folder.FullFolderName));
+ this.SubItems.Add(new ListViewSubItem(this, folder.NameSpace));
+ this.SubItems.Add(new ListViewSubItem(this, folder.ParentId.ToString()));
+ this.SubItems.Add(new ListViewSubItem(this, folder.OwnerUserId.ToString()));
+
+ this.ImageIndex = 0;
+ }
+
+ private StoreFolder folder;
+
+ public StoreFolder Folder {
+ get { return folder; }
+ }
+ }
+}
Added: NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.resx
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.resx (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Folders/FolderManager.resx 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="folderContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>116, 17</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.Designer.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.Designer.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,262 @@
+namespace NMail.Administration.WinForms.Groups {
+ partial class GroupEditor {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.okButton = new System.Windows.Forms.Button();
+ this.groupIdLbl = new System.Windows.Forms.Label();
+ this.groupId = new System.Windows.Forms.TextBox();
+ this.groupNameLbl = new System.Windows.Forms.Label();
+ this.groupName = new System.Windows.Forms.TextBox();
+ this.subGroupList = new System.Windows.Forms.ListView();
+ this.imageList = new System.Windows.Forms.ImageList(this.components);
+ this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+ this.subgroupsLbl = new System.Windows.Forms.Label();
+ this.usersLbl = new System.Windows.Forms.Label();
+ this.userList = new System.Windows.Forms.ListView();
+ this.addGroupBtn = new System.Windows.Forms.Button();
+ this.removeGroupBtn = new System.Windows.Forms.Button();
+ this.removeUserBtn = new System.Windows.Forms.Button();
+ this.addUserBtn = new System.Windows.Forms.Button();
+ this.groupColumnHeader = new System.Windows.Forms.ColumnHeader();
+ this.userColumnHeader = new System.Windows.Forms.ColumnHeader();
+ ((System.ComponentModel.ISupportInitialize) (this.errorProvider)).BeginInit();
+ this.SuspendLayout();
+ //
+ // cancelButton
+ //
+ this.cancelButton.Location = new System.Drawing.Point(93, 306);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 1;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // okButton
+ //
+ this.okButton.Location = new System.Drawing.Point(12, 306);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 0;
+ this.okButton.Text = "Ok";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // groupIdLbl
+ //
+ this.groupIdLbl.AutoSize = true;
+ this.groupIdLbl.Location = new System.Drawing.Point(29, 15);
+ this.groupIdLbl.Name = "groupIdLbl";
+ this.groupIdLbl.Size = new System.Drawing.Size(53, 13);
+ this.groupIdLbl.TabIndex = 2;
+ this.groupIdLbl.Text = "Group ID:";
+ //
+ // groupId
+ //
+ this.groupId.Location = new System.Drawing.Point(88, 12);
+ this.groupId.Name = "groupId";
+ this.groupId.ReadOnly = true;
+ this.groupId.Size = new System.Drawing.Size(157, 20);
+ this.groupId.TabIndex = 0;
+ //
+ // groupNameLbl
+ //
+ this.groupNameLbl.AutoSize = true;
+ this.groupNameLbl.Location = new System.Drawing.Point(12, 43);
+ this.groupNameLbl.Name = "groupNameLbl";
+ this.groupNameLbl.Size = new System.Drawing.Size(70, 13);
+ this.groupNameLbl.TabIndex = 3;
+ this.groupNameLbl.Text = "Group Name:";
+ //
+ // groupName
+ //
+ this.groupName.Location = new System.Drawing.Point(88, 38);
+ this.groupName.Name = "groupName";
+ this.groupName.Size = new System.Drawing.Size(157, 20);
+ this.groupName.TabIndex = 1;
+ //
+ // subGroupList
+ //
+ this.subGroupList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.groupColumnHeader});
+ this.subGroupList.FullRowSelect = true;
+ this.subGroupList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+ this.subGroupList.HideSelection = false;
+ this.subGroupList.Location = new System.Drawing.Point(88, 64);
+ this.subGroupList.Name = "subGroupList";
+ this.subGroupList.Size = new System.Drawing.Size(198, 97);
+ this.subGroupList.SmallImageList = this.imageList;
+ this.subGroupList.TabIndex = 2;
+ this.subGroupList.UseCompatibleStateImageBehavior = false;
+ this.subGroupList.View = System.Windows.Forms.View.Details;
+ //
+ // imageList
+ //
+ this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.imageList.ImageSize = new System.Drawing.Size(16, 16);
+ this.imageList.TransparentColor = System.Drawing.Color.Transparent;
+ //
+ // errorProvider
+ //
+ this.errorProvider.ContainerControl = this;
+ //
+ // subgroupsLbl
+ //
+ this.subgroupsLbl.AutoSize = true;
+ this.subgroupsLbl.Location = new System.Drawing.Point(18, 73);
+ this.subgroupsLbl.Name = "subgroupsLbl";
+ this.subgroupsLbl.Size = new System.Drawing.Size(64, 13);
+ this.subgroupsLbl.TabIndex = 4;
+ this.subgroupsLbl.Text = "Sub-groups:";
+ //
+ // usersLbl
+ //
+ this.usersLbl.AutoSize = true;
+ this.usersLbl.Location = new System.Drawing.Point(45, 177);
+ this.usersLbl.Name = "usersLbl";
+ this.usersLbl.Size = new System.Drawing.Size(37, 13);
+ this.usersLbl.TabIndex = 5;
+ this.usersLbl.Text = "Users:";
+ //
+ // userList
+ //
+ this.userList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.userColumnHeader});
+ this.userList.FullRowSelect = true;
+ this.userList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+ this.userList.HideSelection = false;
+ this.userList.Location = new System.Drawing.Point(88, 167);
+ this.userList.Name = "userList";
+ this.userList.Size = new System.Drawing.Size(198, 97);
+ this.userList.SmallImageList = this.imageList;
+ this.userList.TabIndex = 5;
+ this.userList.UseCompatibleStateImageBehavior = false;
+ this.userList.View = System.Windows.Forms.View.Details;
+ //
+ // addGroupBtn
+ //
+ this.addGroupBtn.Location = new System.Drawing.Point(293, 108);
+ this.addGroupBtn.Name = "addGroupBtn";
+ this.addGroupBtn.Size = new System.Drawing.Size(75, 23);
+ this.addGroupBtn.TabIndex = 3;
+ this.addGroupBtn.Text = "Add";
+ this.addGroupBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.addGroupBtn.UseVisualStyleBackColor = true;
+ this.addGroupBtn.Click += new System.EventHandler(this.addGroupBtn_Click);
+ //
+ // removeGroupBtn
+ //
+ this.removeGroupBtn.Location = new System.Drawing.Point(293, 137);
+ this.removeGroupBtn.Name = "removeGroupBtn";
+ this.removeGroupBtn.Size = new System.Drawing.Size(75, 23);
+ this.removeGroupBtn.TabIndex = 4;
+ this.removeGroupBtn.Text = "Remove Group";
+ this.removeGroupBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.removeGroupBtn.UseVisualStyleBackColor = true;
+ this.removeGroupBtn.Click += new System.EventHandler(this.removeGroupBtn_Click);
+ //
+ // removeUserBtn
+ //
+ this.removeUserBtn.Location = new System.Drawing.Point(293, 240);
+ this.removeUserBtn.Name = "removeUserBtn";
+ this.removeUserBtn.Size = new System.Drawing.Size(75, 23);
+ this.removeUserBtn.TabIndex = 7;
+ this.removeUserBtn.Text = "Remove";
+ this.removeUserBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.removeUserBtn.UseVisualStyleBackColor = true;
+ this.removeUserBtn.Click += new System.EventHandler(this.removeUserBtn_Click);
+ //
+ // addUserBtn
+ //
+ this.addUserBtn.Location = new System.Drawing.Point(293, 211);
+ this.addUserBtn.Name = "addUserBtn";
+ this.addUserBtn.Size = new System.Drawing.Size(75, 23);
+ this.addUserBtn.TabIndex = 6;
+ this.addUserBtn.Text = "Add";
+ this.addUserBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.addUserBtn.UseVisualStyleBackColor = true;
+ this.addUserBtn.Click += new System.EventHandler(this.addUserBtn_Click);
+ //
+ // groupColumnHeader
+ //
+ this.groupColumnHeader.Text = "Sub-Group";
+ //
+ // userColumnHeader
+ //
+ this.userColumnHeader.Text = "User";
+ //
+ // GroupEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(375, 338);
+ this.Controls.Add(this.addUserBtn);
+ this.Controls.Add(this.removeUserBtn);
+ this.Controls.Add(this.removeGroupBtn);
+ this.Controls.Add(this.addGroupBtn);
+ this.Controls.Add(this.userList);
+ this.Controls.Add(this.usersLbl);
+ this.Controls.Add(this.subgroupsLbl);
+ this.Controls.Add(this.subGroupList);
+ this.Controls.Add(this.groupName);
+ this.Controls.Add(this.groupNameLbl);
+ this.Controls.Add(this.groupId);
+ this.Controls.Add(this.groupIdLbl);
+ this.Controls.Add(this.okButton);
+ this.Controls.Add(this.cancelButton);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.Name = "GroupEditor";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Group Editor";
+ ((System.ComponentModel.ISupportInitialize) (this.errorProvider)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.Label groupIdLbl;
+ private System.Windows.Forms.TextBox groupId;
+ private System.Windows.Forms.Label groupNameLbl;
+ private System.Windows.Forms.TextBox groupName;
+ private System.Windows.Forms.ListView subGroupList;
+ private System.Windows.Forms.ImageList imageList;
+ private System.Windows.Forms.ErrorProvider errorProvider;
+ private System.Windows.Forms.ListView userList;
+ private System.Windows.Forms.Label usersLbl;
+ private System.Windows.Forms.Label subgroupsLbl;
+ private System.Windows.Forms.Button removeGroupBtn;
+ private System.Windows.Forms.Button addGroupBtn;
+ private System.Windows.Forms.Button addUserBtn;
+ private System.Windows.Forms.Button removeUserBtn;
+ private System.Windows.Forms.ColumnHeader groupColumnHeader;
+ private System.Windows.Forms.ColumnHeader userColumnHeader;
+ }
+}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Groups/GroupEditor.cs 2007-07-30 13:56:42 UTC (rev 251)
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+using WeifenLuo.WinFormsUI.Docking;
+
+using NMail.Administration.WinForms.Users;
+using NMail.DataTypes.LocalStore;
+using NMail.Icons;
+
+namespace NMail.Administration.WinForms.Groups {
+ /// <summary>
+ /// A simple editor for groups.
+ /// </summary>
+ public partial class GroupEditor : Form {
+
+ public GroupEditor(IDictionary<int, LocalStoreGroup> groups, IDictionary<int, LocalStoreUser> users) {
+ InitializeComponent();
+
+ this.groups = groups;
+ this.users = users;
+
+ this.Group = new LocalStoreGroup();
+
+ this.Icon = IconHelper.GetIcon("edit_group", "actions", IconSize.s16x16);
+ this.imageList.Images.Add(this.Icon = IconHelper.GetIcon("edit_group", "actions", IconSize.s16x16));
+ this.imageList.Images.Add(this.Icon = IconHelper.GetIcon("question", "actions", IconSize.s16x16));
+ this.imageList.Images.Add(this.Icon = IconHelper.GetIcon("edit_user", "actions", IconSize.s16x16));
+ }
+
+ protected IDictionary<int, LocalStoreGroup> groups;
+ protected IDictionary<int, LocalStoreUser> users;
+
+ /// <summary>
+ /// The text on the OK button.
+ /// </summary>
+ public string OkButtonText {
+ get {
+ return this.okButton.Text;
+ }
+ set {
+ this.okButton.Text = value;
+ }
+ }
+
+ private NMail.DataTypes.LocalStore.LocalStoreGroup group;
+
+ /// <summary>
+ /// The group displayed in the editor.
+ /// </summary>
+ public NMail.DataTypes.LocalStore.LocalStoreGroup Group {
+ get { return group; }
+ set {
+ group = value;
+ UpdateGroupDetails();
+ }
+ }
+
+ protected void UpdateGroupSubGroups() {
+ this.subGroupList.Items.Clear();
+ foreach (int groupId in this.group.SubGroupIds) {
+ LocalStoreGroup currentGroup = this.groups[groupId];
+ ListViewItem item = null;
+
+ if (currentGroup == null) {
+ item = new ListViewItem(string.Format("Group Id: {0}", groupId), 1);
+ } else {
+ item = new ListViewItem(currentGroup.Name, 0);
+ }
+
+ item.Tag = groupId;
+ this.subGroupList.Items.Add(item);
+ }
+
+ // Autosize to fit contents
+ this.groupColumnHeader.Width = -1;
+ }
+
+ protected void UpdateGroupUsers() {
+ this.userList.Items.Clear();
+ foreach (int userId in this.group.UserIds) {
+ LocalStoreUser currentUser = this.users[userId];
+ ListViewItem item = null;
+
+ if (currentUser == null) {
+ item = new ListViewItem(string.Format("User Id: {0}", userId, 1));
+ } else {
+ item = new ListViewItem(currentUser.Username, 2);
+ }
+
+ item.Tag = userId;
+ this.userList.Items.Add(item);
+ }
+
+ // Autosize to fit contents
+ this.userColumnHeader.Width = -1;
+ }
+
+ protected void UpdateGroupDetails() {
+ this.groupId.Text = this.group.GroupId.ToString();
+ this.groupName.Text = this.group.Name;
+
+ UpdateGroupSubGroups();
+ UpdateGroupUsers();
+ }
+
+ private void addGroupBtn_Click(object sender, EventArgs e) {
+ // Show the selection dialog
+ SelectGroupDialog selectGroupDialog = new SelectGroupDialog(this.groups.Values);
+ selectGroupDialog.ShowDialog(this);
+
+ if (selectGroupDialog.DialogResult == DialogResult.OK) {
+ // Add the group Id to our group's list of sub-groups
+ this.group.SubGroupIds.Add(selectGroupDialog.SelectedGroup.GroupId);
+
+ UpdateGroupSubGroups();
+ }
+ }
+
+ private void removeGroupBtn_Click(object sender, EventArgs e) {
+ if (this.subGroupList.SelectedItems.Count > 0) {
+ // Confirm with the user
+ DialogResult result = MessageBox.Show(
+ this,
+ "Remove selected sub-groups?",
+ "Confirm remove...",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2);
+
+ if (result == DialogResult.Yes) {
+ foreach (ListViewItem selectedItem in this.subGroupList.SelectedItems) {
+ int currentGroupId = (int) selectedItem.Tag;
+ this.group.SubGroupIds.Remove(currentGroupId);
+
+ UpdateGroupSubGroups();
+ }
+ }
+ }
+ }
+
+ private void addUserBtn_Click(object sender, EventArgs e) {
+ // Show the selection dialog
+ SelectUserDialog selectUserDialog = new SelectUserDialog(this.users.Values);
+ selectUserDialog.ShowDialog(this);
+
+ i...
[truncated message content] |
|
From: <tmy...@us...> - 2007-06-26 12:47:17
|
Revision: 250
http://svn.sourceforge.net/nmailserver/?rev=250&view=rev
Author: tmyroadctfig
Date: 2007-06-26 05:47:19 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
Rework of the SMTP client.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/ISmtpClient.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.MessageRouter/MessageRouter.cs
NMail/trunk/NMail.Sendmail/Sendmail.cs
NMail/trunk/NMail.SmtpClient/NMail.SmtpClient.csproj
NMail/trunk/NMail.SmtpClient/SmtpClient.cs
Added Paths:
-----------
NMail/trunk/NMail.SmtpClient/SmtpDeliveryException.cs
Removed Paths:
-------------
NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs
NMail/trunk/NMail.SmtpClient/SmtpConnectionException.cs
Modified: NMail/trunk/NMail/DataTypes/ISmtpClient.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ISmtpClient.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail/DataTypes/ISmtpClient.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -16,28 +16,19 @@
*/
using System;
+using System.Collections.Generic;
namespace NMail.DataTypes {
/// <summary>
/// The interface for a SMTP client.
/// </summary>
- public interface ISmtpClient {
+ public interface ISmtpClient : IDisposable {
/// <summary>
- /// Connects to an MX for the given destination.
- /// </summary>
- /// <param name="destination">The destination address.</param>
- void Connect(Host destination);
-
- /// <summary>
/// Sends the given message.
/// </summary>
+ /// <param name="destination">The destination host.</param>
/// <param name="message">The message to send.</param>
- /// <returns>The result of the delivery attempt.</returns>
- SmtpDeliveryResult Send(SmtpMessage message);
-
- /// <summary>
- /// Closes the connection to the remote server.
- /// </summary>
- void Close();
+ /// <returns>A list of any failed recipients.</returns>
+ IList<RecipientDeliveryResult> Send(Host destination, SmtpMessage message);
}
}
Deleted: NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -1,68 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane and Daniel Frampton
- *
- * 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.Collections.Generic;
-
-namespace NMail.DataTypes {
- /// <summary>
- /// Details the results of a delivery attempt of a SMTP message.
- /// </summary>
- [Serializable]
- public class SmtpDeliveryResult {
- /// <summary>
- /// A list of results for the recipients of the message.
- /// </summary>
- private ArrayList recipientResultsArray;
-
- /// <summary>
- /// Creates a new instance.
- /// </summary>
- public SmtpDeliveryResult() {
- recipientResultsArray = new ArrayList();
- }
-
- /// <summary>
- /// Adds a set of recipients with the same delivery result. This can be used
- /// when the entire message fails or succeeds.
- /// </summary>
- /// <param name="recipients">The recipients to add.</param>
- /// <param name="result">The result for the recipients.</param>
- public void AddRecipientResults(IList<SmtpMessageRecipient> recipients, DeliveryResult result) {
- foreach (SmtpMessageRecipient recipient in recipients) {
- AddRecipientResult(new RecipientDeliveryResult(recipient, result));
- }
- }
-
- /// <summary>
- /// Adds a single recipient result to this message result.
- /// </summary>
- /// <param name="result">The result to add.</param>
- public void AddRecipientResult(RecipientDeliveryResult result) {
- this.recipientResultsArray.Add(result);
- }
-
- /// <summary>
- /// Returns a list of results for the recipients of the message.
- /// </summary>
- /// <returns>The list of results.</returns>
- public RecipientDeliveryResult[] GetRecipientResults() {
- return (RecipientDeliveryResult[])this.recipientResultsArray.ToArray(typeof(RecipientDeliveryResult));
- }
- }
-}
Modified: NMail/trunk/NMail/NMail.csproj
===================================================================
--- NMail/trunk/NMail/NMail.csproj 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail/NMail.csproj 2007-06-26 12:47:19 UTC (rev 250)
@@ -232,9 +232,6 @@
<Compile Include="DataTypes\Message\SimpleMessageBody.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="DataTypes\SmtpDeliveryResult.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="DataTypes\SmtpMessage.cs">
<SubType>Code</SubType>
</Compile>
Modified: NMail/trunk/NMail.MessageRouter/MessageRouter.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -16,7 +16,7 @@
*/
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Text;
@@ -69,11 +69,22 @@
}
} else {
// Deliver the message to the remote SMTP server
- ISmtpClient client = null;
-
try {
- client = NConfig.Current.CreateSmtpClient();
- client.Connect(batch.Destination);
+
+ using (ISmtpClient client = NConfig.Current.CreateSmtpClient()) {
+
+ // Attempt to deliver each message in the batch
+ foreach (SmtpMessage message in batch.GetMessages()) {
+ // Send the current message
+ IList<RecipientDeliveryResult> deliveryResult = client.Send(batch.Destination, message);
+
+ // If the message was delivered, failed recipients are added to the delivery result
+ foreach (RecipientDeliveryResult result in deliveryResult) {
+ CompleteDeliveryAttempt(message, result);
+ }
+ }
+ }
+
} catch {
// Error communicating with remote SMTP server, fail every message in batch
foreach (SmtpMessage message in batch.GetMessages()) {
@@ -81,30 +92,7 @@
CompleteDeliveryAttempt(message, new DeliveryResult(DeliveryResultType.TemporaryError,
"Error connecting to SMTP server."));
}
- }
-
- // Attempt to deliver each message in the batch
- foreach (SmtpMessage message in batch.GetMessages()) {
- try {
- // Send the current message
- SmtpDeliveryResult deliveryResult = client.Send(message);
-
- // If the message was delivered, failed recipients are added to the delivery result
- foreach (RecipientDeliveryResult result in deliveryResult.GetRecipientResults()) {
- CompleteDeliveryAttempt(message, result);
- }
- } catch (Exception e) {
- log.Info("Temporary failure for message:[" + message.MessageId + "]");
- CompleteDeliveryAttempt(message, new DeliveryResult(DeliveryResultType.TemporaryError,
- "Error communicating with SMTP server."));
- log.Debug(e.Message, e);
- }
- }
-
- try {
- // Disconnect
- if (client != null) client.Close();
- } catch {}
+ }
}
}
@@ -259,7 +247,7 @@
/// <param name="messageRecipient">The recipient to validate.</param>
/// <returns>The result of the request.</returns>
protected override DeliveryResult ValidateRecipientInternal(SmtpMessageRecipient messageRecipient) {
- Hashtable data = new Hashtable();
+ IDictionary<string, object> data = new Dictionary<string, object>();
data["SourceIPAddress"] = messageRecipient.Message.SourceAddress;
data["HeloDomain"] = messageRecipient.Message.ReportedHost;
data["SourceDomain"] = NConfig.Current.DnsClient.ResolveHost((IPAddress) data["SourceIPAddress"]);
Modified: NMail/trunk/NMail.Sendmail/Sendmail.cs
===================================================================
--- NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using System.IO;
using System.Net;
@@ -97,12 +98,11 @@
// Send to local SMTP
SmtpClient.SmtpClient client = new SmtpClient.SmtpClient();
- client.Connect(new Host(IPAddress.Loopback));
- SmtpDeliveryResult result = client.Send(smtpMessage);
- client.Close();
+ IList<RecipientDeliveryResult> result = client.Send((Host) Domain.LocalHost, smtpMessage);
+ client.Dispose();
// Display the results for any failed recipients
- foreach (RecipientDeliveryResult recipientResult in result.GetRecipientResults()) {
+ foreach (RecipientDeliveryResult recipientResult in result) {
if (recipientResult.Type != DeliveryResultType.Success) {
Console.Error.WriteLine("Delivery failed for recipient:[" +
recipientResult.Recipient.ToString() + "].");
Modified: NMail/trunk/NMail.SmtpClient/NMail.SmtpClient.csproj
===================================================================
--- NMail/trunk/NMail.SmtpClient/NMail.SmtpClient.csproj 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail.SmtpClient/NMail.SmtpClient.csproj 2007-06-26 12:47:19 UTC (rev 250)
@@ -110,9 +110,7 @@
<Compile Include="SmtpClientConnection.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="SmtpConnectionException.cs">
- <SubType>Code</SubType>
- </Compile>
+ <Compile Include="SmtpDeliveryException.cs" />
<Compile Include="SmtpServerResponse.cs">
<SubType>Code</SubType>
</Compile>
Modified: NMail/trunk/NMail.SmtpClient/SmtpClient.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -59,69 +59,80 @@
#region ISmtpClient Members
/// <summary>
- /// The current message being sent.
+ /// Sends the given message.
/// </summary>
- private SmtpMessage currentMessage;
+ /// <param name="destination">The destination host.</param>
+ /// <param name="message">The message to send.</param>
+ /// <returns>The result of the delivery attempt.</returns>
+ public IList<RecipientDeliveryResult> Send(Host destination, SmtpMessage message) {
+ DeliveryResult recipientResult = null;
+ IList<RecipientDeliveryResult> result = null;
- /// <summary>
- /// The current delivery result.
- /// </summary>
- private SmtpDeliveryResult currentResult;
+ // Get a list of MXs
+ PopulateMxList(destination);
- /// <summary>
- /// The list of MX host to attempt delivery to.
- /// </summary>
- private Host[] mxHosts;
+ // Try each MX
+ while (this.ConnectedToNextMx()) {
- /// <summary>
- /// An index to the current MX to deliver to.
- /// </summary>
- private int nextMx;
+ result = new List<RecipientDeliveryResult>();
- /// <summary>
- /// Sends the given message.
- /// </summary>
- /// <param name="message">The message to send.</param>
- /// <returns>The result of the delivery attempt.</returns>
- public SmtpDeliveryResult Send(SmtpMessage message) {
- while (true) {
try {
- this.EnsureConnected();
+ if (Preamble(message, result)) {
+ // Premble successful for at least one recipient.
+ SendData(message);
+ }
- this.currentMessage = message;
- this.currentResult = new SmtpDeliveryResult();
+ return result;
- if (Preamble()) {
- // Premble successful for at least one recipient.
- if (!SendData()) {
- // Time out sending data, fail all recipients
- DeliveryResult result = new DeliveryResult(DeliveryResultType.TemporaryError,
- "Timed out sending message data.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(message.Recipients, result);
- }
+ } catch (TimeoutException) {
+ // Timed-out talking to remote server
+ result = new List<RecipientDeliveryResult>();
+ recipientResult = new DeliveryResult(DeliveryResultType.TemporaryError, "Timed out talking to remote server.");
+
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
+ result.Add(new RecipientDeliveryResult(recipient, recipientResult));
}
- return this.currentResult;
- } catch (SmtpConnectionException) {
- // no connection could be found to an MX, fail entire message
- DeliveryResult result = new DeliveryResult(DeliveryResultType.TemporaryError,
- "Error sending message.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(message.Recipients, result);
- return this.currentResult;
+ } catch (SmtpDeliveryException sdex) {
+ // Error during negotiation/preamble/delivery
+ result = new List<RecipientDeliveryResult>();
+ recipientResult = new DeliveryResult(sdex.ResultType, "Error sending message: " + sdex.Message);
- } catch (Exception) {
- // ignore until tried on all connections (SmtpConnectionException)
- continue;
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
+ result.Add(new RecipientDeliveryResult(recipient, recipientResult));
+ }
+
+ // If this is a permanent error don't try any further MXs
+ if (sdex.ResultType == DeliveryResultType.PermanentError) {
+ return result;
+ }
}
}
+
+ // no connection could be found to an MX, fail entire message
+ result = new List<RecipientDeliveryResult>();
+ recipientResult = new DeliveryResult(DeliveryResultType.TemporaryError, "Error sending message.");
+
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
+ result.Add(new RecipientDeliveryResult(recipient, recipientResult));
+ }
+
+ return result;
}
+ #endregion
+ #region IDisposable Members
/// <summary>
+ /// Disposes of this client.
+ /// </summary>
+ public void Dispose() {
+ Close();
+ }
+
+ /// <summary>
/// Closes the connection to the remote server.
/// </summary>
- public void Close() {
+ protected void Close() {
if (this.connection.Connected) {
// be friendly
this.connection.Quit();
@@ -130,64 +141,81 @@
this.connection.Close();
}
}
+ #endregion
+ #region Connection Management
/// <summary>
+ /// The list of MX host to attempt delivery to.
+ /// </summary>
+ private Host[] mxHosts;
+
+ /// <summary>
+ /// An index to the current MX to deliver to.
+ /// </summary>
+ private int nextMx;
+
+ /// <summary>
/// Connects to an MX for the given destination.
/// </summary>
/// <param name="destination">The destination address.</param>
- public void Connect(Host destination) {
+ protected void PopulateMxList(Host destination) {
log.Info("Delivery requested for host:[" + destination.Name + "]");
this.mxHosts = null;
- if (destination.IsDomain) {
- log.Debug("Querying domain for MX records...");
- IDnsClient dns = NMailConfiguration.Current.DnsClient;
- Domain[] mxDomains = dns.ResolveMXRecords(destination.Domain);
- if (mxDomains != null) {
- this.mxHosts = new Host[mxDomains.Length];
- for (int i = 0; i < mxDomains.Length; i++) {
- this.mxHosts[i] = (Host) mxDomains[i];
+ // If there is no relay host get a list of MX servers
+ if (this.config.RelayHost == null) {
+ if (destination.IsDomain) {
+ log.Debug("Querying domain for MX records...");
+ IDnsClient dns = NMailConfiguration.Current.DnsClient;
+ Domain[] mxDomains = dns.ResolveMXRecords(destination.Domain);
+ if (mxDomains != null) {
+ this.mxHosts = new Host[mxDomains.Length];
+ for (int i = 0; i < mxDomains.Length; i++) {
+ this.mxHosts[i] = (Host) mxDomains[i];
+ }
}
}
- }
- // No MX Records or not a domain --> attempt to send direct
- if (mxHosts == null) {
- log.Debug("Using destination host as MX");
- this.mxHosts = new Host[] { destination };
- }
+ // No MX Records or not a domain --> attempt to send direct
+ if (mxHosts == null) {
+ log.Debug("Using destination host as MX");
+ this.mxHosts = new Host[] { destination };
+ }
- log.Debug("Using " + this.mxHosts.Length + " MXs.");
+ log.Debug("Using " + this.mxHosts.Length + " MXs.");
- // start at the first Mx
- this.nextMx = 0;
-
- this.EnsureConnected();
+ // start at the first Mx
+ this.nextMx = 0;
+ }
}
/// <summary>
/// Ensures that a connection to an MX is active. Moves to the next MX(s) if
/// needed.
/// </summary>
- private void EnsureConnected() {
+ private bool ConnectedToNextMx() {
+ // Close any existing connections
+ if (this.connection.Connected) {
+ Close();
+ }
+
if (this.config.RelayHost != null) {
try {
- if (!this.connection.Connected) {
- log.Info("Connecting to:[" + this.config.RelayHost + "]");
- this.connection.Open(this.config.RelayHost, SmtpClientConfiguration.SmtpPort);
+ log.Info("Connecting to:[" + this.config.RelayHost + "]");
+ this.connection.Open(this.config.RelayHost, SmtpClientConfiguration.SmtpPort);
- // Negotiate!
- if (!this.Negotiate()) {
- this.connection.Close();
- }
+ // Negotiate!
+ if (this.Negotiate()) {
+ return true;
}
+
} catch (Exception e) {
log.Debug("Could not connect to smart host:[" + this.config.RelayHost + "]", e);
}
} else {
// are we connected!
- while (!this.connection.Connected && (this.mxHosts.Length > this.nextMx)) {
+ while (this.mxHosts.Length > this.nextMx) {
try {
// Increment nextMx
this.nextMx++;
@@ -197,9 +225,12 @@
this.connection.Open(this.mxHosts[this.nextMx - 1], SmtpClientConfiguration.SmtpPort);
// Negotiate!
- if (!this.Negotiate()) {
- this.connection.Close();
+ if (this.Negotiate()) {
+ return true;
}
+
+ this.connection.Close();
+
} catch (Exception e) {
// ignore all exceptions while trying MXes
log.Debug("Could not connect to MX:[" + this.mxHosts[this.nextMx - 1] + "]", e);
@@ -207,10 +238,8 @@
}
}
- if (!this.connection.Connected) {
- // no more MXes to try!
- throw new SmtpConnectionException("No connection to an MX could be established");
- }
+ this.connection.Close();
+ return false;
}
#endregion
@@ -220,24 +249,22 @@
/// and recipients.
/// </summary>
/// <returns>True on success.</returns>
- private bool Preamble() {
+ private bool Preamble(SmtpMessage smtpMessage, IList<RecipientDeliveryResult> deliveryResult) {
// Determine addtional fields in mail from.
NameValueCollection mailFromParameters = new NameValueCollection();
// Can we send this message?
if (!HasExtension(ESmtpExtensionCode.EightBitMime)) {
- if (currentMessage.Message.Data.Encoding != Encoding.ASCII) {
+ if (smtpMessage.Message.Data.Encoding != Encoding.ASCII) {
// We don't know how to 8BitMime --> 7Bit
- DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
- "Remote server only supports 7BIT and message body is 8BITMIME.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
- return false;
+ throw new SmtpDeliveryException(
+ "Remote server only supports 7BIT and message body is 8BITMIME.",
+ DeliveryResultType.PermanentError);
}
} else {
// Is the body 8 bit mime or 7 bit
mailFromParameters.Add("BODY",
- (currentMessage.Message.Data.Encoding == Encoding.ASCII)
+ (smtpMessage.Message.Data.Encoding == Encoding.ASCII)
? "7BIT"
: "8BITMIME");
}
@@ -245,30 +272,24 @@
// Size Extension specific stuff
if (HasExtension(ESmtpExtensionCode.Size)) {
// Is our message under the limit?
- if (currentMessage.Message.Size > sizeLimit) {
+ if (smtpMessage.Message.Size > sizeLimit) {
// Message is too large
- DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
- "Message is larger than server message size limit.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
- return false;
+ throw new SmtpDeliveryException(
+ "Message is larger than server message size limit.",
+ DeliveryResultType.PermanentError);
}
// Add the mail from size header
- mailFromParameters.Add("SIZE", this.currentMessage.Message.Size.ToString());
+ mailFromParameters.Add("SIZE", smtpMessage.Message.Size.ToString());
}
- try {
- if (HasExtension(ESmtpExtensionCode.Pipelining)) {
- // Supports pipelining - yay!
- return PipelinedPreamble(mailFromParameters);
- }
+ if (HasExtension(ESmtpExtensionCode.Pipelining)) {
+ // Supports pipelining - yay!
+ return PipelinedPreamble(smtpMessage, deliveryResult, mailFromParameters);
+ } else {
// Doesn't support pipelining - boo!
- return SimplePreamble(mailFromParameters);
- } catch (TimeoutException) {
- log.Debug("Timed out communicating with remote server in preamble.");
- return false;
+ return SimplePreamble(smtpMessage, deliveryResult, mailFromParameters);
}
}
@@ -277,9 +298,9 @@
/// </summary>
/// <param name="mailFromParameters">The parameters to send in the "MAIL FROM:" command.</param>
/// <returns>True on success.</returns>
- private bool SimplePreamble(NameValueCollection mailFromParameters) {
+ private bool SimplePreamble(SmtpMessage smtpMessage, IList<RecipientDeliveryResult> deliveryResult, NameValueCollection mailFromParameters) {
// Send "MAIL FROM:" command
- this.connection.MailFrom(this.currentMessage.Sender, mailFromParameters);
+ this.connection.MailFrom(smtpMessage.Sender, mailFromParameters);
// Sender response
this.response = this.connection.GetResponse(this.config.TimeoutMailFrom);
@@ -287,22 +308,18 @@
// Sender error
if (!this.response.OK) {
// Fail all recipients on the message
- DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
- "Server rejected sender address.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
- return false;
+ throw new SmtpDeliveryException("Server rejected sender address.", DeliveryResultType.PermanentError);
}
- bool acceptedRecipient = false;
+ bool acceptedAnyRecipients = false;
- foreach (SmtpMessageRecipient recipient in currentMessage.Recipients) {
+ foreach (SmtpMessageRecipient recipient in smtpMessage.Recipients) {
this.connection.RcptTo(recipient.Address);
this.response = this.connection.GetResponse(this.config.TimeoutRcptTo);
// Send data if any single recipient is accepted
if (this.response.Type == DeliveryResultType.Success) {
- acceptedRecipient = true;
+ acceptedAnyRecipients = true;
}
RecipientDeliveryResult recipientResult = new RecipientDeliveryResult(
@@ -310,18 +327,24 @@
this.response.Type,
this.response.Message);
- currentResult.AddRecipientResult(recipientResult);
+ deliveryResult.Add(recipientResult);
}
- if (!acceptedRecipient) {
- // Remote end rejected all our recipients!
+ if (acceptedAnyRecipients) {
+ // commence data
+ this.connection.Data();
+ this.response = this.connection.GetResponse(this.config.TimeoutData);
+
+ if (!this.response.Continue) {
+ throw new SmtpDeliveryException("Failure during preamble.", DeliveryResultType.TemporaryError);
+ }
+
+ return true;
+
+ } else {
+ // All recipients rejected!
return false;
}
-
- // commence data
- this.connection.Data();
- this.response = this.connection.GetResponse(this.config.TimeoutData);
- return (this.response.Continue);
}
/// <summary>
@@ -329,11 +352,11 @@
/// </summary>
/// <param name="mailFromParameters">The parameters to send in the "MAIL FROM:" command.</param>
/// <returns>True on success.</returns>
- private bool PipelinedPreamble(NameValueCollection mailFromParameters) {
+ private bool PipelinedPreamble(SmtpMessage smtpMessage, IList<RecipientDeliveryResult> deliveryResult, NameValueCollection mailFromParameters) {
// Sender
- this.connection.MailFrom(this.currentMessage.Sender, mailFromParameters);
+ this.connection.MailFrom(smtpMessage.Sender, mailFromParameters);
- IList<SmtpMessageRecipient> recipients = this.currentMessage.Recipients;
+ IList<SmtpMessageRecipient> recipients = smtpMessage.Recipients;
// Recipients
foreach (SmtpMessageRecipient recipient in recipients) {
@@ -349,24 +372,22 @@
// Sender error
if (!this.response.OK) {
// Fail all recipients on the message
- DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
- "Server rejected sender address.");
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
- return false;
+ throw new SmtpDeliveryException("Server rejected sender address.", DeliveryResultType.PermanentError);
}
// Recipient Responses
foreach (SmtpMessageRecipient recipient in recipients) {
this.response = this.connection.GetResponse(this.config.TimeoutRcptTo);
- // Recipient Error
- RecipientDeliveryResult recipientResult = new RecipientDeliveryResult(
- recipient,
- this.response.Type,
- this.response.Message);
+ if (!this.response.OK) {
+ // Recipient Error
+ RecipientDeliveryResult recipientResult = new RecipientDeliveryResult(
+ recipient,
+ this.response.Type,
+ this.response.Message);
- this.currentResult.AddRecipientResult(recipientResult);
+ deliveryResult.Add(recipientResult);
+ }
}
// get response to continue/stop.
@@ -374,11 +395,7 @@
if (!this.response.Continue) {
// not ok to send data: no valid recipients, etc
- DeliveryResult result = new DeliveryResult(this.response.Type, this.response.Message);
- this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
-
- return false;
+ throw new SmtpDeliveryException(this.response.Message, this.response.Type);
}
return true;
@@ -389,30 +406,27 @@
/// <summary>
/// Sends the message data to the server.
/// </summary>
- private bool SendData() {
- return SimpleSendData();
+ private void SendData(SmtpMessage smtpMessage) {
+ SimpleSendData(smtpMessage);
}
/// <summary>
/// Sends the data terminated by a single "."
/// </summary>
- private bool SimpleSendData() {
- try {
- this.connection.DataContents(this.currentMessage.Message);
+ private void SimpleSendData(SmtpMessage smtpMessage) {
+ this.connection.DataContents(smtpMessage.Message);
- int blocks = this.currentMessage.Message.Size / 1024;
- blocks = (blocks > 0) ? blocks : 1;
- this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
+ int blocks = smtpMessage.Message.Size / 1024;
+ blocks = (blocks > 0) ? blocks : 1;
+ this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
- // Discard any extra 3xx messages
- while (this.response.Continue) {
- this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
- }
+ // Discard any extra 3xx messages
+ while (this.response.Continue) {
+ this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
+ }
- return this.response.OK;
- } catch (TimeoutException) {
- log.Debug("Timed out communicating with remote server while sending data.");
- return false;
+ if (!this.response.OK) {
+ throw new SmtpDeliveryException(response.Message, response.Type);
}
}
@@ -443,27 +457,27 @@
/// </summary>
/// <returns>True on success.</returns>
private bool Negotiate() {
- try {
- // wait for a welcome messages
- this.response = this.connection.GetResponse(this.config.TimeoutWelcome);
+ try {
+ // wait for a welcome messages
+ this.response = this.connection.GetResponse(this.config.TimeoutWelcome);
- // are we talking to (what seems to be) an SMTP server?
- if (!this.response.OK)
- return false;
+ // are we talking to (what seems to be) an SMTP server?
+ if (!this.response.OK)
+ return false;
- // Attempt Extended SMTP EHLO
- if (!ExtendedNegotiate()) {
+ // Attempt Extended SMTP EHLO
+ if (!ExtendedNegotiate()) {
- // Fallback to Simple HELO
- return SimpleNegotiate();
- }
+ // Fallback to Simple HELO
+ return SimpleNegotiate();
+ }
- // Enhanced SMTP
- return true;
- } catch (TimeoutException) {
- log.Debug("Timed out communicating with remote server in negotiation.");
- return false;
- }
+ // Enhanced SMTP
+ return true;
+ } catch (TimeoutException) {
+ log.Debug("Timed out communicating with remote server in negotiation.");
+ return false;
+ }
}
/// <summary>
@@ -471,12 +485,12 @@
/// </summary>
/// <returns>True on success.</returns>
private bool SimpleNegotiate() {
- this.connection.Helo(this.config.VisibleHost);
+ this.connection.Helo(this.config.VisibleHost);
- this.response = this.connection.GetResponse(this.config.TimeoutHelo);
+ this.response = this.connection.GetResponse(this.config.TimeoutHelo);
- // Did it work?
- return this.response.OK;
+ // Did it work?
+ return this.response.OK;
}
/// <summary>
@@ -484,71 +498,71 @@
/// </summary>
/// <returns>True on success.</returns>
private bool ExtendedNegotiate() {
- // Send EHLO
- this.connection.Ehlo(this.config.VisibleHost);
+ // Send EHLO
+ this.connection.Ehlo(this.config.VisibleHost);
- this.response = this.connection.GetResponse(this.config.TimeoutEhlo);
+ this.response = this.connection.GetResponse(this.config.TimeoutEhlo);
- if (!this.response.OK) {
- // We have failed!
- return false;
- }
+ if (!this.response.OK) {
+ // We have failed!
+ return false;
+ }
- // Read extensions
- do {
- this.response = this.connection.GetResponse(this.config.TimeoutEhlo);
+ // Read extensions
+ do {
+ this.response = this.connection.GetResponse(this.config.TimeoutEhlo);
- if (this.response.OK) {
- try {
- string[] tokens = response.Message.Split(' ');
+ if (this.response.OK) {
+ try {
+ string[] tokens = response.Message.Split(' ');
- #region Extension Parsing
- switch (tokens[0].ToUpper()) {
- case "8BITMIME":
- this.extensions |= ESmtpExtensionCode.EightBitMime;
- break;
+ #region Extension Parsing
+ switch (tokens[0].ToUpper()) {
+ case "8BITMIME":
+ this.extensions |= ESmtpExtensionCode.EightBitMime;
+ break;
- case "SIZE":
- this.extensions |= ESmtpExtensionCode.Size;
- this.sizeLimit = int.Parse(tokens[1]);
- break;
+ case "SIZE":
+ this.extensions |= ESmtpExtensionCode.Size;
+ this.sizeLimit = int.Parse(tokens[1]);
+ break;
- case "AUTH":
- this.extensions |= ESmtpExtensionCode.Auth;
- break;
+ case "AUTH":
+ this.extensions |= ESmtpExtensionCode.Auth;
+ break;
- case "STARTTLS":
- this.extensions |= ESmtpExtensionCode.StartTls;
- break;
+ case "STARTTLS":
+ this.extensions |= ESmtpExtensionCode.StartTls;
+ break;
- case "PIPELINING":
- this.extensions |= ESmtpExtensionCode.Pipelining;
- break;
+ case "PIPELINING":
+ this.extensions |= ESmtpExtensionCode.Pipelining;
+ break;
- case "CHUNKING":
- this.extensions |= ESmtpExtensionCode.Chunking;
- break;
+ case "CHUNKING":
+ this.extensions |= ESmtpExtensionCode.Chunking;
+ break;
- default:
- //ignore!
- break;
- }
- #endregion
- } catch {
- // ignore extension
- }
- }
- } while (this.response.OK && this.response.Spacer == '-');
+ default:
+ //ignore!
+ break;
+ }
+ #endregion
+ } catch {
+ // ignore extension
+ }
+ }
+ } while (this.response.OK && this.response.Spacer == '-');
- // Negotiated.
- return this.response.OK;
+ // Negotiated.
+ return this.response.OK;
}
/// <summary>
/// Sends a quit to exit from the server.
/// </summary>
private void Quit() {
- this.connection.Quit();
+ this.connection.Quit();
}
/// <summary>
@@ -557,7 +571,7 @@
/// <param name="code">The extension to check.</param>
/// <returns>True if supported.</returns>
private bool HasExtension(ESmtpExtensionCode code) {
- return (this.extensions & code) == code;
+ return (this.extensions & code) == code;
}
#endregion
}
Deleted: NMail/trunk/NMail.SmtpClient/SmtpConnectionException.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpConnectionException.cs 2007-06-26 12:45:18 UTC (rev 249)
+++ NMail/trunk/NMail.SmtpClient/SmtpConnectionException.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -1,24 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane and Daniel Frampton
- *
- * 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;
-
-namespace NMail.SmtpClient {
- public class SmtpConnectionException : ApplicationException {
- public SmtpConnectionException(string message) : base(message) { }
- }
-}
Copied: NMail/trunk/NMail.SmtpClient/SmtpDeliveryException.cs (from rev 192, NMail/trunk/NMail.SmtpClient/SmtpConnectionException.cs)
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpDeliveryException.cs (rev 0)
+++ NMail/trunk/NMail.SmtpClient/SmtpDeliveryException.cs 2007-06-26 12:47:19 UTC (rev 250)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * 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 NMail.DataTypes;
+
+namespace NMail.SmtpClient {
+ /// <summary>
+ /// An SMTP delivery exception.
+ /// </summary>
+ public class SmtpDeliveryException : ApplicationException {
+ public SmtpDeliveryException(string message, DeliveryResultType resultType) : base(message) {
+ this.resultType = resultType;
+ }
+
+ private DeliveryResultType resultType;
+
+ /// <summary>
+ /// The delivery result associated with this delivery exception.
+ /// </summary>
+ public DeliveryResultType ResultType {
+ get { return resultType; }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-26 12:45:17
|
Revision: 249
http://svn.sourceforge.net/nmailserver/?rev=249&view=rev
Author: tmyroadctfig
Date: 2007-06-26 05:45:18 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
Fixed a minor defect. Fixed build output path.
Modified Paths:
--------------
NMail/trunk/NMail.SurveyService/NMail.SurveyService.csproj
NMail/trunk/NMail.SurveyService/SurveyService.cs
Modified: NMail/trunk/NMail.SurveyService/NMail.SurveyService.csproj
===================================================================
--- NMail/trunk/NMail.SurveyService/NMail.SurveyService.csproj 2007-06-26 12:44:09 UTC (rev 248)
+++ NMail/trunk/NMail.SurveyService/NMail.SurveyService.csproj 2007-06-26 12:45:18 UTC (rev 249)
@@ -14,7 +14,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\References\NMail\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -22,7 +22,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
+ <OutputPath>..\References\NMail\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Modified: NMail/trunk/NMail.SurveyService/SurveyService.cs
===================================================================
--- NMail/trunk/NMail.SurveyService/SurveyService.cs 2007-06-26 12:44:09 UTC (rev 248)
+++ NMail/trunk/NMail.SurveyService/SurveyService.cs 2007-06-26 12:45:18 UTC (rev 249)
@@ -62,7 +62,7 @@
RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(NMailServer.NMailRegistryKey, false);
if (nmailServerKey != null) {
- string sentString = nmailServerKey.GetValue("LastSuveryTimestamp") as string;
+ string sentString = nmailServerKey.GetValue("LastSurveyTimestamp") as string;
DateTime sentTimestamp;
if (DateTime.TryParse(sentString, out sentTimestamp)) {
@@ -84,7 +84,7 @@
nmailServerKey = Registry.LocalMachine.CreateSubKey(NMailServer.NMailRegistryKey);
}
- nmailServerKey.SetValue("LastSuveryTimestamp", DateTime.Now.ToString());
+ nmailServerKey.SetValue("LastSurveyTimestamp", DateTime.Now.ToString());
}
protected TimeSpan GetWaitPeriod() {
@@ -92,7 +92,14 @@
if (lastSent.HasValue) {
// TODO: obtain period from config file
- return DateTime.Now - (lastSent.Value + TimeSpan.FromDays(30));
+ TimeSpan waitPeriod = (lastSent.Value + TimeSpan.FromDays(14)) - DateTime.Now;
+
+ // If the scheduled time has passed don't return a -ve wait period
+ if (waitPeriod < TimeSpan.Zero) {
+ waitPeriod = TimeSpan.Zero;
+ }
+
+ return waitPeriod;
}
return TimeSpan.Zero;
@@ -133,8 +140,9 @@
while (this.running) {
// Get the period to wait
TimeSpan waitPeriod = GetWaitPeriod();
+ int waitMilliseconds = (waitPeriod.TotalMilliseconds > Int32.MaxValue) ? -1 : (int) waitPeriod.TotalMilliseconds;
- bool quitSignalled = this.quitEvent.WaitOne((int) waitPeriod.TotalMilliseconds, true);
+ bool quitSignalled = this.quitEvent.WaitOne(waitMilliseconds, true);
if (!quitSignalled) {
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-26 12:44:06
|
Revision: 248
http://svn.sourceforge.net/nmailserver/?rev=248&view=rev
Author: tmyroadctfig
Date: 2007-06-26 05:44:09 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
Fixed a minor defect in TcpTextConnection.
Modified Paths:
--------------
NMail/trunk/NMail/IO/TcpTextConnection.cs
Modified: NMail/trunk/NMail/IO/TcpTextConnection.cs
===================================================================
--- NMail/trunk/NMail/IO/TcpTextConnection.cs 2007-06-26 12:43:20 UTC (rev 247)
+++ NMail/trunk/NMail/IO/TcpTextConnection.cs 2007-06-26 12:44:09 UTC (rev 248)
@@ -143,8 +143,13 @@
// log the client details
if (log.IsInfoEnabled) {
- string message = "Connect to [{0}]({1}).";
- log.Info(String.Format(message, target.Name, target.Address.ToString()));
+ IPEndPoint remoteEndpoint = this.socket.RemoteEndPoint as IPEndPoint;
+
+ if (target.IsDomain) {
+ log.Info(String.Format("Connect to [{0}]({1}).", target.Name, remoteEndpoint.Address.ToString()));
+ } else {
+ log.Info(String.Format("Connect to ({0}).", remoteEndpoint.Address.ToString()));
+ }
}
}
#endregion
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-26 12:43:20
|
Revision: 247
http://svn.sourceforge.net/nmailserver/?rev=247&view=rev
Author: tmyroadctfig
Date: 2007-06-26 05:43:20 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
Work on user management.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
NMail/trunk/NMail.Administration.WinForms/MainForm.cs
NMail/trunk/NMail.Administration.WinForms/NMail.Administration.WinForms.csproj
NMail/trunk/NMail.Administration.WinForms/Users/UserManager.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserManager.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserManager.resx
NMail/trunk/NMail.Icons/NMail.Icons.csproj
Added Paths:
-----------
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.Designer.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.cs
NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.resx
NMail/trunk/NMail.Icons/Resources/16x16/actions/add_user.png
NMail/trunk/NMail.Icons/Resources/16x16/actions/delete_user.png
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics;
using System.Text;
@@ -54,7 +55,9 @@
/// <summary>
/// The username for this local store user.
- /// </summary>
+ /// </summary>
+ [Category("User Details")]
+ [Description("The username for this user.")]
public string Username {
get {
return this.username;
@@ -68,7 +71,11 @@
/// <summary>
/// The user Id for this local store user.
- /// </summary>
+ /// </summary>
+ [Browsable(false)]
+ [Category("User Details")]
+ [Description("The Id for this user.")]
+ [DisplayName("User Id")]
public int UserId {
get {
return this.userId;
@@ -82,7 +89,10 @@
/// <summary>
/// The Id of the user's main folder.
- /// </summary>
+ /// </summary>
+ [Category("User Details")]
+ [Description("The Id of the user's main folder.")]
+ [DisplayName("User Folder Id")]
public int UserFolderId {
get {
return this.userFolderId;
@@ -96,7 +106,10 @@
/// <summary>
/// The user's hard quota limit (null for no hard limit).
- /// </summary>
+ /// </summary>
+ [Category("User Details")]
+ [Description("The user's hard quota.")]
+ [DisplayName("Hard Quota Limit")]
public int? QuotaHardLimit {
get {
return this.quotaHardLimit;
@@ -110,7 +123,10 @@
/// <summary>
/// The limit above which the user will recieve a warning (null for no warning).
- /// </summary>
+ /// </summary>
+ [Category("User Details")]
+ [Description("The user's warning quota.")]
+ [DisplayName("Warning Quota Limit")]
public int? QuotaWarnLimit {
get {
return this.quotaWarnLimit;
Modified: NMail/trunk/NMail.Administration.WinForms/MainForm.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/MainForm.cs 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Administration.WinForms/MainForm.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -180,8 +180,6 @@
}
private void connectMenuItem_Click(object sender, EventArgs e) {
-
- throw new Exception("Testing 123");
// Prompt if already connected
if (this.remoteAdministration != null) {
DialogResult result = MessageBox.Show(
Modified: NMail/trunk/NMail.Administration.WinForms/NMail.Administration.WinForms.csproj
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/NMail.Administration.WinForms.csproj 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Administration.WinForms/NMail.Administration.WinForms.csproj 2007-06-26 12:43:20 UTC (rev 247)
@@ -148,6 +148,10 @@
<SubType>Designer</SubType>
<DependentUpon>SpoolMessageViewer.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Users\UserEditor.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>UserEditor.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Users\UserManager.resx">
<SubType>Designer</SubType>
<DependentUpon>UserManager.cs</DependentUpon>
@@ -183,6 +187,12 @@
<Compile Include="Spool\SmtpSpoolManager.Designer.cs">
<DependentUpon>SmtpSpoolManager.cs</DependentUpon>
</Compile>
+ <Compile Include="Users\UserEditor.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Users\UserEditor.Designer.cs">
+ <DependentUpon>UserEditor.cs</DependentUpon>
+ </Compile>
<Compile Include="Users\UserManager.cs">
<SubType>UserControl</SubType>
</Compile>
Added: NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.Designer.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.Designer.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -0,0 +1,93 @@
+namespace NMail.Administration.WinForms.Users {
+ partial class UserEditor {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.bottomPanel = new System.Windows.Forms.Panel();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.okButton = new System.Windows.Forms.Button();
+ this.userPropertyGrid = new System.Windows.Forms.PropertyGrid();
+ this.bottomPanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // bottomPanel
+ //
+ this.bottomPanel.Controls.Add(this.cancelButton);
+ this.bottomPanel.Controls.Add(this.okButton);
+ this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.bottomPanel.Location = new System.Drawing.Point(0, 239);
+ this.bottomPanel.Name = "bottomPanel";
+ this.bottomPanel.Size = new System.Drawing.Size(292, 32);
+ this.bottomPanel.TabIndex = 0;
+ //
+ // cancelButton
+ //
+ this.cancelButton.Location = new System.Drawing.Point(93, 3);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 1;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // okButton
+ //
+ this.okButton.Location = new System.Drawing.Point(12, 3);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 0;
+ this.okButton.Text = "Ok";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // userPropertyGrid
+ //
+ this.userPropertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.userPropertyGrid.Location = new System.Drawing.Point(0, 0);
+ this.userPropertyGrid.Name = "userPropertyGrid";
+ this.userPropertyGrid.Size = new System.Drawing.Size(292, 239);
+ this.userPropertyGrid.TabIndex = 1;
+ //
+ // UserEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(292, 271);
+ this.Controls.Add(this.userPropertyGrid);
+ this.Controls.Add(this.bottomPanel);
+ this.Name = "UserEditor";
+ this.TabText = "User Editor";
+ this.Text = "User Editor";
+ this.bottomPanel.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel bottomPanel;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.PropertyGrid userPropertyGrid;
+ }
+}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.cs (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2004-2007 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.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+using WeifenLuo.WinFormsUI.Docking;
+
+using NMail.Icons;
+
+namespace NMail.Administration.WinForms.Users {
+ /// <summary>
+ /// A simple editor for users.
+ /// </summary>
+ public partial class UserEditor : DockContent {
+ public UserEditor() {
+ InitializeComponent();
+
+ this.User = new NMail.DataTypes.LocalStore.LocalStoreUser();
+
+ this.Icon = IconHelper.GetIcon("edit_user", "actions", IconSize.s16x16);
+ }
+
+ /// <summary>
+ /// The text on the OK button.
+ /// </summary>
+ public string OkButtonText {
+ get {
+ return this.okButton.Text;
+ }
+ set {
+ this.okButton.Text = value;
+ }
+ }
+
+ private NMail.DataTypes.LocalStore.LocalStoreUser user;
+
+ /// <summary>
+ /// The user displayed in the editor.
+ /// </summary>
+ public NMail.DataTypes.LocalStore.LocalStoreUser User {
+ get { return user; }
+ set {
+ user = value;
+ this.userPropertyGrid.SelectedObject = user;
+ }
+ }
+
+ private void okButton_Click(object sender, EventArgs e) {
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+ private void cancelButton_Click(object sender, EventArgs e) {
+ this.DialogResult = DialogResult.Cancel;
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.resx
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.resx (rev 0)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserEditor.resx 2007-06-26 12:43:20 UTC (rev 247)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: NMail/trunk/NMail.Administration.WinForms/Users/UserManager.Designer.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserManager.Designer.cs 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserManager.Designer.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -25,8 +25,10 @@
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.bottomPanel = new System.Windows.Forms.Panel();
+ this.deleteUserButton = new System.Windows.Forms.Button();
+ this.editUserButton = new System.Windows.Forms.Button();
+ this.addUserButton = new System.Windows.Forms.Button();
this.refreshButton = new System.Windows.Forms.Button();
- this.userSplitContainer = new System.Windows.Forms.SplitContainer();
this.userListView = new System.Windows.Forms.ListView();
this.userIdColumnHeader = new System.Windows.Forms.ColumnHeader();
this.usernameColumnHeader = new System.Windows.Forms.ColumnHeader();
@@ -34,13 +36,21 @@
this.hardQuotaColumnHeader = new System.Windows.Forms.ColumnHeader();
this.userFolderIdColumnHeader = new System.Windows.Forms.ColumnHeader();
this.imageList = new System.Windows.Forms.ImageList(this.components);
+ this.userContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.addUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.editUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.deleteUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.enabledColumnHeader = new System.Windows.Forms.ColumnHeader();
+ this.lockedOutColumnHeader = new System.Windows.Forms.ColumnHeader();
this.bottomPanel.SuspendLayout();
- this.userSplitContainer.Panel1.SuspendLayout();
- this.userSplitContainer.SuspendLayout();
+ this.userContextMenu.SuspendLayout();
this.SuspendLayout();
//
// bottomPanel
//
+ this.bottomPanel.Controls.Add(this.deleteUserButton);
+ this.bottomPanel.Controls.Add(this.editUserButton);
+ this.bottomPanel.Controls.Add(this.addUserButton);
this.bottomPanel.Controls.Add(this.refreshButton);
this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.bottomPanel.Location = new System.Drawing.Point(0, 305);
@@ -48,6 +58,39 @@
this.bottomPanel.Size = new System.Drawing.Size(633, 40);
this.bottomPanel.TabIndex = 0;
//
+ // deleteUserButton
+ //
+ this.deleteUserButton.Location = new System.Drawing.Point(270, 7);
+ this.deleteUserButton.Name = "deleteUserButton";
+ this.deleteUserButton.Size = new System.Drawing.Size(75, 23);
+ this.deleteUserButton.TabIndex = 3;
+ this.deleteUserButton.Text = "Delete User";
+ this.deleteUserButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.deleteUserButton.UseVisualStyleBackColor = true;
+ this.deleteUserButton.Click += new System.EventHandler(this.deleteUserButton_Click);
+ //
+ // editUserButton
+ //
+ this.editUserButton.Location = new System.Drawing.Point(189, 7);
+ this.editUserButton.Name = "editUserButton";
+ this.editUserButton.Size = new System.Drawing.Size(75, 23);
+ this.editUserButton.TabIndex = 2;
+ this.editUserButton.Text = "Edit User";
+ this.editUserButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.editUserButton.UseVisualStyleBackColor = true;
+ this.editUserButton.Click += new System.EventHandler(this.editUserButton_Click);
+ //
+ // addUserButton
+ //
+ this.addUserButton.Location = new System.Drawing.Point(108, 7);
+ this.addUserButton.Name = "addUserButton";
+ this.addUserButton.Size = new System.Drawing.Size(75, 23);
+ this.addUserButton.TabIndex = 1;
+ this.addUserButton.Text = "Add User";
+ this.addUserButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+ this.addUserButton.UseVisualStyleBackColor = true;
+ this.addUserButton.Click += new System.EventHandler(this.addUserButton_Click);
+ //
// refreshButton
//
this.refreshButton.Location = new System.Drawing.Point(4, 7);
@@ -59,20 +102,6 @@
this.refreshButton.UseVisualStyleBackColor = true;
this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
//
- // userSplitContainer
- //
- this.userSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
- this.userSplitContainer.Location = new System.Drawing.Point(0, 0);
- this.userSplitContainer.Name = "userSplitContainer";
- this.userSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
- //
- // userSplitContainer.Panel1
- //
- this.userSplitContainer.Panel1.Controls.Add(this.userListView);
- this.userSplitContainer.Size = new System.Drawing.Size(633, 305);
- this.userSplitContainer.SplitterDistance = 146;
- this.userSplitContainer.TabIndex = 0;
- //
// userListView
//
this.userListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
@@ -80,7 +109,9 @@
this.usernameColumnHeader,
this.warnQuotaColumnHeader,
this.hardQuotaColumnHeader,
- this.userFolderIdColumnHeader});
+ this.userFolderIdColumnHeader,
+ this.enabledColumnHeader,
+ this.lockedOutColumnHeader});
this.userListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.userListView.FullRowSelect = true;
this.userListView.GridLines = true;
@@ -88,11 +119,12 @@
this.userListView.Location = new System.Drawing.Point(0, 0);
this.userListView.MultiSelect = false;
this.userListView.Name = "userListView";
- this.userListView.Size = new System.Drawing.Size(633, 146);
+ this.userListView.Size = new System.Drawing.Size(633, 305);
this.userListView.SmallImageList = this.imageList;
this.userListView.TabIndex = 0;
this.userListView.UseCompatibleStateImageBehavior = false;
this.userListView.View = System.Windows.Forms.View.Details;
+ this.userListView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.userListView_MouseUp);
//
// userIdColumnHeader
//
@@ -122,17 +154,54 @@
this.imageList.ImageSize = new System.Drawing.Size(16, 16);
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
//
+ // userContextMenu
+ //
+ this.userContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.addUserToolStripMenuItem,
+ this.editUserToolStripMenuItem,
+ this.deleteUserToolStripMenuItem});
+ this.userContextMenu.Name = "userContextMenu";
+ this.userContextMenu.Size = new System.Drawing.Size(142, 70);
+ //
+ // addUserToolStripMenuItem
+ //
+ this.addUserToolStripMenuItem.Name = "addUserToolStripMenuItem";
+ this.addUserToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
+ this.addUserToolStripMenuItem.Text = "Add User";
+ this.addUserToolStripMenuItem.Click += new System.EventHandler(this.addUserButton_Click);
+ //
+ // editUserToolStripMenuItem
+ //
+ this.editUserToolStripMenuItem.Name = "editUserToolStripMenuItem";
+ this.editUserToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
+ this.editUserToolStripMenuItem.Text = "Edit User";
+ this.editUserToolStripMenuItem.Click += new System.EventHandler(this.editUserButton_Click);
+ //
+ // deleteUserToolStripMenuItem
+ //
+ this.deleteUserToolStripMenuItem.Name = "deleteUserToolStripMenuItem";
+ this.deleteUserToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
+ this.deleteUserToolStripMenuItem.Text = "Delete User";
+ this.deleteUserToolStripMenuItem.Click += new System.EventHandler(this.deleteUserButton_Click);
+ //
+ // enabledColumnHeader
+ //
+ this.enabledColumnHeader.Text = "Enabled";
+ //
+ // lockedOutColumnHeader
+ //
+ this.lockedOutColumnHeader.Text = "Locked Out";
+ //
// UserManager
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.userSplitContainer);
+ this.Controls.Add(this.userListView);
this.Controls.Add(this.bottomPanel);
this.Name = "UserManager";
this.Size = new System.Drawing.Size(633, 345);
this.bottomPanel.ResumeLayout(false);
- this.userSplitContainer.Panel1.ResumeLayout(false);
- this.userSplitContainer.ResumeLayout(false);
+ this.userContextMenu.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -140,7 +209,6 @@
#endregion
private System.Windows.Forms.Panel bottomPanel;
- private System.Windows.Forms.SplitContainer userSplitContainer;
private System.Windows.Forms.ListView userListView;
private System.Windows.Forms.Button refreshButton;
private System.Windows.Forms.ColumnHeader userIdColumnHeader;
@@ -149,5 +217,14 @@
private System.Windows.Forms.ColumnHeader hardQuotaColumnHeader;
private System.Windows.Forms.ColumnHeader userFolderIdColumnHeader;
private System.Windows.Forms.ImageList imageList;
+ private System.Windows.Forms.Button addUserButton;
+ private System.Windows.Forms.ContextMenuStrip userContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem addUserToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem editUserToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem deleteUserToolStripMenuItem;
+ private System.Windows.Forms.Button editUserButton;
+ private System.Windows.Forms.Button deleteUserButton;
+ private System.Windows.Forms.ColumnHeader enabledColumnHeader;
+ private System.Windows.Forms.ColumnHeader lockedOutColumnHeader;
}
}
Modified: NMail/trunk/NMail.Administration.WinForms/Users/UserManager.cs
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserManager.cs 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserManager.cs 2007-06-26 12:43:20 UTC (rev 247)
@@ -23,6 +23,7 @@
using System.Text;
using System.Windows.Forms;
+using NMail.Authentication;
using NMail.DataTypes.LocalStore;
using NMail.Icons;
@@ -39,21 +40,35 @@
this.mainForm = mainForm;
+ // Setup icons
this.imageList.Images.Add(IconHelper.GetImage("edit_user", "actions", IconSize.s16x16));
this.refreshButton.Image = IconHelper.GetImage("recur", "actions", IconSize.s16x16);
+ this.addUserButton.Image = IconHelper.GetImage("add_user", "actions", IconSize.s16x16);
+ this.editUserButton.Image = IconHelper.GetImage("edit_user", "actions", IconSize.s16x16);
+ this.deleteUserButton.Image = IconHelper.GetImage("delete_user", "actions", IconSize.s16x16);
+
+ this.addUserToolStripMenuItem.Image = IconHelper.GetImage("add_user", "actions", IconSize.s16x16);
+ this.editUserToolStripMenuItem.Image = IconHelper.GetImage("edit_user", "actions", IconSize.s16x16);
+ this.deleteUserToolStripMenuItem.Image = IconHelper.GetImage("delete_user", "actions", IconSize.s16x16);
}
private void refreshButton_Click(object sender, EventArgs e) {
try {
// Get a list of users and groups
ILocalStore localStore = this.mainForm.RemoteAdministration.NMailServer.LocalStore;
+ IAuthenticationProvider authProvider = this.mainForm.RemoteAdministration.NMailServer.AuthenticationProvider;
IList<LocalStoreUser> users = localStore.GetUsers(this.mainForm.AuthenticationToken);
this.userListView.Items.Clear();
// Add them to the list view
foreach (LocalStoreUser user in users) {
- ListViewItem item = new UserListViewItem(user);
+ IAuthenticationToken userAuthToken = authProvider.CreateAuthToken(user.Username);
+ bool enabled = authProvider.IsEnabled(userAuthToken);
+ bool lockedOut = authProvider.IsLockedOut(userAuthToken);
+
+ ListViewItem item = new UserListViewItem(user, enabled, lockedOut);
+
this.userListView.Items.Add(item);
}
@@ -62,6 +77,134 @@
Program.ShowExceptionDialog(ex);
}
}
+
+ private void addUserButton_Click(object sender, EventArgs e) {
+ // Create a new editor and display it
+ UserEditor editor = new UserEditor();
+ editor.TabText = "Add User";
+ editor.OkButtonText = "Add";
+ this.mainForm.DockFloat(editor, new Size(320, 340));
+
+ // Add a handler for the editor's closing event
+ editor.FormClosing += delegate(object s, FormClosingEventArgs fea) {
+
+ if (editor.DialogResult == DialogResult.OK) {
+ // Attempt to add the user
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+ this.mainForm.RemoteAdministration.NMailServer.LocalStore.CreateUser(authToken, editor.User);
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of users
+ refreshButton_Click(this, new EventArgs());
+ }
+ };
+ }
+
+ private void editUserButton_Click(object sender, EventArgs e) {
+ if (this.clickedItem != null) {
+ // Create a new editor and display it
+ UserEditor editor = new UserEditor();
+ editor.TabText = "Edit User";
+ editor.OkButtonText = "Update";
+ editor.User = this.clickedItem.User;
+ this.mainForm.DockFloat(editor, new Size(320, 340));
+
+ // Add a handler for the editor's closing event
+ editor.FormClosing += delegate(object s, FormClosingEventArgs fea) {
+
+ if (editor.DialogResult == DialogResult.OK) {
+ // Attempt to add the user
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+ this.mainForm.RemoteAdministration.NMailServer.LocalStore.UpdateUser(authToken, editor.User);
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of users
+ refreshButton_Click(this, new EventArgs());
+ }
+ };
+ }
+ }
+
+ private void deleteUserButton_Click(object sender, EventArgs e) {
+ if (this.clickedItem != null) {
+ if (this.clickedItem.User.UserId == 1) {
+
+ // Can't delete the administrator account
+ MessageBox.Show(this,
+ "Can't delete the administrator account.",
+ "Error",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ return;
+ }
+
+ // Prompt the user to confirm deletion
+ DialogResult result = MessageBox.Show(
+ this,
+ string.Format("Really delete user '{0}'?", this.clickedItem.User.Username),
+ "Confirm delete...",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2);
+
+ if (result == DialogResult.Yes) {
+ try {
+ NMail.Authentication.IAuthenticationToken authToken = this.mainForm.AuthenticationToken;
+
+ // Check if the user has folders
+ IList<StoreFolder> folders = this.mainForm.RemoteAdministration.NMailServer.LocalStore.GetUserFolders(authToken, this.clickedItem.User.UserId);
+ bool hasFolders = (folders != null && folders.Count > 0);
+
+ if (hasFolders) {
+ // Can't continue then...
+ MessageBox.Show(
+ this,
+ "Can't delete a user that still has folders.",
+ "Error delete user",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Stop);
+ return;
+ }
+
+ // Attempt to delete the user
+ this.mainForm.RemoteAdministration.NMailServer.LocalStore.DeleteUser(authToken, this.clickedItem.User.UserId);
+
+ } catch (Exception ex) {
+ Program.ShowExceptionDialog(ex);
+ }
+
+ // Update the list of users
+ refreshButton_Click(this, new EventArgs());
+ }
+ }
+ }
+
+ private UserListViewItem clickedItem;
+
+ private void userListView_MouseUp(object sender, MouseEventArgs e) {
+ if (e.Button == MouseButtons.Right) {
+ // Get the item clicked on (if any)
+ this.clickedItem = this.userListView.GetItemAt(e.X, e.Y) as UserListViewItem;
+
+ // Update and show the context menu
+ updateContextMenu();
+ this.userContextMenu.Show(Control.MousePosition, ToolStripDropDownDirection.BelowRight);
+ }
+ }
+
+ /// <summary>
+ /// Updates the context menu based on the item clicked on
+ /// </summary>
+ private void updateContextMenu() {
+ this.editUserToolStripMenuItem.Enabled = (this.clickedItem != null);
+ this.deleteUserToolStripMenuItem.Enabled = (this.clickedItem != null);
+ }
}
/// <summary>
@@ -69,14 +212,18 @@
/// </summary>
public class UserListViewItem : ListViewItem {
- public UserListViewItem(LocalStoreUser user) {
+ public UserListViewItem(LocalStoreUser user, bool enabled, bool lockedOut) {
this.user = user;
+ this.enabled = enabled;
+ this.lockedOut = lockedOut;
this.SubItems[0] = new ListViewSubItem(this, user.UserId.ToString());
this.SubItems.Add(new ListViewSubItem(this, user.Username));
this.SubItems.Add(new ListViewSubItem(this, user.QuotaWarnLimit.ToString()));
this.SubItems.Add(new ListViewSubItem(this, user.QuotaHardLimit.ToString()));
this.SubItems.Add(new ListViewSubItem(this, user.UserFolderId.ToString()));
+ this.SubItems.Add(new ListViewSubItem(this, enabled.ToString()));
+ this.SubItems.Add(new ListViewSubItem(this, lockedOut.ToString()));
this.ImageIndex = 0;
}
@@ -86,5 +233,17 @@
public LocalStoreUser User {
get { return user; }
}
+
+ private bool enabled;
+
+ public bool Enabled {
+ get { return enabled; }
+ }
+
+ private bool lockedOut;
+
+ public bool LockedOut {
+ get { return lockedOut; }
+ }
}
}
Modified: NMail/trunk/NMail.Administration.WinForms/Users/UserManager.resx
===================================================================
--- NMail/trunk/NMail.Administration.WinForms/Users/UserManager.resx 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Administration.WinForms/Users/UserManager.resx 2007-06-26 12:43:20 UTC (rev 247)
@@ -120,4 +120,7 @@
<metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
+ <metadata name="userContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>116, 17</value>
+ </metadata>
</root>
\ No newline at end of file
Modified: NMail/trunk/NMail.Icons/NMail.Icons.csproj
===================================================================
--- NMail/trunk/NMail.Icons/NMail.Icons.csproj 2007-06-17 13:11:26 UTC (rev 246)
+++ NMail/trunk/NMail.Icons/NMail.Icons.csproj 2007-06-26 12:43:20 UTC (rev 247)
@@ -63,6 +63,8 @@
<EmbeddedResource Include="Resources\16x16\actions\mail_generic.png" />
<EmbeddedResource Include="Resources\16x16\actions\edit_user.png" />
<EmbeddedResource Include="Resources\22x22\actions\edit_user.png" />
+ <EmbeddedResource Include="Resources\16x16\actions\add_user.png" />
+ <EmbeddedResource Include="Resources\16x16\actions\delete_user.png" />
<Content Include="Resources\LGPL.txt" />
</ItemGroup>
<ItemGroup>
Added: NMail/trunk/NMail.Icons/Resources/16x16/actions/add_user.png
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/NMail.Icons/Resources/16x16/actions/add_user.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: NMail/trunk/NMail.Icons/Resources/16x16/actions/delete_user.png
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/NMail.Icons/Resources/16x16/actions/delete_user.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:11:24
|
Revision: 246
http://svn.sourceforge.net/nmailserver/?rev=246&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:11:26 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Added AJAX support. Added files to ignore list. Updated references.
Modified Paths:
--------------
NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.skin
NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl
NMail/trunk/NMail.WebAccess/Web.config
Added Paths:
-----------
NMail/trunk/NMail.WebAccess/Bin/NMail.LocalStoreData.NHibernate.dll.refresh
Property Changed:
----------------
NMail/trunk/NMail.WebAccess/Bin/
Modified: NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.skin
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.skin 2007-06-17 13:10:35 UTC (rev 245)
+++ NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.skin 2007-06-17 13:11:26 UTC (rev 246)
@@ -20,12 +20,12 @@
<asp:Image runat="server" SkinId="LoginBanner" ImageUrl="~/Images/Skins/Default/LoginBanner.jpg" />
-<asp:Image runat="server" SkinId="MailButtonImage" ImageUrl="~/Images/Crystal/22x22/actions/mail_generic.png" />
-<asp:Image runat="server" SkinId="CalendarButtonImage" ImageUrl="~/Images/CrystalClear/22x22/apps/cal.png" />
-<asp:Image runat="server" SkinId="LogoutButtonImage" ImageUrl="~/Images/CrystalClear/22x22/actions/exit.png" />
-<asp:Image runat="server" SkinID="MailListIcon" ImageUrl="~/Images/CrystalClear/22x22/filesystems/folder_grey.png" />
-<asp:Image runat="Server" SkinID="EnvelopeIcon" ImageUrl="~/Images/CrystalClear/22x22/mimetypes/message2.png" />
+<asp:Image runat="server" SkinId="MailButtonImage" ImageUrl="~/Images/LGPL/22x22/actions/mail_generic.png" />
+<asp:Image runat="server" SkinId="CalendarButtonImage" ImageUrl="~/Images/LGPL/22x22/apps/cal.png" />
+<asp:Image runat="server" SkinId="LogoutButtonImage" ImageUrl="~/Images/LGPL/22x22/actions/exit.png" />
+<asp:Image runat="server" SkinID="MailListIcon" ImageUrl="~/Images/LGPL/22x22/filesystems/folder_grey.png" />
+<asp:Image runat="Server" SkinID="EnvelopeIcon" ImageUrl="~/Images/LGPL/22x22/mimetypes/message2.png" />
-<uc2:SubscribedFolderList runat="server" SkinID="FolderList" TitleIconImageUrl="~/Images/CrystalClear/22x22/filesystems/folder_grey.png" FolderImageUrl="~/Images/CrystalClear/16x16/filesystems/folder_grey.png" />
+<uc2:SubscribedFolderList runat="server" SkinID="FolderList" TitleIconImageUrl="~/Images/LGPL/22x22/filesystems/folder_grey.png" FolderImageUrl="~/Images/LGPL/16x16/filesystems/folder_grey.png" />
<nmwa:RowClickableGridView runat="server" SkinId="MailList" BorderColor="gainsboro" />
\ No newline at end of file
Modified: NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl
===================================================================
--- NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl 2007-06-17 13:10:35 UTC (rev 245)
+++ NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl 2007-06-17 13:11:26 UTC (rev 246)
@@ -90,6 +90,17 @@
<s:element minOccurs="0" maxOccurs="unbounded" name="StoreFolderSerializer" nillable="true" type="tns:StoreFolderSerializer" />
</s:sequence>
</s:complexType>
+ <s:element name="Subscribe">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="authToken" type="s:string" />
+ <s:element minOccurs="1" maxOccurs="1" name="folderId" type="s:int" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="SubscribeResponse">
+ <s:complexType />
+ </s:element>
<s:element name="GetFolderMessageCounts">
<s:complexType>
<s:sequence>
@@ -254,6 +265,12 @@
<wsdl:message name="GetAllSubscribedFoldersSoapOut">
<wsdl:part name="parameters" element="tns:GetAllSubscribedFoldersResponse" />
</wsdl:message>
+ <wsdl:message name="SubscribeSoapIn">
+ <wsdl:part name="parameters" element="tns:Subscribe" />
+ </wsdl:message>
+ <wsdl:message name="SubscribeSoapOut">
+ <wsdl:part name="parameters" element="tns:SubscribeResponse" />
+ </wsdl:message>
<wsdl:message name="GetFolderMessageCountsSoapIn">
<wsdl:part name="parameters" element="tns:GetFolderMessageCounts" />
</wsdl:message>
@@ -305,6 +322,10 @@
<wsdl:input message="tns:GetAllSubscribedFoldersSoapIn" />
<wsdl:output message="tns:GetAllSubscribedFoldersSoapOut" />
</wsdl:operation>
+ <wsdl:operation name="Subscribe">
+ <wsdl:input message="tns:SubscribeSoapIn" />
+ <wsdl:output message="tns:SubscribeSoapOut" />
+ </wsdl:operation>
<wsdl:operation name="GetFolderMessageCounts">
<wsdl:input message="tns:GetFolderMessageCountsSoapIn" />
<wsdl:output message="tns:GetFolderMessageCountsSoapOut" />
@@ -373,6 +394,15 @@
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="Subscribe">
+ <soap:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/Subscribe" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
<wsdl:operation name="GetFolderMessageCounts">
<soap:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetFolderMessageCounts" style="document" />
<wsdl:input>
@@ -466,6 +496,15 @@
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="Subscribe">
+ <soap12:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/Subscribe" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
<wsdl:operation name="GetFolderMessageCounts">
<soap12:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetFolderMessageCounts" style="document" />
<wsdl:input>
Property changes on: NMail/trunk/NMail.WebAccess/Bin
___________________________________________________________________
Name: svn:ignore
- log4net.dll
NMail.dll
NMail.RemoteAccessService.Serializers.dll
NMail.RemoteAccessService.Serializers.pdb
NMail.LocalStore.dll
MenuPilot.dll
+ log4net.dll
NMail.dll
NMail.RemoteAccessService.Serializers.dll
NMail.RemoteAccessService.Serializers.pdb
NMail.LocalStore.dll
MenuPilot.dll
Castle.DynamicProxy.dll
Castle.DynamicProxy.xml
Iesi.Collections.dll
Iesi.Collections.xml
log4net.xml
Mono.Security.dll
NHibernate.dll
NHibernate.xml
NMail.LocalStoreData.NHibernate.dll
NMail.LocalStoreData.NHibernate.pdb
Added: NMail/trunk/NMail.WebAccess/Bin/NMail.LocalStoreData.NHibernate.dll.refresh
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/NMail.WebAccess/Bin/NMail.LocalStoreData.NHibernate.dll.refresh
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: NMail/trunk/NMail.WebAccess/Web.config
===================================================================
--- NMail/trunk/NMail.WebAccess/Web.config 2007-06-17 13:10:35 UTC (rev 245)
+++ NMail/trunk/NMail.WebAccess/Web.config 2007-06-17 13:11:26 UTC (rev 246)
@@ -9,6 +9,17 @@
-->
<configuration>
<configSections>
+ <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
+ <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
+ </sectionGroup>
+ </sectionGroup>
+ </sectionGroup>
+
<section name="NMail" type="NMail.Configuration.NMailConfiguration, NMail"/>
</configSections>
<NMail>
@@ -21,7 +32,11 @@
</appSettings>
<connectionStrings/>
<system.web>
- <pages theme="Default" viewStateEncryptionMode="Never" enableEventValidation="false"/>
+ <pages theme="Default" viewStateEncryptionMode="Never" enableEventValidation="false">
+ <controls>
+ <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ </controls>
+ </pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
@@ -30,11 +45,29 @@
-->
<compilation debug="true">
<assemblies>
- <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
+ <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
+ <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+ <add assembly="VsWebSite.Interop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
+ <add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+ </assemblies>
+ </compilation>
+ <httpHandlers>
+ <remove verb="*" path="*.asmx"/>
+ <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
+ </httpHandlers>
+ <httpModules>
+ <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ </httpModules>
+
<!-- Setup the authentication for the web access. -->
<authentication mode="Forms">
<forms loginUrl="Login.aspx" defaultUrl="Default.aspx" timeout="60" protection="All" slidingExpiration="true"/>
</authentication>
+
<!-- Deny any un-authenticated users. -->
<authorization>
<deny users="?"/>
@@ -68,4 +101,45 @@
</authorization>
</system.web>
</location>
+ <system.web.extensions>
+ <scripting>
+ <webServices>
+ <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
+ <!--
+ <jsonSerialization maxJsonLength="500">
+ <converters>
+ <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
+ </converters>
+ </jsonSerialization>
+ -->
+ <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
+ <!--
+ <authenticationService enabled="true" requireSSL = "true|false"/>
+ -->
+ <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
+ and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
+ writeAccessProperties attributes. -->
+ <!--
+ <profileService enabled="true"
+ readAccessProperties="propertyname1,propertyname2"
+ writeAccessProperties="propertyname1,propertyname2" />
+ -->
+ </webServices>
+ <!--
+ <scriptResourceHandler enableCompression="true" enableCaching="true" />
+ -->
+ </scripting>
+ </system.web.extensions>
+ <system.webServer>
+ <validation validateIntegratedModeConfiguration="false"/>
+ <modules>
+ <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ </modules>
+ <handlers>
+ <remove name="WebServiceHandlerFactory-Integrated"/>
+ <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
+ </handlers>
+ </system.webServer>
</configuration>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:10:33
|
Revision: 245
http://svn.sourceforge.net/nmailserver/?rev=245&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:10:35 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Changed to escape more data.
Modified Paths:
--------------
NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx
NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx.cs
NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx.cs
NMail/trunk/NMail.WebAccess/Mail.aspx.cs
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx 2007-06-17 13:09:16 UTC (rev 244)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx 2007-06-17 13:10:35 UTC (rev 245)
@@ -23,7 +23,7 @@
<div class="PartTitle">
<!-- The title -->
<asp:Image ID="TitleImage" runat="server" SkinID="MailListIcon" />
- <asp:Label ID="TitleLable" runat="server" Text="Folder" />
+ <asp:Label ID="TitleLabel" runat="server" Text="Folder" />
</div>
<asp:Panel ID="MailListPanel" runat="server" ScrollBars="auto" CssClass="MailListPanel">
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs 2007-06-17 13:09:16 UTC (rev 244)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs 2007-06-17 13:10:35 UTC (rev 245)
@@ -50,7 +50,7 @@
this.MailListGridView.DataSource = mailListDataSource;
this.MailListGridView.DataBind();
- this.TitleLable.Text = (this.folderName == null) ? "No folder selected" : this.folderName;
+ this.TitleLabel.Text = (this.folderName == null) ? "No folder selected" : HtmlEscaper.EscapeAll(this.folderName);
}
protected override object SaveControlState()
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx 2007-06-17 13:09:16 UTC (rev 244)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx 2007-06-17 13:10:35 UTC (rev 245)
@@ -27,7 +27,7 @@
<form id="form1" runat="server">
<div class="MessageBody">
<!-- The message body -->
- <asp:Literal ID="MessageBody" runat="server" />
+ <asp:Label ID="MessageBody" runat="server" />
<br />
<!-- The attachments -->
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx 2007-06-17 13:09:16 UTC (rev 244)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx 2007-06-17 13:10:35 UTC (rev 245)
@@ -1,22 +1,36 @@
-0\x82, *\x86H\x86\xF7
-\xA0\x82,0\x82+\xFD10 + |
|
From: <tmy...@us...> - 2007-06-17 13:09:14
|
Revision: 244
http://svn.sourceforge.net/nmailserver/?rev=244&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:09:16 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Ensure a folder is returned.
Modified Paths:
--------------
NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs
Modified: NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs 2007-06-17 13:08:45 UTC (rev 243)
+++ NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs 2007-06-17 13:09:16 UTC (rev 244)
@@ -46,16 +46,27 @@
string authToken = (string)session["AuthToken"];
RemoteAccessService.RemoteAccessService ras = (RemoteAccessService.RemoteAccessService)session["RAS"];
- StoreFolderSerializer[] serializedFolders = ras.GetAllSubscribedFolders(authToken);
+ IList<StoreFolderSerializer> serializedFolders = ras.GetAllSubscribedFolders(authToken);
+
+ // Ensure the user has at least one folder visible
+ if (serializedFolders.Count == 0)
+ {
+ StoreFolderSerializer inbox = ras.GetStoreFolderByName(authToken, "Inbox");
+ ras.Subscribe(authToken, inbox.FolderId);
+ serializedFolders = new List<StoreFolderSerializer>();
+ serializedFolders.Add(inbox);
+ }
+
+ // Get all the folder Ids
+ List<int> folderIds = new List<int>();
List<StoreFolder> result = new List<StoreFolder>();
- List<int> folderIds = new List<int>();
-
foreach (StoreFolderSerializer serializedFolder in serializedFolders)
{
result.Add(new StoreFolder(serializedFolder));
folderIds.Add(serializedFolder.FolderId);
}
+ // Get the message counts for each folder
int[][] folderMessageCounts = ras.GetFolderMessageCounts(authToken, folderIds.ToArray(), (int)StoreMessageFlags.Seen);
for (int i = 0; i < folderMessageCounts.Length; i++)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:08:43
|
Revision: 243
http://svn.sourceforge.net/nmailserver/?rev=243&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:08:45 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Minor changes.
Modified Paths:
--------------
NMail/trunk/NMail.SurveyService/SurveyService.cs
Modified: NMail/trunk/NMail.SurveyService/SurveyService.cs
===================================================================
--- NMail/trunk/NMail.SurveyService/SurveyService.cs 2007-06-17 13:08:07 UTC (rev 242)
+++ NMail/trunk/NMail.SurveyService/SurveyService.cs 2007-06-17 13:08:45 UTC (rev 243)
@@ -36,7 +36,7 @@
/// <summary>
/// A service for periodically surveying the server details and reporting back usage stats.
/// </summary>
- public class SurveyService : IService {
+ public class SurveyService : MarshalByRefObject, IService {
/// <summary>
/// Creates a new instance of the service.
/// </summary>
@@ -78,7 +78,7 @@
/// Sets the last date/time the survey information was sent.
/// </summary>
protected void SetLastSurveyTimestamp() {
- RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(NMailServer.NMailRegistryKey, false);
+ RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(NMailServer.NMailRegistryKey, true);
if (nmailServerKey == null) {
nmailServerKey = Registry.LocalMachine.CreateSubKey(NMailServer.NMailRegistryKey);
@@ -141,7 +141,7 @@
// Send the survey information
SendSurveyInformation();
- } catch (Exception ex) {
+ } catch (Exception) {
// Ignore
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:08:05
|
Revision: 242
http://svn.sourceforge.net/nmailserver/?rev=242&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:08:07 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Fixed some folder related privilege defects.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStore/LocalStore.cs
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-06-17 13:07:49 UTC (rev 241)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-06-17 13:08:07 UTC (rev 242)
@@ -308,13 +308,17 @@
Folder resolvedFolder = getResolvedFolder(authToken, folder);
StoreFolder storeFolder = LocalStoreData.GetStoreFolder(resolvedFolder);
- // Ensure the user has rights to list on the parent folder
- if (storeFolder == null || !hasFolderPrivilege(authToken.Username, storeFolder.FolderId, StoreFolderPrivilege.None)) {
- return null;
+ if (storeFolder != null) {
+
+ // Ensure the user has rights to list on the parent folder
+ if (!storeFolder.ParentId.HasValue || hasFolderPrivilege(authToken.Username, storeFolder.ParentId.Value, StoreFolderPrivilege.Lookup)) {
+
+ // Either have permission or no parent, either way return the folder
+ return storeFolder;
+ }
}
-
- // Either have permission or no parent, either way return the folder
- return storeFolder;
+
+ return null;
}
/// <summary>
@@ -324,15 +328,20 @@
/// <param name="folderId">The Id of the folder to lookup.</param>
/// <returns>The store folder or null if the folder name is invalid.</returns>
public StoreFolder GetStoreFolder(IAuthenticationToken authToken, int folderId) {
+
StoreFolder storeFolder = LocalStoreData.GetStoreFolder(folderId);
- // Ensure the user has rights to list on the parent folder
- if (storeFolder == null || !hasFolderPrivilege(authToken.Username, storeFolder.FolderId, StoreFolderPrivilege.None)) {
- return null;
+ if (storeFolder != null) {
+
+ // Ensure the user has rights to list on the parent folder
+ if (!storeFolder.ParentId.HasValue || hasFolderPrivilege(authToken.Username, storeFolder.ParentId.Value, StoreFolderPrivilege.Lookup)) {
+
+ // Either have permission or no parent, either way return the folder
+ return storeFolder;
+ }
}
- // Either have permission or no parent, either way return the folder
- return storeFolder;
+ return null;
}
#endregion
@@ -488,7 +497,7 @@
List<StoreFolder> removeList = new List<StoreFolder>();
for (int i = 0; i < result.Count; i++) {
- if (!hasFolderPrivilege(authToken.Username, result[i].FolderId, StoreFolderPrivilege.Lookup)) {
+ if (result[i].ParentId.HasValue && !hasFolderPrivilege(authToken.Username, result[i].ParentId.Value, StoreFolderPrivilege.Lookup)) {
removeList.Add(result[i]);
}
}
@@ -1542,6 +1551,11 @@
/// <returns>True if the user has the privilege.</returns>
private bool hasFolderPrivilege(string username, int folderId, StoreFolderPrivilege privilege) {
+ // Check if the user has global folder rights
+ if (hasSystemPrivilege(username, SystemPrivilege.EditAllAcls)) {
+ return true;
+ }
+
// First check if the user has the required privilege on the folder
StoreFolder folder = LocalStoreData.GetStoreFolder(folderId);
StoreFolderAcl currentAcl = LocalStoreData.GetStoreFolderAcl(folderId);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:07:47
|
Revision: 241
http://svn.sourceforge.net/nmailserver/?rev=241&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:07:49 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Changed HtmlEscaper to escape all important HTML characters.
Modified Paths:
--------------
NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs
Modified: NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs 2007-06-17 13:06:54 UTC (rev 240)
+++ NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs 2007-06-17 13:07:49 UTC (rev 241)
@@ -38,19 +38,26 @@
/// <returns>The escaped string.</returns>
public static string EscapeAll(object o)
{
- return EscapeAll(o.ToString());
+ return EscapeAll((o == null) ? null : o.ToString());
}
/// <summary>
- /// Escapes all html "<", ">" and "&"s.
+ /// Escapes all html "<", ">", """, "'" and "&"s.
/// </summary>
/// <param name="html">The data to escape.</param>
/// <returns>The escaped string.</returns>
public static string EscapeAll(string html)
{
+ if (html == null)
+ {
+ return string.Empty;
+ }
+
string result = html.Replace("&", "&");
result = result.Replace("<", "<");
result = result.Replace(">", ">");
+ result = result.Replace("\"", """);
+ result = result.Replace("'", "'");
return result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:06:53
|
Revision: 240
http://svn.sourceforge.net/nmailserver/?rev=240&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:06:54 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Some work on message unit tests.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest1.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/DataTypes/MessageTests.cs
NMail/trunk/NMail.UnitTests/Resources/Test3.eml
Added: NMail/trunk/NMail.UnitTests/DataTypes/MessageTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/DataTypes/MessageTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/DataTypes/MessageTests.cs 2007-06-17 13:06:54 UTC (rev 240)
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+using NMail.DataTypes.Message;
+using NMail.Helper;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.DataTypes {
+ /// <summary>
+ /// Unit tests for the message class.
+ /// </summary>
+ [TestFixture]
+ public class MessageTests {
+ [Test]
+ public void Parsing1() {
+ Message m1 = ResourceHelper.GetMessage("Test3.eml");
+
+ Assert.IsNotNull(m1, "Message not null.");
+
+ m1.ConvertToMultipartBody();
+ IMultipartMessageBody multiPartBody = m1.Body as IMultipartMessageBody;
+ Assert.IsNotNull(multiPartBody, "Valid multipart body.");
+ Assert.AreEqual(2, multiPartBody.MimeParts.Count, "Mime parts.Count == 2");
+
+ Message m2 = new Message(multiPartBody.MimeParts[0]);
+ Assert.AreEqual(MimeContentType.Text, MimeHelper.GetContentType(m2.Headers), "Text content type");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest1.cs 2007-06-17 13:06:01 UTC (rev 239)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest1.cs 2007-06-17 13:06:54 UTC (rev 240)
@@ -33,11 +33,11 @@
IMessageBodyPart part1 = this.localStoreData.GetMessageMimePart(m1Uid, user1.UserFolderId, 1);
Assert.IsNotNull(part1, "Valid part 1.");
- Assert.AreEqual(((IMultipartMessageBody) m1.Body).MimeParts[0].BodyData, part1.BodyData, "Part 1 == m1.Part1");
+ Assert.AreEqual(((IMultipartMessageBody) m1.Body).MimeParts[0].Data, part1.Data, "Part 1 == m1.Part1");
IMessageBodyPart part2 = this.localStoreData.GetMessageMimePart(m1Uid, user1.UserFolderId, 2);
Assert.IsNotNull(part2, "Valid part 2.");
- Assert.AreEqual(((IMultipartMessageBody) m1.Body).MimeParts[1].BodyData, part2.BodyData, "Part 2 == m1.Part2");
+ Assert.AreEqual(((IMultipartMessageBody) m1.Body).MimeParts[1].Data, part2.Data, "Part 2 == m1.Part2");
IMessageBodyPart part3 = this.localStoreData.GetMessageMimePart(0, user1.UserFolderId, 1);
Assert.IsNull(part3, "Invalid part 3.");
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-06-17 13:06:01 UTC (rev 239)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-06-17 13:06:54 UTC (rev 240)
@@ -50,6 +50,7 @@
<Compile Include="DataTypes\FolderTests.cs" />
<Compile Include="DataTypes\HostTests.cs" />
<Compile Include="DataTypes\MessageHeaderTests.cs" />
+ <Compile Include="DataTypes\MessageTests.cs" />
<Compile Include="DNSCacheTests.cs" />
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
@@ -129,6 +130,9 @@
<ItemGroup>
<EmbeddedResource Include="Resources\Test2.eml" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources\Test3.eml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Added: NMail/trunk/NMail.UnitTests/Resources/Test3.eml
===================================================================
--- NMail/trunk/NMail.UnitTests/Resources/Test3.eml (rev 0)
+++ NMail/trunk/NMail.UnitTests/Resources/Test3.eml 2007-06-17 13:06:54 UTC (rev 240)
@@ -0,0 +1,36 @@
+From: "Luke" <luke@local>
+To: "administrator@localhost"
+Subject: Test
+Date: Sun, 17 Jun 2007 22:47:54 +1000
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="----=_NextPart_000_0006_01C7B131.9B425D00"
+X-Priority: 3
+X-MSMail-Priority: Normal
+X-Unsent: 1
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_0006_01C7B131.9B425D00
+Content-Type: text/plain;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+Some HTML.
+------=_NextPart_000_0006_01C7B131.9B425D00
+Content-Type: text/html;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML><HEAD>
+<META http-equiv=3DContent-Type content=3D"text/html; =
+charset=3Diso-8859-1">
+<META content=3D"MSHTML 6.00.6000.16481" name=3DGENERATOR>
+<STYLE></STYLE>
+</HEAD>
+<BODY bgColor=3D#ffffff>
+<DIV><FONT face=3DArial size=3D2>Some HTML.</FONT></DIV></BODY></HTML>
+
+------=_NextPart_000_0006_01C7B131.9B425D00--
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:06:00
|
Revision: 239
http://svn.sourceforge.net/nmailserver/?rev=239&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:06:01 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Added refresh for AJAX toolkit. Added stuff to ignore list
Added Paths:
-----------
NMail/trunk/NMail.Administration.Web/Bin/AjaxControlToolkit.dll.refresh
Property Changed:
----------------
NMail/trunk/NMail.Administration.Web/Bin/
Property changes on: NMail/trunk/NMail.Administration.Web/Bin
___________________________________________________________________
Name: svn:ignore
- log4net.dll
NMail.dll
NMail.Server.dll
Mono.Security.dll
NMail.LocalStoreData.MySql.dll
+ log4net.dll
NMail.dll
NMail.Server.dll
Mono.Security.dll
NMail.LocalStoreData.MySql.dll
AjaxControlToolkit.pdb
Castle.DynamicProxy.dll
Castle.DynamicProxy.xml
Iesi.Collections.dll
Iesi.Collections.xml
log4net.xml
MySql.Data.dll
NHibernate.dll
NHibernate.xml
NMail.LocalStoreData.NHibernate.dll
NMail.LocalStoreData.NHibernate.pdb
Added: NMail/trunk/NMail.Administration.Web/Bin/AjaxControlToolkit.dll.refresh
===================================================================
(Binary files differ)
Property changes on: NMail/trunk/NMail.Administration.Web/Bin/AjaxControlToolkit.dll.refresh
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-06-17 13:05:21
|
Revision: 238
http://svn.sourceforge.net/nmailserver/?rev=238&view=rev
Author: tmyroadctfig
Date: 2007-06-17 06:05:23 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Added support for mail domain mappings.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs 2007-06-17 13:04:21 UTC (rev 237)
+++ NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs 2007-06-17 13:05:23 UTC (rev 238)
@@ -138,6 +138,9 @@
get {
return this.mailboxMappings;
}
+ set {
+ this.mailboxMappings = value;
+ }
}
private IList<ILocalStoreDeliveryAction> allowedActions = new List<ILocalStoreDeliveryAction>();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|