コード例 #1
0
ファイル: ImapMetadata.cs プロジェクト: pengyancai/cs-util
        public ImapMetadata(string[] hierarchicalEntryName, ImapString @value)
            : this(hierarchicalEntryName)
        {
            if (@value == null)
            throw new ArgumentNullException("value");

              this.Value = @value;
        }
コード例 #2
0
ファイル: ImapString.cs プロジェクト: pengyancai/cs-util
        public void TestOpExplicit()
        {
            var str = new ImapString("hoge");

              Assert.AreEqual("hoge", (string)str);
              Assert.AreEqual(str.ToString(), (string)str);

              str = null;

              Assert.IsNull((string)str);
        }
コード例 #3
0
        public void Send(ImapCommand command)
        {
            ClearUnsent();

              var argCount = command.Arguments.Length + (command.CommandString == null ? 0 : 2);
              var argIndex = 0;
              var args = new ImapString[argCount];

              if (command.CommandString != null) {
            args[argIndex++] = command.Tag;
            args[argIndex++] = command.CommandString;
              }

              for (var i = 0; i < command.Arguments.Length; i++, argIndex++) {
            args[argIndex] = command.Arguments[i];
              }

              Enqueue(args);

              Enqueue(Smdn.Formats.Octets.CRLF);

              Send();
        }
コード例 #4
0
 private static ImapSearchCriteria ModSeq(ulong modSequenceValzer, ImapMessageFlag entryFlagName, ImapString entryType)
 {
     if (entryType == null)
     return new ImapSearchCriteria(new[] {ImapCapability.CondStore},
                               "MODSEQ",
                               modSequenceValzer.ToString());
       else
     return new ImapSearchCriteria(new[] {ImapCapability.CondStore},
                               "MODSEQ",
                               new ImapQuotedString(string.Format("/flags/{0}", entryFlagName.ToString())),
                               entryType,
                               modSequenceValzer.ToString());
 }
コード例 #5
0
 private ImapFetchDataItem(ImapString macro, bool isMacro, params ImapString[] equivalentDataItemNames)
     : base(macro)
 {
     this.equivalent = equivalentDataItemNames;
 }
コード例 #6
0
ファイル: ImapSession.cs プロジェクト: pengyancai/cs-util
        public void TestPreProcessTransactionSetLiteralOptions()
        {
            using (var session = Connect()) {
            session.HandlesIncapableAsException = false;

            Assert.IsFalse(session.ServerCapabilities.Has(ImapCapability.LiteralNonSync));
            Assert.IsFalse(session.ServerCapabilities.Has(ImapCapability.Binary));

            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("+ continue\r\n"); server.EnqueueResponse(string.Empty);
            server.EnqueueResponse("0000 OK done\r\n");

            var arguments = new ImapString[] {
              new ImapLiteralString("literal1", Encoding.ASCII, ImapLiteralOptions.Synchronizing),
              new ImapLiteralString("literal2", Encoding.ASCII, ImapLiteralOptions.NonSynchronizing),
              new ImapLiteralString("literal3", Encoding.ASCII, ImapLiteralOptions.NonSynchronizingIfCapable),
              new ImapLiteralString("literal4", Encoding.ASCII, ImapLiteralOptions.Literal),
              new ImapLiteralString("literal5", Encoding.ASCII, ImapLiteralOptions.Literal8),
              new ImapLiteralString("literal6", Encoding.ASCII, ImapLiteralOptions.Literal8IfCapable),
              new ImapLiteralString("literal7", Encoding.ASCII, ImapLiteralOptions.Synchronizing | ImapLiteralOptions.Literal8IfCapable),
              new ImapLiteralString("literal8", Encoding.ASCII, ImapLiteralOptions.NonSynchronizingIfCapable | ImapLiteralOptions.Literal8),
              new ImapParenthesizedString(new ImapLiteralString("nested1", Encoding.ASCII, ImapLiteralOptions.NonSynchronizing),
                                      new ImapLiteralString("nested2", Encoding.ASCII, ImapLiteralOptions.NonSynchronizingIfCapable),
                                      new ImapLiteralString("nested3", Encoding.ASCII, ImapLiteralOptions.Literal8),
                                      new ImapLiteralString("nested4", Encoding.ASCII, ImapLiteralOptions.Literal8IfCapable)),
            };

            session.GenericCommand("X-TEST", arguments);

            Assert.AreEqual("0000 X-TEST " +
                        "{8}\r\nliteral1 " +
                        "{8+}\r\nliteral2 " +
                        "{8}\r\nliteral3 " +
                        "{8}\r\nliteral4 " +
                        "~{8}\r\nliteral5 " +
                        "{8}\r\nliteral6 " +
                        "{8}\r\nliteral7 " +
                        "~{8}\r\nliteral8 " +
                        "({7+}\r\nnested1 " +
                        "{7}\r\nnested2 " +
                        "~{7}\r\nnested3 " +
                        "{7}\r\nnested4)\r\n",
                        server.DequeueAll());
              }
        }
