Example #1
0
 /// <summary>
 /// Initialization
 /// </summary>
 protected override void OnOpen(TimeSpan timeout)
 {
     // Get a mail handler object from the binding
     pMailHandler = EmailBindingElement.GetRaspMailHandlerFromBindingContext(pContext);
     pMailHandler.OnExceptionThrown  += new MailboxExceptionThrown(CallbackMailExceptionThrown);
     pMailHandler.OnInboxStateChange += new OnInboxStateChangeDelegate(CallbackOnInboxStateChange);
 }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="channelManager">channel handler</param>
 /// <param name="bindingElement">The binding element</param>
 /// <param name="mailHandler">The mail handler</param>
 /// <param name="msg">The message</param>
 public EmailReplyChannel(ChannelManagerBase channelManager, IMailHandler mailHandler, MailSoap12TransportBinding msg, EmailBindingElement bindingElement)
     : base(channelManager)
 {
     _msg                    = msg;
     _mailHandler            = mailHandler;
     _asyncTryReceiveRequest = new AsyncTryReceiveRequest(TryReceiveRequest);
     _bindingElement         = bindingElement;
 }
Example #3
0
        /// <summary>
        /// Overriding Clone to return rasp binding
        /// </summary>
        /// <returns>the binding element</returns>
        public override BindingElement Clone()
        {
            EmailBindingElement b = new EmailBindingElement();

            b.CopyElement(this);
            b.ExceptionThrown    = this.ExceptionThrown;
            b.OnInboxStateChange = this.OnInboxStateChange;
            return(b);
        }
Example #4
0
        /// <summary>
        /// OnCreateChannel event
        /// </summary>
        /// <param name="address"></param>
        /// <param name="via"></param>
        /// <returns></returns>
        protected override IRequestChannel OnCreateChannel(System.ServiceModel.EndpointAddress address, Uri via)
        {
            // Get a mail handler object from the binding
            MailHandler mailHandler = EmailBindingElement.GetRaspMailHandlerFromBindingContext(pBindingContext);

            mailHandler.OnExceptionThrown += new MailboxExceptionThrown(mailHandler_OnExceptionThrown);

            // Create the channel
            return(new EmailRequestChannel(mailHandler, address, this));
        }
Example #5
0
 /// <summary>
 /// Copies all settings into the binding
 /// </summary>
 public void CopyElement(EmailBindingElement original)
 {
     _sendingAuthenticationMode   = original.SendingAuthenticationMode;
     _receivingAuthenticationMode = original.ReceivingAuthenticationMode;
     _imapFolder             = original.ImapFolder;
     _pollingInterval        = original.PollingInterval;
     _receivingPassword      = original.ReceivingPassword;
     _receivingServerAddress = original.ReceivingServerAddress;
     _receivingUserName      = original.ReceivingUserName;
     _replyAddress           = original.ReplyAddress;
     _sendingPassword        = original.SendingPassword;
     _sendingServerAddress   = original.SendingServerAddress;
     _sendingUserName        = original.SendingUserName;
     _outboxImplementation   = original.OutboxImplementation;
     _inboxImplementation    = original.InboxImplementation;
     _receivingPort          = original._receivingPort;
     _sendingPort            = original._sendingPort;
     _maxReceivedMessageSize = original._maxReceivedMessageSize;
     if (_maxReceivedMessageSize != 0)
     {
         this.MaxReceivedMessageSize = _maxReceivedMessageSize;
     }
 }
Example #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="msg">The incoming System.ServiceModel.Channels.Message that contains the request</param>
 /// <param name="mailHandler">mailhandler</param>
 /// <param name="bindingElement">The binding element used in the current stack</param>
 public EmailRequestContext(MailSoap12TransportBinding msg, IMailHandler mailHandler, EmailBindingElement bindingElement)
 {
     _requestMessage = msg;
     pMailHandler    = mailHandler;
     _bindingElement = bindingElement;
 }
Example #7
0
        /// <summary>
        /// Creates a rasp mail handler
        /// </summary>
        /// <param name="bindingContext">the binding context</param>
        /// <returns>a rasp mail handler</returns>
        public static MailHandler GetRaspMailHandlerFromBindingContext(BindingContext bindingContext)
        {
            // Get the mail binding from the context
            EmailBindingElement mailBinding = (EmailBindingElement)bindingContext.Binding.Elements.Find <EmailBindingElement>();

            if (mailBinding == null)
            {
                throw new EmailBindingElemenNotFoundtException();
            }

            // Get the type of the outbox implementation

            Type outBoxImplementationType = Type.GetType(mailBinding.OutboxImplementation);

            if (outBoxImplementationType == null)
            {
                throw new MailboxImplementationCouldNotBeFoundException("outbox");
            }

            // Get the type of the inbox implementation
            Type inBoxImplementationType = Type.GetType(mailBinding.InboxImplementation);

            if (inBoxImplementationType == null)
            {
                throw new MailboxImplementationCouldNotBeFoundException("inbox");
            }

            // Read the connection policy from config
            MailServerConnectionPolicy inboxConnectionPolicy = new MailServerConnectionPolicy();

            if (mailBinding.PollingInterval != null && mailBinding.PollingInterval != TimeSpan.Zero)
            {
                inboxConnectionPolicy.PollingInterval = mailBinding.PollingInterval;
            }

            inboxConnectionPolicy.AuthenticationMode = mailBinding.ReceivingAuthenticationMode;
            inboxConnectionPolicy.Port = mailBinding.ReceivingPort;

            MailServerConnectionPolicy outboxConnectionPolicy = new MailServerConnectionPolicy();

            outboxConnectionPolicy.PollingInterval    = inboxConnectionPolicy.PollingInterval;
            outboxConnectionPolicy.AuthenticationMode = mailBinding.SendingAuthenticationMode;
            outboxConnectionPolicy.Port = mailBinding.SendingPort;

            MailServerConfiguration recievingServerConfiguration = new MailServerConfiguration(
                mailBinding.ReceivingServerAddress,
                mailBinding.ReceivingUserName,
                mailBinding.ReceivingPassword,
                mailBinding.ReplyAddress,
                inboxConnectionPolicy);
            MailServerConfiguration sendingServerConfiguration = new MailServerConfiguration(
                mailBinding.SendingServerAddress,
                mailBinding.SendingUserName,
                mailBinding.SendingPassword,
                mailBinding.ReplyAddress,
                outboxConnectionPolicy);
            MailHandlerConfiguration handlerConfiguration = new MailHandlerConfiguration(
                outBoxImplementationType,
                inBoxImplementationType,
                sendingServerConfiguration,
                recievingServerConfiguration);

            return(new MailHandler(handlerConfiguration));
        }