diff options
author | Damian Minkov <damencho@jitsi.org> | 2008-07-15 13:54:02 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2008-07-15 13:54:02 +0000 |
commit | eb6899b736542b4842b231aa573158abc7fe942a (patch) | |
tree | 137b146b4f125f7cd50c52214ef750387a173702 | |
parent | b9b01108c33e30acc87e30eb37939086028ad5f5 (diff) | |
download | jitsi-eb6899b736542b4842b231aa573158abc7fe942a.zip jitsi-eb6899b736542b4842b231aa573158abc7fe942a.tar.gz jitsi-eb6899b736542b4842b231aa573158abc7fe942a.tar.bz2 |
Remove configuration defaults now if values are missing in configuration service they are get from resource settings , but are always saved through configuration service.
8 files changed, 169 insertions, 99 deletions
diff --git a/resources/config/configuration.properties b/resources/config/configuration.properties deleted file mode 100644 index 2afe62a..0000000 --- a/resources/config/configuration.properties +++ /dev/null @@ -1,7 +0,0 @@ -net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled=true -net.java.sip.communicator.impl.gui.autoPopupNewMessage=false -net.java.sip.communicator.impl.gui.sendMessageCommand=Enter -net.java.sip.communicator.impl.gui.sendTypingNotifications=true -net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled=true -net.java.sip.communicator.impl.gui.isMessageHistoryShown=true -net.java.sip.communicator.impl.gui.messageHistorySize=10 diff --git a/resources/config/defaults.properties b/resources/config/defaults.properties index 8d21ef4..4c6f364 100644 --- a/resources/config/defaults.properties +++ b/resources/config/defaults.properties @@ -1,3 +1,11 @@ +net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled=true +net.java.sip.communicator.impl.gui.autoPopupNewMessage=false +net.java.sip.communicator.impl.gui.sendMessageCommand=Enter +net.java.sip.communicator.impl.gui.sendTypingNotifications=true +net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled=true +net.java.sip.communicator.impl.gui.isMessageHistoryShown=true +net.java.sip.communicator.impl.gui.messageHistorySize=10 + applicationName=SIP Communicator applicationWebSite=http://sip-communicator.org fontName=Verdana diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index 217c6d4..f96b11a 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -63,18 +63,6 @@ public class ConfigurationServiceImpl = "net.java.sip.communicator.SYS_PROPS_FILE_NAME"; /** - * Name of the bundle where we will search for color resources. - */ - private static final String DEFAULT_PROPERTIES_BUNDLE_NAME - = "resources.config.configuration"; - - /** - * Bundle which handle access to localized resources. - */ - private static final ResourceBundle DEFAULT_PROPERTIES_BUNDLE - = ResourceBundle.getBundle(DEFAULT_PROPERTIES_BUNDLE_NAME); - - /** * A reference to the currently used configuration file. */ private File configurationFile = null; @@ -489,9 +477,6 @@ public class ConfigurationServiceImpl fileExtractedProperties = loadConfiguration(getConfigurationFile()); this.properties.putAll(fileExtractedProperties); - - Map defaultProperties = loadDefaultProperties(); - this.properties.putAll(defaultProperties); } /** @@ -1237,33 +1222,4 @@ public class ConfigurationServiceImpl } } } - - /** - * Loads default application properties from the application.properties file. - * The application.properties file contains initial application - * configurations, which should also be available through the configuration - * service. - * - * @return a set of all default application properties from the - * application.properties file - */ - Map loadDefaultProperties() - { - Map defaultProps = new Hashtable(); - - Enumeration keys = DEFAULT_PROPERTIES_BUNDLE.getKeys(); - - while (keys.hasMoreElements()) - { - String key = (String) keys.nextElement(); - String value = DEFAULT_PROPERTIES_BUNDLE.getString(key); - - if (!properties.containsKey(key)) - { - defaultProps.put(key, value); - } - } - - return defaultProps; - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 564b783..ab48b5a 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -107,9 +107,14 @@ public class ChatWritePanel ConfigurationService configService = GuiActivator.getConfigurationService(); - String messageCommand = - configService - .getString("net.java.sip.communicator.impl.gui.sendMessageCommand"); + String messageCommandProperty = + "net.java.sip.communicator.impl.gui.sendMessageCommand"; + String messageCommand = configService.getString(messageCommandProperty); + + if(messageCommand == null) + messageCommand = + GuiActivator.getResources(). + getSettingsString(messageCommandProperty); if (messageCommand == null || messageCommand.equalsIgnoreCase("enter")) this.changeSendCommand(true); diff --git a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java index b9cb574..21444ae 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java @@ -60,24 +60,35 @@ public class ConfigurationManager new ConfigurationChangeListener()); // Load the "auPopupNewMessage" property. - String autoPopup = configService.getString( - "net.java.sip.communicator.impl.gui.autoPopupNewMessage"); + String autoPopupProperty = + "net.java.sip.communicator.impl.gui.autoPopupNewMessage"; + + String autoPopup = configService.getString(autoPopupProperty); + + if(autoPopup == null) + autoPopup = GuiActivator.getResources(). + getSettingsString(autoPopupProperty); if(autoPopup != null && autoPopup.equalsIgnoreCase("yes")) autoPopupNewMessage = true; // Load the "sendMessageCommand" property. - String messageCommand = configService.getString( - "net.java.sip.communicator.impl.gui.sendMessageCommand"); + String messageCommandProperty = + "net.java.sip.communicator.impl.gui.sendMessageCommand"; + String messageCommand = configService.getString(messageCommandProperty); + + if(messageCommand == null) + messageCommand = + GuiActivator.getResources().getSettingsString(messageCommandProperty); - if(messageCommand == null || messageCommand != "") + if(messageCommand == null || messageCommand.length() == 0) sendMessageCommand = messageCommand; // Load the showCallPanel property. String callPanelShown = configService.getString( "net.java.sip.communicator.impl.gui.showCallPanel"); - if(callPanelShown != null && callPanelShown != "") + if(callPanelShown != null && callPanelShown.length() > 0) { isCallPanelShown = new Boolean(callPanelShown).booleanValue(); } @@ -86,7 +97,7 @@ public class ConfigurationManager String showOffline = configService.getString( "net.java.sip.communicator.impl.gui.showOffline"); - if(showOffline != null && showOffline != "") + if(showOffline != null && showOffline.length() > 0) { isShowOffline = new Boolean(showOffline).booleanValue(); } @@ -95,7 +106,7 @@ public class ConfigurationManager String isVisible = configService.getString( "net.java.sip.communicator.impl.systray.showApplication"); - if(isVisible != null && isVisible != "") + if(isVisible != null && isVisible.length() > 0) { isApplicationVisible = new Boolean(isVisible).booleanValue(); } @@ -104,17 +115,24 @@ public class ConfigurationManager String quitWarningShown = configService.getString( "net.java.sip.communicator.impl.gui.quitWarningShown"); - if(quitWarningShown != null && quitWarningShown != "") + if(quitWarningShown != null && quitWarningShown.length() > 0) { isQuitWarningShown = new Boolean(quitWarningShown).booleanValue(); } // Load the "sendTypingNotifications" property. - String isSendTypingNotif = configService.getString( - "net.java.sip.communicator.impl.gui.sendTypingNotifications"); + String isSendTypingNotifProperty = + "net.java.sip.communicator.impl.gui.sendTypingNotifications"; + String isSendTypingNotif = + configService.getString(isSendTypingNotifProperty); - if(isSendTypingNotif != null && isSendTypingNotif != "") + if(isSendTypingNotif == null) + isSendTypingNotif = + GuiActivator.getResources(). + getSettingsString(isSendTypingNotifProperty); + + if(isSendTypingNotif != null && isSendTypingNotif.length() > 0) { isSendTypingNotifications = new Boolean(isSendTypingNotif).booleanValue(); @@ -126,7 +144,7 @@ public class ConfigurationManager "net.java.sip.communicator.impl.gui.isMoveContactConfirmationRequested"); if(isMoveContactConfirmationRequestedString != null - && isMoveContactConfirmationRequestedString != "") + && isMoveContactConfirmationRequestedString.length() > 0) { isMoveContactConfirmationRequested = new Boolean(isMoveContactConfirmationRequestedString) @@ -134,12 +152,19 @@ public class ConfigurationManager } // Load the "isMultiChatWindowEnabled" property. + String isMultiChatWindowEnabledStringProperty + = "net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled"; + String isMultiChatWindowEnabledString - = configService.getString( - "net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled"); + = configService.getString(isMultiChatWindowEnabledStringProperty); + + if(isMultiChatWindowEnabledString == null) + isMultiChatWindowEnabledString = + GuiActivator.getResources(). + getSettingsString(isMultiChatWindowEnabledStringProperty); if(isMultiChatWindowEnabledString != null - && isMultiChatWindowEnabledString != "") + && isMultiChatWindowEnabledString.length() > 0) { isMultiChatWindowEnabled = new Boolean(isMultiChatWindowEnabledString) @@ -152,7 +177,7 @@ public class ConfigurationManager "net.java.sip.communicator.impl.gui.isHistoryLoggingEnabled"); if(isHistoryLoggingEnabledString != null - && isHistoryLoggingEnabledString != "") + && isHistoryLoggingEnabledString.length() > 0) { isHistoryLoggingEnabled = new Boolean(isHistoryLoggingEnabledString) @@ -160,12 +185,19 @@ public class ConfigurationManager } // Load the "isHistoryShown" property. + String isHistoryShownStringProperty = + "net.java.sip.communicator.impl.gui.isMessageHistoryShown"; + String isHistoryShownString - = configService.getString( - "net.java.sip.communicator.impl.gui.isMessageHistoryShown"); + = configService.getString(isHistoryShownStringProperty); + + if(isHistoryShownString == null) + isHistoryShownString = + GuiActivator.getResources(). + getSettingsString(isHistoryShownStringProperty); if(isHistoryShownString != null - && isHistoryShownString != "") + && isHistoryShownString.length() > 0) { isHistoryShown = new Boolean(isHistoryShownString) @@ -173,12 +205,18 @@ public class ConfigurationManager } // Load the "chatHistorySize" property. + String chatHistorySizeStringProperty = + "net.java.sip.communicator.impl.gui.messageHistorySize"; String chatHistorySizeString - = configService.getString( - "net.java.sip.communicator.impl.gui.messageHistorySize"); + = configService.getString(chatHistorySizeStringProperty); + + if(chatHistorySizeString == null) + chatHistorySizeString = + GuiActivator.getResources(). + getSettingsString(chatHistorySizeStringProperty); if(chatHistorySizeString != null - && chatHistorySizeString != "") + && chatHistorySizeString.length() > 0) { chatHistorySize = new Integer(chatHistorySizeString) diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryActivator.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryActivator.java index f239c4c..933481d 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryActivator.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryActivator.java @@ -25,7 +25,7 @@ public class MessageHistoryActivator private MessageHistoryServiceImpl msgHistoryService = null; - private static BundleContext bundleContext; + static BundleContext bundleContext; /** * Initialize and start message history diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index 072951a..2dac934 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -14,6 +14,7 @@ import org.osgi.framework.*; import net.java.sip.communicator.impl.msghistory.MessageHistoryActivator.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.event.*; +import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.history.event.*; @@ -70,6 +71,8 @@ public class MessageHistoryServiceImpl private ConfigurationService configService; private MessageHistoryPropertyChangeListener msgHistoryPropListener; + + private static ResourceManagementService resourcesService; public HistoryService getHistoryService() { @@ -620,12 +623,19 @@ public class MessageHistoryServiceImpl // Check if the message history is enabled in the configuration // service, and if not do not register the service. + String isMessageHistoryEnabledPropertyString = + "net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled"; String isMessageHistoryEnabledString = configService.getString( - "net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled"); + isMessageHistoryEnabledPropertyString); + + if(isMessageHistoryEnabledString == null) + isMessageHistoryEnabledString = + getResources(). + getSettingsString(isMessageHistoryEnabledPropertyString); // If the property doesn't exist we stop here. if (isMessageHistoryEnabledString == null - || isMessageHistoryEnabledString == "") + || isMessageHistoryEnabledString.length() == 0) return; boolean isMessageHistoryEnabled @@ -1651,6 +1661,24 @@ public class MessageHistoryServiceImpl return resultAsList.subList(startIndex, resultAsList.size()); } + + public static ResourceManagementService getResources() + { + if (resourcesService == null) + { + ServiceReference serviceReference = MessageHistoryActivator.bundleContext + .getServiceReference(ResourceManagementService.class.getName()); + + if(serviceReference == null) + return null; + + resourcesService = (ResourceManagementService) + MessageHistoryActivator.bundleContext + .getService(serviceReference); + } + + return resourcesService; + } /** * A wrapper around HistorySearchProgressListener diff --git a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java index 91af800..a531ee3 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java @@ -40,38 +40,61 @@ public class ConfigurationManager public static void loadGuiConfigurations() { // Load the "auPopupNewMessage" property. - String autoPopup = configService.getString( - "net.java.sip.communicator.impl.gui.autoPopupNewMessage"); + String autoPopupProperty = + "net.java.sip.communicator.impl.gui.autoPopupNewMessage"; + + String autoPopup = configService.getString(autoPopupProperty); + if(autoPopup == null) + autoPopup = Resources.getApplicationString(autoPopupProperty); + if(autoPopup != null && autoPopup.equalsIgnoreCase("yes")) autoPopupNewMessage = true; // Load the "sendMessageCommand" property. - String messageCommand = configService.getString( - "net.java.sip.communicator.impl.gui.sendMessageCommand"); + String messageCommandProperty = + "net.java.sip.communicator.impl.gui.sendMessageCommand"; + String messageCommand = configService.getString(messageCommandProperty); + + if(messageCommand == null) + messageCommand = + Resources.getApplicationString(messageCommandProperty); - if(messageCommand != null && messageCommand != "") + if(messageCommand != null && messageCommand.length() > 0) { sendMessageCommand = messageCommand; } // Load the "sendTypingNotifications" property. - String isSendTypingNotif = configService.getString( - "net.java.sip.communicator.impl.gui.sendTypingNotifications"); + String isSendTypingNotifProperty = + "net.java.sip.communicator.impl.gui.sendTypingNotifications"; + String isSendTypingNotif = + configService.getString(isSendTypingNotifProperty); + + if(isSendTypingNotif == null) + isSendTypingNotif = + Resources.getApplicationString(isSendTypingNotifProperty); - if(isSendTypingNotif != null && isSendTypingNotif != "") + if(isSendTypingNotif != null && isSendTypingNotif.length() > 0) { isSendTypingNotifications = new Boolean(isSendTypingNotif).booleanValue(); } // Load the "isMultiChatWindowEnabled" property. + String isMultiChatWindowEnabledStringProperty + = "net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled"; + String isMultiChatWindowEnabledString - = configService.getString( - "net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled"); + = configService.getString(isMultiChatWindowEnabledStringProperty); + + if(isMultiChatWindowEnabledString == null) + isMultiChatWindowEnabledString = + Resources. + getApplicationString(isMultiChatWindowEnabledStringProperty); if(isMultiChatWindowEnabledString != null - && isMultiChatWindowEnabledString != "") + && isMultiChatWindowEnabledString.length() > 0) { isMultiChatWindowEnabled = new Boolean(isMultiChatWindowEnabledString) @@ -79,12 +102,20 @@ public class ConfigurationManager } // Load the "isHistoryLoggingEnabled" property. + String isHistoryLoggingEnabledPropertyString = + "net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled"; + String isHistoryLoggingEnabledString = configService.getString( - "net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled"); + isHistoryLoggingEnabledPropertyString); + + if(isHistoryLoggingEnabledString == null) + isHistoryLoggingEnabledString = + Resources. + getApplicationString(isHistoryLoggingEnabledPropertyString); if(isHistoryLoggingEnabledString != null - && isHistoryLoggingEnabledString != "") + && isHistoryLoggingEnabledString.length() > 0) { isHistoryLoggingEnabled = new Boolean(isHistoryLoggingEnabledString) @@ -92,12 +123,18 @@ public class ConfigurationManager } // Load the "isHistoryShown" property. + String isHistoryShownStringProperty = + "net.java.sip.communicator.impl.gui.isMessageHistoryShown"; + String isHistoryShownString - = configService.getString( - "net.java.sip.communicator.impl.gui.isMessageHistoryShown"); + = configService.getString(isHistoryShownStringProperty); + + if(isHistoryShownString == null) + isHistoryShownString = + Resources.getApplicationString(isHistoryShownStringProperty); if(isHistoryShownString != null - && isHistoryShownString != "") + && isHistoryShownString.length() > 0) { isHistoryShown = new Boolean(isHistoryShownString) @@ -105,12 +142,17 @@ public class ConfigurationManager } // Load the "chatHistorySize" property. + String chatHistorySizeStringProperty = + "net.java.sip.communicator.impl.gui.messageHistorySize"; String chatHistorySizeString - = configService.getString( - "net.java.sip.communicator.impl.gui.messageHistorySize"); + = configService.getString(chatHistorySizeStringProperty); + + if(chatHistorySizeString == null) + chatHistorySizeString = + Resources.getApplicationString(chatHistorySizeStringProperty); if(chatHistorySizeString != null - && chatHistorySizeString != "") + && chatHistorySizeString.length() > 0) { chatHistorySize = new Integer(chatHistorySizeString) |