コード例 #1
0
ファイル: Mailbox.cs プロジェクト: c0d3l0g1c/Skycap-Mail
 public static Mailbox Find(Mailbox root, string name)
 {
     string str = StringEncoding.EncodeMailboxName(name);
     if (root.Name == str)
     {
         return root;
     }
     foreach (Mailbox mailbox in root.Children)
     {
         Mailbox mailbox2 = Find(mailbox, name);
         if (mailbox2 != null)
         {
             return mailbox2;
         }
     }
     return null;
 }
コード例 #2
0
        /// <summary>
        /// Ensures a mail header dictionary entry exists for the specified account and folder.
        /// </summary>
        /// <param name="accountSettingsData">The account settings data.</param>
        /// <param name="mailbox">The mailbox.</param>
        public void EnsureMailHeader(AccountSettingsData accountSettingsData, Mailbox mailbox)
        {
            try
            {
                // Make sure the account exists
                if (!this.ContainsKey(accountSettingsData.EmailAddress))
                {
                    this.TryAdd(accountSettingsData.EmailAddress, new ConcurrentDictionary <string, MailHeaderObservableCollectionView>(StringComparer.OrdinalIgnoreCase));
                }

                // Make sure the folder for the account exists
                if (!this[accountSettingsData.EmailAddress].ContainsKey(mailbox.FullName))
                {
                    this[accountSettingsData.EmailAddress].TryAdd(mailbox.FullName, new MailHeaderObservableCollectionView());
                }
            }
            catch (Exception ex)
            {
                LogFile.Instance.LogError(accountSettingsData.EmailAddress, mailbox.Name, ex.ToString());
            }
        }
コード例 #3
0
ファイル: Mailbox.cs プロジェクト: c0d3l0g1c/Skycap-Mail
 private static Mailbox AssembleTree(IEnumerable<KeyValuePair<string[], Mailbox>> paths)
 {
     Mailbox item = new Mailbox();
     Stack<Mailbox> stack = new Stack<Mailbox>();
     int num = 1;
     stack.Push(item);
     foreach (KeyValuePair<string[], Mailbox> pair in paths)
     {
         while (num > pair.Key.Length)
         {
             stack.Pop();
             num--;
         }
         Mailbox mailbox2 = stack.Peek();
         mailbox2.Children.Add(pair.Value);
         pair.Value.Parent = mailbox2;
         stack.Push(pair.Value);
         num++;
     }
     return item;
 }
コード例 #4
0
        /// <summary>
        /// Adds or updates the mail header for the specified account and mailbox.
        /// </summary>
        /// <param name="accountSettingsData">The account settings data.</param>
        /// <param name="mailbox">The mailbox.</param>
        /// <param name="mailHeader">The mail header.</param>
        public void AddOrUpdate(AccountSettingsData accountSettingsData, Mailbox mailbox, MailHeader mailHeader)
        {
            try
            {
                // Ensure the mail header dictionary entry exists
                EnsureMailHeader(accountSettingsData, mailbox);

                // If the header exists - update it
                if (this[accountSettingsData.EmailAddress][mailbox.FullName].Contains(mailHeader))
                {
                    this[accountSettingsData.EmailAddress][mailbox.FullName][this[accountSettingsData.EmailAddress][mailbox.FullName].IndexOf(mailHeader)] = mailHeader;
                }
                // Else if the header does not exist = add it
                else
                {
                    this[accountSettingsData.EmailAddress][mailbox.FullName].Add(mailHeader);
                }
            }
            catch (Exception ex)
            {
                LogFile.Instance.LogError(accountSettingsData.EmailAddress, mailbox.Name, ex.ToString());
            }
        }
コード例 #5
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.MailboxEventArgs class.
 /// </summary>
 /// <param name="mailbox">The mailbox.</param>
 public MailboxEventArgs(Mailbox mailbox)
 {
     // Initialise local variables
     Mailbox = mailbox;
 }
コード例 #6
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.MailboxFailedEventArgs class.
 /// </summary>
 /// <param name="mailbox">The mailbox.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="userErrorMessage">The user error message.</param>
 public MailboxFailedEventArgs(Mailbox mailbox, Exception errorMessage, string userErrorMessage)
     : base(errorMessage, userErrorMessage)
 {
     // Initialise local variables
     Mailbox = mailbox;
 }
