diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties index 77de9f3d9..cf8c6e429 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 27f49f59f..9ef4795d2 100644 Binary files a/lib/installer-exclude/libjitsi.jar and b/lib/installer-exclude/libjitsi.jar differ diff --git a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java index 27052e835..3d4528066 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 @@ void start(BundleContext bc, MetaContactListServiceImpl mclServImpl) // 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 537fd07c0..c462a208c 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.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 @@ private static String getContactAvatar( try { avatarFile = GuiActivator.getFileAccessService() - .getPrivatePersistentFile(avatarPath); + .getPrivatePersistentFile(avatarPath, FileCategory.CACHE); } catch (Exception e) { @@ -1874,7 +1875,7 @@ private static String getContactAvatar( 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 b38d8675e..948716e94 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 static void deleteImage(int index) { 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 static BufferedImage loadImage(int index) imageFile = GuiActivator.getFileAccessService().getPrivatePersistentFile( - imagePath); + imagePath, FileCategory.CACHE); } catch (Exception e) { @@ -108,11 +108,13 @@ private static void moveImage(int oldIndex, int newIndex) 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 static void storeImage(BufferedImage image, int index) 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 d79999967..370558bb0 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 Iterator getExistingIDs() = getFileAccessService().getPrivatePersistentDirectory( (userSetDataDirectory == null) ? DATA_DIRECTORY - : userSetDataDirectory); + : userSetDataDirectory, FileCategory.PROFILE); findDatFiles(vect, histDir); } catch (Exception e) @@ -246,24 +246,29 @@ private File createHistoryDirectories(HistoryID id) 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 @@ private File getDirForHistory(HistoryID id) = 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 bdeb0f169..d528c0cd5 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 @@ synchronized void start(BundleContext bc) // 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 964b6e289..62deaa957 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 net.java.sip.communicator.util.*; +import org.jitsi.service.fileaccess.*; import org.jitsi.service.packetlogging.*; /** @@ -165,12 +166,11 @@ private void getFileNames() 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 421c2c1f0..81aa89a4c 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 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 @@ private String storePicture(byte[] data) + 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 void registrationStateChanged(RegistrationStateChangeEvent evt) + 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 fb5672983..6353fc4d0 100644 --- a/src/net/java/sip/communicator/launcher/SIPCommunicator.java +++ b/src/net/java/sip/communicator/launcher/SIPCommunicator.java @@ -31,6 +31,20 @@ public class SIPCommunicator private static final String[] LEGACY_DIR_NAMES = { ".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). */ @@ -182,12 +196,14 @@ static void setScHomeDir(String osName) * ${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 @@ static void setScHomeDir(String osName) 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 @@ else if (osName.startsWith("Windows")) * 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 @@ else if (osName.startsWith("Windows")) * 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 @@ && new File(defaultLocation, defaultName).isDirectory()) 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 4faa6c15c..722e26487 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.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 void actionPerformed(ActionEvent e) 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 93a87c5c5..df8558620 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 net.java.sip.communicator.util.Logger; +import org.jitsi.service.fileaccess.*; import org.jitsi.util.*; /** @@ -124,7 +125,8 @@ private static void collectHomeFolderLogs(ZipOutputStream out) 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 51204e6c2..092542a89 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 @@ synchronized void start(BundleContext bc) throws Exception 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 @@ synchronized void start(BundleContext bc) throws Exception 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 @@ synchronized void start(BundleContext bc) throws Exception // 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 @@ void setLocale(Parameters.Locale locale) throws Exception 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 @@ void removeLocale(Parameters.Locale locale) throws Exception File dictLocation = SpellCheckActivator.getFileAccessService() - .getPrivatePersistentFile(DICT_DIR + filename); + .getPrivatePersistentFile(DICT_DIR + filename, + FileCategory.CACHE); if (dictLocation.exists()) dictLocation.delete(); @@ -457,7 +462,8 @@ boolean isLocaleAvailable(Parameters.Locale locale) { 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 37dcac199..b9418bc32 100644 --- a/src/net/java/sip/communicator/util/AvatarCacheUtils.java +++ b/src/net/java/sip/communicator/util/AvatarCacheUtils.java @@ -176,7 +176,8 @@ private static byte[] getLocallyStoredAvatar(String avatarPath) File avatarFile = UtilActivator .getFileAccessService() - .getPrivatePersistentFile(avatarPath); + .getPrivatePersistentFile(avatarPath, + FileCategory.CACHE); if(avatarFile.exists()) { @@ -297,10 +298,11 @@ private static void cacheAvatar(String avatarDirPath, 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 49b2ecb21..6a971c990 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}. *

* The field is public so that our Logger could reset it if @@ -135,9 +135,9 @@ private static String getPattern() 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 @@ private static String getPattern() 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 adc6c3633..a6de4cb85 100644 --- a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java +++ b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java @@ -34,6 +34,20 @@ public class LaunchArgHandler private static final String PNAME_SC_HOME_DIR_LOCATION = "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 @@ private int handleConfigArg(String configArg) } 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 33b0fb922..f0d084497 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 @@ private int writeLockFile(File lockFile, InetSocketAddress lockAddress) */ 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 923eeb8c0..d4c17ce28 100644 --- a/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java +++ b/test/net/java/sip/communicator/slick/fileaccess/TestFileAccessService.java @@ -31,12 +31,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. */ @@ -128,8 +122,8 @@ public void testCreateReadWriteFileInTemporaryDirectory() 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 void testCreateReadWriteFileInPersistentDirectory() 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 void testCreatePersistentFile() { try { File file = this.fileAccessService - .getPrivatePersistentFile(fileName); + .getPrivatePersistentFile(fileName, FileCategory.PROFILE); if (!file.exists()) { @@ -201,7 +196,7 @@ public void testDeletePersistentFile() { try { File file = this.fileAccessService - .getPrivatePersistentFile(fileName); + .getPrivatePersistentFile(fileName, FileCategory.PROFILE); if (file.exists()) { @@ -221,7 +216,7 @@ public void testCreateReadWritePersistentFile() try { File file = this.fileAccessService - .getPrivatePersistentFile(fileName); + .getPrivatePersistentFile(fileName, FileCategory.PROFILE); if (!file.exists()) { @@ -243,7 +238,7 @@ public void testPersistentFilePersistency() try { File file = this.fileAccessService - .getPrivatePersistentFile(fileName); + .getPrivatePersistentFile(fileName, FileCategory.PROFILE); if (!file.exists()) { @@ -253,7 +248,7 @@ public void testPersistentFilePersistency() writeReadFile(file); File newFile = this.fileAccessService - .getPrivatePersistentFile(fileName); + .getPrivatePersistentFile(fileName, FileCategory.PROFILE); // Assert that those files are in fact the same assertEquals(file, newFile);