2006-12-12 18:57:24 -05:00
|
|
|
|
package davmail;
|
|
|
|
|
|
|
|
|
|
import davmail.pop.PopServer;
|
|
|
|
|
import davmail.smtp.SmtpServer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DavGateway main class
|
|
|
|
|
*/
|
|
|
|
|
public class DavGateway {
|
2006-12-14 10:14:18 -05:00
|
|
|
|
protected static SmtpServer smtpServer;
|
|
|
|
|
protected static PopServer popServer;
|
2006-12-12 18:57:24 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Start the gateway, listen on sp<EFBFBD>cified smtp and pop3 ports
|
2007-03-14 07:55:37 -04:00
|
|
|
|
* @param args command line parameter config file path
|
2006-12-12 18:57:24 -05:00
|
|
|
|
*/
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
if (args.length >= 1) {
|
2006-12-15 11:44:31 -05:00
|
|
|
|
Settings.setConfigFilePath(args[0]);
|
2006-12-14 10:14:18 -05:00
|
|
|
|
}
|
2006-12-15 11:44:31 -05:00
|
|
|
|
|
2006-12-14 10:14:18 -05:00
|
|
|
|
Settings.load();
|
|
|
|
|
DavGatewayTray.init();
|
|
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void start() {
|
|
|
|
|
// first stop existing servers
|
|
|
|
|
if (smtpServer != null) {
|
|
|
|
|
smtpServer.close();
|
|
|
|
|
try {
|
|
|
|
|
smtpServer.join();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (popServer != null) {
|
|
|
|
|
popServer.close();
|
2006-12-12 18:57:24 -05:00
|
|
|
|
try {
|
2006-12-14 10:14:18 -05:00
|
|
|
|
popServer.join();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
2006-12-12 18:57:24 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-12-14 10:14:18 -05:00
|
|
|
|
int smtpPort = Settings.getIntProperty("davmail.smtpPort");
|
|
|
|
|
if (smtpPort == 0) {
|
|
|
|
|
smtpPort = SmtpServer.DEFAULT_PORT;
|
|
|
|
|
}
|
|
|
|
|
int popPort = Settings.getIntProperty("davmail.popPort");
|
|
|
|
|
if (popPort == 0) {
|
|
|
|
|
popPort = PopServer.DEFAULT_PORT;
|
|
|
|
|
}
|
|
|
|
|
smtpServer = new SmtpServer(smtpPort);
|
|
|
|
|
popServer = new PopServer(popPort);
|
|
|
|
|
smtpServer.start();
|
|
|
|
|
popServer.start();
|
|
|
|
|
|
|
|
|
|
DavGatewayTray.info("DavMail gateway listening on SMTP port " + smtpPort +
|
|
|
|
|
" and POP port " + popPort);
|
|
|
|
|
|
2006-12-12 18:57:24 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|