Remove configuration defaults now if values are missing in configuration service they are get from resource settings , but are always saved through configuration service.

cusax-fix
Damian Minkov 18 years ago
parent b9b01108c3
commit eb6899b736

@ -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

@ -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

@ -62,18 +62,6 @@ public class ConfigurationServiceImpl
private static final String SYS_PROPS_FILE_NAME_PROPERTY
= "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.
*/
@ -489,9 +477,6 @@ public void reloadConfiguration()
fileExtractedProperties =
loadConfiguration(getConfigurationFile());
this.properties.putAll(fileExtractedProperties);
Map defaultProperties = loadDefaultProperties();
this.properties.putAll(defaultProperties);
}
/**
@ -1237,33 +1222,4 @@ public void preloadSystemPropertyFiles()
}
}
}
/**
* 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;
}
}

@ -107,9 +107,14 @@ public ChatWritePanel(ChatPanel panel)
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);

@ -60,24 +60,35 @@ public static void loadGuiConfigurations()
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 static void loadGuiConfigurations()
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 static void loadGuiConfigurations()
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 static void loadGuiConfigurations()
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 static void loadGuiConfigurations()
"net.java.sip.communicator.impl.gui.isMoveContactConfirmationRequested");
if(isMoveContactConfirmationRequestedString != null
&& isMoveContactConfirmationRequestedString != "")
&& isMoveContactConfirmationRequestedString.length() > 0)
{
isMoveContactConfirmationRequested
= new Boolean(isMoveContactConfirmationRequestedString)
@ -134,12 +152,19 @@ public static void loadGuiConfigurations()
}
// 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 static void loadGuiConfigurations()
"net.java.sip.communicator.impl.gui.isHistoryLoggingEnabled");
if(isHistoryLoggingEnabledString != null
&& isHistoryLoggingEnabledString != "")
&& isHistoryLoggingEnabledString.length() > 0)
{
isHistoryLoggingEnabled
= new Boolean(isHistoryLoggingEnabledString)
@ -160,12 +185,19 @@ public static void loadGuiConfigurations()
}
// 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 static void loadGuiConfigurations()
}
// 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)

@ -25,7 +25,7 @@ public class MessageHistoryActivator
private MessageHistoryServiceImpl msgHistoryService = null;
private static BundleContext bundleContext;
static BundleContext bundleContext;
/**
* Initialize and start message history

@ -14,6 +14,7 @@
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 void start(BundleContext bc)
// 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 Collection findLastMessagesBefore(ChatRoom room, Date date, int count)
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

@ -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 static void loadGuiConfigurations()
}
// 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 static void loadGuiConfigurations()
}
// 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 static void loadGuiConfigurations()
}
// 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)

Loading…
Cancel
Save