コード例 #7
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.DeleteMessageEventArgs class.
 /// </summary>
 /// <param name="messagePaths">The message paths to delete.</param>
 /// <param name="mailbox">The mailbox to delete from.</param>
 public DeleteMessageEventArgs(Dictionary <string, string> messagePaths, Mailbox mailbox)
     : base(mailbox)
 {
     // Initialise local variables
     MessagePaths = messagePaths;
 }
コード例 #8
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Data.MailboxListViewItem class.
 /// </summary>
 /// <param name="accountSettingsData">The account settings data.</param>
 /// <param name="mailbox">The mailbox.</param>
 /// <param name="padding">The padding.</param>
 /// <param name="mailboxUnreadEmailCount">The unread email count action.</param>
 public MailboxListViewItem(AccountSettingsData accountSettingsData, Mailbox mailbox, int padding, MailboxUnreadEmailCount mailboxUnreadEmailCountAction)
     : this(accountSettingsData, mailbox, padding, mailboxUnreadEmailCountAction, Visibility.Visible)
 {
 }
コード例 #9
0
ファイル: Mailbox.cs プロジェクト: c0d3l0g1c/Skycap-Mail
        private Mailbox(string name, Mailbox parent, NameAttributesCollection attributes)
            : this(name, parent, name, attributes)
        {

        }
コード例 #10
0
ファイル: Mailbox.cs プロジェクト: c0d3l0g1c/Skycap-Mail
 public override bool Equals(object obj)
 {
     Mailbox mailbox = (Mailbox)obj;
     return (FullName ?? Name).Equals(mailbox.FullName ?? mailbox.Name, StringComparison.OrdinalIgnoreCase);
 }
コード例 #11
0
ファイル: Mailbox.cs プロジェクト: c0d3l0g1c/Skycap-Mail
 public static Mailbox NewMailbox(string name, Mailbox mailbox, string displayName)
 {
     return new Mailbox(name, mailbox, displayName, new NameAttributesCollection(new List<string>().AsEnumerable()));
 }
コード例 #12
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.DownloadingMessageEventArgs class.
 /// </summary>
 /// <param name="uidsFile">The uids file.</param>
 /// <param name="storedUids">The stored uids.</param>
 /// <param name="mailbox">The mailbox.</param>
 /// <param name="statisticInfo">The statistic info.</param>
 /// <param name="totalMessageCount">The total message count.</param>
 /// <param name="totalMessageSize">The total message size.</param>
 /// <param name="currentMessageCount">The total message count.</param>
 /// <param name="currentMessageSize">The total message size.</param>
 /// <param name="remainingMessageCount">The remaining message count.</param>
 /// <param name="remainingMessageSize">The remaining message size.</param>
 public MessageProgressEventArgs(StorageFile uidsFile, IList <string> storedUids, Mailbox mailbox, StatisticInfo statisticInfo, uint totalMessageCount, uint totalMessageSize, uint currentMessageCount, uint currentMessageSize, uint remainingMessageCount, uint remainingMessageSize)
     : base(mailbox, statisticInfo.UniqueNumber, null)
 {
     // Initialise local variables
     UidsFile              = uidsFile;
     StoredUids            = storedUids;
     StatisticInfo         = statisticInfo;
     TotalMessageCount     = totalMessageCount;
     TotalMessageSize      = totalMessageSize;
     CurrentMessageCount   = currentMessageCount;
     CurrentMessageSize    = currentMessageSize;
     RemainingMessageCount = remainingMessageCount;
     RemainingMessageSize  = remainingMessageSize;
 }
