aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/configuration
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
commit85901329b0794b136b96bf745f4ab1572806fc89 (patch)
treef23da7e97cae727f39d825f0fef8348cffb238e4 /src/net/java/sip/communicator/impl/configuration
parent3db2e44f186c59429901b2c899e139ea60117a55 (diff)
parentcf5da997da8820b4050f5b87ee9440a0ede36d1f (diff)
downloadjitsi-85901329b0794b136b96bf745f4ab1572806fc89.zip
jitsi-85901329b0794b136b96bf745f4ab1572806fc89.tar.gz
jitsi-85901329b0794b136b96bf745f4ab1572806fc89.tar.bz2
Merge commit 'cf5da99'HEADmaster
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'src/net/java/sip/communicator/impl/configuration')
-rw-r--r--src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java69
-rw-r--r--src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java29
2 files changed, 61 insertions, 37 deletions
diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
index 1553658..a77b2f5 100644
--- a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
+++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
@@ -28,6 +28,9 @@ import org.jitsi.util.*;
import org.osgi.framework.*;
import java.io.*;
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.util.*;
/**
*
@@ -64,39 +67,38 @@ public class ConfigurationActivator
if (fas != null)
{
- File useDatabaseConfig;
-
+ File usePropFileConfig;
try
{
- useDatabaseConfig
+ usePropFileConfig
= fas.getPrivatePersistentFile(
- ".usedatabaseconfig",
+ ".usepropfileconfig",
FileCategory.PROFILE);
}
catch (Exception ise)
{
-
// There is somewhat of a chicken-and-egg dependency between
// FileConfigurationServiceImpl and ConfigurationServiceImpl:
// FileConfigurationServiceImpl throws IllegalStateException if
// certain System properties are not set,
// ConfigurationServiceImpl will make sure that these properties
- //are set but it will do that later.
+ // are set but it will do that later.
// A SecurityException is thrown when the destination
// is not writable or we do not have access to that folder
- useDatabaseConfig = null;
+ usePropFileConfig = null;
}
- // BETA: if the marker file exists, use the database configuration
- if ((useDatabaseConfig != null) && useDatabaseConfig.exists())
+ if (usePropFileConfig != null && usePropFileConfig.exists())
{
- logger.info("Using database configuration store.");
- this.cs = new JdbcConfigService(fas);
+ logger.info("Using properties file configuration store.");
+ this.cs = LibJitsi.getConfigurationService();
}
}
if (this.cs == null)
- this.cs = LibJitsi.getConfigurationService();
+ {
+ this.cs = new JdbcConfigService(fas);
+ }
bundleContext.registerService(
ConfigurationService.class.getName(),
@@ -139,17 +141,30 @@ public class ConfigurationActivator
// let's check config file and config folder
File homeFolder
= new File(cs.getScHomeDirLocation(), cs.getScHomeDirName());
- CLibrary libc = (CLibrary) Native.loadLibrary("c", CLibrary.class);
-
- libc.chmod(homeFolder.getAbsolutePath(), 0700);
+ Set<PosixFilePermission> perms =
+ new HashSet<PosixFilePermission>()
+ {{
+ add(PosixFilePermission.OWNER_READ);
+ add(PosixFilePermission.OWNER_WRITE);
+ add(PosixFilePermission.OWNER_EXECUTE);
+ }};
+ Files.setPosixFilePermissions(
+ Paths.get(homeFolder.getAbsolutePath()), perms);
String fileName = cs.getConfigurationFilename();
-
if(fileName != null)
{
File cf = new File(homeFolder, fileName);
if(cf.exists())
- libc.chmod(cf.getAbsolutePath(), 0600);
+ {
+ perms = new HashSet<PosixFilePermission>()
+ {{
+ add(PosixFilePermission.OWNER_READ);
+ add(PosixFilePermission.OWNER_WRITE);
+ }};
+ Files.setPosixFilePermissions(
+ Paths.get(cf.getAbsolutePath()), perms);
+ }
}
}
catch(Throwable t)
@@ -164,24 +179,4 @@ public class ConfigurationActivator
throw (ThreadDeath) t;
}
}
-
- /**
- * The JNA interface to the <tt>c</tt> library and the <tt>chmod</tt>
- * function we use to fix permissions of user files and folders.
- */
- public interface CLibrary
- extends Library
- {
- /**
- * Changes file permissions.
- *
- * @param path the path to the file or folder the permissions of which
- * are to be changed.
- * @param mode the mode operand
- * @return <tt>0</tt> upon successful completion; otherwise,
- * <tt>-1</tt>. If <tt>-1</tt> is returned, no change to the file mode
- * occurs.
- */
- public int chmod(String path, int mode);
- }
}
diff --git a/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java b/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java
index 7ba362e..c9c9c3c 100644
--- a/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java
+++ b/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java
@@ -595,6 +595,35 @@ public final class JdbcConfigService
* (non-Javadoc)
*
* @see
+ * org.jitsi.service.configuration.ConfigurationService#getDouble(java.lang
+ * .String, double)
+ */
+ @Override
+ public double getDouble(String propertyName, double defaultValue)
+ {
+ Object value = this.getProperty(propertyName);
+ if (value == null || "".equals(value.toString()))
+ {
+ return defaultValue;
+ }
+
+ try
+ {
+ return Double.parseDouble(value.toString());
+ }
+ catch (NumberFormatException ex)
+ {
+ logger.error(String.format(
+ "'%s' for property %s not a double, returning default (%s)",
+ value, propertyName, defaultValue), ex);
+ return defaultValue;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
* org.jitsi.service.configuration.ConfigurationService#getLong(java.lang
* .String, long)
*/