private static string ClientIdFromItemId(byte[] itemId)
        {
            string text = TraceUtils.DumpBytes(itemId);

            if (text.Length > 40)
            {
                text = text.Substring(text.Length - 40);
            }
            return(text);
        }
 void IDestinationMailbox.ProcessMailboxSignature(byte[] mailboxData)
 {
     base.CreateContext("IDestinationMailbox.ProcessMailbox", new DataContext[]
     {
         new SimpleValueDataContext("MailboxData", TraceUtils.DumpBytes(mailboxData))
     }).Execute(delegate
     {
         ((IDestinationMailbox)this.WrappedObject).ProcessMailboxSignature(mailboxData);
     }, true);
 }
Beispiel #3
0
        private string GetSyncStateSubject(byte[] key)
        {
            DateTime utcNow = DateTime.UtcNow;

            return(string.Format(CultureInfo.InvariantCulture, "SyncState: {0}-{1} :: {2} :: {3}", new object[]
            {
                base.MailboxGuid.ToString(),
                TraceUtils.DumpBytes(key),
                utcNow.ToLongDateString(),
                utcNow.ToLongTimeString()
            }));
        }
Beispiel #4
0
        public static uint ParseUid(byte[] messageEntryId)
        {
            Dictionary <string, string> dictionary = ImapEntryId.ParseMessageEntryId(messageEntryId);
            string s;
            uint   result;

            if (dictionary.TryGetValue("U", out s) && uint.TryParse(s, out result))
            {
                return(result);
            }
            throw new ParsingMessageEntryIdFailedException(TraceUtils.DumpBytes(messageEntryId), new ArgumentException("Cannot parse uid.", "messageEntryId"));
        }
        string IMailbox.LoadSyncState(byte[] key)
        {
            string result = null;

            base.CreateContext("IMailbox.LoadSyncState", new DataContext[]
            {
                new SimpleValueDataContext("Key", TraceUtils.DumpBytes(key))
            }).Execute(delegate
            {
                result = this.WrappedObject.LoadSyncState(key);
            }, true);
            return(result);
        }
        CreateMailboxResult IDestinationMailbox.CreateMailbox(byte[] mailboxData, MailboxSignatureFlags sourceSignatureFlags)
        {
            CreateMailboxResult result = CreateMailboxResult.Success;

            base.CreateContext("IDestinationMailbox.CreateMailbox", new DataContext[]
            {
                new SimpleValueDataContext("MailboxData", TraceUtils.DumpBytes(mailboxData)),
                new SimpleValueDataContext("sourceSignatureFlags", sourceSignatureFlags)
            }).Execute(delegate
            {
                result = ((IDestinationMailbox)this.WrappedObject).CreateMailbox(mailboxData, sourceSignatureFlags);
            }, true);
            return(result);
        }
        MessageRec IMailbox.SaveSyncState(byte[] key, string syncState)
        {
            MessageRec result = null;

            base.CreateContext("IMailbox.SaveSyncState", new DataContext[]
            {
                new SimpleValueDataContext("Key", TraceUtils.DumpBytes(key)),
                new SimpleValueDataContext("SyncStateLength", (syncState != null) ? syncState.Length : 0)
            }).Execute(delegate
            {
                result = this.WrappedObject.SaveSyncState(key, syncState);
            }, true);
            return(result);
        }
Beispiel #8
0
		string IMailbox.LoadSyncState(byte[] key)
		{
			MrsTracer.Provider.Function("PstDestinationMailbox.IMailbox.LoadSyncState(key={0})", new object[]
			{
				TraceUtils.DumpBytes(key)
			});
			this.LoadSyncStateCache();
			string text = this.syncStateCache[key];
			MrsTracer.Provider.Debug("key {0}found.", new object[]
			{
				(text != null) ? string.Empty : "NOT "
			});
			return text;
		}
Beispiel #9
0
 public override string ToString()
 {
     return(string.Format("Rule: Condition: {0}; Actions: {1}; Name '{2}'; Provider: '{3}'; ProviderData: {4}; ExecutionSequence: {5}; Level: {6}; StateFlags: {7}; UserFlags: {8}; IsExtended: {9}", new object[]
     {
         (this.Condition == null) ? "none" : this.Condition.ToString(),
         CommonUtils.ConcatEntries <RuleActionData>(this.Actions, null),
         this.Name,
         this.Provider,
         TraceUtils.DumpBytes(this.ProviderData),
         this.ExecutionSequence,
         this.Level,
         this.StateFlags,
         this.UserFlags,
         this.IsExtended
     }));
 }
