moved imap credentials from MailingList to ImapClient
This commit is contained in:
@@ -13,13 +13,12 @@ import java.util.Properties;
|
||||
public class ImapClient {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ImapClient.class);
|
||||
private final JSONObject config;
|
||||
private boolean stopped = false;
|
||||
private final int port;
|
||||
private final String host, username, password, folderName;
|
||||
private boolean stopped = true;
|
||||
private IMAPFolder inbox;
|
||||
private HashSet<MessageHandler> listeners = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
private class ListeningThread extends Thread {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ListeningThread.class);
|
||||
@@ -41,10 +40,6 @@ public class ImapClient {
|
||||
}
|
||||
|
||||
private void openInbox() throws MessagingException {
|
||||
String host = (String) config.get(Constants.HOST);
|
||||
String username = (String) config.get(Constants.USER);
|
||||
String password = (String) config.get(Constants.PASSWORD);
|
||||
String folderName = (String) config.get(Constants.INBOX);
|
||||
LOG.debug("Connecting and logging in…");
|
||||
Properties props = imapProps();
|
||||
Session session = Session.getInstance(props);
|
||||
@@ -105,15 +100,13 @@ public class ImapClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
public ImapClient(JSONObject config){
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
LOG.debug("Creating ListeningThread…");
|
||||
new ListeningThread().start();
|
||||
LOG.debug("Creating Heartbeat…");
|
||||
new Heartbeat().start();
|
||||
public ImapClient(String host, int port, String username, String password, String folderName) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,4 +114,36 @@ public class ImapClient {
|
||||
listeners.add(messageHandler);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String host(){
|
||||
return host;
|
||||
}
|
||||
|
||||
public String username(){
|
||||
return username;
|
||||
}
|
||||
|
||||
public String password(){
|
||||
return password;
|
||||
}
|
||||
|
||||
public int port(){
|
||||
return port;
|
||||
}
|
||||
|
||||
public String folderName(){
|
||||
return folderName;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
stopped = false;
|
||||
LOG.debug("Creating ListeningThread…");
|
||||
new ListeningThread().start();
|
||||
LOG.debug("Creating Heartbeat…");
|
||||
new Heartbeat().start();
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user