示例#1
0
        public StartTlsTransaction(ImapConnection connection, UpgradeConnectionStreamCallback createAuthenticatedStreamCallback)
            : base(connection)
        {
            if (createAuthenticatedStreamCallback == null)
            throw new ArgumentNullException("createAuthenticatedStreamCallback");

              this.createAuthenticatedStreamCallback = createAuthenticatedStreamCallback;
        }
示例#2
0
        public LoginTransaction(ImapConnection connection, NetworkCredential credential)
            : base(connection)
        {
            if (credential == null)
            throw new ArgumentNullException("credential");

              this.credential = credential;
        }
        public AuthenticateTransaction(ImapConnection connection, NetworkCredential credential, bool sendInitialResponse)
            : base(connection)
        {
            if (credential == null)
            throw new ArgumentNullException("credential");

              this.credential = credential;
              this.sendInitialResponse = sendInitialResponse;
              this.disposeMechanism = true;
        }
        public AuthenticateTransaction(ImapConnection connection, SaslClientMechanism authMechanism, bool sendInitialResponse)
            : base(connection)
        {
            if (authMechanism == null)
            throw new ArgumentNullException("authMechanism");

              this.saslMechanism = authMechanism;
              this.sendInitialResponse = sendInitialResponse;
              this.disposeMechanism = false;
        }
示例#5
0
 public CompressTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#6
0
 public GreetingTransaction(ImapConnection connection)
     : base(connection)
 {
 }
 public UnsubscribeTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#8
0
 public SearchTransaction(ImapConnection connection, bool uid, ImapCapability resultSpecifierCapabilityRequirement)
     : base(connection, uid, resultSpecifierCapabilityRequirement)
 {
 }
示例#9
0
 public CreateTransaction(ImapConnection connection, ImapCapability createParametersCapabilityRequirement)
     : base(connection)
 {
     this.createParametersCapabilityRequirement = createParametersCapabilityRequirement;
 }
示例#10
0
 public CheckTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#11
0
 public IdleTransaction(ImapConnection connection, object keepIdleState, ImapKeepIdleCallback keepIdleCallback)
     : base(connection)
 {
     this.keepIdleState = keepIdleState;
       this.keepIdleCallback = keepIdleCallback;
 }
 protected SubscribeTransactionBase(ImapConnection connection)
     : base(connection)
 {
 }
示例#13
0
 public DeleteTransaction(ImapConnection connection)
     : base(connection)
 {
 }
 public ListExtendedTransaction(ImapConnection connection)
     : base(connection)
 {
 }
 public SendCommandTransactionBase(ImapConnection connection)
     : base(connection)
 {
 }
示例#16
0
 protected SelectTransactionBase(ImapConnection connection, ImapMailbox selectingMailbox, ImapCapability selectParametersCapabilityRequirement)
     : base(connection)
 {
     this.selectingMailbox = selectingMailbox;
       this.selectParametersCapabilityRequirement = selectParametersCapabilityRequirement;
 }
示例#17
0
 public LogoutTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#18
0
 public NoOpTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#19
0
 protected NoOpTransactionBase(ImapConnection connection)
     : base(connection)
 {
 }
示例#20
0
 public ExamineTransaction(ImapConnection connection, ImapMailbox selectingMailbox, ImapCapability selectParametersCapabilityRequirement)
     : base(connection, selectingMailbox, selectParametersCapabilityRequirement)
 {
 }
示例#21
0
 public XListTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#22
0
 public GetQuotaTransaction(ImapConnection connection)
     : base(connection)
 {
 }
 /*
  * must be checked by caller
 ImapCapability IImapExtension.RequiredCapability {
   get { throw new NotImplementedException(); }
 }
 */
 public SetMetadataTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#24
0
 public RenameTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#25
0
 public CloseTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#26
0
 public UnselectTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#27
0
        private void CloseConnection()
        {
            if (connection == null)
            return;

              try {
            TraceInfo("disconnecting");

            connection.Close();

            TraceInfo("disconnected");
              }
              finally {
            TransitStateTo(ImapSessionState.NotConnected);

            connection = null;
              }
        }
示例#28
0
 public LsubTransaction(ImapConnection connection)
     : base(connection)
 {
 }
示例#29
0
        /*
         * transaction methods : connect/disconnect
         */
        private void Connect(string host, int port, UpgradeConnectionStreamCallback createAuthenticatedStreamCallback)
        {
            TraceInfo("connecting");

              this.connection = new ImapConnection(host, port, createAuthenticatedStreamCallback);

              TraceInfo("connected");

              SetServerCapabilities(new ImapCapabilityList(new[] {
            ImapCapability.Imap4Rev1 /* required by GreetingTransaction */
              }));

              ImapCommandResult result;

              using (var t = new GreetingTransaction(connection)) {
            try {
              result = ProcessTransaction(t);

              if (result.Code == ImapCommandResultCode.Bye) {
            var refferalResponseCode = result.GetResponseCode(ImapResponseCode.Referral);

            if (refferalResponseCode != null) {
              // RFC 2221 IMAP4 Login Referrals
              // http://tools.ietf.org/html/rfc2221
              // 4.2. BYE at connection startup referral
              //    An IMAP4 server MAY respond with an untagged BYE and a REFERRAL
              //    response code that contains an IMAP URL to a home server if it is not
              //    willing to accept connections and wishes to direct the client to
              //    another IMAP4 server.
              var referToUri = ImapResponseTextConverter.FromReferral(refferalResponseCode.ResponseText)[0];

              if (handlesReferralAsException) {
                throw new ImapLoginReferralException(string.Format("try another server: '{0}'", refferalResponseCode.ResponseText.Text),
                                                     referToUri);
              }
              else {
                Trace.Info("login referral: '{0}'", refferalResponseCode.ResponseText.Text);
                Trace.Info("  try to connect to {0}", referToUri);
              }
            }
              }

              if (result.Failed)
            throw new ImapConnectionException(string.Concat("connection refused or establishment failed: ", result.ResultText));
            }
            catch (TimeoutException ex) {
              throw new ImapConnectionException("connection timed out", ex);
            }

            if (result.Code == ImapCommandResultCode.PreAuth) {
              UpdateAuthority(null, null);
              TransitStateTo(ImapSessionState.Authenticated);
            }
            else {
              TransitStateTo(ImapSessionState.NotAuthenticated);
            }

            // 7.1. Server Responses - Status Responses
            //       CAPABILITY
            //          Followed by a list of capabilities.  This can appear in the
            //          initial OK or PREAUTH response to transmit an initial
            //          capabilities list.  This makes it unnecessary for a client to
            //          send a separate CAPABILITY command if it recognizes this
            //          response.
            var capabilityResponseCode = result.GetResponseCode(ImapResponseCode.Capability);

            if (capabilityResponseCode == null)
              // clear server capabilities
              SetServerCapabilities(new ImapCapabilityList());
            else
              SetServerCapabilities(ImapResponseTextConverter.FromCapability(capabilityResponseCode.ResponseText));
              }
        }