Minor refactoring.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@9014 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-08-27 23:37:53 +00:00
committed by derek
parent 877a2889c0
commit 3b484b0919
10 changed files with 16 additions and 23 deletions

View File

@ -1103,7 +1103,7 @@ public final class LoginDialog {
*/ */
private void checkForOldSettings() throws Exception { private void checkForOldSettings() throws Exception {
// Check for old settings.xml // Check for old settings.xml
File settingsXML = new File(Spark.getUserSparkHome(), "/settings.xml"); File settingsXML = new File(Spark.getSparkUserHome(), "/settings.xml");
if (settingsXML.exists()) { if (settingsXML.exists()) {
SAXReader saxReader = new SAXReader(); SAXReader saxReader = new SAXReader();
Document pluginXML = null; Document pluginXML = null;

View File

@ -37,8 +37,6 @@ import java.io.IOException;
*/ */
public final class Spark { public final class Spark {
private static final String USER_HOME = System.getProperties().getProperty("user.home");
private static final String USER_SPARK_HOME = System.getProperties().getProperty("user.home") + "/" + getUserConf(); private static final String USER_SPARK_HOME = System.getProperties().getProperty("user.home") + "/" + getUserConf();
public static String ARGUMENTS; public static String ARGUMENTS;
@ -285,30 +283,25 @@ public final class Spark {
* *
* @return Directory name depending on Operating System. * @return Directory name depending on Operating System.
*/ */
public static String getUserConf() { private static String getUserConf() {
if (isLinux()) { if (isLinux()) {
return ".Spark"; return ".Spark";
} }
else if(isWindows()){
return "Spark";
}
return "Spark"; return "Spark";
} }
/**
* Returns the User specific directory for this Spark instance. The user home is where all user specific
* files are placed.
*
* @return the user home;
*/
public static String getUserHome() {
return USER_HOME;
}
/** /**
* Returns the Spark directory for the current user (user.home). The user home is where all user specific * Returns the Spark directory for the current user (user.home). The user home is where all user specific
* files are placed to run Spark within a multi-user system. * files are placed to run Spark within a multi-user system.
* *
* @return the user home / Spark; * @return the user home / Spark;
*/ */
public static String getUserSparkHome() { public static String getSparkUserHome() {
return USER_SPARK_HOME; return USER_SPARK_HOME;
} }

View File

@ -351,7 +351,7 @@ public final class SparkManager {
*/ */
public static File getUserDirectory() { public static File getUserDirectory() {
final String bareJID = sessionManager.getBareAddress(); final String bareJID = sessionManager.getBareAddress();
File userDirectory = new File(Spark.getUserSparkHome(), "/user/" + bareJID); File userDirectory = new File(Spark.getSparkUserHome(), "/user/" + bareJID);
if (!userDirectory.exists()) { if (!userDirectory.exists()) {
userDirectory.mkdirs(); userDirectory.mkdirs();
} }

View File

@ -694,7 +694,7 @@ public class SparkTransferManager {
* @param room the ChatRoom of the user you wish to send the image to. * @param room the ChatRoom of the user you wish to send the image to.
*/ */
public void sendImage(final BufferedImage image, final ChatRoom room) { public void sendImage(final BufferedImage image, final ChatRoom room) {
File tmpDirectory = new File(Spark.getUserSparkHome(), "/tempImages"); File tmpDirectory = new File(Spark.getSparkUserHome(), "/tempImages");
tmpDirectory.mkdirs(); tmpDirectory.mkdirs();
String imageName = "image_" + StringUtils.randomString(2) + ".png"; String imageName = "image_" + StringUtils.randomString(2) + ".png";

View File

@ -196,7 +196,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
// Load Properties file // Load Properties file
props = new Properties(); props = new Properties();
// Save to properties file. // Save to properties file.
propertiesFile = new File(Spark.getUserSparkHome() + "/groups.properties"); propertiesFile = new File(Spark.getSparkUserHome() + "/groups.properties");
try { try {
props.load(new FileInputStream(propertiesFile)); props.load(new FileInputStream(propertiesFile));
} }

View File

@ -430,7 +430,7 @@ public class TranscriptWindow extends ChatArea {
try { try {
SimpleDateFormat formatter; SimpleDateFormat formatter;
File defaultSaveFile = new File(Spark.getUserSparkHome() + "/" + fileName); File defaultSaveFile = new File(Spark.getSparkUserHome() + "/" + fileName);
final JFileChooser fileChooser = new JFileChooser(defaultSaveFile); final JFileChooser fileChooser = new JFileChooser(defaultSaveFile);
fileChooser.setSelectedFile(defaultSaveFile); fileChooser.setSelectedFile(defaultSaveFile);

View File

@ -144,7 +144,7 @@ public class ReceiveMessage extends JPanel {
titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getNickname())); titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getNickname()));
File tempFile = new File(Spark.getUserSparkHome(), "/tmp"); File tempFile = new File(Spark.getSparkUserHome(), "/tmp");
try { try {
tempFile.mkdirs(); tempFile.mkdirs();

View File

@ -98,7 +98,7 @@ public class LayoutSettingsManager {
* @return the settings file. * @return the settings file.
*/ */
public static File getSettingsFile() { public static File getSettingsFile() {
File file = new File(Spark.getUserSparkHome()); File file = new File(Spark.getSparkUserHome());
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
} }

View File

@ -333,7 +333,7 @@ public class SoundPreference implements Preference {
} }
private File getSoundSettingsFile() { private File getSoundSettingsFile() {
File file = new File(Spark.getUserSparkHome()); File file = new File(Spark.getSparkUserHome());
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
} }

View File

@ -85,7 +85,7 @@ public class SettingsManager {
* @return the settings file. * @return the settings file.
*/ */
public static File getSettingsFile() { public static File getSettingsFile() {
File file = new File(Spark.getUserSparkHome()); File file = new File(Spark.getSparkUserHome());
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
} }