コード例 #13
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.DownloadingMessageEventArgs class.
 /// </summary>
 /// <param name="mailbox">The mailbox.</param>
 /// <param name="statisticInfo">The statistic info.</param>
 /// <param name="totalMessageCount">The total message count.</param>
 /// <param name="totalMessageSize">The total message size.</param>
 /// <param name="currentMessageCount">The total message count.</param>
 /// <param name="currentMessageSize">The total message size.</param>
 /// <param name="remainingMessageCount">The remaining message count.</param>
 /// <param name="remainingMessageSize">The remaining message size.</param>
 public MessageProgressEventArgs(Mailbox mailbox, StatisticInfo statisticInfo, uint totalMessageCount, uint totalMessageSize, uint currentMessageCount, uint currentMessageSize, uint remainingMessageCount, uint remainingMessageSize)
     : this(null, null, mailbox, statisticInfo, totalMessageCount, totalMessageSize, currentMessageCount, currentMessageSize, remainingMessageCount, remainingMessageSize)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.MoveMessageEventArgs class.
 /// </summary>
 /// <param name="messagePaths">The message paths to move.</param>
 /// <param name="messages">The messages</param>
 /// <param name="sourceMailbox">The source mailbox.</param>
 /// <param name="destinationMailbox">The destination mailbox.</param>
 public MoveMessageEventArgs(Dictionary <string, string> messagePaths, Dictionary <string, StructuredMessage> messages, Mailbox sourceMailbox, Mailbox destinationMailbox)
     : base(sourceMailbox)
 {
     // Initialise local variables
     MessagePaths       = messagePaths;
     Messages           = messages;
     DestinationMailbox = destinationMailbox;
 }
コード例 #15
0
ファイル: MailHeader.cs プロジェクト: c0d3l0g1c/Skycap-Mail
        /// <summary>
        /// Initialises a new instance of the Skycap.Data.MailHeader class.
        /// </summary>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="uid">The unique message id.</param>
        /// <param name="message">The mail message.</param>
        /// <param name="mailbox">The mailbox.</param>
        public MailHeader(string emailAddress, string uid, StructuredMessage message, Mailbox mailbox)
        {
            // Initialise local variables
            EmailAddress = emailAddress;
            Uid          = uid;
            Comments     = message.Header.Comments;
            Mailbox      = mailbox;
            MessagePath  = message.MessagePath;
            Date         = message.Date;
            From         = (message.From == null ? string.Empty : (string.IsNullOrEmpty(message.From.DisplayName) ? message.From.Address : message.From.DisplayName));
            Subject      = message.Header.Subject;
            IsSeen       = message.IsSeen;
            IsDeleted    = message.IsDeleted;
            AttachmentsImageVisibility = (message.Attachments.Count > 0 ? Visibility.Visible : Visibility.Collapsed);
            ImportanceVisibility       = (message.Header.Importance == MailImportance.Normal ? Visibility.Collapsed : Visibility.Visible);
            switch (message.Header.Importance)
            {
            case MailImportance.Low:
                ImportanceForeground = "Blue";
                break;

            case MailImportance.High:
                ImportanceForeground = "Red";
                break;

            default:
                ImportanceForeground = "Black";
                break;
            }
            IsFlagged     = message.IsFlagged;
            IsImapMessage = (message is ImapMessage);
        }
コード例 #16
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.SendMessageEventArgs class.
 /// </summary>
 /// <param name="messagePaths">The message paths to move.</param>
 /// <param name="messages">The messages</param>
 /// <param name="sourceMailbox">The source mailbox.</param>
 /// <param name="destinationMailbox">The destination mailbox.</param>
 public SendMessageEventArgs(Dictionary <string, string> messagePaths, Dictionary <string, StructuredMessage> messages, Mailbox sourceMailbox, Mailbox destinationMailbox)
     : this(messagePaths, messages, sourceMailbox, destinationMailbox, null)
 {
 }
コード例 #17
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Net.Common.SendMessageEventArgs class.
 /// </summary>
 /// <param name="messagePaths">The message paths to move.</param>
 /// <param name="messages">The messages</param>
 /// <param name="sourceMailbox">The source mailbox.</param>
 /// <param name="destinationMailbox">The destination mailbox.</param>
 /// <param name="sendResult">The send result.</param>
 public SendMessageEventArgs(Dictionary <string, string> messagePaths, Dictionary <string, StructuredMessage> messages, Mailbox sourceMailbox, Mailbox destinationMailbox, SendResult sendResult)
     : base(messagePaths, messages, sourceMailbox, destinationMailbox)
 {
     // Initialise local variables
     SendResult = sendResult;
 }
コード例 #18
0
 /// <summary>
 /// Returns the hash code for this MailboxListViewItem.
 /// </summary>
 /// <returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     return(Mailbox.GetHashCode());
 }