diff --git a/src/java/davmail/Settings.java b/src/java/davmail/Settings.java index b69bd5d2..f924dc13 100644 --- a/src/java/davmail/Settings.java +++ b/src/java/davmail/Settings.java @@ -144,6 +144,7 @@ public final class Settings { SETTINGS.put("davmail.bindAddress", ""); SETTINGS.put("davmail.useSystemProxies", Boolean.TRUE.toString()); SETTINGS.put("davmail.enableProxy", Boolean.FALSE.toString()); + SETTINGS.put("davmail.enableEws", "auto"); SETTINGS.put("davmail.proxyHost", ""); SETTINGS.put("davmail.proxyPort", ""); SETTINGS.put("davmail.proxyUser", ""); @@ -318,6 +319,22 @@ public final class Settings { return value; } + /** + * Get property value or default. + * + * @param property property name + * @param defaultValue default property value + * @return property value + */ + public static synchronized String getProperty(String property, String defaultValue) { + String value = SETTINGS.getProperty(property); + if (value == null) { + value = defaultValue; + } + return value; + } + + /** * Get a property value as char[]. * diff --git a/src/java/davmail/exchange/ExchangeSessionFactory.java b/src/java/davmail/exchange/ExchangeSessionFactory.java index acd06911..df9f9a44 100644 --- a/src/java/davmail/exchange/ExchangeSessionFactory.java +++ b/src/java/davmail/exchange/ExchangeSessionFactory.java @@ -26,6 +26,7 @@ import davmail.exception.WebdavNotAvailableException; import davmail.exchange.dav.DavExchangeSession; import davmail.exchange.ews.EwsExchangeSession; import davmail.http.DavGatewayHttpClientFacade; +import davmail.ui.tray.DavGatewayTray; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; @@ -138,18 +139,19 @@ public final class ExchangeSessionFactory { } if (session == null) { - if (Settings.getBooleanProperty("davmail.enableEws")) { + String enableEws = Settings.getProperty("davmail.enableEws", "auto"); + if ("true".equals(enableEws)) { session = new EwsExchangeSession(poolKey.url, poolKey.userName, poolKey.password); } else { try { session = new DavExchangeSession(poolKey.url, poolKey.userName, poolKey.password); } catch (WebdavNotAvailableException e) { - ExchangeSession.LOGGER.debug(e.getMessage() + ", retry with EWS"); - session = new EwsExchangeSession(poolKey.url, poolKey.userName, poolKey.password); - // success, enable EWS flag - ExchangeSession.LOGGER.debug("EWS found, changing davmail.enableEws setting"); - Settings.setProperty("davmail.enableEws", "true"); - Settings.save(); + if ("auto".equals(enableEws)) { + ExchangeSession.LOGGER.debug(e.getMessage() + ", retry with EWS"); + session = new EwsExchangeSession(poolKey.url, poolKey.userName, poolKey.password); + } else { + DavGatewayTray.warn(new BundleMessage("LOG_WEBDAV_NOT_AVAILABLE")); + } } } ExchangeSession.LOGGER.debug("Created new session: " + session); diff --git a/src/java/davmail/ui/SettingsFrame.java b/src/java/davmail/ui/SettingsFrame.java index 1d09f3dc..479420b9 100644 --- a/src/java/davmail/ui/SettingsFrame.java +++ b/src/java/davmail/ui/SettingsFrame.java @@ -98,7 +98,7 @@ public class SettingsFrame extends JFrame { JCheckBox showStartupBannerCheckBox; JCheckBox disableGuiNotificationsCheckBox; JCheckBox imapAutoExpungeCheckBox; - JCheckBox enableEwsCheckBox; + JComboBox enableEwsComboBox; JCheckBox smtpSaveInSentCheckBox; protected void addSettingComponent(JPanel panel, String label, JComponent component) { @@ -392,12 +392,26 @@ public class SettingsFrame extends JFrame { return networkSettingsPanel; } + protected static final String WEBDAV = "WebDav"; + protected static final String EWS = "EWS"; + protected static final String AUTO = "Auto"; + + protected void setEwsModeSelectedItem(String ewsMode) { + if ("true".equals(ewsMode)) { + enableEwsComboBox.setSelectedItem(EWS); + } else if ("false".equals(ewsMode)) { + enableEwsComboBox.setSelectedItem(WEBDAV); + } else { + enableEwsComboBox.setSelectedItem(AUTO); + } + } + protected JPanel getOtherSettingsPanel() { JPanel otherSettingsPanel = new JPanel(new GridLayout(10, 2)); otherSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_OTHER"))); - enableEwsCheckBox = new JCheckBox(); - enableEwsCheckBox.setSelected(Settings.getBooleanProperty("davmail.enableEws", false)); + enableEwsComboBox = new JComboBox(new String[]{WEBDAV, EWS, AUTO}); + setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto")); caldavEditNotificationsField = new JCheckBox(); caldavEditNotificationsField.setSelected(Settings.getBooleanProperty("davmail.caldavEditNotifications")); caldavAlarmSoundField = new JTextField(Settings.getProperty("davmail.caldavAlarmSound"), 15); @@ -415,7 +429,7 @@ public class SettingsFrame extends JFrame { disableUpdateCheck = new JCheckBox(); disableUpdateCheck.setSelected(Settings.getBooleanProperty("davmail.disableUpdateCheck")); - addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_ENABLE_EWS"), enableEwsCheckBox, + addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_ENABLE_EWS"), enableEwsComboBox, BundleMessage.format("UI_ENABLE_EWS_HELP")); addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_CALDAV_EDIT_NOTIFICATIONS"), caldavEditNotificationsField, BundleMessage.format("UI_CALDAV_EDIT_NOTIFICATIONS_HELP")); @@ -549,7 +563,7 @@ public class SettingsFrame extends JFrame { showStartupBannerCheckBox.setSelected(Settings.getBooleanProperty("davmail.showStartupBanner", true)); disableGuiNotificationsCheckBox.setSelected(Settings.getBooleanProperty("davmail.disableGuiNotifications", false)); imapAutoExpungeCheckBox.setSelected(Settings.getBooleanProperty("davmail.imapAutoExpunge", true)); - enableEwsCheckBox.setSelected(Settings.getBooleanProperty("davmail.enableEws", false)); + setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto")); smtpSaveInSentCheckBox.setSelected(Settings.getBooleanProperty("davmail.smtpSaveInSent", true)); keystoreTypeCombo.setSelectedItem(Settings.getProperty("davmail.ssl.keystoreType")); @@ -692,7 +706,16 @@ public class SettingsFrame extends JFrame { Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected())); Settings.setProperty("davmail.disableGuiNotifications", String.valueOf(disableGuiNotificationsCheckBox.isSelected())); Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected())); - Settings.setProperty("davmail.enableEws", String.valueOf(enableEwsCheckBox.isSelected())); + String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem(); + String enableEws; + if (EWS.equals(selectedEwsMode)) { + enableEws = "true"; + } else if (WEBDAV.equals(selectedEwsMode)) { + enableEws = "false"; + } else { + enableEws = "auto"; + } + Settings.setProperty("davmail.enableEws", enableEws); Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected())); Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem()); diff --git a/src/java/davmailmessages.properties b/src/java/davmailmessages.properties index 160f2829..5123108a 100644 --- a/src/java/davmailmessages.properties +++ b/src/java/davmailmessages.properties @@ -133,6 +133,7 @@ LOG_UNSUPPORTED_REQUEST=Unsupported request: {0} LOG_INVALID_TIMEZONE=Invalid timezone: {0} LOG_ACCESS_FORBIDDEN=Access to {0} forbidden: {1} LOG_DOWNLOAD_PROGRESS=Downloaded {0} KBytes from {1} +LOG_WEBDAV_NOT_AVAILABLE=WebDav not available, retry with EWS mode UI_ABOUT=About... UI_ABOUT_DAVMAIL=About DavMail Gateway UI_ABOUT_DAVMAIL_AUTHOR=DavMail Gateway
By Mickaël Guessant

@@ -266,8 +267,8 @@ NEEDS-ACTION= ACCEPTED=Accepted: TENTATIVE=Tentative: DECLINED=Declined: -UI_ENABLE_EWS=Enable EWS -UI_ENABLE_EWS_HELP=Enable EWS mode on Exchange 2010 or Exchange 2007 with Webdav disabled +UI_ENABLE_EWS=Exchange Protocol +UI_ENABLE_EWS_HELP=Choose EWS on Exchange 2010 or Exchange 2007 with Webdav disabled UI_CALDAV_NOTIFICATION=DavMail: Caldav scheduling notification UI_BUTTON_SEND=Send UI_TO=To: diff --git a/src/java/davmailmessages_fr.properties b/src/java/davmailmessages_fr.properties index c522b49a..5106bea3 100644 --- a/src/java/davmailmessages_fr.properties +++ b/src/java/davmailmessages_fr.properties @@ -123,6 +123,7 @@ LOG_UNABLE_TO_SET_SYSTEM_LOOK_AND_FEEL=Impossible de d LOG_UNABLE_TO_STORE_SETTINGS=Impossible d''enregistrer la configuration LOG_UNSUPPORTED_REQUEST=Requête non supportée : {0} LOG_DOWNLOAD_PROGRESS={0} KOctets téléchargés de {1} +LOG_WEBDAV_NOT_AVAILABLE=WebDav non disponible, réessayer en activant EWS UI_ABOUT=A propos... UI_ABOUT_DAVMAIL=A propos de la Passerelle DavMail UI_ABOUT_DAVMAIL_AUTHOR=Passerelle DavMail
Par Mickaël Guessant

@@ -253,7 +254,7 @@ EXCEPTION_INVALID_PARAMETER=Param UI_USE_SYSTEM_PROXIES=Utiliser la configuration système : UI_SHOW_STARTUP_BANNER=Notification au lancement : UI_SHOW_STARTUP_BANNER_HELP=Afficher ou non la fenêtre de notification au démarrage -UI_DISABLE_GUI_NOTIFICATIONS=Désactiver notifications graphiques +UI_DISABLE_GUI_NOTIFICATIONS=Désactiver notifications graphiques : UI_DISABLE_GUI_NOTIFICATIONS_HELP=Supprimer toutes les notifications graphiques LOG_READ_CLIENT_AUTH_LOGIN=< AUTH LOGIN ******** UI_IMAP_IDLE_DELAY=Délai de surveillance dossier (IMAP) : @@ -266,8 +267,8 @@ UNKNOWN_ATTRIBUTE=Attribut inconnu: {0} ACCEPTED=Accepté : TENTATIVE=Provisoire : DECLINED=Refusé : -UI_ENABLE_EWS=Activer EWS : -UI_ENABLE_EWS_HELP=Activer le mode EWS sur Exchange 2010 ou Exchange 2007 sans support Webdav +UI_ENABLE_EWS=Protocole Exchange : +UI_ENABLE_EWS_HELP=Activer EWS sur Exchange 2010 ou Exchange 2007 sans support Webdav UI_CALDAV_NOTIFICATION=DavMail : Notification Caldav UI_BUTTON_SEND=Envoyer UI_SUBJECT=Sujet :