Skip to contentPackage: ListInfo
ListInfo
Coverage
1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.imap.protocol;
18:
19: import java.util.List;
20: import java.util.ArrayList;
21:
22: import org.eclipse.angus.mail.iap.*;
23: import org.eclipse.angus.mail.iap.ParsingException;
24:
25: /**
26: * A LIST response.
27: *
28: * @author John Mani
29: * @author Bill Shannon
30: */
31:
32: public class ListInfo {
33: public String name = null;
34: public char separator = '/';
35: public boolean hasInferiors = true;
36: public boolean canOpen = true;
37: public int changeState = INDETERMINATE;
38: public String[] attrs;
39:
40: public static final int CHANGED                = 1;
41: public static final int UNCHANGED                = 2;
42: public static final int INDETERMINATE        = 3;
43:
44: public ListInfo(IMAPResponse r) throws ParsingException {
45:         String[] s = r.readSimpleList();
46:
47:         List<String> v = new ArrayList<>();        // accumulate attributes
48:•        if (s != null) {
49:          // non-empty attribute list
50:•         for (int i = 0; i < s.length; i++) {
51:•                if (s[i].equalsIgnoreCase("\\Marked"))
52:                  changeState = CHANGED;
53:•                else if (s[i].equalsIgnoreCase("\\Unmarked"))
54:                  changeState = UNCHANGED;
55:•                else if (s[i].equalsIgnoreCase("\\Noselect"))
56:                  canOpen = false;
57:•                else if (s[i].equalsIgnoreCase("\\Noinferiors"))
58:                  hasInferiors = false;
59:                 v.add(s[i]);
60:          }
61:         }
62:         attrs = v.toArray(new String[v.size()]);
63:
64:         r.skipSpaces();
65:•        if (r.readByte() == '"') {
66:•         if ((separator = (char)r.readByte()) == '\\')
67:                 // escaped separator character
68:                 separator = (char)r.readByte();        
69:          r.skip(1); // skip <">
70:         } else // NIL
71:          r.skip(2);
72:         
73:         r.skipSpaces();
74:         name = r.readAtomString();
75:
76:•        if (!r.supportsUtf8())
77:          // decode the name (using RFC2060's modified UTF7)
78:          name = BASE64MailboxDecoder.decode(name);
79: }
80: }