use of i2p.bote.service.EmailChecker in project i2p.i2p-bote by i2p.
the class I2PBote method initializeServices.
/**
* Initializes daemon threads, doesn't start them yet.
*/
private void initializeServices() {
I2PPacketDispatcher dispatcher = new I2PPacketDispatcher();
i2pSession.addMuxedSessionListener(dispatcher, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
backgroundThreads.add(passwordCache);
I2PSendQueue sendQueue = new I2PSendQueue(i2pSession, dispatcher);
backgroundThreads.add(sendQueue);
// reads packets stored in the relayPacketFolder and sends them
RelayPacketSender relayPacketSender = new RelayPacketSender(sendQueue, relayPacketFolder, configuration);
backgroundThreads.add(relayPacketSender);
I2PAppThread seedless = null;
try {
Class<? extends I2PAppThread> clazz = Class.forName("i2p.bote.service.seedless.SeedlessInitializer").asSubclass(I2PAppThread.class);
Constructor<? extends I2PAppThread> ctor = clazz.getDeclaredConstructor(I2PSocketManager.class);
seedless = ctor.newInstance(socketManager);
backgroundThreads.add(seedless);
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
dht = new KademliaDHT(sendQueue, dispatcher, configuration.getDhtPeerFile(), (DhtPeerSource) seedless);
backgroundThreads.add(dht);
dht.setStorageHandler(EncryptedEmailPacket.class, emailDhtStorageFolder);
dht.setStorageHandler(IndexPacket.class, indexPacketDhtStorageFolder);
dht.setStorageHandler(Contact.class, directoryDhtFolder);
peerManager = new RelayPeerManager(sendQueue, getLocalDestination(), configuration.getRelayPeerFile());
backgroundThreads.add(peerManager);
dispatcher.addPacketListener(emailDhtStorageFolder);
dispatcher.addPacketListener(indexPacketDhtStorageFolder);
dispatcher.addPacketListener(new RelayPacketHandler(relayPacketFolder, dht, sendQueue, i2pSession));
dispatcher.addPacketListener(peerManager);
dispatcher.addPacketListener(relayPacketSender);
ExpirationThread expirationThread = new ExpirationThread();
expirationThread.addExpirationListener(emailDhtStorageFolder);
expirationThread.addExpirationListener(indexPacketDhtStorageFolder);
expirationThread.addExpirationListener(relayPacketSender);
backgroundThreads.add(expirationThread);
outboxProcessor = new OutboxProcessor(dht, outbox, peerManager, relayPacketFolder, identities, configuration, this);
outboxProcessor.addOutboxListener(new OutboxListener() {
/**
* Moves sent emails to the "sent" folder
*/
@Override
public void emailSent(Email email) {
try {
outbox.setNew(email, false);
log.debug("Moving email [" + email + "] to the \"sent\" folder.");
outbox.move(email, sentFolder);
} catch (Exception e) {
log.error("Cannot move email from outbox to sent folder: " + email, e);
}
}
});
backgroundThreads.add(outboxProcessor);
emailChecker = new EmailChecker(identities, configuration, incompleteEmailFolder, emailDhtStorageFolder, indexPacketDhtStorageFolder, this, sendQueue, dht, peerManager);
backgroundThreads.add(emailChecker);
deliveryChecker = new DeliveryChecker(dht, sentFolder, configuration, this);
backgroundThreads.add(deliveryChecker);
}
Aggregations