aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo@jitsi.org>2013-08-06 17:47:10 +0200
committerIngo Bauersachs <ingo@jitsi.org>2013-11-10 21:05:39 +0100
commitf2694065ad7685cb76c23b8aecd39e1481c07c0b (patch)
treeb7342f9464009c3ace7a6cee1f4c871fd4c70b9b
parent6f79b983682bfd08572ba3364e27e68d91632082 (diff)
downloadjitsi-f2694065ad7685cb76c23b8aecd39e1481c07c0b.zip
jitsi-f2694065ad7685cb76c23b8aecd39e1481c07c0b.tar.gz
jitsi-f2694065ad7685cb76c23b8aecd39e1481c07c0b.tar.bz2
Use separate dirs for application logs, cache and configuration data
This is primarily used on Windows to store logs and cached data on the local computers instead of on the network when roaming profiles with folder redirection is used.
-rw-r--r--lib/felix.client.run.properties2
-rw-r--r--lib/installer-exclude/libjitsi.jarbin1583953 -> 1585043 bytes
-rw-r--r--src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java3
-rwxr-xr-xsrc/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java5
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/presence/avatar/AvatarStackManager.java16
-rw-r--r--src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java30
-rw-r--r--src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java6
-rw-r--r--src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java12
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java8
-rw-r--r--src/net/java/sip/communicator/launcher/SIPCommunicator.java67
-rw-r--r--src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java4
-rw-r--r--src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java4
-rw-r--r--src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java18
-rw-r--r--src/net/java/sip/communicator/util/AvatarCacheUtils.java8
-rw-r--r--src/net/java/sip/communicator/util/FileHandler.java8
-rw-r--r--src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java16
-rw-r--r--src/net/java/sip/communicator/util/launchutils/SipCommunicatorLock.java18
-rw-r--r--test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java23
18 files changed, 160 insertions, 88 deletions
diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties
index 77de9f3..cf8c6e4 100644
--- a/lib/felix.client.run.properties
+++ b/lib/felix.client.run.properties
@@ -212,7 +212,7 @@ felix.auto.start.80= \
# file:lib/bundle/architectureviewer1.1.jar
# Specify the directory where oscar should deploy its bundles
-org.osgi.framework.storage=${net.java.sip.communicator.SC_HOME_DIR_LOCATION}/${net.java.sip.communicator.SC_HOME_DIR_NAME}/sip-communicator.bin
+org.osgi.framework.storage=${net.java.sip.communicator.SC_CACHE_DIR_LOCATION}/${net.java.sip.communicator.SC_HOME_DIR_NAME}/sip-communicator.bin
org.osgi.framework.startlevel.beginning=100
felix.startlevel.bundle=100
diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar
index 27f49f5..9ef4795 100644
--- a/lib/installer-exclude/libjitsi.jar
+++ b/lib/installer-exclude/libjitsi.jar
Binary files differ
diff --git a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
index 27052e8..3d45280 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
@@ -295,7 +295,8 @@ public class MclStorageManager
// get a reference to the contact list file.
try
{
- contactlistFile = faService.getPrivatePersistentFile(fileName);
+ contactlistFile = faService.getPrivatePersistentFile(fileName,
+ FileCategory.PROFILE);
if (!contactlistFile.exists() && !contactlistFile.createNewFile())
throw new IOException("Failed to create file"
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
index 537fd07..c462a20 100755
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
@@ -22,6 +22,7 @@ import javax.swing.text.html.*;
import javax.swing.text.html.HTML.*;
import org.jitsi.service.configuration.*;
+import org.jitsi.service.fileaccess.FileCategory;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.chat.history.*;
@@ -1841,7 +1842,7 @@ public class ChatConversationPanel
try
{
avatarFile = GuiActivator.getFileAccessService()
- .getPrivatePersistentFile(avatarPath);
+ .getPrivatePersistentFile(avatarPath, FileCategory.CACHE);
}
catch (Exception e)
{
@@ -1874,7 +1875,7 @@ public class ChatConversationPanel
try
{
avatarFile = GuiActivator.getFileAccessService()
- .getPrivatePersistentFile(avatarPath);
+ .getPrivatePersistentFile(avatarPath, FileCategory.CACHE);
}
catch (Exception e)
{
diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/avatar/AvatarStackManager.java b/src/net/java/sip/communicator/impl/gui/main/presence/avatar/AvatarStackManager.java
index b38d867..948716e 100644
--- a/src/net/java/sip/communicator/impl/gui/main/presence/avatar/AvatarStackManager.java
+++ b/src/net/java/sip/communicator/impl/gui/main/presence/avatar/AvatarStackManager.java
@@ -45,7 +45,7 @@ public class AvatarStackManager
{
File imageFile
= GuiActivator.getFileAccessService().getPrivatePersistentFile(
- fileName);
+ fileName, FileCategory.CACHE);
if (imageFile.exists() && !imageFile.delete())
logger.error("Failed to delete stored image at index " + index);
@@ -72,7 +72,7 @@ public class AvatarStackManager
imageFile
= GuiActivator.getFileAccessService().getPrivatePersistentFile(
- imagePath);
+ imagePath, FileCategory.CACHE);
}
catch (Exception e)
{
@@ -108,11 +108,13 @@ public class AvatarStackManager
try
{
FileAccessService fas = GuiActivator.getFileAccessService();
- File oldFile = fas.getPrivatePersistentFile(oldImagePath);
+ File oldFile = fas.getPrivatePersistentFile(oldImagePath,
+ FileCategory.CACHE);
if (oldFile.exists())
{
- File newFile = fas.getPrivatePersistentFile(newImagePath);
+ File newFile = fas.getPrivatePersistentFile(newImagePath,
+ FileCategory.CACHE);
oldFile.renameTo(newFile);
}
@@ -147,12 +149,14 @@ public class AvatarStackManager
try
{
FileAccessService fas = GuiActivator.getFileAccessService();
- File storeDir = fas.getPrivatePersistentDirectory(STORE_DIR);
+ File storeDir = fas.getPrivatePersistentDirectory(STORE_DIR,
+ FileCategory.CACHE);
// if dir doesn't exist create it
storeDir.mkdirs();
- File file = fas.getPrivatePersistentFile(imagePath);
+ File file = fas.getPrivatePersistentFile(imagePath,
+ FileCategory.CACHE);
ImageIO.write(image, "png", file);
}
diff --git a/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java b/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java
index d799999..370558b 100644
--- a/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java
@@ -101,7 +101,7 @@ public class HistoryServiceImpl
= getFileAccessService().getPrivatePersistentDirectory(
(userSetDataDirectory == null)
? DATA_DIRECTORY
- : userSetDataDirectory);
+ : userSetDataDirectory, FileCategory.PROFILE);
findDatFiles(vect, histDir);
} catch (Exception e)
@@ -246,24 +246,29 @@ public class HistoryServiceImpl
throws IOException
{
String[] idComponents = id.getID();
- String[] dirs = new String[idComponents.length + 1];
- String userSetDataDirectory = System.getProperty("HistoryServiceDirectory");
- if(userSetDataDirectory != null)
- dirs[0] = userSetDataDirectory;
- else
- dirs[0] = DATA_DIRECTORY;
-
- // escape chars in direcotory names
+ // escape chars in directory names
escapeCharacters(idComponents);
- System.arraycopy(idComponents, 0, dirs, 1, dirs.length - 1);
+ String userSetDataDirectory
+ = System.getProperty("HistoryServiceDirectory");
+
+ File dir = new File(userSetDataDirectory != null
+ ? userSetDataDirectory
+ : DATA_DIRECTORY);
+
+ for (String s : idComponents)
+ {
+ dir = new File(dir, s);
+ }
File directory = null;
try
{
directory
- = getFileAccessService().getPrivatePersistentDirectory(dirs);
+ = getFileAccessService().getPrivatePersistentDirectory(
+ dir.toString(),
+ FileCategory.PROFILE);
}
catch (Exception e)
{
@@ -475,7 +480,8 @@ public class HistoryServiceImpl
= getFileAccessService().getPrivatePersistentDirectory(
(userSetDataDirectory == null)
? DATA_DIRECTORY
- : userSetDataDirectory);
+ : userSetDataDirectory,
+ FileCategory.PROFILE);
}
catch (Exception e)
{
diff --git a/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java b/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java
index bdeb0f1..d528c0c 100644
--- a/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/keybindings/KeybindingsServiceImpl.java
@@ -139,13 +139,15 @@ class KeybindingsServiceImpl
// Makes directory for custom bindings if it doesn't exist
File customDir =
faService
- .getPrivatePersistentDirectory(CUSTOM_KEYBINDING_DIR);
+ .getPrivatePersistentDirectory(CUSTOM_KEYBINDING_DIR,
+ FileCategory.PROFILE);
if (!customDir.exists())
customDir.mkdir();
// Gets file access service to reference persistent storage
// of the user
- customFile = faService.getPrivatePersistentFile(customPath);
+ customFile = faService.getPrivatePersistentFile(customPath,
+ FileCategory.PROFILE);
}
catch (Exception exc)
{
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
index 964b6e2..62deaa9 100644
--- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java
@@ -11,6 +11,7 @@ import java.util.*;
import net.java.sip.communicator.util.*;
+import org.jitsi.service.fileaccess.*;
import org.jitsi.service.packetlogging.*;
/**
@@ -165,12 +166,11 @@ public class PacketLoggingServiceImpl
for(int i = 0; i < fileCount; i++)
{
files[i]
- = PacketLoggingActivator.getFileAccessService().getPrivatePersistentFile(
- PacketLoggingActivator.LOGGING_DIR_NAME
- + File.separator
- + "jitsi"
- + i
- + ".pcap");
+ = PacketLoggingActivator.getFileAccessService()
+ .getPrivatePersistentFile(
+ new File(PacketLoggingActivator.LOGGING_DIR_NAME,
+ "jitsi" + i + ".pcap").toString(),
+ FileCategory.LOG);
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java
index 421c2c1..81aa89a 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java
@@ -11,6 +11,8 @@ import java.util.*;
import javax.imageio.*;
+import org.jitsi.service.fileaccess.FileCategory;
+
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.ImageDetail;
@@ -397,13 +399,13 @@ public class OperationSetServerStoredAccountInfoMsnImpl
+ msnProvider.getAccountID().getAccountUniqueID() + ".jpg";
File storeDir = MsnActivator.getFileAccessService()
- .getPrivatePersistentDirectory(STORE_DIR);
+ .getPrivatePersistentDirectory(STORE_DIR, FileCategory.CACHE);
// if dir doesn't exist create it
storeDir.mkdirs();
File file = MsnActivator.getFileAccessService()
- .getPrivatePersistentFile(imagePath);
+ .getPrivatePersistentFile(imagePath, FileCategory.CACHE);
ImageIO.write(
ImageIO.read(new ByteArrayInputStream(data)),
@@ -557,7 +559,7 @@ public class OperationSetServerStoredAccountInfoMsnImpl
+ msnProvider.getAccountID().getAccountUniqueID() + ".jpg";
File file = MsnActivator.getFileAccessService()
- .getPrivatePersistentFile(imagePath);
+ .getPrivatePersistentFile(imagePath, FileCategory.CACHE);
if(file.exists())
{
diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicator.java b/src/net/java/sip/communicator/launcher/SIPCommunicator.java
index fb56729..6353fc4 100644
--- a/src/net/java/sip/communicator/launcher/SIPCommunicator.java
+++ b/src/net/java/sip/communicator/launcher/SIPCommunicator.java
@@ -32,6 +32,20 @@ public class SIPCommunicator
= { ".sip-communicator", "SIP Communicator" };
/**
+ * The name of the property that stores the home dir for cache data, such
+ * as avatars and spelling dictionaries.
+ */
+ public static final String PNAME_SC_CACHE_DIR_LOCATION =
+ "net.java.sip.communicator.SC_CACHE_DIR_LOCATION";
+
+ /**
+ * The name of the property that stores the home dir for application log
+ * files (not history).
+ */
+ public static final String PNAME_SC_LOG_DIR_LOCATION =
+ "net.java.sip.communicator.SC_LOG_DIR_LOCATION";
+
+ /**
* Name of the possible configuration file names (used under macosx).
*/
private static final String[] LEGACY_CONFIGURATION_FILE_NAMES
@@ -182,12 +196,14 @@ public class SIPCommunicator
* ${user.home}/.sip-communicator if it exists (and the new path isn't
* already in use).
*/
- String location = System.getProperty(PNAME_SC_HOME_DIR_LOCATION);
+ String profileLocation = System.getProperty(PNAME_SC_HOME_DIR_LOCATION);
+ String cacheLocation = System.getProperty(PNAME_SC_CACHE_DIR_LOCATION);
+ String logLocation = System.getProperty(PNAME_SC_LOG_DIR_LOCATION);
String name = System.getProperty(PNAME_SC_HOME_DIR_NAME);
boolean isHomeDirnameForced = name != null;
- if ((location == null) || (name == null))
+ if (profileLocation == null || name == null)
{
String defaultLocation = System.getProperty("user.home");
String defaultName = ".jitsi";
@@ -202,11 +218,22 @@ public class SIPCommunicator
if (osName.startsWith("Mac"))
{
- if (location == null)
- location =
+ if (profileLocation == null)
+ profileLocation =
System.getProperty("user.home") + File.separator
+ "Library" + File.separator
+ "Application Support";
+ if (cacheLocation == null)
+ cacheLocation =
+ System.getProperty("user.home") + File.separator
+ + "Library" + File.separator
+ + "Caches";
+ if (logLocation == null)
+ logLocation =
+ System.getProperty("user.home") + File.separator
+ + "Library" + File.separator
+ + "Logs";
+
if (name == null)
name = "Jitsi";
}
@@ -218,15 +245,23 @@ public class SIPCommunicator
* it may be a good idea to follow the OS recommendations and
* use APPDATA on pre-Vista systems as well.
*/
- if (location == null)
- location = System.getenv("APPDATA");
+ if (profileLocation == null)
+ profileLocation = System.getenv("APPDATA");
+ if (cacheLocation == null)
+ cacheLocation = System.getenv("LOCALAPPDATA");
+ if (logLocation == null)
+ logLocation = System.getenv("LOCALAPPDATA");
if (name == null)
name = "Jitsi";
}
/* If there're no OS specifics, use the defaults. */
- if (location == null)
- location = defaultLocation;
+ if (profileLocation == null)
+ profileLocation = defaultLocation;
+ if (cacheLocation == null)
+ cacheLocation = profileLocation;
+ if (logLocation == null)
+ logLocation = profileLocation;
if (name == null)
name = defaultName;
@@ -236,23 +271,23 @@ public class SIPCommunicator
* doesn't look for the default dir.
*/
if (!isHomeDirnameForced
- && (new File(location, name).isDirectory() == false)
+ && (new File(profileLocation, name).isDirectory() == false)
&& new File(defaultLocation, defaultName).isDirectory())
{
- location = defaultLocation;
+ profileLocation = defaultLocation;
name = defaultName;
}
// if we need to check legacy names and there is no current home dir
// already created
if(chekLegacyDirNames
- && !checkHomeFolderExist(location, name, osName))
+ && !checkHomeFolderExist(profileLocation, name, osName))
{
// now check whether a legacy dir name exists and use it
for(String dir : LEGACY_DIR_NAMES)
{
// check the platform specific directory
- if(checkHomeFolderExist(location, dir, osName))
+ if(checkHomeFolderExist(profileLocation, dir, osName))
{
name = dir;
break;
@@ -262,18 +297,20 @@ public class SIPCommunicator
if(checkHomeFolderExist(defaultLocation, dir, osName))
{
name = dir;
- location = defaultLocation;
+ profileLocation = defaultLocation;
break;
}
}
}
- System.setProperty(PNAME_SC_HOME_DIR_LOCATION, location);
+ System.setProperty(PNAME_SC_HOME_DIR_LOCATION, profileLocation);
+ System.setProperty(PNAME_SC_CACHE_DIR_LOCATION, cacheLocation);
+ System.setProperty(PNAME_SC_LOG_DIR_LOCATION, logLocation);
System.setProperty(PNAME_SC_HOME_DIR_NAME, name);
}
// when we end up with the home dirs, make sure we have log dir
- new File(location, name + File.separator + "log").mkdirs();
+ new File(new File(logLocation, name), "log").mkdirs();
}
/**
diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
index 4faa6c1..722e264 100644
--- a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
+++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
@@ -20,6 +20,7 @@ import net.java.sip.communicator.service.dns.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
+import org.jitsi.service.fileaccess.*;
import org.jitsi.service.resources.*;
import org.osgi.framework.*;
@@ -250,7 +251,8 @@ public class DnssecPanel
try
{
f = DnsConfigActivator.getFileAccessService()
- .getPrivatePersistentFile(".usednsjava");
+ .getPrivatePersistentFile(".usednsjava",
+ FileCategory.PROFILE);
if(chkEnabled.isSelected())
{
if(!f.createNewFile() && !f.exists())
diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java
index 93a87c5..df85586 100644
--- a/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java
+++ b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java
@@ -13,6 +13,7 @@ import java.util.zip.*;
import net.java.sip.communicator.util.Logger;
+import org.jitsi.service.fileaccess.*;
import org.jitsi.util.*;
/**
@@ -124,7 +125,8 @@ public class LogsCollector
try
{
File[] fs = LoggingUtilsActivator.getFileAccessService()
- .getPrivatePersistentDirectory(LOGGING_DIR_NAME).listFiles();
+ .getPrivatePersistentDirectory(LOGGING_DIR_NAME,
+ FileCategory.LOG).listFiles();
for(File f : fs)
{
diff --git a/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java b/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java
index 51204e6..092542a 100644
--- a/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java
+++ b/src/net/java/sip/communicator/plugin/spellcheck/SpellChecker.java
@@ -98,7 +98,8 @@ class SpellChecker
SpellCheckActivator.getFileAccessService();
// checks if DICT_DIR exists to see if this is the first run
- File dictionaryDir = faService.getPrivatePersistentFile(DICT_DIR);
+ File dictionaryDir = faService.getPrivatePersistentFile(DICT_DIR,
+ FileCategory.CACHE);
if (!dictionaryDir.exists())
{
@@ -124,7 +125,8 @@ class SpellChecker
String filename = dictUrl.getPath().substring(filenameStart);
File dictLocation =
- faService.getPrivatePersistentFile(DICT_DIR + filename);
+ faService.getPrivatePersistentFile(DICT_DIR + filename,
+ FileCategory.CACHE);
copyDictionary(source, dictLocation);
}
@@ -133,7 +135,8 @@ class SpellChecker
// gets resource for personal dictionary
this.personalDictLocation =
- faService.getPrivatePersistentFile(DICT_DIR + PERSONAL_DICT_NAME);
+ faService.getPrivatePersistentFile(DICT_DIR + PERSONAL_DICT_NAME,
+ FileCategory.PROFILE);
if (!personalDictLocation.exists())
personalDictLocation.createNewFile();
@@ -379,7 +382,8 @@ class SpellChecker
File dictLocation =
SpellCheckActivator.getFileAccessService()
- .getPrivatePersistentFile(DICT_DIR + filename);
+ .getPrivatePersistentFile(DICT_DIR + filename,
+ FileCategory.CACHE);
// downloads dictionary if unavailable (not cached)
if (!dictLocation.exists())
@@ -430,7 +434,8 @@ class SpellChecker
File dictLocation =
SpellCheckActivator.getFileAccessService()
- .getPrivatePersistentFile(DICT_DIR + filename);
+ .getPrivatePersistentFile(DICT_DIR + filename,
+ FileCategory.CACHE);
if (dictLocation.exists())
dictLocation.delete();
@@ -457,7 +462,8 @@ class SpellChecker
{
File dictLocation =
SpellCheckActivator.getFileAccessService()
- .getPrivatePersistentFile(DICT_DIR + filename);
+ .getPrivatePersistentFile(DICT_DIR + filename,
+ FileCategory.CACHE);
return dictLocation.exists();
}
diff --git a/src/net/java/sip/communicator/util/AvatarCacheUtils.java b/src/net/java/sip/communicator/util/AvatarCacheUtils.java
index 37dcac1..b9418bc 100644
--- a/src/net/java/sip/communicator/util/AvatarCacheUtils.java
+++ b/src/net/java/sip/communicator/util/AvatarCacheUtils.java
@@ -176,7 +176,8 @@ public class AvatarCacheUtils
File avatarFile
= UtilActivator
.getFileAccessService()
- .getPrivatePersistentFile(avatarPath);
+ .getPrivatePersistentFile(avatarPath,
+ FileCategory.CACHE);
if(avatarFile.exists())
{
@@ -297,10 +298,11 @@ public class AvatarCacheUtils
avatarDir
= fileAccessService.getPrivatePersistentDirectory(
- avatarDirPath);
+ avatarDirPath, FileCategory.CACHE);
avatarFile
= fileAccessService.getPrivatePersistentFile(
- avatarDirPath + File.separator + avatarFileName);
+ new File(avatarDirPath, avatarFileName).toString(),
+ FileCategory.CACHE);
if(!avatarFile.exists())
{
diff --git a/src/net/java/sip/communicator/util/FileHandler.java b/src/net/java/sip/communicator/util/FileHandler.java
index 49b2ecb..6a971c9 100644
--- a/src/net/java/sip/communicator/util/FileHandler.java
+++ b/src/net/java/sip/communicator/util/FileHandler.java
@@ -41,7 +41,7 @@ public class FileHandler
* %t, %h, %g, %u.
* Also adds the special component :
* %s sip-communicator's home directory, typically -
- * ${net.java.sip.communicator.SC_HOME_DIR_LOCATION}/
+ * ${net.java.sip.communicator.SC_LOG_DIR_LOCATION}/
* ${net.java.sip.communicator.SC_HOME_DIR_NAME}.
* <p>
* The field is public so that our <tt>Logger</tt> could reset it if
@@ -135,9 +135,9 @@ public class FileHandler
FileHandler.class.getName() + ".pattern");
String homeLocation = System.getProperty(
- "net.java.sip.communicator.SC_HOME_DIR_LOCATION");
+ "net.java.sip.communicator.SC_LOG_DIR_LOCATION");
String dirName = System.getProperty(
- "net.java.sip.communicator.SC_HOME_DIR_NAME");
+ "net.java.sip.communicator.SC_HOME_DIR_NAME");
if(homeLocation != null && dirName != null)
{
@@ -149,7 +149,7 @@ public class FileHandler
homeLocation + "/" + dirName);
}
- // if pattern is missing and both dir name and home lcation
+ // if pattern is missing and both dir name and home location
// properties are also not defined its most probably running from
// source or testing - lets create log directory in working dir.
if(pattern == null)
diff --git a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
index adc6c36..a6de4cb 100644
--- a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
+++ b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
@@ -35,6 +35,20 @@ public class LaunchArgHandler
"net.java.sip.communicator.SC_HOME_DIR_LOCATION";
/**
+ * The name of the property that stores the home dir for cache data, such
+ * as avatars or spelling dictionaries.
+ */
+ private static final String PNAME_SC_CACHE_DIR_LOCATION =
+ "net.java.sip.communicator.SC_CACHE_DIR_LOCATION";
+
+ /**
+ * The name of the property that stores the home dir for application logs
+ * (not history).
+ */
+ private static final String PNAME_SC_LOG_DIR_LOCATION =
+ "net.java.sip.communicator.SC_LOG_DIR_LOCATION";
+
+ /**
* The name of the property that contains the name of the SC configuration
* directory.
*/
@@ -381,6 +395,8 @@ public class LaunchArgHandler
}
System.setProperty(PNAME_SC_HOME_DIR_LOCATION, configDir.getParent());
+ System.setProperty(PNAME_SC_CACHE_DIR_LOCATION, configDir.getParent());
+ System.setProperty(PNAME_SC_LOG_DIR_LOCATION, configDir.getParent());
System.setProperty(PNAME_SC_HOME_DIR_NAME, configDir.getName());
//we instantiated our class logger before we had a chance to change
diff --git a/src/net/java/sip/communicator/util/launchutils/SipCommunicatorLock.java b/src/net/java/sip/communicator/util/launchutils/SipCommunicatorLock.java
index 33b0fb9..f0d0844 100644
--- a/src/net/java/sip/communicator/util/launchutils/SipCommunicatorLock.java
+++ b/src/net/java/sip/communicator/util/launchutils/SipCommunicatorLock.java
@@ -473,17 +473,13 @@ public class SipCommunicatorLock extends Thread
*/
private File getLockFile()
{
- String homeDirLocation
- = System.getProperty(SIPCommunicator.PNAME_SC_HOME_DIR_LOCATION);
- String homeDirName
- = System.getProperty(SIPCommunicator.PNAME_SC_HOME_DIR_NAME);
- String fileSeparator = System.getProperty("file.separator");
- String fullLockFileName
- = homeDirLocation + fileSeparator
- + homeDirName + fileSeparator
- + LOCK_FILE_NAME;
-
- return new File(fullLockFileName);
+ String homeDirLocation =
+ System
+ .getProperty(SIPCommunicator.PNAME_SC_CACHE_DIR_LOCATION);
+ String homeDirName = System
+ .getProperty(SIPCommunicator.PNAME_SC_HOME_DIR_NAME);
+
+ return new File(new File(homeDirLocation, homeDirName), LOCK_FILE_NAME);
}
/**
diff --git a/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java b/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java
index 923eeb8..d4c17ce 100644
--- a/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java
+++ b/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java
@@ -32,12 +32,6 @@ public class TestFileAccessService extends TestCase {
private static final String dirName = "fileaccessservice.dir.tst";
/**
- * The persistent directory's name.
- */
- private static final String[] dirNames = { "fileaccessservice.dir.tst",
- "subdir1", "subdir2" };
-
- /**
* The persistent file's name.
*/
private static final String fileName = "fileaccessservice.tst";
@@ -128,8 +122,8 @@ public class TestFileAccessService extends TestCase {
public void testCreatePersistentDirectory()
throws Exception {
try {
- this.fileAccessService.getPrivatePersistentDirectory(dirName);
- this.fileAccessService.getPrivatePersistentDirectory(dirNames);
+ this.fileAccessService.getPrivatePersistentDirectory(dirName,
+ FileCategory.PROFILE);
} catch (IOException e)
{
fail("Error creating the temp directory: " + e.getMessage());
@@ -146,7 +140,8 @@ public class TestFileAccessService extends TestCase {
File privateDir = null;
try {
privateDir = this.fileAccessService
- .getPrivatePersistentDirectory(dirName);
+ .getPrivatePersistentDirectory(dirName,
+ FileCategory.PROFILE);
} catch (IOException e)
{
fail("Error creating the private directory: " + e.getMessage());
@@ -178,7 +173,7 @@ public class TestFileAccessService extends TestCase {
{
try {
File file = this.fileAccessService
- .getPrivatePersistentFile(fileName);
+ .getPrivatePersistentFile(fileName, FileCategory.PROFILE);
if (!file.exists())
{
@@ -201,7 +196,7 @@ public class TestFileAccessService extends TestCase {
{
try {
File file = this.fileAccessService
- .getPrivatePersistentFile(fileName);
+ .getPrivatePersistentFile(fileName, FileCategory.PROFILE);
if (file.exists())
{
@@ -221,7 +216,7 @@ public class TestFileAccessService extends TestCase {
try {
File file = this.fileAccessService
- .getPrivatePersistentFile(fileName);
+ .getPrivatePersistentFile(fileName, FileCategory.PROFILE);
if (!file.exists())
{
@@ -243,7 +238,7 @@ public class TestFileAccessService extends TestCase {
try {
File file = this.fileAccessService
- .getPrivatePersistentFile(fileName);
+ .getPrivatePersistentFile(fileName, FileCategory.PROFILE);
if (!file.exists())
{
@@ -253,7 +248,7 @@ public class TestFileAccessService extends TestCase {
writeReadFile(file);
File newFile = this.fileAccessService
- .getPrivatePersistentFile(fileName);
+ .getPrivatePersistentFile(fileName, FileCategory.PROFILE);
// Assert that those files are in fact the same
assertEquals(file, newFile);