Beispiel #10
0
        private static Dictionary <string, string> ParseKeyValuePairs(byte[] messageEntryId, string[] keyValuePairs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>(ImapEntryId.MessageEntryIdKeys.Length);

            foreach (string text in keyValuePairs)
            {
                string[] array = text.Split(new char[]
                {
                    '='
                });
                if (array.Length == 2)
                {
                    string text2 = array[0];
                    string text3 = array[1];
                    if (string.IsNullOrEmpty(text2) || string.IsNullOrEmpty(text3))
                    {
                        throw new ParsingMessageEntryIdFailedException(TraceUtils.DumpBytes(messageEntryId), new ArgumentException("messageEntryId", string.Format("While parsing message entry id, key {0} value {1}", text2, text3)));
                    }
                    if (dictionary.ContainsKey(text2))
                    {
                        throw new ParsingMessageEntryIdFailedException(TraceUtils.DumpBytes(messageEntryId), new ArgumentException("messageEntryId", string.Format("Duplicate key {0} found while parsing message entry id.", text2)));
                    }
                    dictionary.Add(text2, text3);
                }
            }
            foreach (string text4 in ImapEntryId.MessageEntryIdKeys)
            {
                if (!dictionary.ContainsKey(text4))
                {
                    throw new ParsingMessageEntryIdFailedException(TraceUtils.DumpBytes(messageEntryId), new ArgumentException("messageEntryId", string.Format("Key {0} not found in result.", text4)));
                }
            }
            string text5 = dictionary["V"];

            if (!text5.Equals("1", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new UnsupportedImapMessageEntryIdVersionException(text5);
            }
            string text6 = dictionary["P"];

            if (!text6.Equals("IMAP", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new UnsupportedSyncProtocolException(text6);
            }
            return(dictionary);
        }
        private byte[] CreateItem(byte[] itemEntryId, byte[] folderEntryId, Func <string, string, string, byte[]> executeSync)
        {
            base.CheckDisposed();
            Add add;

            if (!base.EasFolderCache.TryGetValue(folderEntryId, out add))
            {
                MrsTracer.Provider.Warning("Source folder {0} doesn't exist", new object[]
                {
                    TraceUtils.DumpBytes(folderEntryId)
                });
                throw new EasObjectNotFoundException(EasMailbox.GetStringId(folderEntryId));
            }
            string arg     = EasSourceMailbox.ClientIdFromItemId(itemEntryId);
            string syncKey = base.GetPersistedSyncState(folderEntryId).SyncKey;

            return(executeSync(arg, syncKey, add.ServerId));
        }
        private void UpdateItem(byte[] itemEntryId, byte[] folderEntryId, Action <string, string, string> executeSync)
        {
            base.CheckDisposed();
            Add add;

            if (!base.EasFolderCache.TryGetValue(folderEntryId, out add))
            {
                MrsTracer.Provider.Warning("Source folder {0} doesn't exist", new object[]
                {
                    TraceUtils.DumpBytes(folderEntryId)
                });
                throw new EasObjectNotFoundException(EasMailbox.GetStringId(folderEntryId));
            }
            string stringId = EasMailbox.GetStringId(itemEntryId);
            string syncKey  = base.GetPersistedSyncState(folderEntryId).SyncKey;

            executeSync(stringId, syncKey, add.ServerId);
        }
 private void SetReadFlags(byte[] messageEntryId, byte[] folderEntryId, bool isRead)
 {
     base.CheckDisposed();
     using (ImapFolder folder = base.GetFolder <ImapSourceFolder>(folderEntryId))
     {
         if (folder == null)
         {
             MrsTracer.Provider.Warning("Source folder {0} doesn't exist", new object[]
             {
                 TraceUtils.DumpBytes(folderEntryId)
             });
             throw new ImapObjectNotFoundException(TraceUtils.DumpBytes(folderEntryId));
         }
         uint        item = ImapEntryId.ParseUid(messageEntryId);
         List <uint> list = new List <uint>(1);
         list.Add(item);
         List <ImapMessageRec> list2 = folder.Folder.LookupMessages(base.ImapConnection, list);
         if (list2.Count == 0)
         {
             MrsTracer.Provider.Warning("Source message {0} doesn't exist", new object[]
             {
                 TraceUtils.DumpBytes(messageEntryId)
             });
             throw new ImapObjectNotFoundException(TraceUtils.DumpBytes(messageEntryId));
         }
         ImapMailFlags imapMailFlags  = list2[0].ImapMailFlags;
         ImapMailFlags imapMailFlags2 = isRead ? (imapMailFlags | ImapMailFlags.Seen) : (imapMailFlags & ~ImapMailFlags.Seen);
         if (imapMailFlags != imapMailFlags2)
         {
             string text = item.ToString(CultureInfo.InvariantCulture);
             MrsTracer.Provider.Debug("StoreMessageFlags - uid: {0}, flagsToStore: {1}, previousFlags {2}", new object[]
             {
                 text,
                 imapMailFlags2,
                 imapMailFlags
             });
             base.ImapConnection.StoreMessageFlags(text, imapMailFlags2, imapMailFlags);
         }
     }
 }
Beispiel #14
0
        private static Dictionary <string, string> ParseMessageEntryId(byte[] messageEntryId)
        {
            if (messageEntryId == null)
            {
                throw new ParsingMessageEntryIdFailedException(null, new ArgumentNullException("messageEntryId"));
            }
            string text = null;

            try
            {
                text = Encoding.UTF8.GetString(messageEntryId);
            }
            catch (Exception innerException)
            {
                throw new ParsingMessageEntryIdFailedException(TraceUtils.DumpBytes(messageEntryId), innerException);
            }
            string[] keyValuePairs = text.Split(new char[]
            {
                ';'
            });
            return(ImapEntryId.ParseKeyValuePairs(messageEntryId, keyValuePairs));
        }
Beispiel #15
0
		MessageRec IMailbox.SaveSyncState(byte[] key, string syncStateStr)
		{
			MrsTracer.Provider.Function("PstDestinationMailbox.IMailbox.SaveSyncState(key={0})", new object[]
			{
				TraceUtils.DumpBytes(key)
			});
			if (base.IPst == null)
			{
				MrsTracer.Provider.Debug("Skipping sync state save on a previously failed pst file", new object[0]);
				return null;
			}
			try
			{
				this.LoadSyncStateCache();
				this.syncStateCache[key] = syncStateStr;
				base.MessageStorePropertyBag.SetProperty(new PropertyValue(new PropertyTag((PropertyId)this.syncStatePropId, PropertyType.Unicode), this.syncStateCache.Serialize(false)));
				base.IPst.MessageStore.Save();
			}
			catch (PSTExceptionBase innerException)
			{
				throw new UnableToSavePSTSyncStatePermanentException(base.IPst.FileName, innerException);
			}
			return null;
		}
        private byte[] MoveItem(byte[] messageEntryId, byte[] sourceFolderEntryId, byte[] destFolderEntryId, out bool isPermanentDeletionMove)
        {
            isPermanentDeletionMove = false;
            base.CheckDisposed();
            Add add;

            if (!base.EasFolderCache.TryGetValue(sourceFolderEntryId, out add))
            {
                MrsTracer.Provider.Warning("Source folder {0} doesn't exist", new object[]
                {
                    TraceUtils.DumpBytes(sourceFolderEntryId)
                });
                throw new EasObjectNotFoundException(EasMailbox.GetStringId(sourceFolderEntryId));
            }
            Add add2;

            if (!base.EasFolderCache.TryGetValue(destFolderEntryId, out add2))
            {
                MrsTracer.Provider.Warning("Destination folder {0} doesn't exist", new object[]
                {
                    TraceUtils.DumpBytes(destFolderEntryId)
                });
                throw new EasObjectNotFoundException(EasMailbox.GetStringId(destFolderEntryId));
            }
            string stringId = EasMailbox.GetStringId(messageEntryId);

            if (add2.Type == 4 && EasFolder.IsCalendarFolder((EasFolderType)add.Type))
            {
                this.DeleteItem(messageEntryId, sourceFolderEntryId);
                isPermanentDeletionMove = true;
                return(null);
            }
            string stringId2 = base.EasConnectionWrapper.MoveItem(stringId, add.ServerId, add2.ServerId);

            return(EasMailbox.GetEntryId(stringId2));
        }
 protected override string ToStringInternal()
 {
     return(string.Format("DEFER {0}", TraceUtils.DumpBytes(this.Data)));
 }