diff --git a/.gitignore b/.gitignore
index 4898f165f..6ce558bc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,10 @@
.idea/
target/
-*/target/
nbproject/private/
.m2/
webrev
-mbox/.ccls-cache/
/bin/
.classpath
.project
.settings/
+*.iml
diff --git a/.hgignore b/.hgignore
deleted file mode 100644
index e774decb2..000000000
--- a/.hgignore
+++ /dev/null
@@ -1,6 +0,0 @@
-^target/
-/target/
-^nbproject/private/
-^\.m2/
-^webrev
-^src/main/java/javax/mail/Version\.java$
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 90e442bb2..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v. 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0,
-# or the Eclipse Distribution License v. 1.0 which is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-#
-
-dist: focal
-
-sudo: required
-
-language: java
-
-services:
- - docker
-
-jdk:
- - openjdk11
- - openjdk-ea
-
-install: true
-
-script:
- - bash travis.sh
-
-git:
- depth: false
\ No newline at end of file
diff --git a/README.md b/README.md
index 71d35b8ce..43f911d4b 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,45 @@
+# Jakarta Mail
+
+[![Build Status](https://github.com/eclipse-ee4j/mail/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/eclipse-ee4j/mail/actions/workflows/maven.yml?branch=master)
+[![Jakarta Staging (Snapshots)](https://img.shields.io/nexus/s/https/jakarta.oss.sonatype.org/jakarta.mail/jakarta.mail-api.svg)](https://jakarta.oss.sonatype.org/content/repositories/staging/jakarta/mail/jakarta.mail-api/)
+
+Jakarta Mail defines a platform-independent and protocol-independent
+framework to build mail and messaging applications.
+
+**IMPORTANT:** Implementation of the Jakarta Mail API, aka JakartaMail (formerly JavaMail),
+is no longer part of this repository.
+As part of breaking tight integration between Jakarta Mail API and the implementation,
+its sources were moved to the new project - [Eclipse Angus](https://github.com/eclipse-ee4j/angus-mail) -
+and further development continues there. [Eclipse Angus](https://github.com/eclipse-ee4j/angus-mail)
+is direct accessor of JavaMail/JakartaMail.
+
See the [Jakarta Mail web site](https://eclipse-ee4j.github.io/mail).
+
+## License
+
+* The Jakarta Mail API project source code is licensed
+ under the [Eclipse Public License (EPL) v2.0](https://www.eclipse.org/legal/epl-2.0/)
+ and [GNU General Public License (GPL) v2 with Classpath Exception](https://www.gnu.org/software/classpath/license.html);
+ see the license information at the top of each source file.
+* The binary jar files published to the Maven repository are licensed
+ under the same licenses as the corresponding source code;
+ see the file `META-INF/LICENSE.*` in each jar file.
+
+You'll find the text of the licenses in the workspace in various `LICENSE.txt` or `LICENSE.md` files.
+Don't let the presence of these license files in the workspace confuse you into thinking
+that they apply to all files in the workspace.
+
+You should always read the license file included with every download, and read
+the license text included in every source file.
+
+## Contributing
+
+We use [contribution policy](CONTRIBUTING.md), which means we can only accept contributions under
+the terms of [Eclipse Contributor Agreement](http://www.eclipse.org/legal/ECA.php).
+
+## Links
+* [Jakarta Mail web site](https://eclipse-ee4j.github.io/mail)
+* [Jakarta Mail Specification project](https://github.com/eclipse-ee4j/mail-spec)
+* [Jakarta Mail TCK project](https://github.com/eclipse-ee4j/mail-tck)
+* [Jakarta Mail API nightly build job](https://ci.eclipse.org/mail/job/mail-api-build/)
+* [Eclipse Angus project](https://github.com/eclipse-ee4j/angus-mail)
diff --git a/ant-common.xml b/ant-common.xml
deleted file mode 100644
index 25a01bb5c..000000000
--- a/ant-common.xml
+++ /dev/null
@@ -1,165 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${maven.repo.local}/com.sun.wts.tools.mri/jars/maven-repository-importer-${glassfish.maven_repository_importer.version}.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
- importing to CVS...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build.properties b/build.properties
deleted file mode 100644
index 25e1398d8..000000000
--- a/build.properties
+++ /dev/null
@@ -1,108 +0,0 @@
-#
-# Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v. 2.0, which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# This Source Code may also be made available under the following Secondary
-# Licenses when the conditions for such availability set forth in the
-# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
-# version 2 with the GNU Classpath Exception, which is available at
-# https://www.gnu.org/software/classpath/license.html.
-#
-# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-#
-
-### Component Properties ###
-src.dir=mail/src/main/java
-resources.dir=mail/src/main/resources
-component.classes.dir=mail/target/classes
-### Subcomponent Properties ###
-# dsn
-src.dsn.dir=dsn/src/main/java
-resources.dsn.dir=dsn/src/main/resources
-component.classes.dsn.dir=dsn/target/classes
-# gimap
-src.gimap.dir=gimap/src/main/java
-resources.gimap.dir=gimap/src/main/resources
-component.classes.gimap.dir=gimap/target/classes
-# imap
-resources.imap.dir=imap/src/main/resources
-component.classes.imap.dir=imap/target/classes
-# pop3
-resources.pop3.dir=pop3/src/main/resources
-component.classes.pop3.dir=pop3/target/classes
-# smtp
-resources.smtp.dir=smtp/src/main/resources
-component.classes.smtp.dir=smtp/target/classes
-# mbox
-src.mbox.dir=mbox/src/main/java
-resources.mbox.dir=mbox/src/main/resources
-component.classes.mbox.dir=mbox/target/classes
-# demo
-src.demo.dir=demo/src/main/java
-component.classes.demo.dir=demo/target/classes
-# client
-src.client.dir=client/src/main/java
-component.classes.client.dir=client/target/classes
-# servlet
-src.servlet.dir=servlet/src/main/java
-component.classes.servlet.dir=servlet/target/classes
-# webapp
-src.webapp.dir=webapp/src/main/java
-docroot.webapp.dir=webapp/src/main/webapp
-# taglib
-src.taglib.dir=taglib/src/main/java
-resources.taglib.dir=taglib/src/main/resources
-# logging
-src.logging.dir=logging/src/main/java
-component.classes.logging.dir=logging/target/classes
-# legal
-resources.legal.dir=mail/src/main/resources
-#
-maven.netbeans.exec.build=target/classes
-
-# needed to build everything on JDK 1.5
-activation.jar=activation.jar
-# needed to build servlet and webapp demo programs
-javaee.jar=javaee.jar
-# external URL references for javadocs
-javase.url=http://docs.oracle.com/javase/1.5.0/docs/api
-jaf.url=http://docs.oracle.com/javase/6/docs/api
-
-### Additonal Component Properties for standalone release ###
-release.dir=target/release
-release.specversion=1.5
-release.version=1.5.1-SNAPSHOT
-release.mail.jar=${release.dir}/mail.jar
-release.mailapi.jar=${release.dir}/lib/mailapi.jar
-release.imap.jar=${release.dir}/lib/imap.jar
-release.smtp.jar=${release.dir}/lib/smtp.jar
-release.pop3.jar=${release.dir}/lib/pop3.jar
-release.gimap.jar=${release.dir}/lib/gimap.jar
-release.dsn.jar=${release.dir}/lib/dsn.jar
-release.mbox.jar=${release.dir}/lib/mbox.jar
-release.docs.dir=${release.dir}/docs
-release.javadocs.dir=${release.docs.dir}/javadocs
-
-# Following from bootstrap/project.properties
-
-# To support NetBeans' default compile single file target.
-build.dir=build
-build.classes.dir=${build.dir}/classes
-
-## Maven repository importer
-glassfish.maven_repository_importer.version=1.1
-
-###########################################################
-# Compilation Flags #
-###########################################################
-javac.debug=on
-javac.optimize=off
-javac.deprecation=off
-javac.source=1.5
-javac.target=1.5
-
-### Use ant.verbose=-verbose for debugging ant targets
-ant.verbose=
diff --git a/build.xml b/build.xml
deleted file mode 100644
index ebecc7784..000000000
--- a/build.xml
+++ /dev/null
@@ -1,588 +0,0 @@
-
-
-
-
-]>
-
-
-
-
-
-
-
-
-
-
-
-
- &commonBuild;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Oracle
- and/or its affiliates. All Rights Reserved.
- Use is subject to
- license terms<
- /a>.
-]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/client/pom.xml b/client/pom.xml
deleted file mode 100644
index b5a244fdc..000000000
--- a/client/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
- com.sun.mail
- all
- 2.0.2-SNAPSHOT
-
- 4.0.0
- com.sun.mail
- client
- jar
- Jakarta Mail API demo client
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
-
-
- osgi-manifest
- none
-
-
-
-
-
-
- maven-jar-plugin
-
-
- default-jar
- none
-
-
-
-
-
-
-
-
- com.sun.mail
- jakarta.mail
-
-
-
diff --git a/client/src/main/java/ComponentFrame.java b/client/src/main/java/ComponentFrame.java
deleted file mode 100644
index c82b56e7e..000000000
--- a/client/src/main/java/ComponentFrame.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.JFrame;
-import javax.swing.WindowConstants;
-
-
-/**
- * this Frame provides a utility class for displaying a single
- * Component in a Frame.
- *
- * @author Christopher Cotton
- */
-
-public class ComponentFrame extends JFrame {
-
- /**
- * creates the frame
- * @param what the component to display
- */
- public ComponentFrame(Component what) {
- this(what, "Component Frame");
- }
-
- /**
- * creates the frame with the given name
- * @param what the component to display
- * @param name the name of the Frame
- */
- public ComponentFrame(Component what, String name) {
- super(name);
-
- // make sure that we close and dispose ourselves when needed
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-
- // default size of the frame
- setSize(700,600);
-
- // we want to display just the component in the entire frame
- if (what != null) {
- getContentPane().add("Center", what);
- }
- }
-}
diff --git a/client/src/main/java/FolderModel.java b/client/src/main/java/FolderModel.java
deleted file mode 100644
index 783559223..000000000
--- a/client/src/main/java/FolderModel.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import jakarta.mail.*;
-import java.util.Date;
-import javax.swing.table.AbstractTableModel;
-
-/**
- * Maps the messages in a Folder to the Swing's Table Model
- *
- * @author Christopher Cotton
- * @author Bill Shannon
- */
-
-public class FolderModel extends AbstractTableModel {
-
- Folder folder;
- Message[] messages;
-
- String[] columnNames = { "Date", "From", "Subject"};
- Class[] columnTypes = { String.class, String.class, String.class };
-
- public void setFolder(Folder what) throws MessagingException {
- if (what != null) {
-
- // opened if needed
- if (!what.isOpen()) {
- what.open(Folder.READ_WRITE);
- }
-
- // get the messages
- messages = what.getMessages();
- cached = new String[messages.length][];
- } else {
- messages = null;
- cached = null;
- }
- // close previous folder and switch to new folder
- if (folder != null)
- folder.close(true);
- folder = what;
- fireTableDataChanged();
- }
-
- public Message getMessage(int which) {
- return messages[which];
- }
-
- //---------------------
- // Implementation of the TableModel methods
- //---------------------
-
- public String getColumnName(int column) {
- return columnNames[column];
- }
-
- public Class getColumnClass(int column) {
- return columnTypes[column];
- }
-
-
- public int getColumnCount() {
- return columnNames.length;
- }
-
- public int getRowCount() {
- if (messages == null)
- return 0;
-
- return messages.length;
- }
-
- public Object getValueAt(int aRow, int aColumn) {
- switch(aColumn) {
- case 0: // date
- case 1: // From String[] what = getCachedData(aRow);
- case 2: // Subject
- String[] what = getCachedData(aRow);
- if (what != null) {
- return what[aColumn];
- } else {
- return "";
- }
-
- default:
- return "";
- }
- }
-
- protected static String[][] cached;
-
- protected String[] getCachedData(int row) {
- if (cached[row] == null) {
- try{
- Message m = messages[row];
-
- String[] theData = new String[4];
-
- // Date
- Date date = m.getSentDate();
- if (date == null) {
- theData[0] = "Unknown";
- } else {
- theData[0] = date.toString();
- }
-
- // From
- Address[] adds = m.getFrom();
- if (adds != null && adds.length != 0) {
- theData[1] = adds[0].toString();
- } else {
- theData[1] = "";
- }
-
- // Subject
- String subject = m.getSubject();
- if (subject != null) {
- theData[2] = subject;
- } else {
- theData[2] = "(No Subject)";
- }
-
- cached[row] = theData;
- }
- catch (MessagingException e) {
- e.printStackTrace();
- }
- }
-
- return cached[row];
- }
-}
diff --git a/client/src/main/java/FolderTreeNode.java b/client/src/main/java/FolderTreeNode.java
deleted file mode 100644
index be05a61e1..000000000
--- a/client/src/main/java/FolderTreeNode.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import jakarta.mail.Store;
-import jakarta.mail.Folder;
-import jakarta.mail.MessagingException;
-
-/**
- * Node which represents a Folder in the jakarta.mail apis.
- *
- * @author Christopher Cotton
- */
-public class FolderTreeNode extends DefaultMutableTreeNode {
-
- protected Folder folder = null;
- protected boolean hasLoaded = false;
-
- /**
- * creates a tree node that points to the particular Store.
- *
- * @param what the store for this node
- */
- public FolderTreeNode(Folder what) {
- super(what);
- folder = what;
- }
-
-
- /**
- * a Folder is a leaf if it cannot contain sub folders
- */
- public boolean isLeaf() {
- try {
- if ((folder.getType() & Folder.HOLDS_FOLDERS) == 0)
- return true;
- } catch (MessagingException me) { }
-
- // otherwise it does hold folders, and therefore not
- // a leaf
- return false;
- }
-
- /**
- * returns the folder for this node
- */
- public Folder getFolder() {
- return folder;
- }
-
-
-
- /**
- * return the number of children for this folder node. The first
- * time this method is called we load up all of the folders
- * under the store's defaultFolder
- */
-
- public int getChildCount() {
- if (!hasLoaded) {
- loadChildren();
- }
- return super.getChildCount();
- }
-
- protected void loadChildren() {
- // if it is a leaf, just say we have loaded them
- if (isLeaf()) {
- hasLoaded = true;
- return;
- }
-
- try {
- // Folder[] sub = folder.listSubscribed();
- Folder[] sub = folder.list();
-
- // add a FolderTreeNode for each Folder
- int num = sub.length;
- for(int i = 0; i < num; i++) {
- FolderTreeNode node = new FolderTreeNode(sub[i]);
- // we used insert here, since add() would make
- // another recursive call to getChildCount();
- insert(node, i);
- }
-
- } catch (MessagingException me) {
- me.printStackTrace();
- }
- }
-
-
- /**
- * override toString() since we only want to display a folder's
- * name, and not the full path of the folder
- */
- public String toString() {
- return folder.getName();
- }
-
-}
-
diff --git a/client/src/main/java/FolderViewer.java b/client/src/main/java/FolderViewer.java
deleted file mode 100644
index 8ad66eb67..000000000
--- a/client/src/main/java/FolderViewer.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.awt.*;
-import jakarta.mail.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.table.*;
-
-/**
- * @author Christopher Cotton
- * @author Bill Shannon
- */
-
-public class FolderViewer extends JPanel {
-
- FolderModel model = new FolderModel();
- JScrollPane scrollpane;
- JTable table;
-
- public FolderViewer() {
- this(null);
- }
-
- public FolderViewer(Folder what) {
- super(new GridLayout(1,1));
-
- table = new JTable(model);
- table.setShowGrid(false);
-
- scrollpane = new JScrollPane(table);
-
- // setup the folder we were given
- setFolder(what);
-
- // find out what is pressed
- table.getSelectionModel().addListSelectionListener(
- new FolderPressed());
- scrollpane.setPreferredSize(new Dimension(700, 300));
- add(scrollpane);
- }
-
- /**
- * Change the current Folder for the Viewer
- *
- * @param what the folder to be viewed
- */
- public void setFolder(Folder what) {
- try {
- table.getSelectionModel().clearSelection();
- if (SimpleClient.mv != null)
- SimpleClient.mv.setMessage(null);
- model.setFolder(what);
- scrollpane.invalidate();
- scrollpane.validate();
- } catch (MessagingException me) {
- me.printStackTrace();
- }
- }
-
- class FolderPressed implements ListSelectionListener {
-
- public void valueChanged(ListSelectionEvent e) {
- if (model != null && !e.getValueIsAdjusting()) {
- ListSelectionModel lm = (ListSelectionModel) e.getSource();
- int which = lm.getMaxSelectionIndex();
- if (which != -1) {
- // get the message and display it
- Message msg = model.getMessage(which);
- SimpleClient.mv.setMessage(msg);
- }
- }
- }
- }
-}
diff --git a/client/src/main/java/MessageViewer.java b/client/src/main/java/MessageViewer.java
deleted file mode 100644
index 2512e4525..000000000
--- a/client/src/main/java/MessageViewer.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.awt.*;
-import java.awt.event.*;
-import jakarta.mail.*;
-import jakarta.activation.*;
-import java.util.Date;
-import java.io.IOException;
-import javax.swing.JPanel;
-
-/**
- * @author Christopher Cotton
- * @author Bill Shannon
- */
-
-public class MessageViewer extends JPanel implements CommandObject {
-
- Message displayed = null;
- DataHandler dataHandler = null;
- String verb = null;
- Component mainbody;
- TextArea headers;
-
- public MessageViewer() {
- this(null);
- }
-
- public MessageViewer(Message what) {
- // set our layout
- super(new GridBagLayout());
-
- // add the toolbar
- addToolbar();
-
- GridBagConstraints gb = new GridBagConstraints();
- gb.gridwidth = GridBagConstraints.REMAINDER;
- gb.fill = GridBagConstraints.BOTH;
- gb.weightx = 1.0;
- gb.weighty = 0.0;
-
- // add the headers
- headers = new TextArea("", 4, 80, TextArea.SCROLLBARS_NONE);
- headers.setEditable(false);
- add(headers, gb);
-
- // now display our message
- setMessage(what);
- }
-
- /**
- * sets the current message to be displayed in the viewer
- */
- public void setMessage(Message what) {
- displayed = what;
-
- if (mainbody != null)
- remove(mainbody);
-
- if (what != null) {
- loadHeaders();
- mainbody = getBodyComponent();
- } else {
- headers.setText("");
- TextArea dummy = new TextArea("", 24, 80, TextArea.SCROLLBARS_NONE);
- dummy.setEditable(false);
- mainbody = dummy;
- }
-
- // add the main body
- GridBagConstraints gb = new GridBagConstraints();
- gb.gridwidth = GridBagConstraints.REMAINDER;
- gb.fill = GridBagConstraints.BOTH;
- gb.weightx = 1.0;
- gb.weighty = 1.0;
- add(mainbody, gb);
-
- invalidate();
- validate();
- }
-
- protected void addToolbar() {
- GridBagConstraints gb = new GridBagConstraints();
- gb.gridheight = 1;
- gb.gridwidth = 1;
- gb.fill = GridBagConstraints.NONE;
- gb.anchor = GridBagConstraints.WEST;
- gb.weightx = 0.0;
- gb.weighty = 0.0;
- gb.insets = new Insets(4,4,4,4);
-
- // structure button
- gb.gridwidth = GridBagConstraints.REMAINDER; // only for the last one
- Button b = new Button("Structure");
- b.addActionListener( new StructureAction());
- add(b, gb);
- }
-
- protected void loadHeaders() {
- // setup what we want in our viewer
- StringBuffer sb = new StringBuffer();
-
- // date
- sb.append("Date: ");
- try {
- Date duh = displayed.getSentDate();
- if (duh != null) {
- sb.append(duh.toString());
- } else {
- sb.append("Unknown");
- }
-
- sb.append("\n");
-
- // from
- sb.append("From: ");
- Address[] adds = displayed.getFrom();
- if (adds != null && adds.length > 0) {
- sb.append(adds[0].toString());
- }
- sb.append("\n");
-
- // to
- sb.append("To: ");
- adds = displayed.getRecipients(Message.RecipientType.TO);
- if (adds != null && adds.length > 0) {
- sb.append(adds[0].toString());
- }
- sb.append("\n");
-
- // subject
- sb.append("Subject: ");
- sb.append(displayed.getSubject());
-
- headers.setText(sb.toString());
- } catch (MessagingException me) {
- headers.setText("");
- }
- }
-
- protected Component getBodyComponent() {
- //------------
- // now get a content viewer for the main type...
- //------------
- try {
- DataHandler dh = displayed.getDataHandler();
- CommandInfo ci = dh.getCommand("view");
- if (ci == null) {
- throw new MessagingException("view command failed on: " +
- displayed.getContentType());
- }
-
- Object bean = dh.getBean(ci);
- if (bean instanceof Component) {
- return (Component)bean;
- } else {
- throw new MessagingException("bean is not a component " +
- bean.getClass().toString());
- }
- } catch (MessagingException me) {
- return new Label(me.toString());
- }
- }
-
- /**
- * the CommandObject method to accept our DataHandler
- * @param dh the datahandler used to get the content
- */
- public void setCommandContext(String verb,
- DataHandler dh) throws IOException {
- this.verb = verb;
- dataHandler = dh;
-
- Object o = dh.getContent();
- if (o instanceof Message) {
- setMessage((Message)o);
- }
- else {
- System.out.println(
- "MessageViewer - content not a Message object, " + o);
- if (o != null){
- System.out.println(o.getClass().toString());
- }
- }
- }
-
-
- class StructureAction implements ActionListener {
- StringBuffer sb;
-
- public void actionPerformed(ActionEvent e) {
- System.out.println("\n\nMessage Structure");
- dumpPart("", displayed);
- }
-
- protected void dumpPart(String prefix, Part p) {
- try {
- System.out.println(prefix + "----------------");
- System.out.println(prefix +
- "Content-Type: " + p.getContentType());
- System.out.println(prefix +
- "Class: " + p.getClass().toString());
-
- Object o = p.getContent();
- if (o == null) {
- System.out.println(prefix + "Content: is null");
- } else {
- System.out.println(prefix +
- "Content: " + o.getClass().toString());
- }
-
- if (o instanceof Multipart) {
- String newpref = prefix + "\t";
- Multipart mp = (Multipart)o;
- int count = mp.getCount();
- for (int i = 0; i < count; i++) {
- dumpPart(newpref, mp.getBodyPart(i));
- }
- }
- } catch (MessagingException e) {
- e.printStackTrace();
- } catch (IOException ioex) {
- System.out.println("Cannot get content" + ioex.getMessage());
- }
- }
- }
-}
diff --git a/client/src/main/java/MultipartViewer.java b/client/src/main/java/MultipartViewer.java
deleted file mode 100644
index 2a4e07381..000000000
--- a/client/src/main/java/MultipartViewer.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.beans.*;
-import jakarta.activation.*;
-import jakarta.mail.*;
-import javax.swing.JPanel;
-
-
-/**
- * A Viewer Bean for the type multipart/mixed
- *
- * @author Christopher Cotton
- */
-
-public class MultipartViewer extends JPanel implements CommandObject {
-
- protected DataHandler dh = null;
- protected String verb = null;
-
- public MultipartViewer() {
- super(new GridBagLayout());
- }
-
-
- public void setCommandContext(String verb, DataHandler dh) throws IOException {
- this.verb = verb;
- this.dh = dh;
-
- // get the content, and hope it is a Multipart Object
- Object content = dh.getContent();
- if (content instanceof Multipart) {
- setupDisplay((Multipart)content);
- } else {
- setupErrorDisplay(content);
- }
- }
-
- protected void setupDisplay(Multipart mp) {
- // we display the first body part in a main frame on the left, and then
- // on the right we display the rest of the parts as attachments
-
- GridBagConstraints gc = new GridBagConstraints();
- gc.gridheight = GridBagConstraints.REMAINDER;
- gc.fill = GridBagConstraints.BOTH;
- gc.weightx = 1.0;
- gc.weighty = 1.0;
-
- // get the first part
- try {
- BodyPart bp = mp.getBodyPart(0);
- Component comp = getComponent(bp);
- add(comp, gc);
-
- } catch (MessagingException me) {
- add(new Label(me.toString()), gc);
- }
-
- // see if there are more than one parts
- try {
- int count = mp.getCount();
-
- // setup how to display them
- gc.gridwidth = GridBagConstraints.REMAINDER;
- gc.gridheight = 1;
- gc.fill = GridBagConstraints.NONE;
- gc.anchor = GridBagConstraints.NORTH;
- gc.weightx = 0.0;
- gc.weighty = 0.0;
- gc.insets = new Insets(4,4,4,4);
-
- // for each one we create a button with the content type
- for(int i = 1; i < count; i++) { // we skip the first one
- BodyPart curr = mp.getBodyPart(i);
- String label = null;
- if (label == null) label = curr.getFileName();
- if (label == null) label = curr.getDescription();
- if (label == null) label = curr.getContentType();
-
- Button but = new Button(label);
- but.addActionListener( new AttachmentViewer(curr));
- add(but, gc);
- }
-
-
- } catch(MessagingException me2) {
- me2.printStackTrace();
- }
-
- }
-
- protected Component getComponent(BodyPart bp) {
-
- try {
- DataHandler dh = bp.getDataHandler();
- CommandInfo ci = dh.getCommand("view");
- if (ci == null) {
- throw new MessagingException(
- "view command failed on: " +
- bp.getContentType());
- }
-
- Object bean = dh.getBean(ci);
-
- if (bean instanceof Component) {
- return (Component)bean;
- } else {
- if (bean == null)
- throw new MessagingException(
- "bean is null, class " + ci.getCommandClass() +
- " , command " + ci.getCommandName());
- else
- throw new MessagingException(
- "bean is not a awt.Component" +
- bean.getClass().toString());
- }
- }
- catch (MessagingException me) {
- return new Label(me.toString());
- }
- }
-
-
-
- protected void setupErrorDisplay(Object content) {
- String error;
-
- if (content == null)
- error = "Content is null";
- else
- error = "Object not of type Multipart, content class = " +
- content.getClass().toString();
-
- System.out.println(error);
- Label lab = new Label(error);
- add(lab);
- }
-
- class AttachmentViewer implements ActionListener {
-
- BodyPart bp = null;
-
- public AttachmentViewer(BodyPart part) {
- bp = part;
- }
-
- public void actionPerformed(ActionEvent e) {
- ComponentFrame f = new ComponentFrame(
- getComponent(bp), "Attachment");
- f.pack();
- f.show();
- }
- }
-
-}
diff --git a/client/src/main/java/README.txt b/client/src/main/java/README.txt
deleted file mode 100644
index 5b32700c8..000000000
--- a/client/src/main/java/README.txt
+++ /dev/null
@@ -1,107 +0,0 @@
-SimpleClient
-------------
-
-Notes:
-======
-
-This should not be taken as a demo of how to use the Swing API, but
-rather a very simple graphical mail client. It shows how viewers can
-be used to display the content from mail messages. It also (like the
-other demos) shows how to retrieve Folders from a Store, Messages
-from a Folder, and content from Messages.
-
-
-To run the demo:
-================
-
- 1. Set your CLASSPATH to include the "jakarta.mail.jar",
- "jakarta.activation.jar", and the current directory. For example:
-
- export CLASSPATH=/u/me/download/jakarta.mail.jar:/u/me/download/jakarta.activation.jar:.
-
- 2. Go to the demo/client directory
-
- 3. Compile all the files using your Java compiler. For example:
-
- javac *.java
-
- 4. Run the demo. For example:
-
- java SimpleClient -L imap://username:password@hostname/
-
- Note that SimpleClient expects to read the "simple.mailcap"
- file from the current directory. The simple.mailcap file
- contains configuration information about viewers needed by
- the SimpleClient demo program.
-
-
-
-Overview of the Classes
-=======================
-
-Main Classes:
-
- SimpleClient = contains main().
- Uses the parameters to the application to
- locate the correct Store. e.g.
-
- SimpleClient -L imap://cotton:secret@snow-goon/
-
- It will create the main frame and
- creates a tree. The tree uses the
- StoreTreeNodes and FolderTreeNodes.
-
- StoreTreeNode = subclass of Swing's DefaultMutableTreeNode.
- This class shows how to get Folders from
- the Store.
-
- FolderTreeNode = subclass of Swing's DefaultMutableTreeNode.
- If the folder has messages, it will create
- a FolderViewer. Otherwise it will add the
- subfolders to the tree.
-
- SimpleAuthenticator = subclass of jakarta.mail.Authenticator. If
- the Store is missing the username or the
- password, this authenticator will be used.
- It displays a dialog requesting the
- information from the user.
-
-
-Viewing Folders:
-
- FolderViewer = Uses a Swing Table to display all of the
- Message in a Folder. The "model" of the
- data for this Table is a FolderModel which
- knows how to get displayable information
- from a Message.
-
-Jakarta Activation Viewers:
-
- MessageViewer = Uses the content of the DataHandler. The
- content will be a jakarta.mail.Message
- object. Displays the headers and then
- uses Jakarta Activation to find another viewer for
- the content type of the Message. (either
- multipart/mixed, image/gif, or text/plain)
-
- MultipartViewer = Uses the content of the DataHandler. The
- content will be a jakarta.mail.Multipart
- object. Uses Jakarta Activation to find another
- viewer for the first BodyPart's content.
- Also puts Buttons (as "attachments") for
- the rest of the BodyParts. When the
- Button are pressed, it uses Jakarta Activation to
- find a viewer for the BodyPart's content,
- and displays it in a separate frame (using
- ComponentFrame).
-
- TextViewer = Uses the content of the DataHandler. The
- content will be either a java.lang.String
- object, or a java.io.InputStream object.
- Creates a TextArea and sets the text using
- the String or InputStream.
-
-Support Classes:
-
- ComponentFrame = support class which takes a java.awt.Component
- and displays it in a Frame.
diff --git a/client/src/main/java/SimpleAuthenticator.java b/client/src/main/java/SimpleAuthenticator.java
deleted file mode 100644
index 4912628ad..000000000
--- a/client/src/main/java/SimpleAuthenticator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import jakarta.mail.*;
-import java.net.InetAddress;
-import java.awt.*;
-import javax.swing.*;
-
-/**
- * Simple Authenticator for requesting password information.
- *
- * @author Christopher Cotton
- * @author Bill Shannon
- */
-
-public class SimpleAuthenticator extends Authenticator {
-
- Frame frame;
- String username;
- String password;
-
- public SimpleAuthenticator(Frame f) {
- this.frame = f;
- }
-
- protected PasswordAuthentication getPasswordAuthentication() {
-
- // given a prompt?
- String prompt = getRequestingPrompt();
- if (prompt == null)
- prompt = "Please login...";
-
- // protocol
- String protocol = getRequestingProtocol();
- if (protocol == null)
- protocol = "Unknown protocol";
-
- // get the host
- String host = null;
- InetAddress inet = getRequestingSite();
- if (inet != null)
- host = inet.getHostName();
- if (host == null)
- host = "Unknown host";
-
- // port
- String port = "";
- int portnum = getRequestingPort();
- if (portnum != -1)
- port = ", port " + portnum + " ";
-
- // Build the info string
- String info = "Connecting to " + protocol + " mail service on host " +
- host + port;
-
- //JPanel d = new JPanel();
- // XXX - for some reason using a JPanel here causes JOptionPane
- // to display incorrectly, so we workaround the problem using
- // an anonymous JComponent.
- JComponent d = new JComponent() { };
-
- GridBagLayout gb = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
- d.setLayout(gb);
- c.insets = new Insets(2, 2, 2, 2);
-
- c.anchor = GridBagConstraints.WEST;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.weightx = 0.0;
- d.add(constrain(new JLabel(info), gb, c));
- d.add(constrain(new JLabel(prompt), gb, c));
-
- c.gridwidth = 1;
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.NONE;
- c.weightx = 0.0;
- d.add(constrain(new JLabel("Username:"), gb, c));
-
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.HORIZONTAL;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.weightx = 1.0;
- String user = getDefaultUserName();
- JTextField username = new JTextField(user, 20);
- d.add(constrain(username, gb, c));
-
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.EAST;
- c.weightx = 0.0;
- d.add(constrain(new JLabel("Password:"), gb, c));
-
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.HORIZONTAL;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.weightx = 1.0;
- JPasswordField password = new JPasswordField("", 20);
- d.add(constrain(password, gb, c));
- // XXX - following doesn't work
- if (user != null && user.length() > 0)
- password.requestFocus();
- else
- username.requestFocus();
-
- int result = JOptionPane.showConfirmDialog(frame, d, "Login",
- JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
-
- if (result == JOptionPane.OK_OPTION)
- return new PasswordAuthentication(username.getText(),
- password.getText());
- else
- return null;
- }
-
- private Component constrain(Component cmp,
- GridBagLayout gb, GridBagConstraints c) {
- gb.setConstraints(cmp, c);
- return (cmp);
- }
-}
diff --git a/client/src/main/java/SimpleClient.java b/client/src/main/java/SimpleClient.java
deleted file mode 100644
index 3868c5af1..000000000
--- a/client/src/main/java/SimpleClient.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.*;
-import java.io.*;
-import jakarta.mail.*;
-import jakarta.mail.internet.*;
-import jakarta.activation.*;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.table.*;
-import javax.swing.tree.*;
-import javax.swing.event.*;
-
-
-/**
- * Demo app that shows a very simple Mail Client
- *
- * @author Christopher Cotton
- * @author Bill Shannon
- */
-
-public class SimpleClient {
-
- static Vector url = new Vector();
- static FolderViewer fv;
- static MessageViewer mv;
-
- public static void main(String argv[]) {
- boolean usage = false;
-
- for (int optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-L")) {
- url.addElement(argv[++optind]);
- } else if (argv[optind].startsWith("-")) {
- usage = true;
- break;
- } else {
- usage = true;
- break;
- }
- }
-
- if (usage || url.size() == 0) {
- System.out.println("Usage: SimpleClient -L url");
- System.out.println(" where url is protocol://username:password@hostname/");
- System.exit(1);
- }
-
- try {
- // Set up our Mailcap entries. This will allow the JAF
- // to locate our viewers.
- File capfile = new File("simple.mailcap");
- if (!capfile.isFile()) {
- System.out.println(
- "Cannot locate the \"simple.mailcap\" file.");
- System.exit(1);
- }
-
- CommandMap.setDefaultCommandMap( new MailcapCommandMap(
- new FileInputStream(capfile)));
-
- JFrame frame = new JFrame("Simple Jakarta Mail Client");
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {System.exit(0);}});
- //frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-
- // Get a Store object
- SimpleAuthenticator auth = new SimpleAuthenticator(frame);
- Session session =
- Session.getDefaultInstance(System.getProperties(), auth);
- //session.setDebug(true);
-
- DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
-
- // create a node for each store we have
- for (Enumeration e = url.elements() ; e.hasMoreElements() ;) {
- String urlstring = (String) e.nextElement();
- URLName urln = new URLName(urlstring);
- Store store = session.getStore(urln);
-
- StoreTreeNode storenode = new StoreTreeNode(store);
- root.add(storenode);
- }
-
- DefaultTreeModel treeModel = new DefaultTreeModel(root);
- JTree tree = new JTree(treeModel);
- tree.addTreeSelectionListener(new TreePress());
-
- /* Put the Tree in a scroller. */
- JScrollPane sp = new JScrollPane();
- sp.setPreferredSize(new Dimension(250, 300));
- sp.getViewport().add(tree);
-
- /* Create a double buffered JPanel */
- JPanel sv = new JPanel(new BorderLayout());
- sv.add("Center", sp);
-
- fv = new FolderViewer(null);
-
- JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- sv, fv);
- jsp.setOneTouchExpandable(true);
- mv = new MessageViewer();
- JSplitPane jsp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- jsp, mv);
- jsp2.setOneTouchExpandable(true);
-
- frame.getContentPane().add(jsp2);
- frame.pack();
- frame.show();
-
- } catch (Exception ex) {
- System.out.println("SimpletClient caught exception");
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-class TreePress implements TreeSelectionListener {
-
- public void valueChanged(TreeSelectionEvent e) {
- TreePath path = e.getNewLeadSelectionPath();
- if (path != null) {
- Object o = path.getLastPathComponent();
- if (o instanceof FolderTreeNode) {
- FolderTreeNode node = (FolderTreeNode)o;
- Folder folder = node.getFolder();
-
- try {
- if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
- SimpleClient.fv.setFolder(folder);
- }
- } catch (MessagingException me) { }
- }
- }
- }
-}
diff --git a/client/src/main/java/StoreTreeNode.java b/client/src/main/java/StoreTreeNode.java
deleted file mode 100644
index 1d3572105..000000000
--- a/client/src/main/java/StoreTreeNode.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import jakarta.mail.*;
-
-/**
- * Node which represents a Store in the jakarta.mail apis.
- *
- * @author Christopher Cotton
- */
-public class StoreTreeNode extends DefaultMutableTreeNode {
-
- protected Store store = null;
- protected Folder folder = null;
- protected String display = null;
-
- /**
- * creates a tree node that points to the particular Store.
- *
- * @param what the store for this node
- */
- public StoreTreeNode(Store what) {
- super(what);
- store = what;
- }
-
-
- /**
- * a Store is never a leaf node. It can always contain stuff
- */
- public boolean isLeaf() {
- return false;
- }
-
-
- /**
- * return the number of children for this store node. The first
- * time this method is called we load up all of the folders
- * under the store's defaultFolder
- */
-
- public int getChildCount() {
- if (folder == null) {
- loadChildren();
- }
- return super.getChildCount();
- }
-
- protected void loadChildren() {
- try {
- // connect to the Store if we need to
- if (!store.isConnected()) {
- store.connect();
- }
-
- // get the default folder, and list the
- // subscribed folders on it
- folder = store.getDefaultFolder();
- // Folder[] sub = folder.listSubscribed();
- Folder[] sub = folder.list();
-
- // add a FolderTreeNode for each Folder
- int num = sub.length;
- for(int i = 0; i < num; i++) {
- FolderTreeNode node = new FolderTreeNode(sub[i]);
- // we used insert here, since add() would make
- // another recursive call to getChildCount();
- insert(node, i);
- }
-
- } catch (MessagingException me) {
- me.printStackTrace();
- }
- }
-
- /**
- * We override toString() so we can display the store URLName
- * without the password.
- */
-
- public String toString() {
- if (display == null) {
- URLName url = store.getURLName();
- if (url == null) {
- display = store.toString();
- } else {
- // don't show the password
- URLName too = new URLName( url.getProtocol(), url.getHost(), url.getPort(),
- url.getFile(), url.getUsername(), null);
- display = too.toString();
- }
- }
-
- return display;
- }
-
-
-}
-
diff --git a/client/src/main/java/TextViewer.java b/client/src/main/java/TextViewer.java
deleted file mode 100644
index 5d9c3a866..000000000
--- a/client/src/main/java/TextViewer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.awt.*;
-import java.io.*;
-import java.beans.*;
-import jakarta.activation.*;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-
-
-/**
- * A very simple TextViewer Bean for the MIMEType "text/plain"
- *
- * @author Christopher Cotton
- */
-
-public class TextViewer extends JPanel implements CommandObject
-{
-
- private JTextArea text_area = null;
- private DataHandler dh = null;
- private String verb = null;
-
- /**
- * Constructor
- */
- public TextViewer() {
- super(new GridLayout(1,1));
-
- // create the text area
- text_area = new JTextArea();
- text_area.setEditable(false);
- text_area.setLineWrap(true);
-
- // create a scroll pane for the JTextArea
- JScrollPane sp = new JScrollPane();
- sp.setPreferredSize(new Dimension(300, 300));
- sp.getViewport().add(text_area);
-
- add(sp);
- }
-
-
- public void setCommandContext(String verb, DataHandler dh)
- throws IOException {
-
- this.verb = verb;
- this.dh = dh;
-
- this.setInputStream( dh.getInputStream() );
- }
-
-
- /**
- * set the data stream, component to assume it is ready to
- * be read.
- */
- public void setInputStream(InputStream ins) {
-
- int bytes_read = 0;
- // check that we can actually read
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte data[] = new byte[1024];
-
- try {
- while((bytes_read = ins.read(data)) >0)
- baos.write(data, 0, bytes_read);
- ins.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- // convert the buffer into a string
- // place in the text area
- text_area.setText(baos.toString());
-
- }
-}
diff --git a/client/src/main/java/simple.mailcap b/client/src/main/java/simple.mailcap
deleted file mode 100644
index e65e13a33..000000000
--- a/client/src/main/java/simple.mailcap
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Example command map, using the MailcapCommandMap.
-#
-# for our viewers
-#
-message/*;; x-java-view=MessageViewer
-text/plain;; x-java-view=TextViewer
-multipart/*;; x-java-view=MultipartViewer
-
diff --git a/demo/pom.xml b/demo/pom.xml
deleted file mode 100644
index f66d0cc91..000000000
--- a/demo/pom.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
- com.sun.mail
- all
- 2.0.2-SNAPSHOT
-
- 4.0.0
- com.sun.mail
- demo
- jar
- Jakarta Mail API demos
-
-
-
-
- maven-compiler-plugin
-
-
- internal/**
-
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
-
-
- osgi-manifest
- none
-
-
-
-
-
-
- maven-jar-plugin
-
-
- default-jar
- none
-
-
-
-
-
-
-
-
- com.sun.mail
- jakarta.mail
-
-
-
diff --git a/demo/src/main/java/CRLFOutputStream.java b/demo/src/main/java/CRLFOutputStream.java
deleted file mode 100644
index 00cb23dc6..000000000
--- a/demo/src/main/java/CRLFOutputStream.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.io.*;
-
-/**
- * Convert lines into the canonical MIME format, that is,
- * terminate lines with CRLF.
- *
- * This stream can be used with the Part.writeTo and Message.writeTo
- * methods to generate the canonical MIME format of the data for the
- * purpose of (e.g.) sending it via SMTP or computing a digital
- * signature.
- */
-public class CRLFOutputStream extends FilterOutputStream {
- protected int lastb = -1;
- protected static byte[] newline;
- static {
- newline = new byte[2];
- newline[0] = (byte)'\r';
- newline[1] = (byte)'\n';
- }
-
- public CRLFOutputStream(OutputStream os) {
- super(os);
- }
-
- public void write(int b) throws IOException {
- if (b == '\r') {
- out.write(newline);
- } else if (b == '\n') {
- if (lastb != '\r')
- out.write(newline);
- } else {
- out.write(b);
- }
- lastb = b;
- }
-
- public void write(byte b[]) throws IOException {
- write(b, 0, b.length);
- }
-
- public void write(byte b[], int off, int len) throws IOException {
- int start = off;
-
- len += off;
- for (int i = start; i < len ; i++) {
- if (b[i] == '\r') {
- out.write(b, start, i - start);
- out.write(newline);
- start = i + 1;
- } else if (b[i] == '\n') {
- if (lastb != '\r') {
- out.write(b, start, i - start);
- out.write(newline);
- }
- start = i + 1;
- }
- lastb = b[i];
- }
- if ((len - start) > 0)
- out.write(b, start, len - start);
- }
-}
diff --git a/demo/src/main/java/NewlineOutputStream.java b/demo/src/main/java/NewlineOutputStream.java
deleted file mode 100644
index c6200295d..000000000
--- a/demo/src/main/java/NewlineOutputStream.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.io.*;
-
-/**
- * Convert the various newline conventions to the local platform's
- * newline convention.
- *
- * This stream can be used with the Message.writeTo method to
- * generate a message that uses the local plaform's line terminator
- * for the purpose of (e.g.) saving the message to a local file.
- */
-public class NewlineOutputStream extends FilterOutputStream {
- private int lastb = -1;
- private static byte[] newline;
-
- public NewlineOutputStream(OutputStream os) {
- super(os);
- if (newline == null) {
- String s = System.lineSeparator();
- if (s == null || s.length() <= 0)
- s = "\n";
- try {
- newline = s.getBytes("iso-8859-1"); // really us-ascii
- } catch (UnsupportedEncodingException ex) {
- // should never happen
- newline = new byte[] { (byte)'\n' };
- }
- }
- }
-
- public void write(int b) throws IOException {
- if (b == '\r') {
- out.write(newline);
- } else if (b == '\n') {
- if (lastb != '\r')
- out.write(newline);
- } else {
- out.write(b);
- }
- lastb = b;
- }
-
- public void write(byte b[]) throws IOException {
- write(b, 0, b.length);
- }
-
- public void write(byte b[], int off, int len) throws IOException {
- for (int i = 0 ; i < len ; i++) {
- write(b[off + i]);
- }
- }
-}
diff --git a/demo/src/main/java/README.txt b/demo/src/main/java/README.txt
deleted file mode 100644
index 3168ed62b..000000000
--- a/demo/src/main/java/README.txt
+++ /dev/null
@@ -1,384 +0,0 @@
- README for the demo programs in this directory
- ==============================================
-
-These demo programs illustrate how to use the Jakarta Mail API to
-perform a number of common email functions. Note these these
-programs are not intended to be examples of good user interfaces,
-or good command line interfaces. No one is expected to actually
-*use* these programs for anything real. Rather, their value is
-in the source code. Don't look at their command line arguments
-or user interface to figure out what Jakarta Mail can do, look at
-their source code. We strongly recommend that you read the
-source code and understand what these programs are doing before
-running them.
-
-All of these programs are simple command line tools with a UNIX
-style interface. On Windows you'll need to run them in an MS-DOS
-window. We apologize in advance for the inconsistency in how these
-programs accept options. There are generally two styles. The very
-simple style (e.g., as used by copier.java) requires a fixed number
-of arguments in a fixed order. Others (e.g., folderlist.java) take
-UNIX-style options, many of which are optional, and which may appear
-in any order. The following notes should help you figure it out,
-but if in doubt, read the source code.
-
-
-
-- copier.java
-
- This program copies the specified messages from one folder to
- another. Both folders must belong to the same store.
-
- Usage:
- java copier
-
- Arguments (in order):
-
- : URL of the Store. The URL should include
- the password as well (if needed).
- Example: "imap://john:password@mailstore.com"
-
- : source folder
- : destination folder
- : start message number
- : end message number
-
-
-- folderlist.java
-
- This program lists information about the folders in a Store.
-
- Usage:
- java folderlist -L -T -H -U -P
- [-R ] [-r] [-v] [-D]
-
- Options:
-
- -L : URL of the Store. The URL should include
- the password as well (if needed).
- Example: "imap://john:password@mailstore.com"
- -T : store protocol (Ex: "imap")
- -H : hostname of store.
- -U : username (if needed)
- -P : password (if needed)
- -R : root of the folder hierarchy. This is optional. If
- not present, listing starts from the default folder.
- -r : list recursively - folder and all subfolders.
- -v : verbose - show more info about each folder.
- -D : Turn on session debugging
- : folders that match this pattern are listed. Use "*"
- as wildcard to match everything.
-
-
-- monitor.java
-
- Illustrates how to monitor a folder for interesting events,
- like new mail arrival.
-
- Usage:
- java monitor
-
- Arguments (in order):
-
- : hostname of store.
- : username (if needed)
- : password (if needed)
- : folder to monitor
- : frequency of monitoring
-
-
-- mover.java
-
- Moves messages between folders. The folders must belong to the
- same store.
-
- Usage:
- java mover -T -H -U -P [-v]
- -s -d [-x]
-
- Options:
-
- -T : store protocol (Ex: "imap")
- -H : hostname of store.
- -U : username (if needed)
- -P : password (if needed)
- -s : source folder
- -d : destination folder
- -v : Optional verbose option
- -x : Optional expunge option, to expunge the deleted
- messages from src
-
- Arguments (in order):
-
- : start message number
- : end message number
-
-
-- msgmultisendsample.java
-
- Demonstrates how to construct and send a multipart message.
-
- Usage:
- java msgmultisendsample true|false
-
- Arguments (in order):
-
- : Recipient address
- : Sender address
- : name of SMTP server
- true|false : "true" to turn on session debugging, "false" otherwise
-
-
-- msgsend.java
-
- Send a simple text message. Optionally saves a copy
- of the outgoing message in a folder (record-folder).
-
- Most parameters to this program are optional. When
- the program is run, it interactively asks for
- the "To" and "Subject" fields if not already available.
- Then the program expects the body of the message.
- After you type in the body, hit Ctrl-D on Unix
- systems or Ctrl-Z on Windows systems to send
- the message.
-
- Usage:
- java msgsend -L -T -H -U
- -P -s -o -c -b
- -f -M [-d]
-
- Options:
-
- -L : URL of the store for the record-folder
- -T : If is not present, this indicates
- the store protocol for the record-folder.
- -H : If is not present, this indicates
- the hostname for the record-folder.
- -U : If is not present, this indicates
- the username for the record-folder.
- -P : If is not present, this indicates
- the password for the record-folder.
- -f : name of record-folder.
- -M : Host name of SMTP server. Defaults to "localhost"
- which often works on UNIX but rarely on Windows.
- -s : Subject of message to be sent
- -o : From address of message to be sent
- -c : Cc address of message to be sent
- -b : Bcc address of message to be sent
- -d : Turn on session debugging.
- -a : Include file as an attachment with the message
-
- Argument:
-
- : To address of message to be sent
-
-
-- msgsendsample.java
-
- Demonstrates how to construct and send a simple text message.
-
- Usage:
- java msgsendsample true|false
-
- Arguments (in order):
-
- : Recipient address
- : Sender address
- : name of SMTP server
- true|false : "true" to turn on session debugging, "false" otherwise
-
-
-- msgshow.java
-
- Displays message(s) from a folder or from stdin.
-
- Usage:
- java msgshow -L -T -H -p
- -U -P -f
- [-D] [-s] [-S] [-a] [-v] [msgnum]
- java msgshow -m [-D] [-s] [-S] [-v]
-
- Options:
-
- -L : URL of the Store. The URL should include
- the password as well (if needed).
- Example: "imap://john:password@mailstore.com"
- -T : If is not present, this indicates
- the store protocol
- -H : If is not present, this indicates
- the hostname
- -p : If is not present, this indicates
- the port number (usually not needed)
- -U : If is not present, this indicates
- the username
- -P : If is not present, this indicates
- the password
- -f : Folder to open
- -m : Read message from standard input
- -D : Turn on session debugging
- -s : Show the structure of the message, but not the contents
- -S : Save attachments to appropriately named files
- -a : Show ALERTS and NOTIFICATIONS from the Store
- -v : Verbose mode - show total messages and number of new messages
-
- Argument:
-
- : the message to be displayed. If this
- parameter is not present, all messages in the
- folder are displayed.
-
-
-- namespace.java
-
- Displays the namespaces supported by a store.
-
- Usage:
- java namespace -L -T -H -p
- -U -P [-D]
-
- Options:
-
- -L : URL of the Store. The URL should include
- the password as well (if needed).
- Example: "imap://john:password@mailstore.com"
- -T : If is not present, this indicates
- the store protocol
- -H : If is not present, this indicates
- the hostname
- -p : If is not present, this indicates
- the port number (usually not needed)
- -U : If is not present, this indicates
- the username
- -P : If is not present, this indicates
- the password
- -D : Turn on session debugging
-
-
-- populate.java
-
- Copies an entire folder hierarchy from one message store to
- another.
-
- Usage:
- java populate -s -d -D -f
-
- Options:
-
- -s : URL of source folder
- -d : URL of destination folder
- -D : Turn on session debugging
- -f : force the copy to occur even if the destination
- folder already exists
- -S : skip special folders named "SCCS", "Drafts", "Trash", and
- "Shared Folders"
- -c : clear out old folders before copying messages
- -P : don't preserve flags when copying messages
-
-
-- registry.java
-
- Demonstrates how to query the Jakarta Mail "registry" for providers,
- set default providers, etc.
-
- Usage:
- java registry
-
-
-- search.java
-
- Search the given folder for messages matching the
- given criteria. Illustrates the use of the
- jakarta.mail.search package.
-
- Usage:
- java search -L -T -H -U -P
- -f -subject -from
- -today -or
-
- Options:
-
- -L : URL of the store
- -T : If is not present, this indicates
- the store protocol
- -H : If is not present, this indicates
- the hostname
- -U : If is not present, this indicates
- the username
- -P : If is not present, this indicates
- the password
- -f : folder to search
-
- -or : If this flag is present, the search will
- return messages that match any one of the
- below criteria. Else the search will only
- return messages that match all the criteria
-
- -subject : search for messages containing this string
- as the Subject
- -from : search for messages containing this string
- as the From address
- -today : search for messages received today
-
-
-- sendfile.java
-
- Send the specified file to the given address. The file
- is sent as an attachment. An SMTP server must be available.
-
- Usage:
- java sendfile true|false
-
- Arguments (in order):
-
- : Recipient address
- : Sender address
- : name of SMTP server
- : name of file to be sent
- true|false : "true" to turn on session debugging, "false" otherwise
-
-
-- sendhtml.java
-
- The sendhtml program works like the msgsend program, taking
- the same options and input, but the text collected from the
- user is sent as type "text/html" instead of "text/plain".
-
- This program is a good example of how to send arbitrary
- string data as any arbitrary MIME type.
-
-
-- smtpsend.java
-
- Takes the same options as the msgsend program, but illustrates
- how to handle SMTP-specific error codes. Also accepts the
- following options:
-
- Option:
-
- -v : verbose output
- -A : use SMTP authentication
- -S : use SSL
-
-- transport.java
-
- Illustrates how to use an explicit Transport object, how to
- handle transport exceptions, and how to handle transport events.
-
- Usage:
- java transport true|false
-
- Arguments (in order):
-
- : Recipient address
- : Sender address
- : name of SMTP server
- : name of file to be sent
- true|false : "true" to turn on session debugging, "false" otherwise
-
-
-- uidmsgshow.java
-
- The uidmsgshow program works like the msgshow program, taking
- the same options, except instead of using message numbers, it
- uses message UID's. This will typically only work with IMAP
- message stores.
diff --git a/demo/src/main/java/copier.java b/demo/src/main/java/copier.java
deleted file mode 100644
index 73ae3b9ec..000000000
--- a/demo/src/main/java/copier.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/**
- *
- * @author Christopher Cotton
- */
-
-import jakarta.mail.*;
-
-/**
- * copier will copy a specified number of messages from one folder
- * to another folder. it demonstrates how to use the Jakarta Mail APIs
- * to copy messages.
- *
- * Usage for copier: copier store urlname
- * src folderdest folderstart msg #end msg #
- *
- */
-
-public class copier {
-
- public static void main(String argv[]) {
- boolean debug = false; // change to get more errors
-
- if (argv.length != 5) {
- System.out.println( "usage: copier " +
- "");
- return;
- }
-
- try {
- URLName url = new URLName(argv[0]);
- String src = argv[1]; // source folder
- String dest = argv[2]; // dest folder
- int start = Integer.parseInt(argv[3]); // copy from message #
- int end = Integer.parseInt(argv[4]); // to message #
-
- // Get the default Session object
-
- Session session = Session.getInstance(System.getProperties(), null);
- // session.setDebug(debug);
-
- // Get a Store object that implements the protocol.
- Store store = session.getStore(url);
- store.connect();
- System.out.println("Connected...");
-
- // Open Source Folder
- Folder folder = store.getFolder(src);
- folder.open(Folder.READ_WRITE);
- System.out.println("Opened source...");
-
- if (folder.getMessageCount() == 0) {
- System.out.println("Source folder has no messages ..");
- folder.close(false);
- store.close();
- }
-
- // Open destination folder, create if needed
- Folder dfolder = store.getFolder(dest);
- if (!dfolder.exists()) // create
- dfolder.create(Folder.HOLDS_MESSAGES);
-
- Message[] msgs = folder.getMessages(start, end);
- System.out.println("Got messages...");
-
- // Copy messages into destination,
- folder.copyMessages(msgs, dfolder);
- System.out.println("Copied messages...");
-
- // Close the folder and store
- folder.close(false);
- store.close();
- System.out.println("Closed folder and store...");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- System.exit(0);
- }
-}
diff --git a/demo/src/main/java/folderlist.java b/demo/src/main/java/folderlist.java
deleted file mode 100644
index ec9dc0c26..000000000
--- a/demo/src/main/java/folderlist.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.Properties;
-import jakarta.mail.*;
-
-import com.sun.mail.imap.*;
-
-/**
- * Demo app that exercises the Message interfaces.
- * List information about folders.
- *
- * @author John Mani
- * @author Bill Shannon
- */
-
-public class folderlist {
- static String protocol = null;
- static String host = null;
- static String user = null;
- static String password = null;
- static String url = null;
- static String root = null;
- static String pattern = "%";
- static boolean recursive = false;
- static boolean verbose = false;
- static boolean debug = false;
-
- public static void main(String argv[]) throws Exception {
- int optind;
- for (optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-T")) {
- protocol = argv[++optind];
- } else if (argv[optind].equals("-H")) {
- host = argv[++optind];
- } else if (argv[optind].equals("-U")) {
- user = argv[++optind];
- } else if (argv[optind].equals("-P")) {
- password = argv[++optind];
- } else if (argv[optind].equals("-L")) {
- url = argv[++optind];
- } else if (argv[optind].equals("-R")) {
- root = argv[++optind];
- } else if (argv[optind].equals("-r")) {
- recursive = true;
- } else if (argv[optind].equals("-v")) {
- verbose = true;
- } else if (argv[optind].equals("-D")) {
- debug = true;
- } else if (argv[optind].equals("--")) {
- optind++;
- break;
- } else if (argv[optind].startsWith("-")) {
- System.out.println(
-"Usage: folderlist [-T protocol] [-H host] [-U user] [-P password] [-L url]");
- System.out.println(
-"\t[-R root] [-r] [-v] [-D] [pattern]");
- System.exit(1);
- } else {
- break;
- }
- }
- if (optind < argv.length)
- pattern = argv[optind];
-
- // Get a Properties object
- Properties props = System.getProperties();
-
- // Get a Session object
- Session session = Session.getInstance(props, null);
- session.setDebug(debug);
-
- // Get a Store object
- Store store = null;
- Folder rf = null;
- if (url != null) {
- URLName urln = new URLName(url);
- store = session.getStore(urln);
- store.connect();
- } else {
- if (protocol != null)
- store = session.getStore(protocol);
- else
- store = session.getStore();
-
- // Connect
- if (host != null || user != null || password != null)
- store.connect(host, user, password);
- else
- store.connect();
- }
-
- // List namespace
- if (root != null)
- rf = store.getFolder(root);
- else
- rf = store.getDefaultFolder();
-
- dumpFolder(rf, false, "");
- if ((rf.getType() & Folder.HOLDS_FOLDERS) != 0) {
- Folder[] f = rf.list(pattern);
- for (int i = 0; i < f.length; i++)
- dumpFolder(f[i], recursive, " ");
- }
-
- store.close();
- }
-
- static void dumpFolder(Folder folder, boolean recurse, String tab)
- throws Exception {
- System.out.println(tab + "Name: " + folder.getName());
- System.out.println(tab + "Full Name: " + folder.getFullName());
- System.out.println(tab + "URL: " + folder.getURLName());
-
- if (verbose) {
- if (!folder.isSubscribed())
- System.out.println(tab + "Not Subscribed");
-
- if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
- if (folder.hasNewMessages())
- System.out.println(tab + "Has New Messages");
- System.out.println(tab + "Total Messages: " +
- folder.getMessageCount());
- System.out.println(tab + "New Messages: " +
- folder.getNewMessageCount());
- System.out.println(tab + "Unread Messages: " +
- folder.getUnreadMessageCount());
- }
- if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0)
- System.out.println(tab + "Is Directory");
-
- /*
- * Demonstrate use of IMAP folder attributes
- * returned by the IMAP LIST response.
- */
- if (folder instanceof IMAPFolder) {
- IMAPFolder f = (IMAPFolder)folder;
- String[] attrs = f.getAttributes();
- if (attrs != null && attrs.length > 0) {
- System.out.println(tab + "IMAP Attributes:");
- for (int i = 0; i < attrs.length; i++)
- System.out.println(tab + " " + attrs[i]);
- }
- }
- }
-
- System.out.println();
-
- if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
- if (recurse) {
- Folder[] f = folder.list();
- for (int i = 0; i < f.length; i++)
- dumpFolder(f[i], recurse, tab + " ");
- }
- }
- }
-}
diff --git a/demo/src/main/java/internal/TtyAuthenticator.java b/demo/src/main/java/internal/TtyAuthenticator.java
deleted file mode 100644
index d664bca1a..000000000
--- a/demo/src/main/java/internal/TtyAuthenticator.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.io.*;
-import java.net.*;
-import jakarta.mail.*;
-import jakarta.mail.PasswordAuthentication;
-import jakarta.mail.Authenticator;
-
-/**
- * A simple Authenticator that prompts for the user name and password on stdin.
- * Puts up a dialog something like:
- *
- * Connecting to <protocol> mail service on host <addr>, port <port>.
- * <prompt>
- *
- * User Name: [defaultUserName]
- * Password:
- *
- *
- * @author Bill Shannon
- */
-
-public class TtyAuthenticator extends Authenticator {
-
- /**
- * @return The PasswordAuthentication collected from the
- * user, or null if none is provided.
- */
- protected PasswordAuthentication getPasswordAuthentication() {
- BufferedReader in = new BufferedReader(
- new InputStreamReader((System.in)));
- StringBuffer sb = new StringBuffer();
- sb.append("Connecting to ");
- sb.append(getRequestingProtocol());
- sb.append(" mail service on host ");
- sb.append(getRequestingSite().getHostName());
- int port = getRequestingPort();
- if (port > 0) {
- sb.append(", port ");
- sb.append(port);
- }
- sb.append(".");
- System.out.println(sb.toString());
- String prompt = getRequestingPrompt();
- if (prompt != null)
- System.out.println(prompt);
- System.out.println();
- String userName = get(in, "User Name", getDefaultUserName());
- String password = getpw("Password");
- if (userName == null)
- return null;
- else
- return new PasswordAuthentication(userName, password);
- }
-
- private static final String get(BufferedReader in,
- String name, String value) {
- PrintStream p = System.out;
-
- p.print(name + ": ");
- if (value != null)
- p.print("[" + value + "] ");
- p.flush();
-
- try {
- String s = in.readLine();
- if (s.length() == 0)
- return value;
- else
- return s;
- } catch (IOException e) {
- return value;
- }
- }
-
- private static final String getpw(String name) {
- Console cons;
- char[] passwd;
- if ((cons = System.console()) != null &&
- (passwd = cons.readPassword("[%s] ", name)) != null)
- return new String(passwd);
- return "";
- }
-
- // main program, for debugging.
- // Usage: java TtyAuthenticator host port protocol prompt defaultUser
- public static void main(String argv[]) throws Exception {
- Session sess = Session.getInstance(System.getProperties(),
- new TtyAuthenticator());
- PasswordAuthentication pw = sess.requestPasswordAuthentication(
- InetAddress.getByName(argv[0]),
- Integer.parseInt(argv[1]), argv[2], z(argv[3]), z(argv[4]));
- System.out.println("User: " + n(pw.getUserName()));
- System.out.println("Password: " + n(pw.getPassword()));
- }
-
- private static final String n(String s) {
- return s == null ? "" : s;
- }
-
- private static final String z(String s) {
- return s.length() > 0 ? s : null;
- }
-}
diff --git a/demo/src/main/java/internal/answer.java b/demo/src/main/java/internal/answer.java
deleted file mode 100644
index 80cc8161b..000000000
--- a/demo/src/main/java/internal/answer.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.*;
-import java.io.*;
-import jakarta.mail.*;
-import jakarta.mail.search.*;
-import jakarta.mail.internet.*;
-
-/**
- * Program to manage the javamail@Sun.COM mailing list by keeping track
- * of which messages have been answered. Message that have been answered
- * have the ANSWERED flag set. Messages that are replies to other messages
- * have the FLAGGED flag set.
- *
- * Note that this program operates on the log file directly and thus all
- * access to the log file using this program must be through the same
- * IMAP server so that the flags are handled consistently.
- *
- * When run with no message number arguments it will list the unanswered
- * messages. The -u flag will cause it to first update the mailbox to
- * account for any recent replies.
- *
- * When run with message number arguments it will mark those messages as
- * answered. This is useful for marking spam and other random messages
- * that will never be replied to.
- *
- * The -a flag will cause it to mark all messages as answered. Useful for
- * flushing the ever accumulating spam.
- *
- * @author Bill Shannon
- */
-
-public class answer {
-
- static String protocol = "imap";
- static String host = "anybodys.sfbay";
- static String user = "javamail";
- static String password = "1javamail1";
- static String mbox =
- "/net/anybodys.sfbay/export6/javamail/logs/javamail.log";
- static String url = null;
- static boolean verbose = false;
- static boolean update = false;
- static boolean markAll = false;
-
- public static void main(String argv[]) {
- int optind;
-
- for (optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-T")) {
- protocol = argv[++optind];
- } else if (argv[optind].equals("-H")) {
- host = argv[++optind];
- } else if (argv[optind].equals("-U")) {
- user = argv[++optind];
- } else if (argv[optind].equals("-P")) {
- password = argv[++optind];
- } else if (argv[optind].equals("-v")) {
- verbose = true;
- } else if (argv[optind].equals("-f")) {
- mbox = argv[++optind];
- } else if (argv[optind].equals("-L")) {
- url = argv[++optind];
- } else if (argv[optind].equals("-u")) {
- update = true;
- } else if (argv[optind].equals("-a")) {
- markAll = true;
- update = true;
- } else if (argv[optind].equals("--")) {
- optind++;
- break;
- } else if (argv[optind].startsWith("-")) {
- System.out.println(
-"Usage: answer [-L url] [-T protocol] [-H host] [-U user] [-P password]\n" +
-"\t[-f mailbox] [-v] [-u] [-a] [msgno ...]");
- System.exit(1);
- } else {
- break;
- }
- }
-
- try {
- // Get a Properties object
- Properties props = System.getProperties();
-
- // Get a Session object
- Session session = Session.getDefaultInstance(props,
- new TtyAuthenticator());
-
- // Get a Store object
- Store store = null;
- if (url != null) {
- URLName urln = new URLName(url);
- store = session.getStore(urln);
- store.connect();
- } else {
- if (protocol != null)
- store = session.getStore(protocol);
- else
- store = session.getStore();
-
- // Connect
- if (host != null || user != null || password != null)
- store.connect(host, user, password);
- else
- store.connect();
- }
-
-
- // Open the Folder
-
- Folder folder = store.getDefaultFolder();
- if (folder == null) {
- System.out.println("No default folder");
- System.exit(1);
- }
-
- folder = folder.getFolder(mbox);
- if (folder == null) {
- System.out.println("Invalid folder");
- System.exit(1);
- }
-
- if (optind < argv.length || update)
- folder.open(Folder.READ_WRITE);
- else
- folder.open(Folder.READ_ONLY);
- int totalMessages = folder.getMessageCount();
-
- if (totalMessages == 0) {
- System.out.println("Empty folder");
- folder.close(false);
- store.close();
- System.exit(1);
- }
-
- if (verbose) {
- int newMessages = folder.getNewMessageCount();
- pv("Total messages = " + totalMessages);
- pv("New messages = " + newMessages);
- pv("-------------------------------");
- }
-
- if (optind >= argv.length) {
- // get all messages that aren't answered or flagged
- Flags f = new Flags();
- f.add(Flags.Flag.ANSWERED);
- f.add(Flags.Flag.FLAGGED);
-
- // Use a suitable FetchProfile
- FetchProfile fp = new FetchProfile();
- fp.add(FetchProfile.Item.ENVELOPE);
- fp.add(FetchProfile.Item.FLAGS);
-
- Message[] msgs = folder.search(new FlagTerm(f, false));
- folder.fetch(msgs, fp);
-
- if (update) {
- doUpdate(msgs);
- // re-fetch messages
- msgs = folder.search(new FlagTerm(f, false));
- pv("");
- pv("");
- }
-
- System.out.println("Unanswered messages:");
- for (int i = 0; i < msgs.length; i++) {
- Message msg = msgs[i];
- System.out.println("--------------------------");
- System.out.println("MESSAGE #" +
- msg.getMessageNumber() + ":");
- Question q = new Question(msg);
- System.out.println(q);
- if (q.isReply())
- System.out.println(
- "A reply to a message we haven't seen");
- if (markAll) {
- int msgno = msg.getMessageNumber();
- if (q.isReply()) {
- pv("Flagging message #" + msgno);
- msg.setFlag(Flags.Flag.FLAGGED, true);
- } else {
- pv("Answering message #" + msgno);
- msg.setFlag(Flags.Flag.ANSWERED, true);
- }
- }
- }
-
- } else {
- for (int i = optind; i < argv.length; i++) {
- int msgno = Integer.parseInt(argv[i]);
- Message msg = folder.getMessage(msgno);
- Question q = new Question(msg);
- if (q.isReply()) {
- pv("Flagging message #" + msgno);
- msg.setFlag(Flags.Flag.FLAGGED, true);
- } else {
- pv("Answering message #" + msgno);
- msg.setFlag(Flags.Flag.ANSWERED, true);
- }
- }
- }
-
- folder.close(false);
- store.close();
- } catch (Exception ex) {
- System.out.println("Oops, got exception! " + ex.getMessage());
- ex.printStackTrace();
- System.exit(1);
- }
- System.exit(0);
- }
-
- /**
- * Update the mailbox to account for any replies.
- */
- static void doUpdate(Message[] msgs) throws MessagingException {
- // a hash table of all the unanswered questions
- Hashtable qt = new Hashtable();
-
- Address javamailAddress = new InternetAddress("javamail@Sun.COM");
- SearchTerm javamail = new OrTerm(
- new RecipientTerm(Message.RecipientType.TO, javamailAddress),
- new RecipientTerm(Message.RecipientType.CC, javamailAddress));
-
- for (int i = 0; i < msgs.length; i++) {
- Message msg = msgs[i];
- pv("--------------------------");
- pv("MESSAGE #" + msg.getMessageNumber() + ":");
- Question q = new Question(msg);
- pv(q.toString());
- Question q0;
- if ((q0 = (Question)qt.get(q)) != null) {
- pv("Found in table");
- if (q.isReply()) {
- Message qm = q0.getMessage();
- if (!qm.isSet(Flags.Flag.ANSWERED)) {
- pv("Answered:");
- pv(q0.toString());
- qm.setFlag(Flags.Flag.ANSWERED, true);
- }
- pv("is reply, flagging it");
- msg.setFlag(Flags.Flag.FLAGGED, true);
- } else {
- // a second copy of a message that's not a reply?
- // shouldn't happen.
- }
- } else {
- pv("NOT found in table");
- if (q.isReply()) {
- // a reply to a message we haven't seen?
- pv("flagging, but no original msg");
- msg.setFlag(Flags.Flag.FLAGGED, true);
- } else {
- // an original question, put it in the table
- qt.put(q, q);
- // if the message looks like spam, flag it
- if (!javamail.match(msg)) {
- pv("SPAM!!!");
- msg.setFlag(Flags.Flag.FLAGGED, true);
- }
- }
- }
- }
- }
-
- /**
- * Print verbose.
- */
- static void pv(String s) {
- if (verbose)
- System.out.println(s);
- }
-}
-
-/**
- * This class represents a single "question" sent to javamail@Sun.COM,
- * or possibly a reply to such a question.
- */
-class Question {
- Message msg;
- Address sender;
- Address[] recipients;
- String subject;
- Date date;
- boolean reply = false;
-
- Question(Message msg) throws MessagingException {
- this.msg = msg;
- sender = msg.getReplyTo()[0]; // XXX - assume only one
- subject = msg.getSubject();
- if (subject == null)
- subject = "";
- else if (subject.regionMatches(true, 0, "Re: ", 0, 4)) {
- subject = subject.substring(4);
- reply = true;
- recipients = msg.getRecipients(Message.RecipientType.TO);
- }
- subject = subject.trim();
- date = msg.getSentDate();
- if (date == null)
- date = msg.getReceivedDate();
- }
-
- public boolean isReply() {
- return reply;
- }
-
- public Message getMessage() {
- return msg;
- }
-
- public int hashCode() {
- return subject.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof Question))
- return false;
- Question q = (Question)obj;
- if (this.reply == q.reply)
- return this.sender.equals(q.sender) &&
- this.subject.equals(q.subject);
-
- /*
- * A reply is equal to a question if the sender of the question
- * is one of the recipients of the reply.
- */
- Question qq, qr;
- if (this.reply) {
- qq = q;
- qr = this;
- } else {
- qq = this;
- qr = q;
- }
- for (int i = 0; i < qr.recipients.length; i++) {
- if (qq.sender.equals(qr.recipients[i]))
- return true;
- }
- return false;
- }
-
- public String toString() {
- return "Date: " + date + "\nFrom: " + sender + "\nSubject: " + subject;
- }
-}
diff --git a/demo/src/main/java/internal/foldersplit.java b/demo/src/main/java/internal/foldersplit.java
deleted file mode 100644
index 24d6832a0..000000000
--- a/demo/src/main/java/internal/foldersplit.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.*;
-import java.text.*;
-import jakarta.mail.*;
-
-/**
- *
- * Split mail folders according to date of messages.
- *
- * @author Bill Shannon
- */
-
-public class foldersplit {
-
- static String protocol;
- static String host = null;
- static String user = null;
- static String password = null;
- static String dst = null;
- static String url = null;
- static int port = -1;
- static boolean verbose = false;
- static boolean debug = false;
- static boolean nop = false;
- static SimpleDateFormat df = new SimpleDateFormat("yyyy.MM");
-
- public static void main(String argv[]) {
- int optind;
-
- for (optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-T")) {
- protocol = argv[++optind];
- } else if (argv[optind].equals("-H")) {
- host = argv[++optind];
- } else if (argv[optind].equals("-U")) {
- user = argv[++optind];
- } else if (argv[optind].equals("-P")) {
- password = argv[++optind];
- } else if (argv[optind].equals("-d")) {
- dst = argv[++optind];
- } else if (argv[optind].equals("-v")) {
- verbose = true;
- } else if (argv[optind].equals("-n")) {
- nop = true;
- } else if (argv[optind].equals("-D")) {
- debug = true;
- } else if (argv[optind].equals("-L")) {
- url = argv[++optind];
- } else if (argv[optind].equals("-p")) {
- port = Integer.parseInt(argv[++optind]);
- } else if (argv[optind].equals("--")) {
- optind++;
- break;
- } else if (argv[optind].startsWith("-")) {
- System.out.println(
-"Usage: foldersplit [-L url] [-T protocol] [-H host] [-p port] [-U user]");
- System.out.println(
-"\t[-P password] [-v] [-D] folder ...");
- System.exit(1);
- } else {
- break;
- }
- }
-
- try {
- // Get a Properties object
- Properties props = System.getProperties();
-
- // Get a Session object
- Session session = Session.getDefaultInstance(props, null);
- session.setDebug(debug);
-
- // Get a Store object
- Store store = null;
- if (url != null) {
- URLName urln = new URLName(url);
- store = session.getStore(urln);
- store.connect();
- } else {
- if (protocol != null)
- store = session.getStore(protocol);
- else
- store = session.getStore();
-
- // Connect
- if (host != null || user != null || password != null)
- store.connect(host, port, user, password);
- else
- store.connect();
- }
-
-
- // Open the Folder
-
- Folder deffolder = store.getDefaultFolder();
- if (deffolder == null) {
- System.out.println("No default folder");
- System.exit(1);
- }
- Folder dstfolder;
- if (dst == null) {
- dstfolder = deffolder;
- } else {
- dstfolder = deffolder.getFolder(dst);
- if (dstfolder == null) {
- System.out.println("No destination folder");
- System.exit(1);
- }
- }
-
- Folder outf = null;
- for (; optind < argv.length; optind++) {
- Folder folder = deffolder.getFolder(argv[optind]);
- if (folder == null) {
- System.out.println("Invalid folder: " + argv[optind]);
- continue;
- }
- System.out.println("Folder: " + folder.getFullName());
-
- folder.open(Folder.READ_ONLY);
- int totalMessages = folder.getMessageCount();
-
- if (totalMessages == 0) {
- System.out.println("Empty folder");
- folder.close(false);
- continue;
- }
-
- if (verbose) {
- int newMessages = folder.getNewMessageCount();
- System.out.println("Total messages = " + totalMessages);
- System.out.println("New messages = " + newMessages);
- System.out.println("-------------------------------");
- }
-
- // Attributes & Flags for all messages ..
- Message[] msgs = folder.getMessages();
-
- // Use a suitable FetchProfile
- FetchProfile fp = new FetchProfile();
- fp.add(FetchProfile.Item.ENVELOPE);
- fp.add(FetchProfile.Item.FLAGS);
- folder.fetch(msgs, fp);
-
- for (int i = 0; i < msgs.length; i++) {
- if (verbose) {
- System.out.println("--------------------------");
- System.out.println("MESSAGE #" + (i + 1) + ":");
- }
- Date d = msgs[i].getReceivedDate();
- if (d != null) {
- String n = df.format(d);
- if (verbose)
- System.out.println(n);
- if (outf == null || !n.equals(outf.getName())) {
- outf = dstfolder.getFolder(n);
- if (!outf.exists()) {
- System.out.println("Creating: " +
- outf.getFullName());
- if (!nop)
- outf.create(Folder.HOLDS_MESSAGES);
- }
- }
- }
- if (!nop)
- outf.appendMessages(new Message[] { msgs[i] });
- }
- folder.close(false);
- }
-
- store.close();
- } catch (Exception ex) {
- System.out.println("Oops, got exception! " + ex.getMessage());
- ex.printStackTrace();
- }
- System.exit(1);
- }
-}
diff --git a/demo/src/main/java/internal/fpopulate.java b/demo/src/main/java/internal/fpopulate.java
deleted file mode 100644
index 6a33a8e63..000000000
--- a/demo/src/main/java/internal/fpopulate.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.io.*;
-import jakarta.mail.*;
-import jakarta.mail.internet.*;
-
-/*
- * Copy folder hierarchies between files and a Store. This is a useful
- * utility to populate new (and possibly empty) mail stores. Specify
- * the source as a directory name and the destination folders as a URL.
- *
- * @author John Mani
- * @author Bill Shannon
- */
-
-public class fpopulate {
-
- static boolean force = false;
- static boolean skipSCCS = false;
- static boolean clear = false;
-
- static Session session;
-
- public static void main(String argv[]) {
- String srcdir = null;
- String dstURL = null;
- boolean debug = false;
-
- int optind;
-
- for (optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-s")) {
- srcdir = argv[++optind];
- } else if (argv[optind].equals("-d")) {
- dstURL = argv[++optind];
- } else if (argv[optind].equals("-D")) {
- debug = true;
- } else if (argv[optind].equals("-f")) {
- force = true;
- } else if (argv[optind].equals("-S")) {
- skipSCCS = true;
- } else if (argv[optind].equals("-c")) {
- clear = true;
- } else if (argv[optind].equals("--")) {
- optind++;
- break;
- } else if (argv[optind].startsWith("-")) {
- printUsage();
- System.exit(1);
- } else {
- break;
- }
- }
-
- try {
-
- if (srcdir == null || dstURL == null) {
- printUsage();
- System.exit(1);
- }
-
- session = Session.getDefaultInstance(
- System.getProperties(), null);
- session.setDebug(debug);
-
- // Get source folder
- File srcFolder = new File(srcdir);
- if (!srcFolder.exists()) {
- System.out.println("source folder does not exist");
- System.exit(1);
- }
-
- // Set up destination folder
- URLName dstURLName = new URLName(dstURL);
- Folder dstFolder;
- // Check if the destination URL has a folder specified. If
- // not, we use the source folder name
- if (dstURLName.getFile() == null) {
- Store s = session.getStore(dstURLName);
- s.connect();
- dstFolder = s.getFolder(srcFolder.getName());
- } else
- dstFolder = session.getFolder(new URLName(dstURL));
-
- if (clear && dstFolder.exists()) {
- if (!dstFolder.delete(true)) {
- System.out.println("couldn't delete " +
- dstFolder.getFullName());
- return;
- }
- }
- copy(srcFolder, dstFolder);
-
- // Close the respective stores.
- dstFolder.getStore().close();
-
- } catch (MessagingException mex) {
- System.out.println(mex.getMessage());
- mex.printStackTrace();
- } catch (IOException ioex) {
- System.out.println(ioex.getMessage());
- ioex.printStackTrace();
- }
- }
-
- private static void copy(File src, Folder dst)
- throws MessagingException, IOException {
- System.out.println("Populating " + dst.getFullName());
-
- if (!dst.exists()) {
- // Create it.
- int type = holdsMessages(src) ?
- Folder.HOLDS_MESSAGES : Folder.HOLDS_FOLDERS;
- if (!dst.create(type)) {
- System.out.println("couldn't create " + dst.getFullName());
- return;
- }
-
- // Copy over any messages from src to dst
- if (holdsMessages(src))
- copyMessages(src, dst);
- } else {
- System.out.println(dst.getFullName() + " already exists");
- // Copy over any messges from src to dst
- if (force && holdsMessages(src))
- copyMessages(src, dst);
- }
-
- // Copy over subfolders
- if (holdsFolders(src)) {
- String[] sf = src.list();
- for (int i = 0; sf != null && i < sf.length; i++) {
- // skip SCCS directories?
- if (skipSCCS && sf[i].equals("SCCS"))
- continue;
- File f = new File(src, sf[i]);
- if (f.isDirectory())
- copy(f, dst.getFolder(sf[i]));
- }
- }
- }
-
- /**
- * Does this directory hold messages?
- * Return true if there's at least one message.
- */
- private static boolean holdsMessages(File f) {
- File msg = new File(f, "1");
- return msg.exists();
- }
-
- private static boolean holdsFolders(File f) {
- return !holdsMessages(f); // XXX - hack for now
- }
-
- /**
- * Copy message files from the source directory to the
- * destination folder. Message files must be named "1",
- * "2", etc. The first missing number terminates the
- * copy.
- */
- private static void copyMessages(File src, Folder dst)
- throws MessagingException, IOException {
- System.out.println(" Copy from " + src + " to " + dst);
- int msgnum = 1;
- Message[] msgs = new Message[1];
- for (;;) {
- File f = new File(src, String.valueOf(msgnum));
- if (!f.exists()) // break when we find a message missing
- break;
- FileInputStream fis = new FileInputStream(f);
- BufferedInputStream is = new BufferedInputStream(fis);
- is.mark(1024);
- DataInputStream dis = new DataInputStream(is);
- String line = dis.readLine();
- /*
- * If it's in UNIX mbox format, we skip the first line,
- * otherwise we start reading at the beginning.
- */
- if (!line.startsWith("From "))
- is.reset();
- MimeMessage msg = new MimeMessage(session, is);
- fis.close();
- msgs[0] = msg;
- dst.appendMessages(msgs);
- msgnum++;
- }
- System.out.println(" Copied " + (msgnum - 1) + " messages");
- }
-
- private static void printUsage() {
- System.out.println("fpopulate [-D] [-f] [-S] [-c] " +
- "-s source_dir -d dest_url");
- System.out.println("URLs are of the form: " +
- "protocol://username:password@hostname/foldername");
- System.out.println("The destination URL does not need a foldername," +
- " in which case, the source foldername is used");
- }
-}
diff --git a/demo/src/main/java/internal/msgsperweek.java b/demo/src/main/java/internal/msgsperweek.java
deleted file mode 100644
index d3474e461..000000000
--- a/demo/src/main/java/internal/msgsperweek.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.*;
-import java.text.*;
-import java.io.*;
-import jakarta.mail.*;
-import jakarta.mail.search.*;
-import jakarta.mail.internet.*;
-
-/**
- * Program that generates stats about new messages received per week
- * by the javamail@Sun.COM mailing list. It tracks *new* messages only,
- * the rule being that the message has a single addressee:
- * "javamail@Sun.COM". Also searches each message body for the "pop3"
- * string and counts its occurrence.
- *
- * Note that this program operates on the log file directly and thus all
- * access to the log file using this program must be through the same
- * IMAP server so that the flags are handled consistently.
- *
- * @author Max Spivak
- */
-
-public class msgsperweek {
-
- static String protocol = "imap";
- static String host = "anybodys.sfbay";
- static String user = "javamail";
- static String password = "1javamail1";
- static String mbox =
- "/net/anybodys.sfbay/export6/javamail/logs/javamail.log";
- static String url = null;
- static boolean verbose = false;
- static boolean doPop3 = false;
- static Calendar cal = null;
-
- public static void main(String argv[]) {
- int optind;
-
- for (optind = 0; optind < argv.length; optind++) {
- if (argv[optind].equals("-T")) {
- protocol = argv[++optind];
- } else if (argv[optind].equals("-H")) {
- host = argv[++optind];
- } else if (argv[optind].equals("-U")) {
- user = argv[++optind];
- } else if (argv[optind].equals("-P")) {
- password = argv[++optind];
- } else if (argv[optind].equals("-v")) {
- verbose = true;
- } else if (argv[optind].equals("-f")) {
- mbox = argv[++optind];
- } else if (argv[optind].equals("-L")) {
- url = argv[++optind];
- } else if (argv[optind].equals("-p")) {
- doPop3 = true;
- } else if (argv[optind].equals("--")) {
- optind++;
- break;
- } else if (argv[optind].startsWith("-")) {
- System.out.println(
-"Usage: msgperweek [-L url] [-T protocol] [-H host] [-U user] [-P password]\n"+
-"\t[-f mailbox] [-v] [-p]");
- System.exit(1);
- } else {
- break;
- }
- }
-
- System.out.println("msgsperweek: Generating stats, please wait...");
-
- cal = Calendar.getInstance();
-
- try {
- // Get a Properties object
- Properties props = System.getProperties();
-
- // Get a Session object
- Session session = Session.getDefaultInstance(props,
- new TtyAuthenticator());
-
- //if (verbose)
- //session.setDebug(true);
-
- // Get a Store object
- Store store = null;
- if (url != null) {
- URLName urln = new URLName(url);
- store = session.getStore(urln);
- store.connect();
- } else {
- if (protocol != null)
- store = session.getStore(protocol);
- else
- store = session.getStore();
-
- // Connect
- if (host != null || user != null || password != null)
- store.connect(host, user, password);
- else
- store.connect();
- }
-
-
- // Open the Folder
-
- Folder folder = store.getDefaultFolder();
- if (folder == null) {
- System.out.println("No default folder");
- System.exit(1);
- }
-
- folder = folder.getFolder(mbox);
- if (folder == null) {
- System.out.println("Invalid folder");
- System.exit(1);
- }
-
- folder.open(Folder.READ_ONLY);
- int totalMessages = folder.getMessageCount();
-
- if (totalMessages == 0) {
- System.out.println("Empty folder");
- folder.close(false);
- store.close();
- System.exit(1);
- }
-
- if (verbose) {
- int newMessages = folder.getNewMessageCount();
- pv("Total messages = " + totalMessages);
- pv("New messages = " + newMessages);
- pv("-------------------------------");
- }
-
- // Use a suitable FetchProfile
- FetchProfile fp = new FetchProfile();
- fp.add(FetchProfile.Item.ENVELOPE);
-
- SearchTerm term = new RecipientTerm(Message.RecipientType.TO,
- new InternetAddress("javamail@sun.com"));
- Message[] msgs = folder.search(term);
- folder.fetch(msgs, fp);
-
- Hashtable wks = new Hashtable();
- int totalCount = 0;
- BodyTerm pop3Search = new BodyTerm("pop3");
- int pop3Requests = 0;
-
- // go through each msg and count it if it's an incoming msg
- for (int i = 0; i < msgs.length; i++) {
- // make sure we only have a single addressee:
- // javamail@sun.com, which means it's a new message
- // from outside of Sun
- Address[] recs=msgs[i].getRecipients(Message.RecipientType.TO);
- if (recs.length > 1)
- continue;
-
- // get msgs date
- Date d = msgs[i].getSentDate();
- if (d == null)
- d = msgs[i].getReceivedDate();
- cal.setTime(d);
-
- // figure out what week it is
- int week = cal.get(Calendar.WEEK_OF_YEAR);
- int yr = cal.get(Calendar.YEAR);
- String wkInYr = week + " " + yr;
-
- // increment that week's count
- String num = (String)wks.get(wkInYr);
- totalCount++;
- if (num == null)
- wks.put(wkInYr, "1");
- else {
- int count = Integer.parseInt(num);
- count++;
- Integer str = new Integer(count);
- wks.put(wkInYr, str.toString());
- }
-
- // check for pop3 requests
- if (doPop3 && pop3Search.match(msgs[i]))
- pop3Requests++;
- }
-
- // print out the statistics
- int startWk = 40;
- int startYr = 1997;
- Calendar now = Calendar.getInstance();
- now.setTime(new Date());
- cal.set(startYr, 1, 1);
- cal.set(Calendar.WEEK_OF_YEAR, startWk);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
- DateFormat df = new SimpleDateFormat("E MMM dd yyyy");
- int totalWks = 0;
-
- System.out.println("\nNumber of new messages a week sent to javamail@Sun.COM by external JavaMail\nusers. This does not include our answers and follow-up mail.");
- for (;;) {
- if (cal.after(now))
- break;
- else {
- totalWks++;
- String wkInYr = (cal.get(Calendar.WEEK_OF_YEAR)) +
- " " +
- (cal.get(Calendar.YEAR));
- Object o = wks.get(wkInYr);
- if (o != null) {
- String i = (String)o;
- System.out.println(" week of " +
- df.format(cal.getTime()) +
- ": " +
- i + " messages");
- }
-
- // increment to next week
- cal.add(Calendar.WEEK_OF_YEAR, 1);
- }
- }
- System.out.println("------------------");
- System.out.println("Total messages received: " + totalCount);
- System.out.println("Average messages/week: " +
- totalCount/totalWks);
- if (doPop3)
- System.out.println("Total POP3 requests: " + pop3Requests);
- folder.close(false);
- store.close();
- } catch (Exception ex) {
- System.out.println("Oops, got exception! " + ex.getMessage());
- ex.printStackTrace();
- }
- System.exit(1);
- }
-
-
- /**
- * Print verbose.
- */
- static void pv(String s) {
- if (verbose)
- System.out.println(s);
- }
-}
diff --git a/demo/src/main/java/internal/testidle.java b/demo/src/main/java/internal/testidle.java
deleted file mode 100644
index aee234291..000000000
--- a/demo/src/main/java/internal/testidle.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-import jakarta.mail.*;
-import jakarta.mail.event.*;
-import jakarta.mail.internet.*;
-import jakarta.activation.*;
-
-import com.sun.mail.imap.*;
-
-/**
- * Test program for IDLE support in IMAP provider.
- *
- * Run several threads that access the folder's connection
- * while another thread runs the IDLE command. A timer
- * thread checks that each thread is making progress, to
- * detect deadlock.
- *
- * XXX - Should have another thread add messages to the folder
- * to test the new message notification works properly.
- */
-public class testidle {
-
- public static Store store;
- public static Folder folder;
- public static boolean showStructure = false;
- public static boolean saveAttachments = false;
- public static int attnum = 0;
- public static int totalTime;
-
- public static final AtomicBoolean stop = new AtomicBoolean(false);
- public static final AtomicInteger folderProgress = new AtomicInteger();
- public static final AtomicInteger msgProgress = new AtomicInteger();
-
- public static void main(String argv[]) {
- if (argv.length != 5) {
- System.out.println(
- "Usage: testidle