/// <summary>
        /// Validate if the given two buffers are equal
        /// </summary>
        /// <param name="operation">Fast transfer operation</param>
        /// <param name="firstBufferIndex">The first buffer's index</param>
        /// <param name="secondBufferIndex">The second buffer's index</param>
        /// <returns>Returns true only if the two buffers are equal</returns>
        public bool AreEqual(EnumFastTransferOperation operation, int firstBufferIndex, int secondBufferIndex)
        {
            if (firstBufferIndex <= 0 || secondBufferIndex <= 0)
            {
                return false;
            }
            else
            {
                byte[] firstBuffer = this.streamBufferContainer[firstBufferIndex];
                byte[] secondBuffer = this.streamBufferContainer[secondBufferIndex];
                if (firstBuffer.Length != secondBuffer.Length)
                {
                    return false;
                }
                else
                {
                    for (int i = 0; i < firstBuffer.Length; i++)
                    {
                        if (firstBuffer[i] != secondBuffer[i])
                        {
                            return false;
                        }
                    }

                    return true;
                }
            }
        }
        /// <summary>
        /// Initializes a FastTransfer operation on a folder for downloading content and descendant subobjects for messages identified by a given set of IDs.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="sourceHandleIndex">Folder object handle index. </param>
        /// <param name="copyFlag">Defines parameters of the FastTransfer download operation.</param>
        /// <param name="option">Defines the parameters of a download operation.</param>
        /// <param name="messageIds">The list of MIDs the messages should copy.</param>
        /// <param name="copyMessageHandleIndex">The message handle index.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult FastTransferSourceCopyMessages(int serverId, int sourceHandleIndex, RopFastTransferSourceCopyMessagesCopyFlags copyFlag, SendOptionAlls option, Sequence<int> messageIds, out int copyMessageHandleIndex)
        {
            // Initialize ROP data
            RopResult result = RopResult.InvalidParameter;
            copyMessageHandleIndex = -1;
            this.streamType = FastTransferStreamType.MessageList;
            RopFastTransferSourceCopyMessagesRequest req;
            uint sourceHandle = this.handleContainer[sourceHandleIndex];
            ushort idcount = (ushort)messageIds.Count;
            ulong[] messageId = new ulong[idcount];
            int index = 0;
            foreach (int mID in messageIds)
            {
                messageId[index++] = this.objectIdContainer[mID];
            }

            // Construct ROP request.
            req.RopId = 0x4B;
            req.LogonId = 0x00;
            req.InputHandleIndex = 0x00;
            req.OutputHandleIndex = 0x01;
            req.MessageIdCount = idcount;
            req.MessageIds = messageId;
            req.CopyFlags = (byte)copyFlag;
            req.SendOptions = (byte)option;

            // Stores message id and copy flag
            this.previousOperation = EnumFastTransferOperation.FastTransferSourceCopyMessage;
            this.messageIdForFastTransferSourceCopyMessages = (long)messageId[0];
            this.copyFlagForFastTransferSourceCopyMessages = copyFlag;

            // Send request and get response.
            RopFastTransferSourceCopyMessagesResponse response = (RopFastTransferSourceCopyMessagesResponse)this.Process(serverId, req, sourceHandle);
            result = (RopResult)response.ReturnValue;

            if (result == RopResult.Success)
            {
                copyMessageHandleIndex = AdapterHelper.GetHandleIndex();
                this.handleContainer.Add(copyMessageHandleIndex, this.responseSOHs[response.OutputHandleIndex]);
            }

            // Verify ROP FastTransferSourceCopyMessages
            this.VerifyRopFastTransferSourceCopyMessages(req, response);

            return result;
        }
        /// <summary>
        /// Initializes a FastTransfer operation to download content from a given messaging object and its descendant subobjects.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="sourceHandleIndex">Folder or message object handle index. </param>
        /// <param name="handleType">Type of object handle </param>
        /// <param name="level">Variable indicate whether copy the descendant subobjects.</param>
        /// <param name="copyFlag">Defines parameters of the FastTransfer download operation.</param>
        /// <param name="option">Defines the parameters of a download operation.</param>
        /// <param name="propertyTags">Array of properties and subobjects to exclude.</param>
        /// <param name="copyToHandleIndex">The properties handle index.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult FastTransferSourceCopyTo(int serverId, int sourceHandleIndex, InputHandleType handleType, bool level, CopyToCopyFlags copyFlag, SendOptionAlls option, Sequence<string> propertyTags, out int copyToHandleIndex)
        {
            // Initialize ROP returned value.
            RopResult result = RopResult.InvalidParameter;
            copyToHandleIndex = -1;
            ushort propertyCount = (ushort)propertyTags.Count;
            this.currentCopyFlag = copyFlag;

            // Get stream type.
            switch (handleType)
            {
                case InputHandleType.FolderHandle:
                    this.streamType = FastTransferStreamType.folderContent;
                    break;
                case InputHandleType.MessageHandle:
                    this.streamType = FastTransferStreamType.MessageContent;
                    break;
                case InputHandleType.AttachmentHandle:
                    this.streamType = FastTransferStreamType.attachmentContent;
                    break;
                default:
                    break;
            }

            // Initialize input propertyTags
            PropertyTag[] messagePropertyTags = new PropertyTag[propertyCount];
            for (int i = 0; i < propertyCount; i++)
            {
                messagePropertyTags[i] = this.propertyTagsDictionary[propertyTags[i]];
            }

            // Stores the values for further verification
            this.previousOperation = EnumFastTransferOperation.FastTransferSourceCopyTo;
            this.propertyTags = messagePropertyTags;

            // Construct ROP request.
            uint sourceHandle = this.handleContainer[sourceHandleIndex];
            RopFastTransferSourceCopyToRequest request;
            request.RopId = 0x4D;
            request.LogonId = 0X00;
            request.InputHandleIndex = 0x00;
            request.OutputHandleIndex = 0x01;

            // This value specifies the level at which the copy is occurring,Non-Zero: exclude all descendant subobjects from being copied
            request.Level = level ? (byte)1 : (byte)0;
            request.CopyFlags = (uint)copyFlag;
            request.SendOptions = (byte)option;
            request.PropertyTagCount = propertyCount;
            request.PropertyTags = messagePropertyTags;

            // Send request and get response.
            RopFastTransferSourceCopyToResponse response = (RopFastTransferSourceCopyToResponse)this.Process(serverId, request, sourceHandle);
            result = (RopResult)response.ReturnValue;

            if (result == RopResult.Success)
            {
                copyToHandleIndex = AdapterHelper.GetHandleIndex();
                this.handleContainer.Add(copyToHandleIndex, this.responseSOHs[response.OutputHandleIndex]);
            }

            // Verify ROP FastTransferSourceCopyTo
            this.VerifyRopFastTransferSourceCopyTo(request, response);

            return result;
        }
        /// <summary>
        /// Initializes a FastTransfer operation to download content from a given messaging object and its descendant subobjects.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="sourceHandleIndex">Folder or message object handle index. </param>
        /// <param name="handleType">Type of object handle. </param>
        /// <param name="level">Variable indicate whether copy the descendant subobjects.</param>
        /// <param name="copyFlag">Defines parameters of the FastTransfer download operation.</param>
        /// <param name="option">Defines the parameters of a download operation.</param>
        /// <param name="propertyTags">The list of properties and subobjects to exclude.</param>
        /// <param name="copyPropertiesHandleIndex">The properties handle index.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult FastTransferSourceCopyProperties(int serverId, int sourceHandleIndex, InputHandleType handleType, bool level, CopyPropertiesCopyFlags copyFlag, SendOptionAlls option, Sequence<string> propertyTags, out int copyPropertiesHandleIndex)
        {
            // Initialize ROP data.
            RopResult result = RopResult.InvalidParameter;
            RopFastTransferSourceCopyPropertiesRequest req;
            copyPropertiesHandleIndex = -1;
            uint sourceHandle = this.handleContainer[sourceHandleIndex];

            // Get stream type.
            switch (handleType)
            {
                case InputHandleType.FolderHandle:
                    this.streamType = FastTransferStreamType.folderContent;
                    break;
                case InputHandleType.MessageHandle:
                    this.streamType = FastTransferStreamType.MessageContent;
                    break;
                case InputHandleType.AttachmentHandle:
                    this.streamType = FastTransferStreamType.attachmentContent;
                    break;
                default:
                    break;
            }

            // Initialize input propertyTags.
            ushort propertyCount = (ushort)propertyTags.Count;
            PropertyTag[] messageSamplePropertyTags = new PropertyTag[propertyCount];
            for (int i = 0; i < propertyCount; i++)
            {
                messageSamplePropertyTags[i] = this.propertyTagsDictionary[propertyTags[i]];
            }

            this.previousOperation = EnumFastTransferOperation.FastTransferSourceCopyProperties;
            this.propertyTags = messageSamplePropertyTags;
            this.copySubObjects = !level;

            // Construct ROP request.
            req.RopId = 0x69;
            req.LogonId = 0x00;
            req.InputHandleIndex = 0x00;
            req.OutputHandleIndex = 0x01;

            // This value specifies the level at which the copy is occurring, which is specified in [MS-OXCROPS].
            req.Level = (byte)(level ? 1 : 0);

            req.CopyFlags = (byte)copyFlag;
            req.SendOptions = (byte)option;
            req.PropertyTagCount = propertyCount;
            req.PropertyTags = messageSamplePropertyTags;

            // Send request and get response.
            RopFastTransferSourceCopyPropertiesResponse response = (RopFastTransferSourceCopyPropertiesResponse)this.Process(serverId, req, sourceHandle);
            result = (RopResult)response.ReturnValue;

            if (result == RopResult.Success)
            {
                copyPropertiesHandleIndex = AdapterHelper.GetHandleIndex();
                this.handleContainer.Add(copyPropertiesHandleIndex, this.responseSOHs[response.OutputHandleIndex]);
            }

            // Verify ROP FastTransferSourceCopyProperties
            this.VerifyRopFastTransferSourceCopyProperties(req, response);

            return result;
        }
Пример #5
0
        private static bool AreEqual(EnumFastTransferOperation operation, int firstBufferIndex, int secondBufferIndex)
        {
            // Identify whether the firstBuffer and the secondBuffer are equal or not.
            if (firstBufferIndex <= 0 || secondBufferIndex <= 0)
            {
                return false;
            }

            bool returnValue = true;
            return returnValue;
        }