use of games.strategy.engine.pbem.GmailEmailSender in project triplea by triplea-game.
the class PbemSetupPanel method loadEmailSender.
/**
* Configures the list of Email senders. If the game was saved we use this email sender.
* Since passwords are not stored in save games, the LocalBeanCache is checked
*
* @param data
* the game data
*/
private void loadEmailSender(final GameData data) {
// The list of email, either loaded from cache or created
final List<IEmailSender> emailSenders = new ArrayList<>();
emailSenders.add(useCacheIfAvailable(new NullEmailSender()));
emailSenders.add(useCacheIfAvailable(new GmailEmailSender()));
emailSenders.add(useCacheIfAvailable(new HotmailEmailSender()));
emailSenders.add(useCacheIfAvailable(new GenericEmailSender()));
emailSenderEditor.setBeans(emailSenders);
// now get the sender from the save game, update it with credentials from the cache, and set it
final IEmailSender sender = (IEmailSender) data.getProperties().get(PBEMMessagePoster.EMAIL_SENDER_PROP_NAME);
if (sender != null) {
final IEmailSender cached = (IEmailSender) LocalBeanCache.INSTANCE.getSerializable(sender.getClass().getCanonicalName());
if (cached != null) {
sender.setUserName(cached.getUserName());
sender.setPassword(cached.getPassword());
sender.setCredentialsSaved(cached.areCredentialsSaved());
}
emailSenderEditor.setSelectedBean(sender);
}
}
Aggregations