]>
git.argeo.org Git - gpl/argeo-slc.git/blob - ext/javax.mail.mbox/src/com/sun/mail/mbox/MboxStore.java
2 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
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.
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.
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17 package com
.sun
.mail
.mbox
;
22 public class MboxStore
extends Store
{
27 static Flags permFlags
;
30 // we support all flags
31 permFlags
= new Flags();
32 permFlags
.add(Flags
.Flag
.SEEN
);
33 permFlags
.add(Flags
.Flag
.RECENT
);
34 permFlags
.add(Flags
.Flag
.DELETED
);
35 permFlags
.add(Flags
.Flag
.FLAGGED
);
36 permFlags
.add(Flags
.Flag
.ANSWERED
);
37 permFlags
.add(Flags
.Flag
.DRAFT
);
38 permFlags
.add(Flags
.Flag
.USER
);
41 public MboxStore(Session session
, URLName url
) {
44 // XXX - handle security exception
45 user
= System
.getProperty("user.name");
46 home
= System
.getProperty("user.home");
47 String os
= System
.getProperty("os.name");
49 String cl
= "com.sun.mail.mbox." + os
+ "Mailbox";
50 mb
= (Mailbox
)Class
.forName(cl
).
51 getDeclaredConstructor().newInstance();
52 } catch (Exception e
) {
53 mb
= new DefaultMailbox();
58 * Since we do not have any authentication
59 * to do and we do not want a dialog put up asking the user for a
60 * password we always succeed in connecting.
61 * But if we're given a password, that means the user is
62 * doing something wrong so fail the request.
64 protected boolean protocolConnect(String host
, int port
, String user
,
65 String passwd
) throws MessagingException
{
68 throw new AuthenticationFailedException(
69 "mbox does not allow passwords");
70 // XXX - should we use the user?
74 protected void setURLName(URLName url
) {
75 // host, user, password, and file don't matter so we strip them out
76 if (url
!= null && (url
.getUsername() != null ||
77 url
.getHost() != null ||
78 url
.getFile() != null))
79 url
= new URLName(url
.getProtocol(), null, -1, null, null, null);
80 super.setURLName(url
);
84 public Folder
getDefaultFolder() throws MessagingException
{
87 return new MboxFolder(this, null);
90 public Folder
getFolder(String name
) throws MessagingException
{
93 return new MboxFolder(this, name
);
96 public Folder
getFolder(URLName url
) throws MessagingException
{
98 return getFolder(url
.getFile());
101 private void checkConnected() throws MessagingException
{
103 throw new MessagingException("Not connected");
106 MailFile
getMailFile(String folder
) {
107 return mb
.getMailFile(user
, folder
);
110 Session
getSession() {