summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Application/ApplicationPathProvider.cpp47
-rw-r--r--Swiften/Application/ApplicationPathProvider.h36
-rw-r--r--Swiften/Application/CocoaApplication.h19
-rw-r--r--Swiften/Application/CocoaApplication.mm24
-rw-r--r--Swiften/Application/MacOSXApplicationPathProvider.cpp49
-rw-r--r--Swiften/Application/MacOSXApplicationPathProvider.h27
-rw-r--r--Swiften/Application/PlatformApplicationPathProvider.h26
-rw-r--r--Swiften/Application/SConscript22
-rw-r--r--Swiften/Application/UnitTest/ApplicationPathProviderTest.cpp49
-rw-r--r--Swiften/Application/UnixApplicationPathProvider.cpp66
-rw-r--r--Swiften/Application/UnixApplicationPathProvider.h34
-rw-r--r--Swiften/Application/WindowsApplicationPathProvider.cpp27
-rw-r--r--Swiften/Application/WindowsApplicationPathProvider.h38
-rw-r--r--Swiften/SConscript4
14 files changed, 1 insertions, 467 deletions
diff --git a/Swiften/Application/ApplicationPathProvider.cpp b/Swiften/Application/ApplicationPathProvider.cpp
deleted file mode 100644
index 634f183..0000000
--- a/Swiften/Application/ApplicationPathProvider.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <boost/filesystem.hpp>
-#include <iostream>
-
-#include "Swiften/Application/ApplicationPathProvider.h"
-#include "Swiften/Base/foreach.h"
-
-namespace Swift {
-
-ApplicationPathProvider::ApplicationPathProvider(const String& applicationName) : applicationName(applicationName) {
-}
-
-ApplicationPathProvider::~ApplicationPathProvider() {
-}
-
-boost::filesystem::path ApplicationPathProvider::getAvatarDir() const {
- return getDataDir() / "avatars";
-}
-
-boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& profile) const {
- boost::filesystem::path result(getHomeDir() / profile.getUTF8String());
- try {
- boost::filesystem::create_directory(result);
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- 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
deleted file mode 100644
index 7bd2630..0000000
--- a/Swiften/Application/ApplicationPathProvider.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <boost/filesystem.hpp>
-#include <vector>
-
-#include "Swiften/Base/String.h"
-
-namespace Swift {
- class ApplicationPathProvider {
- public:
- ApplicationPathProvider(const String& applicationName);
- virtual ~ApplicationPathProvider();
-
- boost::filesystem::path getAvatarDir() const;
- virtual boost::filesystem::path getHomeDir() const = 0;
- virtual boost::filesystem::path getDataDir() 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;
- }
-
- private:
- String applicationName;
- };
-}
diff --git a/Swiften/Application/CocoaApplication.h b/Swiften/Application/CocoaApplication.h
deleted file mode 100644
index 3b19d28..0000000
--- a/Swiften/Application/CocoaApplication.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-namespace Swift {
- class CocoaApplication {
- public:
- CocoaApplication();
- ~CocoaApplication();
-
- private:
- class Private;
- Private* d;
- };
-}
diff --git a/Swiften/Application/CocoaApplication.mm b/Swiften/Application/CocoaApplication.mm
deleted file mode 100644
index c5b3335..0000000
--- a/Swiften/Application/CocoaApplication.mm
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "Swiften/Application/CocoaApplication.h"
-
-#include <AppKit/AppKit.h>
-#include <Cocoa/Cocoa.h>
-
-namespace Swift {
-
-class CocoaApplication::Private {
- public:
- NSAutoreleasePool* autoReleasePool_;
-};
-
-CocoaApplication::CocoaApplication() {
- d = new CocoaApplication::Private();
- NSApplicationLoad();
- d->autoReleasePool_ = [[NSAutoreleasePool alloc] init];
-}
-
-CocoaApplication::~CocoaApplication() {
- [d->autoReleasePool_ release];
- delete d;
-}
-
-}
diff --git a/Swiften/Application/MacOSXApplicationPathProvider.cpp b/Swiften/Application/MacOSXApplicationPathProvider.cpp
deleted file mode 100644
index 8ff4cb3..0000000
--- a/Swiften/Application/MacOSXApplicationPathProvider.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/Application/MacOSXApplicationPathProvider.h"
-
-#include <iostream>
-#include <mach-o/dyld.h>
-
-#include "Swiften/Base/ByteArray.h"
-
-namespace Swift {
-
-MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
- resourceDirs.push_back(getExecutableDir() / "../Resources");
- resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
-}
-
-boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const {
- boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName().getUTF8String());
- try {
- boost::filesystem::create_directory(result);
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- return result;
-}
-
-boost::filesystem::path MacOSXApplicationPathProvider::getHomeDir() const {
- return boost::filesystem::path(getenv("HOME"));
-}
-
-
-boost::filesystem::path MacOSXApplicationPathProvider::getExecutableDir() const {
- ByteArray path;
- uint32_t size = 4096;
- path.resize(size);
- if (_NSGetExecutablePath(path.getData(), &size) == 0) {
- return boost::filesystem::path(path.toString().getUTF8Data()).parent_path();
- }
- else {
- return boost::filesystem::path();
- }
-}
-
-}
diff --git a/Swiften/Application/MacOSXApplicationPathProvider.h b/Swiften/Application/MacOSXApplicationPathProvider.h
deleted file mode 100644
index 85cca0a..0000000
--- a/Swiften/Application/MacOSXApplicationPathProvider.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Application/ApplicationPathProvider.h"
-
-namespace Swift {
- class MacOSXApplicationPathProvider : public ApplicationPathProvider {
- public:
- MacOSXApplicationPathProvider(const String& name);
-
- virtual boost::filesystem::path getHomeDir() const;
- boost::filesystem::path getDataDir() 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/PlatformApplicationPathProvider.h b/Swiften/Application/PlatformApplicationPathProvider.h
deleted file mode 100644
index e59bb9a..0000000
--- a/Swiften/Application/PlatformApplicationPathProvider.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Base/Platform.h"
-
-#if defined(SWIFTEN_PLATFORM_MACOSX)
-#include "Swiften/Application/MacOSXApplicationPathProvider.h"
-namespace Swift {
- typedef MacOSXApplicationPathProvider PlatformApplicationPathProvider;
-}
-#elif defined(SWIFTEN_PLATFORM_WIN32)
-#include "Swiften/Application/WindowsApplicationPathProvider.h"
-namespace Swift {
- typedef WindowsApplicationPathProvider PlatformApplicationPathProvider;
-}
-#else
-#include "Swiften/Application/UnixApplicationPathProvider.h"
-namespace Swift {
- typedef UnixApplicationPathProvider PlatformApplicationPathProvider;
-}
-#endif
diff --git a/Swiften/Application/SConscript b/Swiften/Application/SConscript
deleted file mode 100644
index d3a2383..0000000
--- a/Swiften/Application/SConscript
+++ /dev/null
@@ -1,22 +0,0 @@
-Import("swiften_env")
-
-sources = [
- "ApplicationPathProvider.cpp",
- ]
-
-if swiften_env["PLATFORM"] == "darwin" and swiften_env["target"] == "native" :
- sources += [
- "CocoaApplication.mm",
- "MacOSXApplicationPathProvider.cpp",
- ]
-elif swiften_env["PLATFORM"] == "win32" :
- sources += [
- "WindowsApplicationPathProvider.cpp"
- ]
-else :
- sources += [
- "UnixApplicationPathProvider.cpp"
- ]
-
-objects = swiften_env.StaticObject(sources)
-swiften_env.Append(SWIFTEN_OBJECTS = [objects])
diff --git a/Swiften/Application/UnitTest/ApplicationPathProviderTest.cpp b/Swiften/Application/UnitTest/ApplicationPathProviderTest.cpp
deleted file mode 100644
index 3b46e6e..0000000
--- a/Swiften/Application/UnitTest/ApplicationPathProviderTest.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-
-#include "Swiften/Application/PlatformApplicationPathProvider.h"
-#include "Swiften/Base/String.h"
-
-using namespace Swift;
-
-class ApplicationPathProviderTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ApplicationPathProviderTest);
- CPPUNIT_TEST(testGetDataDir);
- CPPUNIT_TEST(testGetExecutableDir);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- testling_ = new PlatformApplicationPathProvider("SwiftTest");
- }
-
- void tearDown() {
- delete testling_;
- }
-
- void testGetDataDir() {
- boost::filesystem::path dir = testling_->getDataDir();
-
- CPPUNIT_ASSERT(boost::filesystem::exists(dir));
- CPPUNIT_ASSERT(boost::filesystem::is_directory(dir));
-
- boost::filesystem::remove(dir);
- }
-
- void testGetExecutableDir() {
- boost::filesystem::path dir = testling_->getExecutableDir();
- CPPUNIT_ASSERT(boost::filesystem::is_directory(dir));
- CPPUNIT_ASSERT(String(dir.string()).endsWith("UnitTest"));
- }
-
- private:
- ApplicationPathProvider* testling_;
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ApplicationPathProviderTest);
diff --git a/Swiften/Application/UnixApplicationPathProvider.cpp b/Swiften/Application/UnixApplicationPathProvider.cpp
deleted file mode 100644
index b474ecf..0000000
--- a/Swiften/Application/UnixApplicationPathProvider.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/Application/UnixApplicationPathProvider.h"
-
-#include <boost/filesystem/convenience.hpp>
-
-namespace Swift {
-
-UnixApplicationPathProvider::UnixApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
- resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
- char* xdgDataDirs = getenv("XDG_DATA_DIRS");
- if (xdgDataDirs) {
- std::vector<String> dataDirs = String(xdgDataDirs).split(':');
- if (!dataDirs.empty()) {
- foreach(const String& dir, dataDirs) {
- resourceDirs.push_back(boost::filesystem::path(dir.getUTF8String()) / "swift");
- }
- return;
- }
- }
- resourceDirs.push_back("/usr/local/share/swift");
- resourceDirs.push_back("/usr/share/swift");
-}
-
-boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const {
- return boost::filesystem::path(getenv("HOME"));
-}
-
-boost::filesystem::path UnixApplicationPathProvider::getDataDir() const {
- char* xdgDataHome = getenv("XDG_DATA_HOME");
- String dataDir;
- if (xdgDataHome) {
- dataDir = String(xdgDataHome);
- }
-
- boost::filesystem::path dataPath = (dataDir.isEmpty() ?
- getHomeDir() / ".local" / "share"
- : boost::filesystem::path(dataDir.getUTF8String())) / getApplicationName().getLowerCase().getUTF8String();
-
- try {
- boost::filesystem::create_directories(dataPath);
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- return dataPath;
-}
-
-boost::filesystem::path UnixApplicationPathProvider::getExecutableDir() const {
- ByteArray path;
- path.resize(4096);
- size_t size = readlink("/proc/self/exe", path.getData(), path.getSize());
- if (size > 0) {
- path.resize(size);
- return boost::filesystem::path(path.toString().getUTF8Data()).parent_path();
- }
- else {
- return boost::filesystem::path();
- }
-}
-
-}
diff --git a/Swiften/Application/UnixApplicationPathProvider.h b/Swiften/Application/UnixApplicationPathProvider.h
deleted file mode 100644
index c1bfd95..0000000
--- a/Swiften/Application/UnixApplicationPathProvider.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Application/ApplicationPathProvider.h"
-
-#include <iostream>
-#include <unistd.h>
-
-#include "Swiften/Base/ByteArray.h"
-#include "Swiften/Base/foreach.h"
-
-namespace Swift {
- class UnixApplicationPathProvider : public ApplicationPathProvider {
- public:
- UnixApplicationPathProvider(const String& name);
-
- virtual boost::filesystem::path getHomeDir() const;
- boost::filesystem::path getDataDir() 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/WindowsApplicationPathProvider.cpp b/Swiften/Application/WindowsApplicationPathProvider.cpp
deleted file mode 100644
index e02da1e..0000000
--- a/Swiften/Application/WindowsApplicationPathProvider.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/Application/WindowsApplicationPathProvider.h"
-
-#include <windows.h>
-
-#include "Swiften/Base/ByteArray.h"
-
-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 {
- ByteArray data;
- data.resize(2048);
- GetModuleFileName(NULL, data.getData(), data.getSize());
- return boost::filesystem::path(data.toString().getUTF8Data()).parent_path();
-}
-
-}
diff --git a/Swiften/Application/WindowsApplicationPathProvider.h b/Swiften/Application/WindowsApplicationPathProvider.h
deleted file mode 100644
index a026dba..0000000
--- a/Swiften/Application/WindowsApplicationPathProvider.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Application/ApplicationPathProvider.h"
-
-namespace Swift {
- class WindowsApplicationPathProvider : public ApplicationPathProvider {
- public:
- WindowsApplicationPathProvider(const String& name);
-
- boost::filesystem::path getDataDir() const {
- char* appDirRaw = getenv("APPDATA");
- boost::filesystem::path result(boost::filesystem::path(appDirRaw) / getApplicationName().getUTF8String());
- boost::filesystem::create_directory(result);
- return result;
- }
-
- boost::filesystem::path getHomeDir() const {
- //FIXME: This should be My Documents
-
- char* homeDirRaw = getenv("USERPROFILE");
- return boost::filesystem::path(homeDirRaw);
- }
-
- 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/SConscript b/Swiften/SConscript
index 7665fb0..ace9ab7 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -120,7 +120,6 @@ if env["SCONS_STAGE"] == "build" :
"Base",
"StringPrep",
"SASL",
- "Application",
"EventLoop",
"Parser",
"JID",
@@ -142,7 +141,6 @@ if env["SCONS_STAGE"] == "build" :
myenv.StaticLibrary("Swiften", sources + swiften_env["SWIFTEN_OBJECTS"])
env.Append(UNITTEST_SOURCES = [
- File("Application/UnitTest/ApplicationPathProviderTest.cpp"),
File("Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp"),
File("Avatars/UnitTest/VCardAvatarManagerTest.cpp"),
File("Avatars/UnitTest/CombinedAvatarProviderTest.cpp"),
@@ -261,4 +259,4 @@ if env["SCONS_STAGE"] == "build" :
swiften_header += "#include \"" + os.path.relpath(os.path.join(root, file), top_path) + "\"\n"
for file in ["EventLoop/SimpleEventLoop.h"] :
swiften_header += "#include \"Swiften/" + file + "\"\n"
- swiften_env.WriteVal("Swiften.h", swiften_env.Value(swiften_header)) \ No newline at end of file
+ swiften_env.WriteVal("Swiften.h", swiften_env.Value(swiften_header))