コード例 #7
0
ファイル: ImapMetadata.cs プロジェクト: pengyancai/cs-util
 public ImapMetadata(string entryName, ImapString @value)
     : this(SplitEntryName(entryName), @value)
 {
 }
コード例 #8
0
ファイル: ImapMetadata.cs プロジェクト: pengyancai/cs-util
        /// <param name="value">The value can be null to indicate that the entry is to be removed.</param>
        public static ImapMetadata CreateSharedVendorMetadata(ImapString @value, string hierarchicalEntryName, params string[] hierarchicalEntryNames)
        {
            var entryName = new List<string>(new[] {"shared", "vendor"});

              entryName.Add(hierarchicalEntryName);
              entryName.AddRange(hierarchicalEntryNames);

              if (@value == null)
            return new ImapMetadata(entryName.ToArray());
              else
            return new ImapMetadata(entryName.ToArray(), @value);
        }
コード例 #9
0
 private static ImapSortCriteria CreateReversed(ImapString criteria)
 {
     // REVERSE
       //    Followed by another sort criterion, has the effect of that
       //    criterion but in reverse (descending) order.
       //       Note: REVERSE only reverses a single criterion, and does not
       //       affect the implicit "sequence number" sort criterion if all
       //       other criteria are identical.  Consequently, a sort of
       //       REVERSE SUBJECT is not the same as a reverse ordering of a
       //       SUBJECT sort.  This can be avoided by use of additional
       //       criteria, e.g., SUBJECT DATE vs. REVERSE SUBJECT REVERSE
       //       DATE.  In general, however, it's better (and faster, if the
       //       client has a "reverse current ordering" command) to reverse
       //       the results in the client instead of issuing a new SORT.
       return new ImapSortCriteria(new[] {ImapCapability.Sort}, "REVERSE", criteria);
 }
コード例 #10
0
 private static ImapSortCriteria Create(ImapString criteria)
 {
     return new ImapSortCriteria(new[] {ImapCapability.Sort}, criteria);
 }
コード例 #11
0
 private ImapStoreDataItem(ImapString itemName, ImapString[] items)
     : base(items)
 {
     this.itemName = itemName;
 }
コード例 #12
0
        // common construction method
        private static ImapStoreDataItem FlagsCommon(ImapString itemName, IImapMessageFlagSet flags)
        {
            if (flags == null)
            throw new ArgumentNullException("flags");
              else if (flags.Count == 0)
            throw new ArgumentException("must contain at least one keyword or flag", "flags");

              return new ImapStoreDataItem(itemName, flags.GetNonApplicableFlagsRemoved().ToArray());
        }
コード例 #13
0
        private ImapCommandResult XListInternal(string referenceName,
                                            ImapString mailboxName,
                                            out ImapMailbox[] mailboxes)
        {
            if (referenceName == null)
            throw new ArgumentNullException("referenceName");

              using (var t = new XListTransaction(connection)) {
            return ListLsubInternal(t, referenceName, mailboxName, out mailboxes);
              }
        }
コード例 #14
0
        private ImapCommandResult ListLsubInternal(ListTransactionBase t,
                                               string referenceName,
                                               ImapString mailboxName,
                                               out ImapMailbox[] mailboxes)
        {
            RejectNonAuthenticatedState();

              mailboxes = null;

              t.RequestArguments["reference name"] = new ImapQuotedString(referenceName);
              t.RequestArguments["mailbox name"] = mailboxName;

              if (ProcessTransaction(t).Succeeded)
            mailboxes = Array.ConvertAll<ImapMailboxList, ImapMailbox>(t.Result.Value, mailboxManager.GetExistOrCreate);

              return t.Result;
        }