[Nmailserver-commits] SF.net SVN: nmailserver: [123] NMail/trunk/NMail
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-01-24 09:02:08
|
Revision: 123
http://svn.sourceforge.net/nmailserver/?rev=123&view=rev
Author: tmyroadctfig
Date: 2007-01-24 01:02:05 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
Changed some LocalStore methods to use folderId instead of folder. Further work on WebAccess.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/Helper/MimeHelper.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.ImapService/State/ExamineState.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.RemoteAccessService/App_Code/RemoteAccessService.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/NMail.RemoteAccessService.Serializers.csproj
NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs
NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.css
NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl
NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx
NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs
NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx
NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx.cs
NMail/trunk/NMail.WebAccess/Mail.aspx
Added Paths:
-----------
NMail/trunk/NMail/DataTypes/BodyStructure.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/MessageHeadersSerializer.cs
NMail/trunk/NMail.WebAccess/App_Code/Helper.cs
NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs
NMail/trunk/NMail.WebAccess/App_Code/RowClickableGridView.cs
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx.cs
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx
NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx.cs
Removed Paths:
-------------
NMail/trunk/NMail/DataTypes/Imap/BodyStructure.cs
Copied: NMail/trunk/NMail/DataTypes/BodyStructure.cs (from rev 112, NMail/trunk/NMail/DataTypes/Imap/BodyStructure.cs)
===================================================================
--- NMail/trunk/NMail/DataTypes/BodyStructure.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/BodyStructure.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-2006 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.Helper;
+
+namespace NMail.DataTypes {
+ /// <summary>
+ /// Represents a the structure of a message body.
+ /// </summary>
+ [Serializable]
+ public class BodyStructure : List<BodyStructure> {
+
+ public BodyStructure(IMessageBodyPart bodyPart) {
+ this.headers = bodyPart.Headers;
+
+ if (bodyPart.MultipartBody) {
+ foreach (IMessageBodyPart part in bodyPart.MimeParts) {
+ this.Add(new BodyStructure(part));
+ }
+ } else {
+ // Count the number of lines in the message body
+ string bodyData = bodyPart.BodyData.ToString();
+ int index = bodyData.IndexOf(Message.Terminator);
+ while (index != -1) {
+ this.bodyLineCount++;
+ index = bodyData.IndexOf(Message.Terminator, index + 1);
+ }
+
+ this.bodyCharacterCount = bodyData.Length;
+ }
+ }
+
+ public BodyStructure(MessageHeaders headers) {
+ }
+
+ private MessageHeaders headers;
+
+ /// <summary>
+ /// The message headers associated with this level of the body structure.
+ /// </summary>
+ public MessageHeaders Headers {
+ get { return headers; }
+ set { headers = value; }
+ }
+
+ private int bodyLineCount;
+
+ /// <summary>
+ /// The number of lines in the message body. Only valid for bodystructures
+ /// without multiple parts.
+ /// </summary>
+ public int BodyLineCount {
+ get { return bodyLineCount; }
+ set { bodyLineCount = value; }
+ }
+
+ private int bodyCharacterCount;
+
+ /// <summary>
+ /// The number of characters in the body. Only valid for bodystructures
+ /// witout multiple parts.
+ /// </summary>
+ public int BodyCharacterCount {
+ get { return bodyCharacterCount; }
+ set { bodyCharacterCount = value; }
+ }
+
+
+ public override string ToString() {
+ if (this.Count > 0) {
+ StringBuilder data = new StringBuilder();
+ data.Append("(");
+
+ foreach (BodyStructure child in this) {
+ data.Append(child.ToString());
+ }
+
+ data.Append("\"MIXED\")");
+ return data.ToString();
+
+ } else {
+ MimeContentTransferEncoding encoding = MimeHelper.GetTransferEncoding(this.headers);
+ MimeContentType contentType = MimeHelper.GetContentType(this.headers);
+ string charset = MimeHelper.GetCharacterSet(this.headers);
+
+ string encodingStr = encoding.ToString().ToUpper();
+ if (encoding == MimeContentTransferEncoding.EightBit) {
+ encodingStr = "8bit";
+ } else if (encoding == MimeContentTransferEncoding.SevenBit) {
+ encodingStr = "7bit";
+ }
+
+ return string.Format("(\"{0}\" \"{1}\" (\"charset\" \"{2}\") {3} {4} \"{5}\" {6} {7} NIL NIL NIL)",
+ contentType.ToString().ToLower(),
+ "plain",
+ charset,
+ "NIL", // body-fld-id
+ "NIL", // body-fld-desc
+ encodingStr,
+ this.bodyCharacterCount,
+ this.bodyLineCount);
+ }
+ }
+ }
+}
Deleted: NMail/trunk/NMail/DataTypes/Imap/BodyStructure.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Imap/BodyStructure.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail/DataTypes/Imap/BodyStructure.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -1,79 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using NMail.Helper;
-
-namespace NMail.DataTypes.Imap {
- public class BodyStructure {
-
- protected IMessageBodyPart bodyPart;
-
- public BodyStructure(IMessageBodyPart bodyPart) {
- this.bodyPart = bodyPart;
- }
-
- public override string ToString() {
- if (this.bodyPart.MultipartBody) {
- StringBuilder data = new StringBuilder();
- data.Append("(");
-
- foreach (IMessageBodyPart part in this.bodyPart.MimeParts) {
- BodyStructure partStructure = new BodyStructure(part);
- data.Append(partStructure.ToString());
- }
-
- data.Append("\"MIXED\")");
- return data.ToString();
-
- } else {
- MimeContentTransferEncoding encoding = MimeHelper.GetTransferEncoding(this.bodyPart.Headers);
- MimeContentType contentType = MimeHelper.GetContentType(this.bodyPart.Headers);
- string charset = MimeHelper.GetCharacterSet(this.bodyPart.Headers);
-
- // Count the number of lines in the message body
- string bodyData = this.bodyPart.BodyData.ToString();
- int lines = 0;
- int index = bodyData.IndexOf(Message.Terminator);
- while (index != -1) {
- lines++;
- index = bodyData.IndexOf(Message.Terminator, index + 1);
- }
-
- string encodingStr = encoding.ToString().ToUpper();
- if (encoding == MimeContentTransferEncoding.EightBit) {
- encodingStr = "8bit";
- } else if (encoding == MimeContentTransferEncoding.SevenBit) {
- encodingStr = "7bit";
- }
-
- return string.Format("(\"{0}\" \"{1}\" (\"charset\" \"{2}\") {3} {4} \"{5}\" {6} {7} NIL NIL NIL)",
- contentType.ToString().ToLower(),
- "plain",
- charset,
- "NIL", // body-fld-id
- "NIL", // body-fld-desc
- encodingStr,
- this.bodyPart.BodyData.Length,
- lines);
- }
- }
- }
-}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -273,19 +273,28 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the headers for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="messagePart">The number of the part to get.</param>
/// <returns>The MIME part or null if the part is invalid.</returns>
- IMessageBodyPart GetMessageMimePart(IAuthenticationToken authToken, int messageId, StoreFolder folder, int messagePart);
+ IMessageBodyPart GetMessageMimePart(IAuthenticationToken authToken, int messageId, int folderId, int messagePart);
/// <summary>
/// Gets the entire message.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message or null if the message Id is invalid.</returns>
- Message GetMessage(IAuthenticationToken authToken, int messageId, StoreFolder folder);
+ Message GetMessage(IAuthenticationToken authToken, int messageId, int folderId);
+
+ /// <summary>
+ /// Gets the body structure for a message.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="messageId">The Id of the message to get the structure for.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The body structure or null.</returns>
+ BodyStructure GetBodyStructure(IAuthenticationToken authToken, int messageId, int folderId);
#endregion
#region Message Counts
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -214,18 +214,18 @@
/// Gets a specific MIME part from the message.
/// </summary>
/// <param name="messageId">The Id of the message to get the headers for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="messagePart">The number of the part to get.</param>
/// <returns>The MIME part or null if the part is invalid.</returns>
- IMessageBodyPart GetMessageMimePart(int messageId, StoreFolder folder, int messagePart);
+ IMessageBodyPart GetMessageMimePart(int messageId, int folderId, int messagePart);
/// <summary>
/// Gets the entire message.
/// </summary>
/// <param name="messageId">The Id of the message to get.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message or null if the message Id is invalid.</returns>
- Message GetMessage(int messageId, StoreFolder folder);
+ Message GetMessage(int messageId, int folderId);
#endregion
#region Message Counts
Modified: NMail/trunk/NMail/Helper/MimeHelper.cs
===================================================================
--- NMail/trunk/NMail/Helper/MimeHelper.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail/Helper/MimeHelper.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -170,21 +170,35 @@
/// <param name="headers">The headers to get the content type from.</param>
/// <returns>The parsed content type.</returns>
public static MimeContentType GetContentType(MessageHeaders headers) {
- return GetContentType(headers[ContentTypeHeader]);
+ string temp;
+ return GetContentType(headers[ContentTypeHeader], out temp);
}
/// <summary>
/// Gets the MIME content type from the given MIME header line. The default
/// content type is text.
/// </summary>
+ /// <param name="headers">The headers to get the content type from.</param>
+ /// <param name="subType">The detected sub-type.</param>
+ /// <returns>The parsed content type.</returns>
+ public static MimeContentType GetContentType(MessageHeaders headers, out string subType) {
+ return GetContentType(headers[ContentTypeHeader], out subType);
+ }
+
+ /// <summary>
+ /// Gets the MIME content type from the given MIME header line. The default
+ /// content type is text.
+ /// </summary>
/// <remarks>
/// The MIME header line for this value is named "Content-Type".
/// </remarks>
/// <param name="contentType">The header line to parse.</param>
+ /// <param name="subType">The detected sub-type.</param>
/// <returns>The parsed content type.</returns>
- public static MimeContentType GetContentType(string contentType) {
+ public static MimeContentType GetContentType(string contentType, out string subType) {
if (contentType == null) {
+ subType = "plain";
return MimeContentType.Text;
} else {
@@ -192,8 +206,16 @@
string type = contentType.Replace("\"", string.Empty).Trim();
// Chop at the slash
- type = type.Substring(0, type.IndexOf("/")).ToLower();
+ string[] tokens = type.Split("/".ToCharArray(), 2);
+ if (tokens.Length < 2) {
+ subType = "plain";
+ return MimeContentType.Text;
+ }
+
+ subType = tokens[1].ToLower();
+ type = tokens[0].ToLower();
+
switch (type) {
case "text":
return MimeContentType.Text;
Modified: NMail/trunk/NMail/NMail.csproj
===================================================================
--- NMail/trunk/NMail/NMail.csproj 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail/NMail.csproj 2007-01-24 09:02:05 UTC (rev 123)
@@ -130,11 +130,11 @@
<Compile Include="DataTypes\ACLs\StoreFolderAcl.cs" />
<Compile Include="DataTypes\ACLs\StoreFolderPrivilege.cs" />
<Compile Include="DataTypes\ACLs\UserGroupAdminPrivilege.cs" />
+ <Compile Include="DataTypes\BodyStructure.cs" />
<Compile Include="DataTypes\Service\BaseService.cs" />
<Compile Include="DataTypes\Service\BaseSession.cs" />
<Compile Include="DataTypes\Envelope.cs" />
<Compile Include="DataTypes\IDnsClient.cs" />
- <Compile Include="DataTypes\Imap\BodyStructure.cs" />
<Compile Include="DataTypes\Imap\FetchBodyItem.cs" />
<Compile Include="DataTypes\Imap\FetchBodySectionType.cs" />
<Compile Include="DataTypes\Imap\FetchDataItem.cs" />
Modified: NMail/trunk/NMail.ImapService/State/ExamineState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -59,7 +59,7 @@
}
// Get the message
- Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
// Attempt to copy the message
DeliveryResult result = LocalStore.DeliverMessage(Session.AuthenticationToken, message, dstFolder);
@@ -247,7 +247,7 @@
if (bodyItem.SectionType == FetchBodySectionType.All) {
// Get the entire message from the local store
- Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
data += "[] {" + message.Size + "}" + this.Session.Connection.Terminator + message.Data.ToString();
response.AppendResponseItem(data);
@@ -281,7 +281,7 @@
}
// Get the mime part from the local store
- IMessageBodyPart bodyPart = LocalStore.GetMessageMimePart(Session.AuthenticationToken, messageUid, this.selectedFolder, mimePart);
+ IMessageBodyPart bodyPart = LocalStore.GetMessageMimePart(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, mimePart);
if (extractSubPart) {
// TODO extractSubPart
@@ -299,7 +299,7 @@
if (mimePartString == string.Empty) {
// Get the full body from the store
- Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
// Append it to the response
data += "[" + bodyItem.SectionName + "] {" + message.Size + "}"
@@ -318,7 +318,7 @@
}
// Get the mime part from the local store
- IMessageBodyPart bodyPart = LocalStore.GetMessageMimePart(Session.AuthenticationToken, messageUid, this.selectedFolder, mimePart);
+ IMessageBodyPart bodyPart = LocalStore.GetMessageMimePart(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, mimePart);
if (extractSubPart) {
// TODO extractSubPart
@@ -336,8 +336,7 @@
StringBuilder data = new StringBuilder();
data.Append("BODYSTRUCTURE ");
- Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, Session.SelectedFolder);
- BodyStructure bodyStructure = new BodyStructure(message);
+ BodyStructure bodyStructure = LocalStore.GetBodyStructure(Session.AuthenticationToken, messageUid, Session.SelectedFolder.FolderId);
data.Append(bodyStructure.ToString());
response.AppendResponseItem(data.ToString());
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -858,16 +858,16 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the headers for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="messagePart">The number of the part to get.</param>
/// <returns>The MIME part or null if the part is invalid.</returns>
- public IMessageBodyPart GetMessageMimePart(IAuthenticationToken authToken, int messageId, StoreFolder folder, int messagePart) {
+ public IMessageBodyPart GetMessageMimePart(IAuthenticationToken authToken, int messageId, int folderId, int messagePart) {
// Ensure the user has rights to get the message
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message part
- return LocalStoreData.GetMessageMimePart(messageId, folder, messagePart);
+ return LocalStoreData.GetMessageMimePart(messageId, folderId, messagePart);
} else {
return null;
@@ -881,22 +881,46 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message or null if the message Id is invalid.</returns>
- public Message GetMessage(IAuthenticationToken authToken, int messageId, StoreFolder folder) {
+ public Message GetMessage(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message
- return LocalStoreData.GetMessage(messageId, folder);
+ return LocalStoreData.GetMessage(messageId, folderId);
} else {
return null;
}
}
#endregion
+
+ #region Get Body Structure
+ /// <summary>
+ /// Gets the body structure for a message.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="messageId">The Id of the message to get the structure for.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The body structure or null.</returns>
+ public BodyStructure GetBodyStructure(IAuthenticationToken authToken, int messageId, int folderId) {
+
+ // Ensure the user has rights to get the message
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
+
+ // Return the message
+ Message message = LocalStoreData.GetMessage(messageId, folderId);
+ return new BodyStructure(message);
+
+ } else {
+ return null;
+ }
+
+ }
#endregion
+ #endregion
#region Message Counts
#region Get Message Count
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -666,11 +666,11 @@
#endregion
#region GetMessageMimePart
- public IMessageBodyPart GetMessageMimePart(int messageId, StoreFolder folder, int messagePart) {
+ public IMessageBodyPart GetMessageMimePart(int messageId, int folderId, int messagePart) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT md.Data FROM Message m, MessageData md WHERE m.MessageId = md.MessageId AND m.FolderId = ?FolderId AND m.FolderMessageId = ?FolderMessageId AND md.Part = ?Part";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
cmd.Parameters.Add("?Part", messagePart);
byte[] bodyDataBytes = (byte[]) cmd.ExecuteScalar();
@@ -681,21 +681,21 @@
#endregion
#region GetMessage
- public Message GetMessage(int messageId, StoreFolder folder) {
+ public Message GetMessage(int messageId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT MimeMessage FROM Message WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
SByte sb = (SByte) cmd.ExecuteScalar();
bool mimeMessage = (sb == 1) ? true : false;
Message result = null;
- MessageHeaders headers = this.GetMessageHeaders(messageId, folder.FolderId);
+ MessageHeaders headers = this.GetMessageHeaders(messageId, folderId);
if (mimeMessage) {
cmd.CommandText = "SELECT Preamble, Postamble FROM Message WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
MySqlDataReader reader = cmd.ExecuteReader();
@@ -712,7 +712,7 @@
reader.Close();
cmd.CommandText = "SELECT md.Data FROM Message m, MessageData md WHERE m.MessageId = md.MessageId AND m.FolderId = ?FolderId AND m.FolderMessageId = ?FolderMessageId ORDER BY md.Part";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
reader = cmd.ExecuteReader();
ArrayList mimePartList = new ArrayList();
@@ -728,7 +728,7 @@
} else {
cmd.CommandText = "SELECT md.Data FROM Message m, MessageData md WHERE m.MessageId = md.MessageId AND m.FolderId = ?FolderId AND m.FolderMessageId = ?FolderMessageId AND md.Part = 1";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
byte[] data = (byte[]) cmd.ExecuteScalar();
Modified: NMail/trunk/NMail.RemoteAccessService/App_Code/RemoteAccessService.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService/App_Code/RemoteAccessService.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.RemoteAccessService/App_Code/RemoteAccessService.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -248,7 +248,52 @@
throw new InvalidOperationException("Authentication token is not valid.");
}
#endregion
+
+ #region GetMessageStructure
+ /// <summary>
+ /// Gets the message structure for a given message Id and folder Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="messageId">The Id of the message to get.</param>
+ /// <param name="folderId">The Id of the folder to get.</param>
+ /// <returns>The message structure.</returns>
+ [WebMethod]
+ public BodyStructureSerializer GetMessageStructure(string authToken, int messageId, int folderId)
+ {
+ IAuthenticationToken token = ValidateAuthenticationToken(authToken);
+ if (token != null)
+ {
+ BodyStructure bodyStructure = ServiceState.remoteAdmin.NMailServer.LocalStore.GetBodyStructure(token, messageId, folderId);
+ return new BodyStructureSerializer(bodyStructure);
+ }
+ throw new InvalidOperationException("Authentication token is not valid.");
+ }
+ #endregion
+
+ #region GetMessageMimePart
+ /// <summary>
+ /// Gets a MIME part from the message body for a given message Id and folder Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="mimePart">The part of the message to get.</param>
+ /// <param name="messageId">The Id of the message to get.</param>
+ /// <param name="folderId">The Id of the folder to get.</param>
+ /// <returns>The MIME part.</returns>
+ [WebMethod]
+ public string GetMessageMimePart(string authToken, int mimePart, int messageId, int folderId)
+ {
+ IAuthenticationToken token = ValidateAuthenticationToken(authToken);
+ if (token != null)
+ {
+ IMessageBodyPart part = ServiceState.remoteAdmin.NMailServer.LocalStore.GetMessageMimePart(token, messageId, folderId, mimePart);
+ return Convert.ToBase64String(part.BodyData.Bytes);
+ }
+
+ throw new InvalidOperationException("Authentication token is not valid.");
+ }
+ #endregion
+
protected IAuthenticationToken ValidateAuthenticationToken(string authToken)
{
Guid key = new Guid(Convert.FromBase64String(authToken));
Added: NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs (rev 0)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+using NMail.DataTypes;
+
+namespace NMail.RemoteAccessService.Serializers.DataTypes {
+ /// <summary>
+ /// A simple XML serializer for the bodystructure type.
+ /// </summary>
+ [XmlRoot("BodyStructure")]
+ [SoapType(IncludeInSchema = true, Namespace = "http://nmailserver.sf.net/RemoteAccessService/1.0", TypeName = "BodyStructure")]
+ public class BodyStructureSerializer {
+ public BodyStructureSerializer() { }
+
+ public BodyStructureSerializer(BodyStructure bodyStructure) {
+ this.headers = new MessageHeadersSerializer(bodyStructure.Headers);
+
+ foreach (BodyStructure child in bodyStructure) {
+ this.parts.Add(new BodyStructureSerializer(child));
+ }
+ }
+
+ private MessageHeadersSerializer headers;
+
+ public MessageHeadersSerializer Headers {
+ get { return headers; }
+ set { headers = value; }
+ }
+
+ private List<BodyStructureSerializer> parts = new List<BodyStructureSerializer>();
+
+ public List<BodyStructureSerializer> Parts {
+ get { return parts = new List<BodyStructureSerializer>(); }
+ }
+ }
+}
Added: NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/MessageHeadersSerializer.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/MessageHeadersSerializer.cs (rev 0)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/MessageHeadersSerializer.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+using NMail.DataTypes;
+
+namespace NMail.RemoteAccessService.Serializers.DataTypes {
+ /// <summary>
+ /// A simple XML serializer for the message headers type.
+ /// </summary>
+ [XmlRoot("Headers")]
+ [SoapType(IncludeInSchema = true, Namespace = "http://nmailserver.sf.net/RemoteAccessService/1.0", TypeName = "Headers")]
+ public class MessageHeadersSerializer {
+ public MessageHeadersSerializer() { }
+
+ public MessageHeadersSerializer(MessageHeaders messageHeaders) {
+ this.headers = Convert.ToBase64String(messageHeaders.Data.Bytes);
+ }
+
+ private string headers;
+
+ /// <summary>
+ /// A base 64 encoded copy of the raw headers.
+ /// </summary>
+ public string Headers {
+ get { return headers; }
+ set { headers = value; }
+ }
+
+ public MessageHeaders GetMessageHeaders() {
+ return new MessageHeaders(new ByteString(Convert.FromBase64String(this.headers), Encoding.ASCII));
+ }
+ }
+}
Modified: NMail/trunk/NMail.RemoteAccessService.Serializers/NMail.RemoteAccessService.Serializers.csproj
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/NMail.RemoteAccessService.Serializers.csproj 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/NMail.RemoteAccessService.Serializers.csproj 2007-01-24 09:02:05 UTC (rev 123)
@@ -33,8 +33,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="DataTypes\BodyStructureSerializer.cs" />
<Compile Include="DataTypes\EnvelopeSerializer.cs" />
<Compile Include="DataTypes\LocalStore\StoreFolderSerializer.cs" />
+ <Compile Include="DataTypes\MessageHeadersSerializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Added: NMail/trunk/NMail.WebAccess/App_Code/Helper.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/Helper.cs (rev 0)
+++ NMail/trunk/NMail.WebAccess/App_Code/Helper.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,33 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Text;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+using NMail.DataTypes;
+using RemoteAccessService;
+
+namespace NMail.WebAccess
+{
+ public static class Helper
+ {
+ public static BodyStructure GetBodyStructure(BodyStructureSerializer serializedBody)
+ {
+ ByteString headerData = new ByteString(Convert.FromBase64String(serializedBody.Headers.Headers), Encoding.ASCII);
+ MessageHeaders headers = new MessageHeaders(headerData);
+ BodyStructure result = new BodyStructure(headers);
+
+ for (int i = 0; i < serializedBody.Parts.Length; i++)
+ {
+ result.Add(GetBodyStructure(serializedBody.Parts[i]));
+ }
+
+ return result;
+ }
+ }
+}
Added: NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs (rev 0)
+++ NMail/trunk/NMail.WebAccess/App_Code/HtmlEscaper.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,31 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+namespace NMail.WebAccess
+{
+ /// <summary>
+ /// Provides methods for escaping HTML.
+ /// </summary>
+ public static class HtmlEscaper
+ {
+ public static string EscapeAll(object o)
+ {
+ return EscapeAll(o.ToString());
+ }
+
+ public static string EscapeAll(string html)
+ {
+ string result = html.Replace("<", "<");
+ result = result.Replace(">", ">");
+
+ return result;
+ }
+ }
+}
Added: NMail/trunk/NMail.WebAccess/App_Code/RowClickableGridView.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/RowClickableGridView.cs (rev 0)
+++ NMail/trunk/NMail.WebAccess/App_Code/RowClickableGridView.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,46 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+namespace NMail.WebAccess
+{
+ /// <summary>
+ /// A grid view that allows rows to be selected by clicking on them.
+ /// </summary>
+ public class RowClickableGridView : System.Web.UI.WebControls.GridView
+ {
+ public RowClickableGridView() : base() {}
+
+ protected override void PrepareControlHierarchy()
+ {
+ base.PrepareControlHierarchy();
+
+ for (int i = 0; i < this.Rows.Count; i++)
+ {
+ string argument = "rowClicked:" + i;
+ this.Rows[i].Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, argument));
+ }
+ }
+
+ protected override void RaisePostBackEvent(string eventArgument)
+ {
+ if (eventArgument.StartsWith("rowClicked:"))
+ {
+ eventArgument = eventArgument.Remove(0, 11);
+ int row = int.Parse(eventArgument);
+ this.SelectedIndex = row;
+ this.OnSelectedIndexChanged(new EventArgs());
+ }
+ else
+ {
+ base.RaisePostBackEvent(eventArgument);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/App_Code/SubscribedFolderDataSource.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -44,6 +44,25 @@
return result;
}
+
+ public static NMail.DataTypes.LocalStore.StoreFolder GetStoreFolder(int folderId)
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ string authToken = (string)session["AuthToken"];
+ RemoteAccessService.RemoteAccessService ras = (RemoteAccessService.RemoteAccessService)session["RAS"];
+
+ return GetStoreFolder(ras.GetStoreFolderByFolderId(authToken, folderId));
+ }
+
+ public static NMail.DataTypes.LocalStore.StoreFolder GetStoreFolder(StoreFolderSerializer serializedFolder)
+ {
+ return new NMail.DataTypes.LocalStore.StoreFolder(
+ serializedFolder.NameSpace,
+ serializedFolder.Name,
+ serializedFolder.FolderId,
+ serializedFolder.ParentId,
+ serializedFolder.HasChildren);
+ }
}
public class StoreFolder : NMail.DataTypes.LocalStore.StoreFolder
Modified: NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.css
===================================================================
--- NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.css 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/App_Themes/Default/Default.css 2007-01-24 09:02:05 UTC (rev 123)
@@ -1,6 +1,7 @@
body
{
font-family: Sans-Serif;
+
}
.LoginBox
@@ -30,6 +31,11 @@
padding-right: 0.5em;
}
+.SubscribedFolderList
+{
+ background-color: White;
+}
+
.SubscribedFolder
{
}
@@ -42,6 +48,7 @@
.MailList
{
width: 100%;
+ background-color: White;
}
.MailListSelectedItem
Modified: NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl
===================================================================
--- NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/App_WebReferences/RemoteAccessService/RemoteAccessService.wsdl 2007-01-24 09:02:05 UTC (rev 123)
@@ -155,6 +155,55 @@
<s:element minOccurs="0" maxOccurs="1" name="To" type="s:string" />
</s:sequence>
</s:complexType>
+ <s:element name="GetMessageStructure">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="authToken" type="s:string" />
+ <s:element minOccurs="1" maxOccurs="1" name="messageId" type="s:int" />
+ <s:element minOccurs="1" maxOccurs="1" name="folderId" type="s:int" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="GetMessageStructureResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="1" maxOccurs="1" name="BodyStructure" nillable="true" type="tns:BodyStructureSerializer" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:complexType name="BodyStructureSerializer">
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="Headers" type="tns:MessageHeadersSerializer" />
+ <s:element minOccurs="0" maxOccurs="1" name="Parts" type="tns:ArrayOfBodyStructureSerializer" />
+ </s:sequence>
+ </s:complexType>
+ <s:complexType name="MessageHeadersSerializer">
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="Headers" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ <s:complexType name="ArrayOfBodyStructureSerializer">
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="unbounded" name="BodyStructureSerializer" nillable="true" type="tns:BodyStructureSerializer" />
+ </s:sequence>
+ </s:complexType>
+ <s:element name="GetMessageMimePart">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="authToken" type="s:string" />
+ <s:element minOccurs="1" maxOccurs="1" name="mimePart" type="s:int" />
+ <s:element minOccurs="1" maxOccurs="1" name="messageId" type="s:int" />
+ <s:element minOccurs="1" maxOccurs="1" name="folderId" type="s:int" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="GetMessageMimePartResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="GetMessageMimePartResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="AuthenticateSoapIn">
@@ -199,6 +248,18 @@
<wsdl:message name="GetAllMessageEnvelopesSoapOut">
<wsdl:part name="parameters" element="tns:GetAllMessageEnvelopesResponse" />
</wsdl:message>
+ <wsdl:message name="GetMessageStructureSoapIn">
+ <wsdl:part name="parameters" element="tns:GetMessageStructure" />
+ </wsdl:message>
+ <wsdl:message name="GetMessageStructureSoapOut">
+ <wsdl:part name="parameters" element="tns:GetMessageStructureResponse" />
+ </wsdl:message>
+ <wsdl:message name="GetMessageMimePartSoapIn">
+ <wsdl:part name="parameters" element="tns:GetMessageMimePart" />
+ </wsdl:message>
+ <wsdl:message name="GetMessageMimePartSoapOut">
+ <wsdl:part name="parameters" element="tns:GetMessageMimePartResponse" />
+ </wsdl:message>
<wsdl:portType name="RemoteAccessServiceSoap">
<wsdl:operation name="Authenticate">
<wsdl:input message="tns:AuthenticateSoapIn" />
@@ -228,6 +289,14 @@
<wsdl:input message="tns:GetAllMessageEnvelopesSoapIn" />
<wsdl:output message="tns:GetAllMessageEnvelopesSoapOut" />
</wsdl:operation>
+ <wsdl:operation name="GetMessageStructure">
+ <wsdl:input message="tns:GetMessageStructureSoapIn" />
+ <wsdl:output message="tns:GetMessageStructureSoapOut" />
+ </wsdl:operation>
+ <wsdl:operation name="GetMessageMimePart">
+ <wsdl:input message="tns:GetMessageMimePartSoapIn" />
+ <wsdl:output message="tns:GetMessageMimePartSoapOut" />
+ </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RemoteAccessServiceSoap" type="tns:RemoteAccessServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
@@ -294,6 +363,24 @@
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="GetMessageStructure">
+ <soap:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetMessageStructure" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="GetMessageMimePart">
+ <soap:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetMessageMimePart" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="RemoteAccessServiceSoap12" type="tns:RemoteAccessServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
@@ -360,6 +447,24 @@
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="GetMessageStructure">
+ <soap12:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetMessageStructure" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="GetMessageMimePart">
+ <soap12:operation soapAction="http://nmailserver.sf.net/RemoteAccessService/1.0/GetMessageMimePart" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
</wsdl:binding>
<wsdl:service name="RemoteAccessService">
<wsdl:port name="RemoteAccessServiceSoap" binding="tns:RemoteAccessServiceSoap">
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx 2007-01-24 09:02:05 UTC (rev 123)
@@ -1,5 +1,7 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MailList.ascx.cs" Inherits="Controls_Mail_MailList" %>
-<asp:GridView
+
+<%@ Register Namespace="NMail.WebAccess" TagPrefix="nmwa" %>
+<nmwa:RowClickableGridView
SkinID="MailList"
AutoGenerateColumns="false"
ID="MailListGridView"
@@ -10,17 +12,24 @@
SelectedRowStyle-CssClass="MailListSelectedItem"
CssClass="MailList"
Width="100%"
- DataSourceID="MailListDataSource">
+ OnSelectedIndexChanged="MailList_OnSelectedIndexChanged"
+ DataSourceID="MailListDataSource" DataKeyNames="Key">
<Columns>
<asp:TemplateField HeaderText="From">
- <ItemTemplate><%# Eval("Value.From") %></ItemTemplate>
+ <ItemTemplate>
+<%# NMail.WebAccess.HtmlEscaper.EscapeAll(Eval("Value.From")) %>
+</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subject">
- <ItemTemplate><%# Eval("Value.Subject") %></ItemTemplate>
+ <ItemTemplate>
+<%# NMail.WebAccess.HtmlEscaper.EscapeAll(Eval("Value.Subject")) %>
+</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
- <ItemTemplate><%# Eval("Value.Date") %></ItemTemplate>
+ <ItemTemplate>
+<%# NMail.WebAccess.HtmlEscaper.EscapeAll(Eval("Value.Date")) %>
+</ItemTemplate>
</asp:TemplateField>
</Columns>
@@ -31,7 +40,7 @@
<SelectedRowStyle CssClass="MailListSelectedItem" />
<HeaderStyle CssClass="MailListHeader" />
<AlternatingRowStyle CssClass="MailListAlternatingRow" />
-</asp:GridView>
+</nmwa:RowClickableGridView>
<asp:ObjectDataSource ID="MailListDataSource" runat="server" SelectMethod="GetMessageEnvelopes" TypeName="NMail.WebAcess.MailListDataSource" >
<SelectParameters>
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MailList.ascx.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -13,6 +13,18 @@
{
protected void Page_Load(object sender, EventArgs e) {}
+ protected void MailList_OnSelectedIndexChanged(object sender, EventArgs args)
+ {
+ if (this.MailListGridView.SelectedIndex == -1)
+ {
+ Session.Remove("SelectedMessageId");
+ }
+ else
+ {
+ Session["SelectedMessageId"] = this.MailListGridView.SelectedValue;
+ }
+ }
+
#region IWebPart Members
private string catalogIconImageUrl;
@@ -48,17 +60,15 @@
get { return null; }
}
- private string title = "Mail List";
-
public string Title
{
get
{
- return this.title;
+ return Session["SelectedFolderName"] as string;
}
set
{
- this.title = value;
+ throw new NotSupportedException("Can't set the title manually for the mail list.");
}
}
Added: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx (rev 0)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,16 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MessageBody.aspx.cs" Inherits="Controls_Mail_MessageBody" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+ <title>Untitled Page</title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div class="MessageBody">
+ <asp:Literal ID="MessageBody" runat="server" />
+ </div>
+ </form>
+</body>
+</html>
Added: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx.cs (rev 0)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageBody.aspx.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,65 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Collections;
+using System.Text;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+using NMail.DataTypes;
+using NMail.Helper;
+using NMail.WebAccess;
+using RemoteAccessService;
+
+public partial class Controls_Mail_MessageBody : System.Web.UI.Page
+{
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ int selectedFolderId = (int) Session["SelectedFolderId"];
+ int messageId = (int) Session["SelectedMessageId"];
+
+ string authToken = (string) Session["AuthToken"];
+ RemoteAccessService.RemoteAccessService ras = (RemoteAccessService.RemoteAccessService) Session["RAS"];
+
+ BodyStructureSerializer bs = ras.GetMessageStructure(authToken, messageId, selectedFolderId);
+ BodyStructure bodyStructure = Helper.GetBodyStructure(bs);
+
+ int bodyPartNumber = 1;
+
+ if (bodyStructure.Count == 0)
+ {
+ // Simple message body, only one part to the message
+ bodyPartNumber = 1;
+ }
+ else
+ {
+ // Search for the best part
+ for (int i = 0; i < bodyStructure.Count; i++)
+ {
+ string subType;
+ MimeContentType contentType = MimeHelper.GetContentType(bodyStructure[i].Headers, out subType);
+
+ if (contentType == MimeContentType.Text)
+ {
+ // We'll take the first text part we find unless something better appears
+ bodyPartNumber = i + 1;
+
+ if (subType == "html")
+ {
+ // We'll display the first HTML part we find
+ break;
+ }
+ }
+ }
+ }
+
+ string base64Body = ras.GetMessageMimePart(authToken, bodyPartNumber, messageId, selectedFolderId);
+ string bodyData = Encoding.UTF8.GetString(Convert.FromBase64String(base64Body));
+
+ this.MessageBody.Text = bodyData;
+ }
+}
Added: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx (rev 0)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,3 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MessageViewer.ascx.cs" Inherits="Controls_Mail_MessageViewer" %>
+
+<iframe src="Controls/Mail/MessageBody.aspx"></iframe>
\ No newline at end of file
Added: NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx.cs (rev 0)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/MessageViewer.ascx.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -0,0 +1,18 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Collections;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+public partial class Controls_Mail_MessageViewer : System.Web.UI.UserControl
+{
+ protected void Page_Load(object sender, EventArgs e)
+ {
+
+ }
+}
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx 2007-01-24 09:02:05 UTC (rev 123)
@@ -2,25 +2,27 @@
<%@ Register Assembly="MenuPilot" Namespace="MenuPilot.Web.Ui" TagPrefix="mp" %>
-<asp:Repeater
- ID="FolderRepeater"
- runat="server"
- OnItemCommand="FolderRepeater_OnItemCommand"
- DataSourceID="SubscribedFolderDataSource">
-
- <ItemTemplate>
- <asp:LinkButton
- Text='<%# GetFolderString(Container.DataItem) %>'
- CommandArgument='<%# DataBinder.Eval(Container.DataItem, "FolderId") %>'
- CommandName="SelectedFolderChanged"
- runat="server"
- ID="LinkButton" />
- <br />
- </ItemTemplate>
-</asp:Repeater>
+<div class="SubscribedFolderList">
+ <asp:Repeater
+ ID="FolderRepeater"
+ runat="server"
+ OnItemCommand="FolderRepeater_OnItemCommand"
+ DataSourceID="SubscribedFolderDataSource">
+
+ <ItemTemplate>
+ <asp:LinkButton
+ Text='<%# GetFolderString(Container.DataItem) %>'
+ CommandArgument='<%# DataBinder.Eval(Container.DataItem, "FolderId") %>'
+ CommandName="SelectedFolderChanged"
+ runat="server"
+ ID="LinkButton" />
+ <br />
+ </ItemTemplate>
+ </asp:Repeater>
-<asp:ObjectDataSource
- ID="SubscribedFolderDataSource"
- runat="server"
- SelectMethod="GetSubscribedFolders"
- TypeName="NMail.WebAccess.SubscribedFolderDataSource" />
\ No newline at end of file
+ <asp:ObjectDataSource
+ ID="SubscribedFolderDataSource"
+ runat="server"
+ SelectMethod="GetSubscribedFolders"
+ TypeName="NMail.WebAccess.SubscribedFolderDataSource" />
+</div>
\ No newline at end of file
Modified: NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx.cs
===================================================================
--- NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx.cs 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/Controls/Mail/SubscribedFolderList.ascx.cs 2007-01-24 09:02:05 UTC (rev 123)
@@ -48,7 +48,9 @@
protected void FolderRepeater_OnItemCommand(object sender, CommandEventArgs args)
{
int folderId = int.Parse(args.CommandArgument as string);
+ NMail.DataTypes.LocalStore.StoreFolder folder = NMail.WebAccess.SubscribedFolderDataSource.GetStoreFolder(folderId);
Session["SelectedFolderId"] = folderId;
+ Session["SelectedFolderName"] = folder.FullFolderName;
}
}
\ No newline at end of file
Modified: NMail/trunk/NMail.WebAccess/Mail.aspx
===================================================================
--- NMail/trunk/NMail.WebAccess/Mail.aspx 2007-01-21 06:14:55 UTC (rev 122)
+++ NMail/trunk/NMail.WebAccess/Mail.aspx 2007-01-24 09:02:05 UTC (rev 123)
@@ -1,5 +1,7 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Mail.aspx.cs" Inherits="Mail" %>
+<%@ Register Src="Controls/Mail/MessageViewer.ascx" TagName="MessageViewer" TagPrefix="uc4" %>
+
<%@ Register Src="Controls/Mail/MailList.ascx" TagName="MailList" TagPrefix="uc3" %>
<%@ Register Src="Controls/Mail/SubscribedFolderList.ascx" TagName="SubscribedFolderList" TagPrefix="uc2" %>
@@ -10,7 +12,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
- <title>Untitled Page</title>
+ <title>Mail</title>
</head>
<body>
<form id="form1" runat="server">
@@ -19,27 +21,31 @@
<table width="100%" border="0">
<tr>
<td rowspan="3" valign="top">
- <asp:WebPartZone ID="LeftZone" runat="server">
+ <asp:WebPartZone ID="LeftZone" runat="server" HeaderText=" ">
+ <CloseVerb Enabled="false" Visible="false" />
<ZoneTemplate>
+ <uc2:SubscribedFolderList ID="SubscribedFolderList" runat="server" />
<uc1:LinkButtonList ID="ViewList" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
</td>
<td valign="top">
- <asp:WebPartZone ID="TopZone" runat="server" LayoutOrientation="Horizontal">
+ <asp:WebPartZone Width="100%" ID="TopZone" runat="server" LayoutOrientation="Horizontal" HeaderText=" ">
+ <CloseVerb Enabled="false" Visible="false" />
</asp:WebPartZone>
</td>
<td rowspan="3" valign="top">
- <asp:WebPartZone ID="RightZone" runat="server">
+ <asp:WebPartZone ID="RightZone" runat="server" HeaderText=" ">
+ <CloseVerb Enabled="false" Visible="false" />
<ZoneTemplate>
- <uc2:SubscribedFolderList ID="SubscribedFolderList" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
</td>
</tr>
<tr>
<td valign="top">
- <asp:WebPartZone ID="CenterZone" runat="server" LayoutOrientation="Horizontal" HeaderText=" ">
+ <asp:WebPartZone Width="100%" ID="CenterZone" runat="server" LayoutOrientation="Vertical" HeaderText=" ">
+ <CloseVerb Enabled="false" Visible="false" />
<ZoneTemplate>
<uc3:MailList ID="MailList1" runat="server" />
</ZoneTemplate>
@@ -48,7 +54,11 @@
</tr>
<tr>
<td valign="top">
- <asp:WebPartZone ID="BottomZone" runat="server" LayoutOrientation="Horizontal">
+ <asp:WebPartZone Width="100%" ID="BottomZone" runat="server" LayoutOrientation="Horizontal" HeaderText=" ">
+ <CloseVerb Enabled="false" Visible="false" />
+ <ZoneTemplate>
+ <uc4:MessageViewer ID="MessageViewer1" runat="server" />
+ </ZoneTemplate>
</asp:WebPartZone>
</td>
</tr>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|