summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-04 14:40:41 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-04 14:40:41 (GMT)
commite49bc0460be4b94904b6e965845fb8f228672379 (patch)
treeb435b764d08b70e56e4605224e812c12d67beaac /Swiften
parentd9e7abfd22ef30e6535b8bb290b9bd1ef7a7bff0 (diff)
downloadswift-e49bc0460be4b94904b6e965845fb8f228672379.zip
swift-e49bc0460be4b94904b6e965845fb8f228672379.tar.bz2
Moved platform-specific stuff out of Application.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Application/Application.cpp14
-rw-r--r--Swiften/Application/Application.h2
-rw-r--r--Swiften/Application/MacOSX/MacOSXApplication.cpp4
-rw-r--r--Swiften/Application/MacOSX/MacOSXApplication.h1
-rw-r--r--Swiften/Application/Unix/UnixApplication.h4
-rw-r--r--Swiften/Application/Windows/WindowsApplication.h8
6 files changed, 18 insertions, 15 deletions
diff --git a/Swiften/Application/Application.cpp b/Swiften/Application/Application.cpp
index e5c925a..be77e95 100644
--- a/Swiften/Application/Application.cpp
+++ b/Swiften/Application/Application.cpp
@@ -21,20 +21,6 @@ boost::filesystem::path Application::getAvatarDir() const {
return getSettingsDir() / "avatars";
}
-boost::filesystem::path Application::getHomeDir() const {
- // FIXME: Does this work on windows?
- // No it doesn't, putting alternative paths in for the moment.
- char* homeDirRaw = getenv("HOME");
- if (!homeDirRaw) {
- homeDirRaw = getenv("APPDATA");
- }
- if (!homeDirRaw) {
- homeDirRaw = getenv("USERPROFILE");
- }
- boost::filesystem::path homeDir(homeDirRaw);
- return homeDir;
-}
-
boost::filesystem::path Application::getProfileDir(const String& profile) const {
boost::filesystem::path result(getHomeDir() / profile.getUTF8String());
boost::filesystem::create_directory(result);
diff --git a/Swiften/Application/Application.h b/Swiften/Application/Application.h
index a65b1de..20d686c 100644
--- a/Swiften/Application/Application.h
+++ b/Swiften/Application/Application.h
@@ -15,7 +15,7 @@ namespace Swift {
boost::filesystem::path getSettingsFileName() const;
boost::filesystem::path getAvatarDir() const;
- boost::filesystem::path getHomeDir() const;
+ virtual boost::filesystem::path getHomeDir() const = 0;
virtual boost::filesystem::path getSettingsDir() const = 0;
boost::filesystem::path getProfileDir(const String& profile) const;
diff --git a/Swiften/Application/MacOSX/MacOSXApplication.cpp b/Swiften/Application/MacOSX/MacOSXApplication.cpp
index 1df2bfa..79d7586 100644
--- a/Swiften/Application/MacOSX/MacOSXApplication.cpp
+++ b/Swiften/Application/MacOSX/MacOSXApplication.cpp
@@ -15,4 +15,8 @@ boost::filesystem::path MacOSXApplication::getSettingsDir() const {
return result;
}
+boost::filesystem::path MacOSXApplication::getHomeDir() const {
+ return boost::filesystem::path(getenv("HOME"));
+}
+
}
diff --git a/Swiften/Application/MacOSX/MacOSXApplication.h b/Swiften/Application/MacOSX/MacOSXApplication.h
index 9e77c54..e408ffd 100644
--- a/Swiften/Application/MacOSX/MacOSXApplication.h
+++ b/Swiften/Application/MacOSX/MacOSXApplication.h
@@ -11,6 +11,7 @@ namespace Swift {
public:
MacOSXApplication(const String& name);
+ virtual boost::filesystem::path getHomeDir() const;
virtual ApplicationMessageDisplay* getApplicationMessageDisplay();
boost::filesystem::path getSettingsDir() const;
diff --git a/Swiften/Application/Unix/UnixApplication.h b/Swiften/Application/Unix/UnixApplication.h
index 0b7bf67..d087bd8 100644
--- a/Swiften/Application/Unix/UnixApplication.h
+++ b/Swiften/Application/Unix/UnixApplication.h
@@ -15,6 +15,10 @@ namespace Swift {
return &messageDisplay_;
}
+ virtual boost::filesystem::path getHomeDir() const {
+ return boost::filesystem::path(getenv("HOME"));
+ }
+
boost::filesystem::path getSettingsDir() const {
boost::filesystem::path result(getHomeDir() / ("." + getName().getLowerCase().getUTF8String()));
boost::filesystem::create_directory(result);
diff --git a/Swiften/Application/Windows/WindowsApplication.h b/Swiften/Application/Windows/WindowsApplication.h
index 9f1abb4..7b9ee74 100644
--- a/Swiften/Application/Windows/WindowsApplication.h
+++ b/Swiften/Application/Windows/WindowsApplication.h
@@ -22,6 +22,14 @@ namespace Swift {
return result;
}
+ boost::filesystem::path Application::getHomeDir() const {
+ char* homeDirRaw = getenv("APPDATA");
+ if (!homeDirRaw) {
+ homeDirRaw = getenv("USERPROFILE");
+ }
+ return boost::filesystem::path(homeDirRaw);
+ }
+
private:
NullApplicationMessageDisplay messageDisplay_;
};