diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-20 17:14:02 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-20 18:25:17 (GMT) |
commit | b3dc968b7c424351bac87bfed42681bd0500d86c (patch) | |
tree | 1f3ec7ee8f8b3e9d3e274ba77684b8606dc96377 /Swiften | |
parent | 5fa4903a7c1c7a7733afdd1d6c4c5dcccec97b19 (diff) | |
download | swift-b3dc968b7c424351bac87bfed42681bd0500d86c.zip swift-b3dc968b7c424351bac87bfed42681bd0500d86c.tar.bz2 |
Don't bundle sounds.
Diffstat (limited to 'Swiften')
7 files changed, 41 insertions, 0 deletions
diff --git a/Swiften/Application/ApplicationPathProvider.cpp b/Swiften/Application/ApplicationPathProvider.cpp index ec19160..47ef1ad 100644 --- a/Swiften/Application/ApplicationPathProvider.cpp +++ b/Swiften/Application/ApplicationPathProvider.cpp @@ -10,6 +10,7 @@ #include <iostream> #include "Swiften/Application/ApplicationPathProvider.h" +#include "Swiften/Base/foreach.h" namespace Swift { @@ -38,4 +39,15 @@ boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& pro return result; } +boost::filesystem::path ApplicationPathProvider::getResourcePath(const String& resource) const { + std::vector<boost::filesystem::path> resourcePaths = getResourceDirs(); + foreach(const boost::filesystem::path& resourcePath, resourcePaths) { + boost::filesystem::path r(resourcePath / resource.getUTF8String()); + if (boost::filesystem::exists(r)) { + return r; + } + } + return boost::filesystem::path(); +} + } diff --git a/Swiften/Application/ApplicationPathProvider.h b/Swiften/Application/ApplicationPathProvider.h index cf97299..e9c0864 100644 --- a/Swiften/Application/ApplicationPathProvider.h +++ b/Swiften/Application/ApplicationPathProvider.h @@ -7,6 +7,7 @@ #pragma once #include <boost/filesystem.hpp> +#include <vector> #include "Swiften/Base/String.h" @@ -22,8 +23,10 @@ namespace Swift { virtual boost::filesystem::path getSettingsDir() const = 0; virtual boost::filesystem::path getExecutableDir() const = 0; boost::filesystem::path getProfileDir(const String& profile) const; + boost::filesystem::path getResourcePath(const String& resource) const; protected: + virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0; const String& getApplicationName() const { return applicationName; } diff --git a/Swiften/Application/MacOSXApplicationPathProvider.cpp b/Swiften/Application/MacOSXApplicationPathProvider.cpp index e4b17da..08ce885 100644 --- a/Swiften/Application/MacOSXApplicationPathProvider.cpp +++ b/Swiften/Application/MacOSXApplicationPathProvider.cpp @@ -14,6 +14,8 @@ namespace Swift { MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { + resourceDirs.push_back(getExecutableDir() / "../Resources"); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } boost::filesystem::path MacOSXApplicationPathProvider::getSettingsDir() const { diff --git a/Swiften/Application/MacOSXApplicationPathProvider.h b/Swiften/Application/MacOSXApplicationPathProvider.h index e03c753..72cfb38 100644 --- a/Swiften/Application/MacOSXApplicationPathProvider.h +++ b/Swiften/Application/MacOSXApplicationPathProvider.h @@ -16,5 +16,12 @@ namespace Swift { virtual boost::filesystem::path getHomeDir() const; boost::filesystem::path getSettingsDir() const; virtual boost::filesystem::path getExecutableDir() const; + + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } + + private: + std::vector<boost::filesystem::path> resourceDirs; }; } diff --git a/Swiften/Application/UnixApplicationPathProvider.h b/Swiften/Application/UnixApplicationPathProvider.h index 50cd4be..676cb94 100644 --- a/Swiften/Application/UnixApplicationPathProvider.h +++ b/Swiften/Application/UnixApplicationPathProvider.h @@ -17,6 +17,8 @@ namespace Swift { class UnixApplicationPathProvider : public ApplicationPathProvider { public: UnixApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { + resourceDirs.push_back("/usr/share/swift"); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } virtual boost::filesystem::path getHomeDir() const { @@ -46,6 +48,13 @@ namespace Swift { return boost::filesystem::path(); } } + + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } + + private: + std::vector<boost::filesystem::path> resourceDirs; }; } diff --git a/Swiften/Application/WindowsApplicationPathProvider.cpp b/Swiften/Application/WindowsApplicationPathProvider.cpp index 2e84e90..e02da1e 100644 --- a/Swiften/Application/WindowsApplicationPathProvider.cpp +++ b/Swiften/Application/WindowsApplicationPathProvider.cpp @@ -13,6 +13,8 @@ namespace Swift { WindowsApplicationPathProvider::WindowsApplicationPathProvider(const String& name) : ApplicationPathProvider(name) { + resourceDirs.push_back(getExecutableDir()); + resourceDirs.push_back(getExecutableDir() / "../resources"); // Development } boost::filesystem::path WindowsApplicationPathProvider::getExecutableDir() const { diff --git a/Swiften/Application/WindowsApplicationPathProvider.h b/Swiften/Application/WindowsApplicationPathProvider.h index 1ba4298..1879300 100644 --- a/Swiften/Application/WindowsApplicationPathProvider.h +++ b/Swiften/Application/WindowsApplicationPathProvider.h @@ -28,5 +28,11 @@ namespace Swift { } virtual boost::filesystem::path getExecutableDir() const; + virtual std::vector<boost::filesystem::path> getResourceDirs() const { + return resourceDirs; + } + + private: + std::vector<boost::filesystem::path> resourceDirs; }; } |