summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /SwifTools
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'SwifTools')
-rw-r--r--SwifTools/Application/ApplicationPathProvider.cpp34
-rw-r--r--SwifTools/Application/ApplicationPathProvider.h34
-rw-r--r--SwifTools/Application/CocoaApplication.h16
-rw-r--r--SwifTools/Application/CocoaApplication.mm14
-rw-r--r--SwifTools/Application/MacOSXApplicationPathProvider.cpp22
-rw-r--r--SwifTools/Application/MacOSXApplicationPathProvider.h22
-rw-r--r--SwifTools/Application/PlatformApplicationPathProvider.h6
-rw-r--r--SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp62
-rw-r--r--SwifTools/Application/UnixApplicationPathProvider.cpp62
-rw-r--r--SwifTools/Application/UnixApplicationPathProvider.h22
-rw-r--r--SwifTools/Application/WindowsApplicationPathProvider.cpp24
-rw-r--r--SwifTools/Application/WindowsApplicationPathProvider.h22
-rw-r--r--SwifTools/AutoUpdater/AutoUpdater.h10
-rw-r--r--SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp10
-rw-r--r--SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h12
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.h20
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.mm24
-rw-r--r--SwifTools/Cocoa/CocoaAction.mm18
-rw-r--r--SwifTools/Cocoa/CocoaUtil.h40
-rw-r--r--SwifTools/CrashReporter.cpp50
-rw-r--r--SwifTools/CrashReporter.h14
-rw-r--r--SwifTools/Dock/Dock.h12
-rw-r--r--SwifTools/Dock/MacOSXDock.h14
-rw-r--r--SwifTools/Dock/MacOSXDock.mm10
-rw-r--r--SwifTools/Dock/NullDock.h12
-rw-r--r--SwifTools/Dock/WindowsDock.h52
-rw-r--r--SwifTools/HunspellChecker.cpp52
-rw-r--r--SwifTools/HunspellChecker.h20
-rw-r--r--SwifTools/Idle/ActualIdleDetector.cpp16
-rw-r--r--SwifTools/Idle/ActualIdleDetector.h26
-rw-r--r--SwifTools/Idle/DummyIdleQuerier.h14
-rw-r--r--SwifTools/Idle/IdleDetector.h60
-rw-r--r--SwifTools/Idle/IdleQuerier.h10
-rw-r--r--SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp14
-rw-r--r--SwifTools/Idle/MacOSXIdleQuerier.cpp22
-rw-r--r--SwifTools/Idle/MacOSXIdleQuerier.h14
-rw-r--r--SwifTools/Idle/PlatformIdleQuerier.cpp12
-rw-r--r--SwifTools/Idle/PlatformIdleQuerier.h20
-rw-r--r--SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp296
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.cpp16
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.h10
-rw-r--r--SwifTools/Idle/XSSIdleQuerier.cpp38
-rw-r--r--SwifTools/Idle/XSSIdleQuerier.h22
-rw-r--r--SwifTools/LastLineTracker.cpp24
-rw-r--r--SwifTools/LastLineTracker.h18
-rw-r--r--SwifTools/Linkify.cpp160
-rw-r--r--SwifTools/Linkify.h28
-rw-r--r--SwifTools/MacOSXChecker.h16
-rw-r--r--SwifTools/MacOSXChecker.mm50
-rw-r--r--SwifTools/Notifier/GNTPNotifier.cpp88
-rw-r--r--SwifTools/Notifier/GNTPNotifier.h46
-rw-r--r--SwifTools/Notifier/GrowlNotifier.h54
-rw-r--r--SwifTools/Notifier/GrowlNotifier.mm130
-rw-r--r--SwifTools/Notifier/GrowlNotifierDelegate.h8
-rw-r--r--SwifTools/Notifier/GrowlNotifierDelegate.mm8
-rw-r--r--SwifTools/Notifier/LoggingNotifier.h32
-rw-r--r--SwifTools/Notifier/NotificationCenterNotifier.h22
-rw-r--r--SwifTools/Notifier/NotificationCenterNotifier.mm98
-rw-r--r--SwifTools/Notifier/NotificationCenterNotifierDelegate.h2
-rw-r--r--SwifTools/Notifier/NotificationCenterNotifierDelegate.mm6
-rw-r--r--SwifTools/Notifier/Notifier.cpp40
-rw-r--r--SwifTools/Notifier/Notifier.h70
-rw-r--r--SwifTools/Notifier/NullNotifier.h14
-rw-r--r--SwifTools/Notifier/SnarlNotifier.cpp74
-rw-r--r--SwifTools/Notifier/SnarlNotifier.h48
-rw-r--r--SwifTools/Notifier/TogglableNotifier.h100
-rw-r--r--SwifTools/Notifier/Win32NotifierWindow.h12
-rw-r--r--SwifTools/SpellChecker.h28
-rw-r--r--SwifTools/SpellCheckerFactory.cpp16
-rw-r--r--SwifTools/SpellCheckerFactory.h12
-rw-r--r--SwifTools/SpellParser.cpp76
-rw-r--r--SwifTools/SpellParser.h26
-rw-r--r--SwifTools/TabComplete.cpp60
-rw-r--r--SwifTools/TabComplete.h22
-rw-r--r--SwifTools/URIHandler/MacOSXURIHandler.h20
-rw-r--r--SwifTools/URIHandler/MacOSXURIHandler.mm54
-rw-r--r--SwifTools/URIHandler/NullURIHandler.h14
-rw-r--r--SwifTools/URIHandler/URIHandler.h12
-rw-r--r--SwifTools/URIHandler/UnitTest/XMPPURITest.cpp312
-rw-r--r--SwifTools/URIHandler/XMPPURI.cpp138
-rw-r--r--SwifTools/URIHandler/XMPPURI.h116
-rw-r--r--SwifTools/UnitTest/LastLineTrackerTest.cpp92
-rw-r--r--SwifTools/UnitTest/LinkifyTest.cpp448
-rw-r--r--SwifTools/UnitTest/SpellParserTest.cpp64
-rw-r--r--SwifTools/UnitTest/TabCompleteTest.cpp486
85 files changed, 2222 insertions, 2222 deletions
diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp
index ebe9654..3a86f28 100644
--- a/SwifTools/Application/ApplicationPathProvider.cpp
+++ b/SwifTools/Application/ApplicationPathProvider.cpp
@@ -22,29 +22,29 @@ ApplicationPathProvider::~ApplicationPathProvider() {
}
boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string& profile) const {
- boost::filesystem::path result(getHomeDir() / profile);
- 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 result(getHomeDir() / profile);
+ 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 std::string& resource) const {
- std::vector<boost::filesystem::path> resourcePaths = getResourceDirs();
- foreach(const boost::filesystem::path& resourcePath, resourcePaths) {
- boost::filesystem::path r(resourcePath / resource);
- if (boost::filesystem::exists(r)) {
- return r;
- }
- }
- return boost::filesystem::path();
+ std::vector<boost::filesystem::path> resourcePaths = getResourceDirs();
+ foreach(const boost::filesystem::path& resourcePath, resourcePaths) {
+ boost::filesystem::path r(resourcePath / resource);
+ if (boost::filesystem::exists(r)) {
+ return r;
+ }
+ }
+ return boost::filesystem::path();
}
boost::filesystem::path ApplicationPathProvider::getExecutableDir() const {
- return Paths::getExecutablePath();
+ return Paths::getExecutablePath();
}
}
diff --git a/SwifTools/Application/ApplicationPathProvider.h b/SwifTools/Application/ApplicationPathProvider.h
index aba9687..399ac5d 100644
--- a/SwifTools/Application/ApplicationPathProvider.h
+++ b/SwifTools/Application/ApplicationPathProvider.h
@@ -12,24 +12,24 @@
#include <boost/filesystem.hpp>
namespace Swift {
- class ApplicationPathProvider {
- public:
- ApplicationPathProvider(const std::string& applicationName);
- virtual ~ApplicationPathProvider();
+ class ApplicationPathProvider {
+ public:
+ ApplicationPathProvider(const std::string& applicationName);
+ virtual ~ApplicationPathProvider();
- virtual boost::filesystem::path getHomeDir() const = 0;
- virtual boost::filesystem::path getDataDir() const = 0;
- boost::filesystem::path getExecutableDir() const;
- boost::filesystem::path getProfileDir(const std::string& profile) const;
- boost::filesystem::path getResourcePath(const std::string& resource) const;
+ virtual boost::filesystem::path getHomeDir() const = 0;
+ virtual boost::filesystem::path getDataDir() const = 0;
+ boost::filesystem::path getExecutableDir() const;
+ boost::filesystem::path getProfileDir(const std::string& profile) const;
+ boost::filesystem::path getResourcePath(const std::string& resource) const;
- protected:
- virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0;
- const std::string& getApplicationName() const {
- return applicationName;
- }
+ protected:
+ virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0;
+ const std::string& getApplicationName() const {
+ return applicationName;
+ }
- private:
- std::string applicationName;
- };
+ private:
+ std::string applicationName;
+ };
}
diff --git a/SwifTools/Application/CocoaApplication.h b/SwifTools/Application/CocoaApplication.h
index 2653aca..a3e281c 100644
--- a/SwifTools/Application/CocoaApplication.h
+++ b/SwifTools/Application/CocoaApplication.h
@@ -7,13 +7,13 @@
#pragma once
namespace Swift {
- class CocoaApplication {
- public:
- CocoaApplication();
- ~CocoaApplication();
+ class CocoaApplication {
+ public:
+ CocoaApplication();
+ ~CocoaApplication();
- private:
- class Private;
- Private* d;
- };
+ private:
+ class Private;
+ Private* d;
+ };
}
diff --git a/SwifTools/Application/CocoaApplication.mm b/SwifTools/Application/CocoaApplication.mm
index cbb5f2e..f879014 100644
--- a/SwifTools/Application/CocoaApplication.mm
+++ b/SwifTools/Application/CocoaApplication.mm
@@ -6,19 +6,19 @@
namespace Swift {
class CocoaApplication::Private {
- public:
- NSAutoreleasePool* autoReleasePool_;
+ public:
+ NSAutoreleasePool* autoReleasePool_;
};
CocoaApplication::CocoaApplication() {
- d = new CocoaApplication::Private();
- NSApplicationLoad();
- d->autoReleasePool_ = [[NSAutoreleasePool alloc] init];
+ d = new CocoaApplication::Private();
+ NSApplicationLoad();
+ d->autoReleasePool_ = [[NSAutoreleasePool alloc] init];
}
CocoaApplication::~CocoaApplication() {
- [d->autoReleasePool_ release];
- delete d;
+ [d->autoReleasePool_ release];
+ delete d;
}
}
diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
index 2c35cbe..086bbaa 100644
--- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp
+++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
@@ -13,23 +13,23 @@
namespace Swift {
MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
- resourceDirs.push_back(getExecutableDir() / "../Resources");
- resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
+ 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());
- 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 result(getHomeDir() / "Library/Application Support" / getApplicationName());
+ 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"));
+ return boost::filesystem::path(getenv("HOME"));
}
}
diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.h b/SwifTools/Application/MacOSXApplicationPathProvider.h
index 93797bc..9d8f619 100644
--- a/SwifTools/Application/MacOSXApplicationPathProvider.h
+++ b/SwifTools/Application/MacOSXApplicationPathProvider.h
@@ -9,18 +9,18 @@
#include <SwifTools/Application/ApplicationPathProvider.h>
namespace Swift {
- class MacOSXApplicationPathProvider : public ApplicationPathProvider {
- public:
- MacOSXApplicationPathProvider(const std::string& name);
+ class MacOSXApplicationPathProvider : public ApplicationPathProvider {
+ public:
+ MacOSXApplicationPathProvider(const std::string& name);
- virtual boost::filesystem::path getHomeDir() const;
- boost::filesystem::path getDataDir() const;
+ virtual boost::filesystem::path getHomeDir() const;
+ boost::filesystem::path getDataDir() const;
- virtual std::vector<boost::filesystem::path> getResourceDirs() const {
- return resourceDirs;
- }
+ virtual std::vector<boost::filesystem::path> getResourceDirs() const {
+ return resourceDirs;
+ }
- private:
- std::vector<boost::filesystem::path> resourceDirs;
- };
+ private:
+ std::vector<boost::filesystem::path> resourceDirs;
+ };
}
diff --git a/SwifTools/Application/PlatformApplicationPathProvider.h b/SwifTools/Application/PlatformApplicationPathProvider.h
index d9400a4..5de91fe 100644
--- a/SwifTools/Application/PlatformApplicationPathProvider.h
+++ b/SwifTools/Application/PlatformApplicationPathProvider.h
@@ -11,16 +11,16 @@
#if defined(SWIFTEN_PLATFORM_MACOSX)
#include <SwifTools/Application/MacOSXApplicationPathProvider.h>
namespace Swift {
- typedef MacOSXApplicationPathProvider PlatformApplicationPathProvider;
+ typedef MacOSXApplicationPathProvider PlatformApplicationPathProvider;
}
#elif defined(SWIFTEN_PLATFORM_WIN32)
#include <SwifTools/Application/WindowsApplicationPathProvider.h>
namespace Swift {
- typedef WindowsApplicationPathProvider PlatformApplicationPathProvider;
+ typedef WindowsApplicationPathProvider PlatformApplicationPathProvider;
}
#else
#include <SwifTools/Application/UnixApplicationPathProvider.h>
namespace Swift {
- typedef UnixApplicationPathProvider PlatformApplicationPathProvider;
+ typedef UnixApplicationPathProvider PlatformApplicationPathProvider;
}
#endif
diff --git a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
index df59505..433b379 100644
--- a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
+++ b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
@@ -18,37 +18,37 @@
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(boost::ends_with(pathToString(dir), "UnitTest"));
- }
-
- private:
- ApplicationPathProvider* testling_;
+ 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(boost::ends_with(pathToString(dir), "UnitTest"));
+ }
+
+ private:
+ ApplicationPathProvider* testling_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ApplicationPathProviderTest);
diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp
index 0708bb2..c561d72 100644
--- a/SwifTools/Application/UnixApplicationPathProvider.cpp
+++ b/SwifTools/Application/UnixApplicationPathProvider.cpp
@@ -20,45 +20,45 @@
namespace Swift {
UnixApplicationPathProvider::UnixApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
- resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
- resourceDirs.push_back(getExecutableDir() / ".." / "share" / boost::to_lower_copy(getApplicationName())); // Local install
- char* xdgDataDirs = getenv("XDG_DATA_DIRS");
- if (xdgDataDirs) {
- std::vector<std::string> dataDirs = String::split(xdgDataDirs, ':');
- if (!dataDirs.empty()) {
- foreach(const std::string& dir, dataDirs) {
- resourceDirs.push_back(boost::filesystem::path(dir) / "swift");
- }
- return;
- }
- }
- resourceDirs.push_back("/usr/local/share/" + boost::to_lower_copy(getApplicationName()));
- resourceDirs.push_back("/usr/share/" + boost::to_lower_copy(getApplicationName()));
+ resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
+ resourceDirs.push_back(getExecutableDir() / ".." / "share" / boost::to_lower_copy(getApplicationName())); // Local install
+ char* xdgDataDirs = getenv("XDG_DATA_DIRS");
+ if (xdgDataDirs) {
+ std::vector<std::string> dataDirs = String::split(xdgDataDirs, ':');
+ if (!dataDirs.empty()) {
+ foreach(const std::string& dir, dataDirs) {
+ resourceDirs.push_back(boost::filesystem::path(dir) / "swift");
+ }
+ return;
+ }
+ }
+ resourceDirs.push_back("/usr/local/share/" + boost::to_lower_copy(getApplicationName()));
+ resourceDirs.push_back("/usr/share/" + boost::to_lower_copy(getApplicationName()));
}
boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const {
- char* home = getenv("HOME");
- return home ? boost::filesystem::path(home) : boost::filesystem::path();
+ char* home = getenv("HOME");
+ return home ? boost::filesystem::path(home) : boost::filesystem::path();
}
boost::filesystem::path UnixApplicationPathProvider::getDataDir() const {
- char* xdgDataHome = getenv("XDG_DATA_HOME");
- std::string dataDir;
- if (xdgDataHome) {
- dataDir = std::string(xdgDataHome);
- }
+ char* xdgDataHome = getenv("XDG_DATA_HOME");
+ std::string dataDir;
+ if (xdgDataHome) {
+ dataDir = std::string(xdgDataHome);
+ }
- boost::filesystem::path dataPath = (dataDir.empty() ?
- getHomeDir() / ".local" / "share"
- : boost::filesystem::path(dataDir)) / boost::to_lower_copy(getApplicationName());
+ boost::filesystem::path dataPath = (dataDir.empty() ?
+ getHomeDir() / ".local" / "share"
+ : boost::filesystem::path(dataDir)) / boost::to_lower_copy(getApplicationName());
- try {
- boost::filesystem::create_directories(dataPath);
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- return dataPath;
+ try {
+ boost::filesystem::create_directories(dataPath);
+ }
+ catch (const boost::filesystem::filesystem_error& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ }
+ return dataPath;
}
}
diff --git a/SwifTools/Application/UnixApplicationPathProvider.h b/SwifTools/Application/UnixApplicationPathProvider.h
index 96f4955..9e27a93 100644
--- a/SwifTools/Application/UnixApplicationPathProvider.h
+++ b/SwifTools/Application/UnixApplicationPathProvider.h
@@ -9,19 +9,19 @@
#include <SwifTools/Application/ApplicationPathProvider.h>
namespace Swift {
- class UnixApplicationPathProvider : public ApplicationPathProvider {
- public:
- UnixApplicationPathProvider(const std::string& name);
+ class UnixApplicationPathProvider : public ApplicationPathProvider {
+ public:
+ UnixApplicationPathProvider(const std::string& name);
- virtual boost::filesystem::path getHomeDir() const;
- boost::filesystem::path getDataDir() const;
+ virtual boost::filesystem::path getHomeDir() const;
+ boost::filesystem::path getDataDir() const;
- virtual std::vector<boost::filesystem::path> getResourceDirs() const {
- return resourceDirs;
- }
+ virtual std::vector<boost::filesystem::path> getResourceDirs() const {
+ return resourceDirs;
+ }
- private:
- std::vector<boost::filesystem::path> resourceDirs;
- };
+ private:
+ std::vector<boost::filesystem::path> resourceDirs;
+ };
}
diff --git a/SwifTools/Application/WindowsApplicationPathProvider.cpp b/SwifTools/Application/WindowsApplicationPathProvider.cpp
index 0b0c9cf..e90214c 100644
--- a/SwifTools/Application/WindowsApplicationPathProvider.cpp
+++ b/SwifTools/Application/WindowsApplicationPathProvider.cpp
@@ -15,24 +15,24 @@
namespace Swift {
WindowsApplicationPathProvider::WindowsApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
- resourceDirs.push_back(getExecutableDir());
- resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
+ resourceDirs.push_back(getExecutableDir());
+ resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
}
boost::filesystem::path WindowsApplicationPathProvider::getDataDir() const {
- wchar_t* appDirRaw = _wgetenv(L"APPDATA");
- assert(appDirRaw);
- boost::filesystem::path result(
- boost::filesystem::path(appDirRaw) / getApplicationName());
- boost::filesystem::create_directory(result);
- return result;
+ wchar_t* appDirRaw = _wgetenv(L"APPDATA");
+ assert(appDirRaw);
+ boost::filesystem::path result(
+ boost::filesystem::path(appDirRaw) / getApplicationName());
+ boost::filesystem::create_directory(result);
+ return result;
}
boost::filesystem::path WindowsApplicationPathProvider::getHomeDir() const {
- //FIXME: This should be My Documents
- wchar_t* homeDirRaw = _wgetenv(L"USERPROFILE");
- assert(homeDirRaw);
- return boost::filesystem::path(homeDirRaw);
+ //FIXME: This should be My Documents
+ wchar_t* homeDirRaw = _wgetenv(L"USERPROFILE");
+ assert(homeDirRaw);
+ return boost::filesystem::path(homeDirRaw);
}
diff --git a/SwifTools/Application/WindowsApplicationPathProvider.h b/SwifTools/Application/WindowsApplicationPathProvider.h
index 6d0f5bd..bf8dada 100644
--- a/SwifTools/Application/WindowsApplicationPathProvider.h
+++ b/SwifTools/Application/WindowsApplicationPathProvider.h
@@ -9,18 +9,18 @@
#include <SwifTools/Application/ApplicationPathProvider.h>
namespace Swift {
- class WindowsApplicationPathProvider : public ApplicationPathProvider {
- public:
- WindowsApplicationPathProvider(const std::string& name);
+ class WindowsApplicationPathProvider : public ApplicationPathProvider {
+ public:
+ WindowsApplicationPathProvider(const std::string& name);
- boost::filesystem::path getDataDir() const;
- boost::filesystem::path getHomeDir() const;
+ boost::filesystem::path getDataDir() const;
+ boost::filesystem::path getHomeDir() const;
- virtual std::vector<boost::filesystem::path> getResourceDirs() const {
- return resourceDirs;
- }
+ virtual std::vector<boost::filesystem::path> getResourceDirs() const {
+ return resourceDirs;
+ }
- private:
- std::vector<boost::filesystem::path> resourceDirs;
- };
+ private:
+ std::vector<boost::filesystem::path> resourceDirs;
+ };
}
diff --git a/SwifTools/AutoUpdater/AutoUpdater.h b/SwifTools/AutoUpdater/AutoUpdater.h
index 12abc22..dec85c9 100644
--- a/SwifTools/AutoUpdater/AutoUpdater.h
+++ b/SwifTools/AutoUpdater/AutoUpdater.h
@@ -7,10 +7,10 @@
#pragma once
namespace Swift {
- class AutoUpdater {
- public:
- virtual ~AutoUpdater();
+ class AutoUpdater {
+ public:
+ virtual ~AutoUpdater();
- virtual void checkForUpdates() = 0;
- };
+ virtual void checkForUpdates() = 0;
+ };
}
diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
index 424c6e0..f693224 100644
--- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
+++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
@@ -16,18 +16,18 @@ namespace Swift {
bool PlatformAutoUpdaterFactory::isSupported() const {
#ifdef HAVE_SPARKLE
- return true;
+ return true;
#else
- return false;
+ return false;
#endif
}
AutoUpdater* PlatformAutoUpdaterFactory::createAutoUpdater(const std::string& appcastURL) {
#ifdef HAVE_SPARKLE
- return new SparkleAutoUpdater(appcastURL);
+ return new SparkleAutoUpdater(appcastURL);
#else
- (void) appcastURL;
- return NULL;
+ (void) appcastURL;
+ return NULL;
#endif
}
diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
index 24a2f21..9942d6a 100644
--- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
+++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
@@ -7,12 +7,12 @@
#include <string>
namespace Swift {
- class AutoUpdater;
+ class AutoUpdater;
- class PlatformAutoUpdaterFactory {
- public:
- bool isSupported() const;
+ class PlatformAutoUpdaterFactory {
+ public:
+ bool isSupported() const;
- AutoUpdater* createAutoUpdater(const std::string& appcastURL);
- };
+ AutoUpdater* createAutoUpdater(const std::string& appcastURL);
+ };
}
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.h b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
index 351d075..95ca35e 100644
--- a/SwifTools/AutoUpdater/SparkleAutoUpdater.h
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
@@ -11,15 +11,15 @@
#include <SwifTools/AutoUpdater/AutoUpdater.h>
namespace Swift {
- class SparkleAutoUpdater : public AutoUpdater {
- public:
- SparkleAutoUpdater(const std::string& url);
- ~SparkleAutoUpdater();
+ class SparkleAutoUpdater : public AutoUpdater {
+ public:
+ SparkleAutoUpdater(const std::string& url);
+ ~SparkleAutoUpdater();
- void checkForUpdates();
-
- private:
- class Private;
- Private* d;
- };
+ void checkForUpdates();
+
+ private:
+ class Private;
+ Private* d;
+ };
}
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
index c35abc8..bcd1388 100644
--- a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
@@ -6,29 +6,29 @@
namespace Swift {
class SparkleAutoUpdater::Private {
- public:
- SUUpdater* updater;
+ public:
+ SUUpdater* updater;
};
SparkleAutoUpdater::SparkleAutoUpdater(const std::string& url) {
- d = new Private;
+ d = new Private;
- d->updater = [SUUpdater sharedUpdater];
- [d->updater retain];
- [d->updater setAutomaticallyChecksForUpdates: true];
+ d->updater = [SUUpdater sharedUpdater];
+ [d->updater retain];
+ [d->updater setAutomaticallyChecksForUpdates: true];
- NSURL* nsurl = [NSURL URLWithString:
- [NSString stringWithUTF8String: url.c_str()]];
- [d->updater setFeedURL: nsurl];
+ NSURL* nsurl = [NSURL URLWithString:
+ [NSString stringWithUTF8String: url.c_str()]];
+ [d->updater setFeedURL: nsurl];
}
SparkleAutoUpdater::~SparkleAutoUpdater() {
- [d->updater release];
- delete d;
+ [d->updater release];
+ delete d;
}
void SparkleAutoUpdater::checkForUpdates() {
- [d->updater checkForUpdatesInBackground];
+ [d->updater checkForUpdatesInBackground];
}
}
diff --git a/SwifTools/Cocoa/CocoaAction.mm b/SwifTools/Cocoa/CocoaAction.mm
index 6daba2e..341da2c 100644
--- a/SwifTools/Cocoa/CocoaAction.mm
+++ b/SwifTools/Cocoa/CocoaAction.mm
@@ -7,24 +7,24 @@
#include <SwifTools/Cocoa/CocoaAction.h>
@implementation CocoaAction {
- boost::function<void ()>* function;
+ boost::function<void ()>* function;
}
- (id) initWithFunction: (boost::function<void()>*) f {
- if ((self = [super init])) {
- function = f;
- }
- return self;
+ if ((self = [super init])) {
+ function = f;
+ }
+ return self;
}
- (void) dealloc {
- delete function;
- [super dealloc];
+ delete function;
+ [super dealloc];
}
- (void) doAction: (id) sender {
- (void) sender;
- (*function)();
+ (void) sender;
+ (*function)();
}
@end
diff --git a/SwifTools/Cocoa/CocoaUtil.h b/SwifTools/Cocoa/CocoaUtil.h
index 83d95b6..8c4dd64 100644
--- a/SwifTools/Cocoa/CocoaUtil.h
+++ b/SwifTools/Cocoa/CocoaUtil.h
@@ -11,37 +11,37 @@ namespace {
inline std::string ns2StdString(NSString* _Nullable nsString);
inline std::string ns2StdString(NSString* _Nullable nsString) {
- std::string stdString;
- if (nsString != nil) {
- stdString = std::string([nsString cStringUsingEncoding:NSUTF8StringEncoding]);
- }
- return stdString;
+ std::string stdString;
+ if (nsString != nil) {
+ stdString = std::string([nsString cStringUsingEncoding:NSUTF8StringEncoding]);
+ }
+ return stdString;
}
inline NSString* _Nonnull std2NSString(const std::string& stdString);
inline NSString* _Nonnull std2NSString(const std::string& stdString) {
- NSString* _Nullable nsString = [NSString stringWithUTF8String:stdString.c_str()];
- if (nsString == nil) {
- nsString = @"";
- }
- // At this point nsString is guaranteed to be not null/nil.
- return static_cast<NSString* _Nonnull>(nsString);
+ NSString* _Nullable nsString = [NSString stringWithUTF8String:stdString.c_str()];
+ if (nsString == nil) {
+ nsString = @"";
+ }
+ // At this point nsString is guaranteed to be not null/nil.
+ return static_cast<NSString* _Nonnull>(nsString);
}
}
// Intrusive pointer for NSObjects
-namespace boost {
- inline void intrusive_ptr_add_ref(NSObject* _Nonnull object) {
- [object retain];
- }
-
- inline void intrusive_ptr_release(NSObject* _Nonnull object) {
- [object release];
- }
+namespace boost {
+ inline void intrusive_ptr_add_ref(NSObject* _Nonnull object) {
+ [object retain];
+ }
+
+ inline void intrusive_ptr_release(NSObject* _Nonnull object) {
+ [object release];
+ }
}
-// Including intrusive_ptr after ref/release methods to avoid compilation
+// Including intrusive_ptr after ref/release methods to avoid compilation
// errors with CLang
#include <boost/intrusive_ptr.hpp>
diff --git a/SwifTools/CrashReporter.cpp b/SwifTools/CrashReporter.cpp
index 35db605..b401e76 100644
--- a/SwifTools/CrashReporter.cpp
+++ b/SwifTools/CrashReporter.cpp
@@ -24,46 +24,46 @@
#if defined(SWIFTEN_PLATFORM_WINDOWS)
static bool handleDump(const wchar_t* /* dir */, const wchar_t* /* id*/, void* /* context */, EXCEPTION_POINTERS*, MDRawAssertionInfo*, bool /* succeeded */) {
- return false;
+ return false;
}
#else
static bool handleDump(const char* /* dir */, const char* /* id*/, void* /* context */, bool /* succeeded */) {
- return false;
+ return false;
}
#endif
namespace Swift {
struct CrashReporter::Private {
- boost::shared_ptr<google_breakpad::ExceptionHandler> handler;
+ boost::shared_ptr<google_breakpad::ExceptionHandler> handler;
};
CrashReporter::CrashReporter(const boost::filesystem::path& path) {
- // Create the path that will contain the crash dumps
- if (!boost::filesystem::exists(path)) {
- try {
- boost::filesystem::create_directories(path);
- }
- catch (const boost::filesystem::filesystem_error& e) {
- SWIFT_LOG(error) << "ERROR: " << e.what() << std::endl;
- }
- }
+ // Create the path that will contain the crash dumps
+ if (!boost::filesystem::exists(path)) {
+ try {
+ boost::filesystem::create_directories(path);
+ }
+ catch (const boost::filesystem::filesystem_error& e) {
+ SWIFT_LOG(error) << "ERROR: " << e.what() << std::endl;
+ }
+ }
- p = boost::make_shared<Private>();
+ p = boost::make_shared<Private>();
#if defined(SWIFTEN_PLATFORM_WINDOWS)
- // FIXME: Need UTF8 conversion from string to wstring
- std::string pathString = pathToString(path);
- p->handler = boost::shared_ptr<google_breakpad::ExceptionHandler>(
- // Not using make_shared, because 'handleDump' seems to have problems with VC2010
- new google_breakpad::ExceptionHandler(
- std::wstring(pathString.begin(), pathString.end()),
- (google_breakpad::ExceptionHandler::FilterCallback) 0,
- handleDump,
- (void*) 0,
- google_breakpad::ExceptionHandler::HANDLER_ALL));
+ // FIXME: Need UTF8 conversion from string to wstring
+ std::string pathString = pathToString(path);
+ p->handler = boost::shared_ptr<google_breakpad::ExceptionHandler>(
+ // Not using make_shared, because 'handleDump' seems to have problems with VC2010
+ new google_breakpad::ExceptionHandler(
+ std::wstring(pathString.begin(), pathString.end()),
+ (google_breakpad::ExceptionHandler::FilterCallback) 0,
+ handleDump,
+ (void*) 0,
+ google_breakpad::ExceptionHandler::HANDLER_ALL));
// Turning it off for Mac, because it doesn't really help us
//#elif defined(SWIFTEN_PLATFORM_MACOSX)
-// p->handler = boost::make_shared<google_breakpad::ExceptionHandler>(pathToString(path), (google_breakpad::ExceptionHandler::FilterCallback) 0, handleDump, (void*) 0, true, (const char*) 0);
+// p->handler = boost::make_shared<google_breakpad::ExceptionHandler>(pathToString(path), (google_breakpad::ExceptionHandler::FilterCallback) 0, handleDump, (void*) 0, true, (const char*) 0);
#endif
}
@@ -73,7 +73,7 @@ CrashReporter::CrashReporter(const boost::filesystem::path& path) {
// Dummy implementation
namespace Swift {
- CrashReporter::CrashReporter(const boost::filesystem::path&) {}
+ CrashReporter::CrashReporter(const boost::filesystem::path&) {}
}
#endif
diff --git a/SwifTools/CrashReporter.h b/SwifTools/CrashReporter.h
index cce6c43..ee71223 100644
--- a/SwifTools/CrashReporter.h
+++ b/SwifTools/CrashReporter.h
@@ -12,12 +12,12 @@
#include <boost/shared_ptr.hpp>
namespace Swift {
- class CrashReporter {
- public:
- CrashReporter(const boost::filesystem::path& path);
+ class CrashReporter {
+ public:
+ CrashReporter(const boost::filesystem::path& path);
- private:
- struct Private;
- boost::shared_ptr<Private> p;
- };
+ private:
+ struct Private;
+ boost::shared_ptr<Private> p;
+ };
}
diff --git a/SwifTools/Dock/Dock.h b/SwifTools/Dock/Dock.h
index cf7ee5f..6120445 100644
--- a/SwifTools/Dock/Dock.h
+++ b/SwifTools/Dock/Dock.h
@@ -7,12 +7,12 @@
#pragma once
namespace Swift {
-
- class Dock {
- public:
- virtual ~Dock();
- virtual void setNumberOfPendingMessages(int i) = 0;
- };
+ class Dock {
+ public:
+ virtual ~Dock();
+
+ virtual void setNumberOfPendingMessages(int i) = 0;
+ };
}
diff --git a/SwifTools/Dock/MacOSXDock.h b/SwifTools/Dock/MacOSXDock.h
index 60347fb..6b33506 100644
--- a/SwifTools/Dock/MacOSXDock.h
+++ b/SwifTools/Dock/MacOSXDock.h
@@ -9,13 +9,13 @@
#include <SwifTools/Dock/Dock.h>
namespace Swift {
-
- class CocoaApplication;
- class MacOSXDock : public Dock {
- public:
- MacOSXDock(CocoaApplication* application);
+ class CocoaApplication;
- virtual void setNumberOfPendingMessages(int i);
- };
+ class MacOSXDock : public Dock {
+ public:
+ MacOSXDock(CocoaApplication* application);
+
+ virtual void setNumberOfPendingMessages(int i);
+ };
}
diff --git a/SwifTools/Dock/MacOSXDock.mm b/SwifTools/Dock/MacOSXDock.mm
index f231e9a..5c7207c 100644
--- a/SwifTools/Dock/MacOSXDock.mm
+++ b/SwifTools/Dock/MacOSXDock.mm
@@ -19,11 +19,11 @@ MacOSXDock::MacOSXDock(CocoaApplication*) {
}
void MacOSXDock::setNumberOfPendingMessages(int i) {
- std::string label(i > 0 ? boost::lexical_cast<std::string>(i) : "");
- NSString *labelString = [[NSString alloc] initWithUTF8String: label.c_str()];
- [[NSApp dockTile] setBadgeLabel: labelString];
- [labelString release];
- [NSApp requestUserAttention: NSInformationalRequest];
+ std::string label(i > 0 ? boost::lexical_cast<std::string>(i) : "");
+ NSString *labelString = [[NSString alloc] initWithUTF8String: label.c_str()];
+ [[NSApp dockTile] setBadgeLabel: labelString];
+ [labelString release];
+ [NSApp requestUserAttention: NSInformationalRequest];
}
}
diff --git a/SwifTools/Dock/NullDock.h b/SwifTools/Dock/NullDock.h
index e4433f6..9f3c554 100644
--- a/SwifTools/Dock/NullDock.h
+++ b/SwifTools/Dock/NullDock.h
@@ -9,11 +9,11 @@
#include <SwifTools/Dock/Dock.h>
namespace Swift {
- class NullDock : public Dock {
- public:
- NullDock() {}
+ class NullDock : public Dock {
+ public:
+ NullDock() {}
- virtual void setNumberOfPendingMessages(int) {
- }
- };
+ virtual void setNumberOfPendingMessages(int) {
+ }
+ };
}
diff --git a/SwifTools/Dock/WindowsDock.h b/SwifTools/Dock/WindowsDock.h
index 07b0eff..fc10a48 100644
--- a/SwifTools/Dock/WindowsDock.h
+++ b/SwifTools/Dock/WindowsDock.h
@@ -14,30 +14,30 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class WindowsDock : public Dock {
- public:
- WindowsDock(QSystemTrayIcon* tray, Notifier* notifier) : tray(tray), notifier(notifier) {}
-
- virtual void setNumberOfPendingMessages(int i) {
- if (notifier->isAvailable()) {
- return;
- }
-
- if (i > 0) {
- std::string message = boost::lexical_cast<std::string>(i) + " new message";
- if (i > 1) {
- message += "s";
- }
- message += " received.";
- tray->showMessage("New messages", message.c_str(), QSystemTrayIcon::NoIcon);
- }
- else {
- tray->showMessage("", "", QSystemTrayIcon::NoIcon, 0);
- }
- }
-
- private:
- QSystemTrayIcon* tray;
- Notifier* notifier;
- };
+ class WindowsDock : public Dock {
+ public:
+ WindowsDock(QSystemTrayIcon* tray, Notifier* notifier) : tray(tray), notifier(notifier) {}
+
+ virtual void setNumberOfPendingMessages(int i) {
+ if (notifier->isAvailable()) {
+ return;
+ }
+
+ if (i > 0) {
+ std::string message = boost::lexical_cast<std::string>(i) + " new message";
+ if (i > 1) {
+ message += "s";
+ }
+ message += " received.";
+ tray->showMessage("New messages", message.c_str(), QSystemTrayIcon::NoIcon);
+ }
+ else {
+ tray->showMessage("", "", QSystemTrayIcon::NoIcon, 0);
+ }
+ }
+
+ private:
+ QSystemTrayIcon* tray;
+ Notifier* notifier;
+ };
}
diff --git a/SwifTools/HunspellChecker.cpp b/SwifTools/HunspellChecker.cpp
index 2fe7a21..fb1a5d6 100644
--- a/SwifTools/HunspellChecker.cpp
+++ b/SwifTools/HunspellChecker.cpp
@@ -21,44 +21,44 @@
namespace Swift {
HunspellChecker::HunspellChecker(const char* affix_path, const char* dictionary_path) {
- speller_ = new Hunspell(affix_path, dictionary_path);
+ speller_ = new Hunspell(affix_path, dictionary_path);
}
HunspellChecker::~HunspellChecker() {
- delete speller_;
+ delete speller_;
}
bool HunspellChecker::isCorrect(const std::string& word) {
- return speller_->spell(word.c_str());
+ return speller_->spell(word.c_str());
}
void HunspellChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) {
- char **suggestList = NULL;
- int words_returned = 0;
- if (!word.empty()) {
- words_returned = speller_->suggest(&suggestList, word.c_str());
- if (suggestList != NULL) {
- for (int i = 0; i < words_returned; ++i) {
- list.push_back(suggestList[i]);
- free(suggestList[i]);
- }
- free(suggestList);
- }
- }
+ char **suggestList = NULL;
+ int words_returned = 0;
+ if (!word.empty()) {
+ words_returned = speller_->suggest(&suggestList, word.c_str());
+ if (suggestList != NULL) {
+ for (int i = 0; i < words_returned; ++i) {
+ list.push_back(suggestList[i]);
+ free(suggestList[i]);
+ }
+ free(suggestList);
+ }
+ }
}
void HunspellChecker::checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) {
- if (!fragment.empty()) {
- parser_->check(fragment, misspelledPositions);
- for (PositionPairList::iterator it = misspelledPositions.begin(); it != misspelledPositions.end();) {
- if (isCorrect(fragment.substr(boost::get<0>(*it), boost::get<1>(*it) - boost::get<0>(*it)))) {
- it = misspelledPositions.erase(it);
- }
- else {
- ++it;
- }
- }
- }
+ if (!fragment.empty()) {
+ parser_->check(fragment, misspelledPositions);
+ for (PositionPairList::iterator it = misspelledPositions.begin(); it != misspelledPositions.end();) {
+ if (isCorrect(fragment.substr(boost::get<0>(*it), boost::get<1>(*it) - boost::get<0>(*it)))) {
+ it = misspelledPositions.erase(it);
+ }
+ else {
+ ++it;
+ }
+ }
+ }
}
}
diff --git a/SwifTools/HunspellChecker.h b/SwifTools/HunspellChecker.h
index 689e0e7..076b468 100644
--- a/SwifTools/HunspellChecker.h
+++ b/SwifTools/HunspellChecker.h
@@ -22,14 +22,14 @@
class Hunspell;
namespace Swift {
- class HunspellChecker : public SpellChecker {
- public:
- HunspellChecker(const char* affix_path, const char* dict_path);
- virtual ~HunspellChecker();
- virtual bool isCorrect(const std::string& word);
- virtual void getSuggestions(const std::string& word, std::vector<std::string>& list);
- virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions);
- private:
- Hunspell* speller_;
- };
+ class HunspellChecker : public SpellChecker {
+ public:
+ HunspellChecker(const char* affix_path, const char* dict_path);
+ virtual ~HunspellChecker();
+ virtual bool isCorrect(const std::string& word);
+ virtual void getSuggestions(const std::string& word, std::vector<std::string>& list);
+ virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions);
+ private:
+ Hunspell* speller_;
+ };
}
diff --git a/SwifTools/Idle/ActualIdleDetector.cpp b/SwifTools/Idle/ActualIdleDetector.cpp
index dac4a5e..2a16fca 100644
--- a/SwifTools/Idle/ActualIdleDetector.cpp
+++ b/SwifTools/Idle/ActualIdleDetector.cpp
@@ -16,20 +16,20 @@
namespace Swift {
ActualIdleDetector::ActualIdleDetector(IdleQuerier* querier, TimerFactory* timerFactory, int refreshRateMilliseconds) : querier(querier) {
- timer = timerFactory->createTimer(refreshRateMilliseconds);
- timer->onTick.connect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
- timer->start();
+ timer = timerFactory->createTimer(refreshRateMilliseconds);
+ timer->onTick.connect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
+ timer->start();
}
ActualIdleDetector::~ActualIdleDetector() {
- timer->onTick.disconnect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
- timer->stop();
+ timer->onTick.disconnect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
+ timer->stop();
}
void ActualIdleDetector::handleTimerTick() {
- timer->stop();
- setIdle(querier->getIdleTimeSeconds() >= getIdleTimeSeconds());
- timer->start();
+ timer->stop();
+ setIdle(querier->getIdleTimeSeconds() >= getIdleTimeSeconds());
+ timer->start();
}
}
diff --git a/SwifTools/Idle/ActualIdleDetector.h b/SwifTools/Idle/ActualIdleDetector.h
index 739a005..194606f 100644
--- a/SwifTools/Idle/ActualIdleDetector.h
+++ b/SwifTools/Idle/ActualIdleDetector.h
@@ -11,20 +11,20 @@
#include <SwifTools/Idle/IdleDetector.h>
namespace Swift {
- class IdleQuerier;
- class TimerFactory;
- class Timer;
+ class IdleQuerier;
+ class TimerFactory;
+ class Timer;
- class ActualIdleDetector : public IdleDetector, public boost::bsignals::trackable {
- public:
- ActualIdleDetector(IdleQuerier*, TimerFactory*, int refreshRateMilliseconds);
- ~ActualIdleDetector();
+ class ActualIdleDetector : public IdleDetector, public boost::bsignals::trackable {
+ public:
+ ActualIdleDetector(IdleQuerier*, TimerFactory*, int refreshRateMilliseconds);
+ ~ActualIdleDetector();
- private:
- void handleTimerTick();
+ private:
+ void handleTimerTick();
- private:
- IdleQuerier* querier;
- boost::shared_ptr<Timer> timer;
- };
+ private:
+ IdleQuerier* querier;
+ boost::shared_ptr<Timer> timer;
+ };
}
diff --git a/SwifTools/Idle/DummyIdleQuerier.h b/SwifTools/Idle/DummyIdleQuerier.h
index 068d9ad..d3f5177 100644
--- a/SwifTools/Idle/DummyIdleQuerier.h
+++ b/SwifTools/Idle/DummyIdleQuerier.h
@@ -9,12 +9,12 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class DummyIdleQuerier : public IdleQuerier {
- public:
- DummyIdleQuerier() {}
+ class DummyIdleQuerier : public IdleQuerier {
+ public:
+ DummyIdleQuerier() {}
- virtual int getIdleTimeSeconds() {
- return 0;
- }
- };
+ virtual int getIdleTimeSeconds() {
+ return 0;
+ }
+ };
}
diff --git a/SwifTools/Idle/IdleDetector.h b/SwifTools/Idle/IdleDetector.h
index 7819f54..88a1c4c 100644
--- a/SwifTools/Idle/IdleDetector.h
+++ b/SwifTools/Idle/IdleDetector.h
@@ -11,34 +11,34 @@
#include <Swiften/Base/boost_bsignals.h>
namespace Swift {
- class IdleDetector {
- public:
- IdleDetector() : idle(false), idleTimeSeconds(300) {}
- virtual ~IdleDetector();
-
- void setIdleTimeSeconds(int time) {
- idleTimeSeconds = time;
- }
-
- int getIdleTimeSeconds() const {
- return idleTimeSeconds;
- }
-
- virtual bool isIdle() const {
- return idle;
- }
-
- boost::signal<void (bool /* isIdle */)> onIdleChanged;
-
- void setIdle(bool b) {
- if (b != idle) {
- idle = b;
- onIdleChanged(b);
- }
- }
-
- private:
- bool idle;
- int idleTimeSeconds;
- };
+ class IdleDetector {
+ public:
+ IdleDetector() : idle(false), idleTimeSeconds(300) {}
+ virtual ~IdleDetector();
+
+ void setIdleTimeSeconds(int time) {
+ idleTimeSeconds = time;
+ }
+
+ int getIdleTimeSeconds() const {
+ return idleTimeSeconds;
+ }
+
+ virtual bool isIdle() const {
+ return idle;
+ }
+
+ boost::signal<void (bool /* isIdle */)> onIdleChanged;
+
+ void setIdle(bool b) {
+ if (b != idle) {
+ idle = b;
+ onIdleChanged(b);
+ }
+ }
+
+ private:
+ bool idle;
+ int idleTimeSeconds;
+ };
}
diff --git a/SwifTools/Idle/IdleQuerier.h b/SwifTools/Idle/IdleQuerier.h
index ba4879d..e0de8be 100644
--- a/SwifTools/Idle/IdleQuerier.h
+++ b/SwifTools/Idle/IdleQuerier.h
@@ -7,10 +7,10 @@
#pragma once
namespace Swift {
- class IdleQuerier {
- public:
- virtual ~IdleQuerier();
+ class IdleQuerier {
+ public:
+ virtual ~IdleQuerier();
- virtual int getIdleTimeSeconds() = 0;
- };
+ virtual int getIdleTimeSeconds() = 0;
+ };
}
diff --git a/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp b/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
index 365ed1a..a0b78e6 100644
--- a/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
+++ b/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
@@ -14,11 +14,11 @@
using namespace Swift;
int main() {
- PlatformIdleQuerier querier;
- while (true) {
- std::cout << "Idle time: " << querier.getIdleTimeSeconds() << std::endl;
- Swift::sleep(1000);
- }
- assert(false);
- return 0;
+ PlatformIdleQuerier querier;
+ while (true) {
+ std::cout << "Idle time: " << querier.getIdleTimeSeconds() << std::endl;
+ Swift::sleep(1000);
+ }
+ assert(false);
+ return 0;
}
diff --git a/SwifTools/Idle/MacOSXIdleQuerier.cpp b/SwifTools/Idle/MacOSXIdleQuerier.cpp
index f7d4199..6d6780b 100644
--- a/SwifTools/Idle/MacOSXIdleQuerier.cpp
+++ b/SwifTools/Idle/MacOSXIdleQuerier.cpp
@@ -16,20 +16,20 @@
namespace Swift {
MacOSXIdleQuerier::MacOSXIdleQuerier() : ioService(0) {
- mach_port_t masterPort;
- IOMasterPort(MACH_PORT_NULL, &masterPort);
- ioService = IOServiceGetMatchingService(masterPort, IOServiceMatching("IOHIDSystem"));
- assert(ioService);
+ mach_port_t masterPort;
+ IOMasterPort(MACH_PORT_NULL, &masterPort);
+ ioService = IOServiceGetMatchingService(masterPort, IOServiceMatching("IOHIDSystem"));
+ assert(ioService);
}
int MacOSXIdleQuerier::getIdleTimeSeconds() {
- CFTypeRef property = IORegistryEntryCreateCFProperty(ioService, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
- uint64_t idle = 0;
- bool result = CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle);
- assert(result);
- (void) result;
- CFRelease(property);
- return boost::numeric_cast<int>(idle / 1000000000);
+ CFTypeRef property = IORegistryEntryCreateCFProperty(ioService, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
+ uint64_t idle = 0;
+ bool result = CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle);
+ assert(result);
+ (void) result;
+ CFRelease(property);
+ return boost::numeric_cast<int>(idle / 1000000000);
}
}
diff --git a/SwifTools/Idle/MacOSXIdleQuerier.h b/SwifTools/Idle/MacOSXIdleQuerier.h
index 7f70e88..8ff747c 100644
--- a/SwifTools/Idle/MacOSXIdleQuerier.h
+++ b/SwifTools/Idle/MacOSXIdleQuerier.h
@@ -11,13 +11,13 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class MacOSXIdleQuerier : public IdleQuerier {
- public:
- MacOSXIdleQuerier();
+ class MacOSXIdleQuerier : public IdleQuerier {
+ public:
+ MacOSXIdleQuerier();
- virtual int getIdleTimeSeconds();
+ virtual int getIdleTimeSeconds();
- private:
- io_service_t ioService;
- };
+ private:
+ io_service_t ioService;
+ };
}
diff --git a/SwifTools/Idle/PlatformIdleQuerier.cpp b/SwifTools/Idle/PlatformIdleQuerier.cpp
index bf8f778..5855749 100644
--- a/SwifTools/Idle/PlatformIdleQuerier.cpp
+++ b/SwifTools/Idle/PlatformIdleQuerier.cpp
@@ -24,21 +24,21 @@ namespace Swift {
PlatformIdleQuerier::PlatformIdleQuerier() : querier(NULL) {
#if defined(SWIFTEN_PLATFORM_MACOSX)
#if defined(HAVE_IOKIT) && !defined(SWIFTEN_PLATFORM_IPHONE)
- querier = new MacOSXIdleQuerier();
+ querier = new MacOSXIdleQuerier();
#else
- querier = new DummyIdleQuerier();
+ querier = new DummyIdleQuerier();
#endif
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
- querier = new WindowsIdleQuerier();
+ querier = new WindowsIdleQuerier();
#elif defined(HAVE_XSS)
- querier = new XSSIdleQuerier();
+ querier = new XSSIdleQuerier();
#else
- querier = new DummyIdleQuerier();
+ querier = new DummyIdleQuerier();
#endif
}
PlatformIdleQuerier::~PlatformIdleQuerier() {
- delete querier;
+ delete querier;
}
}
diff --git a/SwifTools/Idle/PlatformIdleQuerier.h b/SwifTools/Idle/PlatformIdleQuerier.h
index 676dad0..1221ada 100644
--- a/SwifTools/Idle/PlatformIdleQuerier.h
+++ b/SwifTools/Idle/PlatformIdleQuerier.h
@@ -9,16 +9,16 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class PlatformIdleQuerier : public IdleQuerier {
- public:
- PlatformIdleQuerier();
- ~PlatformIdleQuerier();
+ class PlatformIdleQuerier : public IdleQuerier {
+ public:
+ PlatformIdleQuerier();
+ ~PlatformIdleQuerier();
- virtual int getIdleTimeSeconds() {
- return querier->getIdleTimeSeconds();
- }
+ virtual int getIdleTimeSeconds() {
+ return querier->getIdleTimeSeconds();
+ }
- private:
- IdleQuerier* querier;
- };
+ private:
+ IdleQuerier* querier;
+ };
}
diff --git a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
index c97705e..8af66fc 100644
--- a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
+++ b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
@@ -19,154 +19,154 @@
using namespace Swift;
class ActualIdleDetectorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ActualIdleDetectorTest);
- CPPUNIT_TEST(testDestructor);
- CPPUNIT_TEST(testHandleTick_Idle);
- CPPUNIT_TEST(testHandleTick_Idle_AlreadyIdle);
- CPPUNIT_TEST(testHandleTick_NotIdle);
- CPPUNIT_TEST(testHandleTick_NotIdle_AlreadyNotIdle);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- querier = new MockIdleQuerier();
- timerFactory = new MockTimerFactory();
- idleEvents.clear();
- }
-
- void tearDown() {
- delete timerFactory;
- delete querier;
- }
-
- void testDestructor() {
- ActualIdleDetector* testling = createDetector();
- testling->setIdleTimeSeconds(15);
- delete testling;
-
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
- }
-
- void testHandleTick_Idle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
-
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- }
-
- void testHandleTick_Idle_AlreadyIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- querier->idleTime = 30;
- timerFactory->updateTime(30000);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- }
-
- void testHandleTick_NotIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- querier->idleTime = 5;
- timerFactory->updateTime(30000);
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- CPPUNIT_ASSERT(!idleEvents[1]);
- }
-
- void testHandleTick_NotIdle_AlreadyNotIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 5;
-
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
- }
-
- private:
- ActualIdleDetector* createDetector() {
- ActualIdleDetector* detector = new ActualIdleDetector(querier, timerFactory, 10);
- detector->onIdleChanged.connect(boost::bind(&ActualIdleDetectorTest::handleIdle, this, _1));
- return detector;
- }
-
- void handleIdle(bool b) {
- idleEvents.push_back(b);
- }
-
- private:
- struct MockIdleQuerier : public IdleQuerier {
- MockIdleQuerier() : idleTime(0) {}
- virtual int getIdleTimeSeconds() { return idleTime; }
- int idleTime;
- };
-
- struct MockTimer : public Timer {
- MockTimer(int interval) : interval(interval), running(false), lastTime(0) {}
-
- virtual void start() {
- running = true;
- }
-
- virtual void stop() {
- running = false;
- }
-
- virtual void updateTime(int currentTime) {
- if (lastTime == currentTime) {
- return;
- }
- if (running) {
- int time = lastTime;
- while (time <= currentTime) {
- onTick();
- time += interval;
- }
- }
- lastTime = currentTime;
- }
-
- int interval;
- bool running;
- int lastTime;
- };
-
- struct MockTimerFactory : public TimerFactory {
- MockTimerFactory() {}
-
- void updateTime(int milliseconds) {
- foreach(boost::shared_ptr<MockTimer> timer, timers) {
- timer->updateTime(milliseconds);
- }
- }
-
- boost::shared_ptr<Timer> createTimer(int milliseconds) {
- boost::shared_ptr<MockTimer> timer(new MockTimer(milliseconds));
- timers.push_back(timer);
- return timer;
- }
-
- std::vector<boost::shared_ptr<MockTimer> > timers;
- };
-
- MockIdleQuerier* querier;
- MockTimerFactory* timerFactory;
- std::vector<bool> idleEvents;
+ CPPUNIT_TEST_SUITE(ActualIdleDetectorTest);
+ CPPUNIT_TEST(testDestructor);
+ CPPUNIT_TEST(testHandleTick_Idle);
+ CPPUNIT_TEST(testHandleTick_Idle_AlreadyIdle);
+ CPPUNIT_TEST(testHandleTick_NotIdle);
+ CPPUNIT_TEST(testHandleTick_NotIdle_AlreadyNotIdle);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ querier = new MockIdleQuerier();
+ timerFactory = new MockTimerFactory();
+ idleEvents.clear();
+ }
+
+ void tearDown() {
+ delete timerFactory;
+ delete querier;
+ }
+
+ void testDestructor() {
+ ActualIdleDetector* testling = createDetector();
+ testling->setIdleTimeSeconds(15);
+ delete testling;
+
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
+ }
+
+ void testHandleTick_Idle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ }
+
+ void testHandleTick_Idle_AlreadyIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ querier->idleTime = 30;
+ timerFactory->updateTime(30000);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ }
+
+ void testHandleTick_NotIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ querier->idleTime = 5;
+ timerFactory->updateTime(30000);
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ CPPUNIT_ASSERT(!idleEvents[1]);
+ }
+
+ void testHandleTick_NotIdle_AlreadyNotIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 5;
+
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
+ }
+
+ private:
+ ActualIdleDetector* createDetector() {
+ ActualIdleDetector* detector = new ActualIdleDetector(querier, timerFactory, 10);
+ detector->onIdleChanged.connect(boost::bind(&ActualIdleDetectorTest::handleIdle, this, _1));
+ return detector;
+ }
+
+ void handleIdle(bool b) {
+ idleEvents.push_back(b);
+ }
+
+ private:
+ struct MockIdleQuerier : public IdleQuerier {
+ MockIdleQuerier() : idleTime(0) {}
+ virtual int getIdleTimeSeconds() { return idleTime; }
+ int idleTime;
+ };
+
+ struct MockTimer : public Timer {
+ MockTimer(int interval) : interval(interval), running(false), lastTime(0) {}
+
+ virtual void start() {
+ running = true;
+ }
+
+ virtual void stop() {
+ running = false;
+ }
+
+ virtual void updateTime(int currentTime) {
+ if (lastTime == currentTime) {
+ return;
+ }
+ if (running) {
+ int time = lastTime;
+ while (time <= currentTime) {
+ onTick();
+ time += interval;
+ }
+ }
+ lastTime = currentTime;
+ }
+
+ int interval;
+ bool running;
+ int lastTime;
+ };
+
+ struct MockTimerFactory : public TimerFactory {
+ MockTimerFactory() {}
+
+ void updateTime(int milliseconds) {
+ foreach(boost::shared_ptr<MockTimer> timer, timers) {
+ timer->updateTime(milliseconds);
+ }
+ }
+
+ boost::shared_ptr<Timer> createTimer(int milliseconds) {
+ boost::shared_ptr<MockTimer> timer(new MockTimer(milliseconds));
+ timers.push_back(timer);
+ return timer;
+ }
+
+ std::vector<boost::shared_ptr<MockTimer> > timers;
+ };
+
+ MockIdleQuerier* querier;
+ MockTimerFactory* timerFactory;
+ std::vector<bool> idleEvents;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ActualIdleDetectorTest);
diff --git a/SwifTools/Idle/WindowsIdleQuerier.cpp b/SwifTools/Idle/WindowsIdleQuerier.cpp
index ef1738b..f766436 100644
--- a/SwifTools/Idle/WindowsIdleQuerier.cpp
+++ b/SwifTools/Idle/WindowsIdleQuerier.cpp
@@ -14,14 +14,14 @@ WindowsIdleQuerier::WindowsIdleQuerier() {
}
int WindowsIdleQuerier::getIdleTimeSeconds() {
- LASTINPUTINFO info;
- info.cbSize = sizeof(info);
- if (GetLastInputInfo(&info)) {
- return (GetTickCount() - info.dwTime) / 1000;
- }
- else {
- return 0;
- }
+ LASTINPUTINFO info;
+ info.cbSize = sizeof(info);
+ if (GetLastInputInfo(&info)) {
+ return (GetTickCount() - info.dwTime) / 1000;
+ }
+ else {
+ return 0;
+ }
}
}
diff --git a/SwifTools/Idle/WindowsIdleQuerier.h b/SwifTools/Idle/WindowsIdleQuerier.h
index 557ecab..198c6e9 100644
--- a/SwifTools/Idle/WindowsIdleQuerier.h
+++ b/SwifTools/Idle/WindowsIdleQuerier.h
@@ -9,10 +9,10 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class WindowsIdleQuerier : public IdleQuerier {
- public:
- WindowsIdleQuerier();
+ class WindowsIdleQuerier : public IdleQuerier {
+ public:
+ WindowsIdleQuerier();
- virtual int getIdleTimeSeconds();
- };
+ virtual int getIdleTimeSeconds();
+ };
}
diff --git a/SwifTools/Idle/XSSIdleQuerier.cpp b/SwifTools/Idle/XSSIdleQuerier.cpp
index 883f76f..03c5330 100644
--- a/SwifTools/Idle/XSSIdleQuerier.cpp
+++ b/SwifTools/Idle/XSSIdleQuerier.cpp
@@ -14,31 +14,31 @@
namespace Swift {
XSSIdleQuerier::XSSIdleQuerier() : display(NULL), info(NULL) {
- display = XOpenDisplay(NULL);
- assert(display);
- rootWindow = DefaultRootWindow(display);
- int event, error;
- available = XScreenSaverQueryExtension(display, &event, &error);
- if (available) {
- info = XScreenSaverAllocInfo();
- }
- else {
- std::cerr << "Warning: XScreenSaver extension not found. Idle time detection will not work." << std::endl;
- }
+ display = XOpenDisplay(NULL);
+ assert(display);
+ rootWindow = DefaultRootWindow(display);
+ int event, error;
+ available = XScreenSaverQueryExtension(display, &event, &error);
+ if (available) {
+ info = XScreenSaverAllocInfo();
+ }
+ else {
+ std::cerr << "Warning: XScreenSaver extension not found. Idle time detection will not work." << std::endl;
+ }
}
XSSIdleQuerier::~XSSIdleQuerier() {
- XFree(info);
+ XFree(info);
}
int XSSIdleQuerier::getIdleTimeSeconds() {
- if (available) {
- XScreenSaverQueryInfo(display, rootWindow, info);
- return info->idle / 1000;
- }
- else {
- return 0;
- }
+ if (available) {
+ XScreenSaverQueryInfo(display, rootWindow, info);
+ return info->idle / 1000;
+ }
+ else {
+ return 0;
+ }
}
}
diff --git a/SwifTools/Idle/XSSIdleQuerier.h b/SwifTools/Idle/XSSIdleQuerier.h
index ae5a502..225f781 100644
--- a/SwifTools/Idle/XSSIdleQuerier.h
+++ b/SwifTools/Idle/XSSIdleQuerier.h
@@ -12,17 +12,17 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class XSSIdleQuerier : public IdleQuerier {
- public:
- XSSIdleQuerier();
- ~XSSIdleQuerier();
+ class XSSIdleQuerier : public IdleQuerier {
+ public:
+ XSSIdleQuerier();
+ ~XSSIdleQuerier();
- virtual int getIdleTimeSeconds();
+ virtual int getIdleTimeSeconds();
- private:
- Display* display;
- Window rootWindow;
- bool available;
- XScreenSaverInfo* info;
- };
+ private:
+ Display* display;
+ Window rootWindow;
+ bool available;
+ XScreenSaverInfo* info;
+ };
}
diff --git a/SwifTools/LastLineTracker.cpp b/SwifTools/LastLineTracker.cpp
index 9428ff4..b9f1aa3 100644
--- a/SwifTools/LastLineTracker.cpp
+++ b/SwifTools/LastLineTracker.cpp
@@ -15,22 +15,22 @@
using namespace Swift;
LastLineTracker::LastLineTracker() {
- lastFocus = true;
- shouldMove = false;
+ lastFocus = true;
+ shouldMove = false;
}
void LastLineTracker::setHasFocus(bool focus) {
- if (!focus && lastFocus) {
- shouldMove = true;
- lastFocus = focus;
- return;
- }
- shouldMove = false;
- lastFocus = focus;
+ if (!focus && lastFocus) {
+ shouldMove = true;
+ lastFocus = focus;
+ return;
+ }
+ shouldMove = false;
+ lastFocus = focus;
}
bool LastLineTracker::getShouldMoveLastLine() {
- bool ret = shouldMove;
- shouldMove = false;
- return ret;
+ bool ret = shouldMove;
+ shouldMove = false;
+ return ret;
}
diff --git a/SwifTools/LastLineTracker.h b/SwifTools/LastLineTracker.h
index b7c9a3b..7156ec3 100644
--- a/SwifTools/LastLineTracker.h
+++ b/SwifTools/LastLineTracker.h
@@ -7,13 +7,13 @@
#pragma once
namespace Swift {
- class LastLineTracker {
- public:
- LastLineTracker();
- void setHasFocus(bool focus);
- bool getShouldMoveLastLine();
- private:
- bool lastFocus;
- bool shouldMove;
- };
+ class LastLineTracker {
+ public:
+ LastLineTracker();
+ void setHasFocus(bool focus);
+ bool getShouldMoveLastLine();
+ private:
+ bool lastFocus;
+ bool shouldMove;
+ };
}
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp
index 324d145..b1557e5 100644
--- a/SwifTools/Linkify.cpp
+++ b/SwifTools/Linkify.cpp
@@ -16,89 +16,89 @@ namespace Swift {
static boost::regex linkifyRegexp("^(https?://|xmpp:).*");
std::string Linkify::linkify(const std::string& input) {
- std::ostringstream result;
- std::vector<char> currentURL;
- bool inURL = false;
- for (size_t i = 0; i < input.size(); ++i) {
- char c = input[i];
- if (inURL) {
- if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
- currentURL.push_back(c);
- }
- else {
- std::string url(&currentURL[0], currentURL.size());
- result << "<a href=\"" << url << "\">" << url << "</a>";
- currentURL.clear();
- inURL = false;
- result << c;
- }
- }
- else {
- if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
- currentURL.push_back(c);
- inURL = true;
- }
- else {
- result << c;
- }
- }
- }
- if (!currentURL.empty()) {
- std::string url(&currentURL[0], currentURL.size());
- result << "<a href=\"" << url << "\">" << url << "</a>";
- }
- return std::string(result.str());
+ std::ostringstream result;
+ std::vector<char> currentURL;
+ bool inURL = false;
+ for (size_t i = 0; i < input.size(); ++i) {
+ char c = input[i];
+ if (inURL) {
+ if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
+ currentURL.push_back(c);
+ }
+ else {
+ std::string url(&currentURL[0], currentURL.size());
+ result << "<a href=\"" << url << "\">" << url << "</a>";
+ currentURL.clear();
+ inURL = false;
+ result << c;
+ }
+ }
+ else {
+ if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
+ currentURL.push_back(c);
+ inURL = true;
+ }
+ else {
+ result << c;
+ }
+ }
+ }
+ if (!currentURL.empty()) {
+ std::string url(&currentURL[0], currentURL.size());
+ result << "<a href=\"" << url << "\">" << url << "</a>";
+ }
+ return std::string(result.str());
}
std::pair<std::vector<std::string>, size_t> Linkify::splitLink(const std::string& input) {
- std::vector<std::string> result;
- std::pair<std::vector<std::string>, size_t> pair;
- std::vector<char> currentURL;
- bool inURL = false;
- size_t urlStartsAt = 0;
- for (size_t i = 0; i < input.size(); ++i) {
- char c = input[i];
- if (inURL) {
- if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
- // Keep parsing
- }
- else {
- std::string url(input.substr(urlStartsAt, i - urlStartsAt));
- result.push_back(url);
- inURL = false;
- size_t remaining = input.size() - i;
- if (remaining > 0) {
- result.push_back(input.substr(i, remaining));
- }
- pair.first = result;
- pair.second = urlStartsAt == 0 ? 0 : 1;
- return pair;
- }
- }
- else {
- if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
- urlStartsAt = i;
- inURL = true;
- if (i > 0) {
- result.push_back(input.substr(0, i));
- }
- }
- else {
- // Just keep swimming
- }
- }
- }
- if (urlStartsAt > 0 || inURL) {
- std::string url(input.substr(urlStartsAt, input.size() - urlStartsAt));
- result.push_back(url);
- pair.first = result;
- pair.second = urlStartsAt == 0 ? 0 : 1;
- }
- else {
- pair.first.push_back(input);
- pair.second = 1;
- }
- return pair;
+ std::vector<std::string> result;
+ std::pair<std::vector<std::string>, size_t> pair;
+ std::vector<char> currentURL;
+ bool inURL = false;
+ size_t urlStartsAt = 0;
+ for (size_t i = 0; i < input.size(); ++i) {
+ char c = input[i];
+ if (inURL) {
+ if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) {
+ // Keep parsing
+ }
+ else {
+ std::string url(input.substr(urlStartsAt, i - urlStartsAt));
+ result.push_back(url);
+ inURL = false;
+ size_t remaining = input.size() - i;
+ if (remaining > 0) {
+ result.push_back(input.substr(i, remaining));
+ }
+ pair.first = result;
+ pair.second = urlStartsAt == 0 ? 0 : 1;
+ return pair;
+ }
+ }
+ else {
+ if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
+ urlStartsAt = i;
+ inURL = true;
+ if (i > 0) {
+ result.push_back(input.substr(0, i));
+ }
+ }
+ else {
+ // Just keep swimming
+ }
+ }
+ }
+ if (urlStartsAt > 0 || inURL) {
+ std::string url(input.substr(urlStartsAt, input.size() - urlStartsAt));
+ result.push_back(url);
+ pair.first = result;
+ pair.second = urlStartsAt == 0 ? 0 : 1;
+ }
+ else {
+ pair.first.push_back(input);
+ pair.second = 1;
+ }
+ return pair;
}
}
diff --git a/SwifTools/Linkify.h b/SwifTools/Linkify.h
index 98d55d6..64c92dc 100644
--- a/SwifTools/Linkify.h
+++ b/SwifTools/Linkify.h
@@ -10,18 +10,18 @@
#include <vector>
namespace Swift {
- namespace Linkify {
- std::string linkify(const std::string&);
- /**
- * Parse the string for a URI. The string will be split by the URI, and the segments plus index of the URI returned.
- * If no URI is found the index will be result.size() (i.e. an invalid index)
- *
- * Examples:
- * "not a URI" -> <<"not a URI">, -1>
- * "http://swift.im" -> <<"http://swift.im">, 0
- * " See http://swift.im" -> <<" See ", "http://swift.im">, 1>
- * "Right, http://swift.im it is" -> <<"Right, ", "http://swift.im", " it is">, 1>
- */
- std::pair<std::vector<std::string>, size_t> splitLink(const std::string& text);
- }
+ namespace Linkify {
+ std::string linkify(const std::string&);
+ /**
+ * Parse the string for a URI. The string will be split by the URI, and the segments plus index of the URI returned.
+ * If no URI is found the index will be result.size() (i.e. an invalid index)
+ *
+ * Examples:
+ * "not a URI" -> <<"not a URI">, -1>
+ * "http://swift.im" -> <<"http://swift.im">, 0
+ * " See http://swift.im" -> <<" See ", "http://swift.im">, 1>
+ * "Right, http://swift.im it is" -> <<"Right, ", "http://swift.im", " it is">, 1>
+ */
+ std::pair<std::vector<std::string>, size_t> splitLink(const std::string& text);
+ }
}
diff --git a/SwifTools/MacOSXChecker.h b/SwifTools/MacOSXChecker.h
index 0bc7356..be9a32a 100644
--- a/SwifTools/MacOSXChecker.h
+++ b/SwifTools/MacOSXChecker.h
@@ -19,12 +19,12 @@
#include <SwifTools/SpellChecker.h>
namespace Swift {
- class MacOSXChecker : public SpellChecker {
- public:
- MacOSXChecker();
- virtual ~MacOSXChecker();
- virtual bool isCorrect(const std::string& word);
- virtual void getSuggestions(const std::string& word, std::vector<std::string>& list);
- virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions);
- };
+ class MacOSXChecker : public SpellChecker {
+ public:
+ MacOSXChecker();
+ virtual ~MacOSXChecker();
+ virtual bool isCorrect(const std::string& word);
+ virtual void getSuggestions(const std::string& word, std::vector<std::string>& list);
+ virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions);
+ };
}
diff --git a/SwifTools/MacOSXChecker.mm b/SwifTools/MacOSXChecker.mm
index eefea97..5f4f9c3 100644
--- a/SwifTools/MacOSXChecker.mm
+++ b/SwifTools/MacOSXChecker.mm
@@ -21,43 +21,43 @@
namespace Swift {
MacOSXChecker::MacOSXChecker() {
- NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
- [spellChecker setAutomaticallyIdentifiesLanguages:YES];
+ NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
+ [spellChecker setAutomaticallyIdentifiesLanguages:YES];
}
MacOSXChecker::~MacOSXChecker() {
}
bool MacOSXChecker::isCorrect(const std::string& /*word*/) {
- // No content since it doesn't seem to be used anywhere.
- return false;
+ // No content since it doesn't seem to be used anywhere.
+ return false;
}
void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) {
- NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
- NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()];
- NSArray* suggestions = [spellChecker guessesForWordRange:NSMakeRange(0, [wordString length]) inString:wordString language:nil inSpellDocumentWithTag:0];
- for(unsigned int i = 0; i < [suggestions count]; ++i) {
- list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String]));
- }
- [wordString release];
+ NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
+ NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()];
+ NSArray* suggestions = [spellChecker guessesForWordRange:NSMakeRange(0, [wordString length]) inString:wordString language:nil inSpellDocumentWithTag:0];
+ for(unsigned int i = 0; i < [suggestions count]; ++i) {
+ list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String]));
+ }
+ [wordString release];
}
void MacOSXChecker::checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) {
- NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
- size_t nextLocation = 0;
- NSRange range;
- NSString *fragmentString = [[NSString alloc] initWithUTF8String: fragment.c_str()];
- do {
- range = [spellChecker checkSpellingOfString:fragmentString startingAt:static_cast<long>(nextLocation)];
- if (range.location != NSNotFound) {
- if (range.location < nextLocation)
- break;
- misspelledPositions.push_back(PositionPair(static_cast<int>(range.location), static_cast<int>(range.location + range.length)));
- nextLocation = range.location + range.length + 1;
- }
- } while (range.location != NSNotFound);
- [fragmentString release];
+ NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
+ size_t nextLocation = 0;
+ NSRange range;
+ NSString *fragmentString = [[NSString alloc] initWithUTF8String: fragment.c_str()];
+ do {
+ range = [spellChecker checkSpellingOfString:fragmentString startingAt:static_cast<long>(nextLocation)];
+ if (range.location != NSNotFound) {
+ if (range.location < nextLocation)
+ break;
+ misspelledPositions.push_back(PositionPair(static_cast<int>(range.location), static_cast<int>(range.location + range.length)));
+ nextLocation = range.location + range.length + 1;
+ }
+ } while (range.location != NSNotFound);
+ [fragmentString release];
}
}
diff --git a/SwifTools/Notifier/GNTPNotifier.cpp b/SwifTools/Notifier/GNTPNotifier.cpp
index 01e8726..62203b4 100644
--- a/SwifTools/Notifier/GNTPNotifier.cpp
+++ b/SwifTools/Notifier/GNTPNotifier.cpp
@@ -21,67 +21,67 @@
namespace Swift {
GNTPNotifier::GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory) : name(name), icon(icon), connectionFactory(connectionFactory), initialized(false), registered(false) {
- // Registration message
- std::ostringstream message;
- message << "GNTP/1.0 REGISTER NONE\r\n";
- message << "Application-Name: " << name << "\r\n";
- message << "Application-Icon: file://" << pathToString(icon) << "\r\n";
- message << "Notifications-Count: " << getAllTypes().size() << "\r\n";
- std::vector<Notifier::Type> defaultTypes = getDefaultTypes();
- std::vector<Notifier::Type> allTypes = getAllTypes();
- foreach(Notifier::Type type, allTypes) {
- message << "\r\n";
- message << "Notification-Name: " << typeToString(type) << "\r\n";
- message << "Notification-Enabled: " << (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end() ? "false" : "true") << "\r\n";
- }
- message << "\r\n";
+ // Registration message
+ std::ostringstream message;
+ message << "GNTP/1.0 REGISTER NONE\r\n";
+ message << "Application-Name: " << name << "\r\n";
+ message << "Application-Icon: file://" << pathToString(icon) << "\r\n";
+ message << "Notifications-Count: " << getAllTypes().size() << "\r\n";
+ std::vector<Notifier::Type> defaultTypes = getDefaultTypes();
+ std::vector<Notifier::Type> allTypes = getAllTypes();
+ foreach(Notifier::Type type, allTypes) {
+ message << "\r\n";
+ message << "Notification-Name: " << typeToString(type) << "\r\n";
+ message << "Notification-Enabled: " << (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end() ? "false" : "true") << "\r\n";
+ }
+ message << "\r\n";
- send(message.str());
+ send(message.str());
}
GNTPNotifier::~GNTPNotifier() {
}
void GNTPNotifier::send(const std::string& message) {
- if (currentConnection) {
- return;
- }
- currentMessage = message;
- currentConnection = connectionFactory->createConnection();
- currentConnection->onConnectFinished.connect(boost::bind(&GNTPNotifier::handleConnectFinished, this, _1));
- currentConnection->onDataRead.connect(boost::bind(&GNTPNotifier::handleDataRead, this, _1));
- currentConnection->connect(HostAddressPort(HostAddress("127.0.0.1"), 23053));
+ if (currentConnection) {
+ return;
+ }
+ currentMessage = message;
+ currentConnection = connectionFactory->createConnection();
+ currentConnection->onConnectFinished.connect(boost::bind(&GNTPNotifier::handleConnectFinished, this, _1));
+ currentConnection->onDataRead.connect(boost::bind(&GNTPNotifier::handleDataRead, this, _1));
+ currentConnection->connect(HostAddressPort(HostAddress("127.0.0.1"), 23053));
}
void GNTPNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()>) {
- if (registered) {
- std::ostringstream message;
- message << "GNTP/1.0 NOTIFY NONE\r\n";
- message << "Application-Name: " << name << "\r\n";
- message << "Notification-Name: " << typeToString(type) << "\r\n";
- message << "Notification-Title: " << subject << "\r\n";
- message << "Notification-Text: " << description << "\r\n";
- message << "Notification-Icon: " << pathToString(picture) << "\r\n";
- message << "\r\n";
- send(message.str());
- }
+ if (registered) {
+ std::ostringstream message;
+ message << "GNTP/1.0 NOTIFY NONE\r\n";
+ message << "Application-Name: " << name << "\r\n";
+ message << "Notification-Name: " << typeToString(type) << "\r\n";
+ message << "Notification-Title: " << subject << "\r\n";
+ message << "Notification-Text: " << description << "\r\n";
+ message << "Notification-Icon: " << pathToString(picture) << "\r\n";
+ message << "\r\n";
+ send(message.str());
+ }
}
void GNTPNotifier::handleConnectFinished(bool error) {
- if (!initialized) {
- initialized = true;
- registered = !error;
- }
+ if (!initialized) {
+ initialized = true;
+ registered = !error;
+ }
- if (!error) {
- currentConnection->write(currentMessage.c_str());
- }
+ if (!error) {
+ currentConnection->write(currentMessage.c_str());
+ }
}
void GNTPNotifier::handleDataRead(const ByteArray&) {
- currentConnection->onDataRead.disconnect(boost::bind(&GNTPNotifier::handleDataRead, this, _1));
- currentConnection->onConnectFinished.disconnect(boost::bind(&GNTPNotifier::handleConnectFinished, this, _1));
- currentConnection.reset();
+ currentConnection->onDataRead.disconnect(boost::bind(&GNTPNotifier::handleDataRead, this, _1));
+ currentConnection->onConnectFinished.disconnect(boost::bind(&GNTPNotifier::handleConnectFinished, this, _1));
+ currentConnection.reset();
}
}
diff --git a/SwifTools/Notifier/GNTPNotifier.h b/SwifTools/Notifier/GNTPNotifier.h
index 92ff5a3..44811e7 100644
--- a/SwifTools/Notifier/GNTPNotifier.h
+++ b/SwifTools/Notifier/GNTPNotifier.h
@@ -13,27 +13,27 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class ConnectionFactory;
-
- class GNTPNotifier : public Notifier {
- public:
- GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory);
- ~GNTPNotifier();
-
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
-
- private:
- void handleConnectFinished(bool error);
- void handleDataRead(const ByteArray& data);
- void send(const std::string& message);
-
- private:
- std::string name;
- boost::filesystem::path icon;
- ConnectionFactory* connectionFactory;
- bool initialized;
- bool registered;
- std::string currentMessage;
- Connection::ref currentConnection;
- };
+ class ConnectionFactory;
+
+ class GNTPNotifier : public Notifier {
+ public:
+ GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory);
+ ~GNTPNotifier();
+
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+
+ private:
+ void handleConnectFinished(bool error);
+ void handleDataRead(const ByteArray& data);
+ void send(const std::string& message);
+
+ private:
+ std::string name;
+ boost::filesystem::path icon;
+ ConnectionFactory* connectionFactory;
+ bool initialized;
+ bool registered;
+ std::string currentMessage;
+ Connection::ref currentConnection;
+ };
}
diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h
index 9c90471..b4c4eba 100644
--- a/SwifTools/Notifier/GrowlNotifier.h
+++ b/SwifTools/Notifier/GrowlNotifier.h
@@ -11,31 +11,31 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- /**
- * Preconditions for using growlnotifier:
- * - Must be part a bundle.
- * - The Carbon/Cocoa application loop must be running (e.g. through QApplication)
- * such that notifications are coming through.
- */
- class GrowlNotifier : public Notifier {
- public:
- GrowlNotifier(const std::string& name);
- ~GrowlNotifier();
-
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
- virtual bool isExternallyConfigured() const;
-
- // Called by the delegate. Don't call.
- void handleNotificationClicked(void* data);
- void handleNotificationTimedOut(void* data);
-
- virtual void purgeCallbacks();
-
- private:
- void clearPendingNotifications();
-
- private:
- class Private;
- boost::shared_ptr<Private> p;
- };
+ /**
+ * Preconditions for using growlnotifier:
+ * - Must be part a bundle.
+ * - The Carbon/Cocoa application loop must be running (e.g. through QApplication)
+ * such that notifications are coming through.
+ */
+ class GrowlNotifier : public Notifier {
+ public:
+ GrowlNotifier(const std::string& name);
+ ~GrowlNotifier();
+
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual bool isExternallyConfigured() const;
+
+ // Called by the delegate. Don't call.
+ void handleNotificationClicked(void* data);
+ void handleNotificationTimedOut(void* data);
+
+ virtual void purgeCallbacks();
+
+ private:
+ void clearPendingNotifications();
+
+ private:
+ class Private;
+ boost::shared_ptr<Private> p;
+ };
}
diff --git a/SwifTools/Notifier/GrowlNotifier.mm b/SwifTools/Notifier/GrowlNotifier.mm
index d5bdf6f..e9ffff7 100644
--- a/SwifTools/Notifier/GrowlNotifier.mm
+++ b/SwifTools/Notifier/GrowlNotifier.mm
@@ -17,101 +17,101 @@
#pragma GCC diagnostic ignored "-Wold-style-cast"
namespace {
- struct Context {
- Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {}
+ struct Context {
+ Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {}
- boost::function<void()>* callback;
- };
+ boost::function<void()>* callback;
+ };
}
namespace Swift {
class GrowlNotifier::Private {
- public:
- std::set<Context*> pendingNotifications;
- boost::intrusive_ptr<GrowlNotifierDelegate> delegate;
+ public:
+ std::set<Context*> pendingNotifications;
+ boost::intrusive_ptr<GrowlNotifierDelegate> delegate;
};
GrowlNotifier::GrowlNotifier(const std::string& name) {
- p = boost::make_shared<Private>();
- p->delegate = boost::intrusive_ptr<GrowlNotifierDelegate>([[GrowlNotifierDelegate alloc] init], false);
- p->delegate.get().notifier = this;
- p->delegate.get().name = std2NSString(name);
-
- NSMutableArray* allNotifications = [[NSMutableArray alloc] init];
- foreach(Type type, getAllTypes()) {
- [allNotifications addObject: std2NSString(typeToString(type))];
- }
-
- NSMutableArray* defaultNotifications = [[NSMutableArray alloc] init];
- foreach(Type type, getDefaultTypes()) {
- [defaultNotifications addObject: std2NSString(typeToString(type))];
- }
-
- p->delegate.get().registrationDictionary = [[[NSDictionary alloc]
- initWithObjects: [NSArray arrayWithObjects: allNotifications, defaultNotifications, nil]
- forKeys: [NSArray arrayWithObjects: GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT, nil]] autorelease];
-
- [allNotifications release];
- [defaultNotifications release];
-
- [GrowlApplicationBridge setGrowlDelegate: p->delegate.get()];
+ p = boost::make_shared<Private>();
+ p->delegate = boost::intrusive_ptr<GrowlNotifierDelegate>([[GrowlNotifierDelegate alloc] init], false);
+ p->delegate.get().notifier = this;
+ p->delegate.get().name = std2NSString(name);
+
+ NSMutableArray* allNotifications = [[NSMutableArray alloc] init];
+ foreach(Type type, getAllTypes()) {
+ [allNotifications addObject: std2NSString(typeToString(type))];
+ }
+
+ NSMutableArray* defaultNotifications = [[NSMutableArray alloc] init];
+ foreach(Type type, getDefaultTypes()) {
+ [defaultNotifications addObject: std2NSString(typeToString(type))];
+ }
+
+ p->delegate.get().registrationDictionary = [[[NSDictionary alloc]
+ initWithObjects: [NSArray arrayWithObjects: allNotifications, defaultNotifications, nil]
+ forKeys: [NSArray arrayWithObjects: GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT, nil]] autorelease];
+
+ [allNotifications release];
+ [defaultNotifications release];
+
+ [GrowlApplicationBridge setGrowlDelegate: p->delegate.get()];
}
GrowlNotifier::~GrowlNotifier() {
- [GrowlApplicationBridge setGrowlDelegate: nil];
- clearPendingNotifications();
+ [GrowlApplicationBridge setGrowlDelegate: nil];
+ clearPendingNotifications();
}
void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {
- ByteArray picture;
- readByteArrayFromFile(picture, picturePath);
-
- Context* context = new Context(callback);
- // Growl sometimes sends timeout notifications twice for the same message. We therefore need
- // to keep track of which ones have already been processed.
- p->pendingNotifications.insert(context);
-
- [GrowlApplicationBridge
- notifyWithTitle: std2NSString(subject)
- description: std2NSString(description)
- notificationName: std2NSString(typeToString(type))
- iconData: [NSData dataWithBytes: vecptr(picture) length: picture.size()]
- priority: 0
- isSticky: NO
- clickContext: [NSData dataWithBytes: &context length: sizeof(context)]];
+ ByteArray picture;
+ readByteArrayFromFile(picture, picturePath);
+
+ Context* context = new Context(callback);
+ // Growl sometimes sends timeout notifications twice for the same message. We therefore need
+ // to keep track of which ones have already been processed.
+ p->pendingNotifications.insert(context);
+
+ [GrowlApplicationBridge
+ notifyWithTitle: std2NSString(subject)
+ description: std2NSString(description)
+ notificationName: std2NSString(typeToString(type))
+ iconData: [NSData dataWithBytes: vecptr(picture) length: picture.size()]
+ priority: 0
+ isSticky: NO
+ clickContext: [NSData dataWithBytes: &context length: sizeof(context)]];
}
void GrowlNotifier::handleNotificationClicked(void* rawData) {
- Context* context = *(Context**) [((NSData*) rawData) bytes];
- if (p->pendingNotifications.erase(context) > 0) {
- if (!context->callback->empty()) {
- (*context->callback)();
- }
- delete context;
- }
+ Context* context = *(Context**) [((NSData*) rawData) bytes];
+ if (p->pendingNotifications.erase(context) > 0) {
+ if (!context->callback->empty()) {
+ (*context->callback)();
+ }
+ delete context;
+ }
}
void GrowlNotifier::handleNotificationTimedOut(void* rawData) {
- Context* context = *(Context**) [((NSData*) rawData) bytes];
- if (p->pendingNotifications.erase(context) > 0) {
- delete context;
- }
+ Context* context = *(Context**) [((NSData*) rawData) bytes];
+ if (p->pendingNotifications.erase(context) > 0) {
+ delete context;
+ }
}
bool GrowlNotifier::isExternallyConfigured() const {
- return ![GrowlApplicationBridge isMistEnabled];
+ return ![GrowlApplicationBridge isMistEnabled];
}
void GrowlNotifier::purgeCallbacks() {
- clearPendingNotifications();
+ clearPendingNotifications();
}
void GrowlNotifier::clearPendingNotifications() {
- foreach (Context* context, p->pendingNotifications) {
- delete context;
- }
- p->pendingNotifications.clear();
+ foreach (Context* context, p->pendingNotifications) {
+ delete context;
+ }
+ p->pendingNotifications.clear();
}
}
diff --git a/SwifTools/Notifier/GrowlNotifierDelegate.h b/SwifTools/Notifier/GrowlNotifierDelegate.h
index 0640ff7..f4ce132 100644
--- a/SwifTools/Notifier/GrowlNotifierDelegate.h
+++ b/SwifTools/Notifier/GrowlNotifierDelegate.h
@@ -7,13 +7,13 @@
#import <Growl/Growl.h>
namespace Swift {
- class GrowlNotifier;
+ class GrowlNotifier;
}
@interface GrowlNotifierDelegate : NSObject<GrowlApplicationBridgeDelegate> {
- Swift::GrowlNotifier* notifier;
- NSString* name;
- NSDictionary* registrationDictionary;
+ Swift::GrowlNotifier* notifier;
+ NSString* name;
+ NSDictionary* registrationDictionary;
}
@property (nonatomic, retain) NSDictionary* registrationDictionary;
diff --git a/SwifTools/Notifier/GrowlNotifierDelegate.mm b/SwifTools/Notifier/GrowlNotifierDelegate.mm
index 1d934ad..77df3ab 100644
--- a/SwifTools/Notifier/GrowlNotifierDelegate.mm
+++ b/SwifTools/Notifier/GrowlNotifierDelegate.mm
@@ -17,19 +17,19 @@
using namespace Swift;
- (NSString *) applicationNameForGrowl {
- return name;
+ return name;
}
- (NSDictionary*) registrationDictionaryForGrowl {
- return registrationDictionary;
+ return registrationDictionary;
}
- (void) growlNotificationWasClicked: (id) clickContext {
- notifier->handleNotificationClicked(clickContext);
+ notifier->handleNotificationClicked(clickContext);
}
- (void) growlNotificationTimedOut: (id) clickContext {
- notifier->handleNotificationTimedOut(clickContext);
+ notifier->handleNotificationTimedOut(clickContext);
}
@end
diff --git a/SwifTools/Notifier/LoggingNotifier.h b/SwifTools/Notifier/LoggingNotifier.h
index d50cb2d..e12500b 100644
--- a/SwifTools/Notifier/LoggingNotifier.h
+++ b/SwifTools/Notifier/LoggingNotifier.h
@@ -11,23 +11,23 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class LoggingNotifier : public Notifier {
- public:
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
- notifications.push_back(Notification(type, subject, description, picture, callback));
- }
+ class LoggingNotifier : public Notifier {
+ public:
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ notifications.push_back(Notification(type, subject, description, picture, callback));
+ }
- struct Notification {
- Notification(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {}
- Type type;
- std::string subject;
- std::string description;
- boost::filesystem::path picture;
- boost::function<void()> callback;
- };
+ struct Notification {
+ Notification(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {}
+ Type type;
+ std::string subject;
+ std::string description;
+ boost::filesystem::path picture;
+ boost::function<void()> callback;
+ };
- virtual void purgeCallbacks() {}
+ virtual void purgeCallbacks() {}
- std::vector<Notification> notifications;
- };
+ std::vector<Notification> notifications;
+ };
}
diff --git a/SwifTools/Notifier/NotificationCenterNotifier.h b/SwifTools/Notifier/NotificationCenterNotifier.h
index 0d43c5b..75b4df7 100644
--- a/SwifTools/Notifier/NotificationCenterNotifier.h
+++ b/SwifTools/Notifier/NotificationCenterNotifier.h
@@ -18,21 +18,21 @@ namespace Swift {
*/
class NotificationCenterNotifier : public Notifier {
public:
- NotificationCenterNotifier();
- virtual ~NotificationCenterNotifier();
+ NotificationCenterNotifier();
+ virtual ~NotificationCenterNotifier();
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void ()> callback);
- virtual void purgeCallbacks();
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void ()> callback);
+ virtual void purgeCallbacks();
- /**
- * @brief The handleUserNotificationActivated is called by the delegate, when a user activates/clicks on a notification.
- * @param identifier The std::string UUID identifiying the notification.
- */
- void handleUserNotificationActivated(const std::string& identifier);
+ /**
+ * @brief The handleUserNotificationActivated is called by the delegate, when a user activates/clicks on a notification.
+ * @param identifier The std::string UUID identifiying the notification.
+ */
+ void handleUserNotificationActivated(const std::string& identifier);
private:
- class Private;
- boost::shared_ptr<Private> p;
+ class Private;
+ boost::shared_ptr<Private> p;
};
}
diff --git a/SwifTools/Notifier/NotificationCenterNotifier.mm b/SwifTools/Notifier/NotificationCenterNotifier.mm
index 01e6368..57b9a4b 100644
--- a/SwifTools/Notifier/NotificationCenterNotifier.mm
+++ b/SwifTools/Notifier/NotificationCenterNotifier.mm
@@ -19,78 +19,78 @@
#include <SwifTools/Cocoa/CocoaUtil.h>
namespace {
- struct Context {
- Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {
- }
+ struct Context {
+ Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {
+ }
- ~Context() {
- delete callback;
- }
+ ~Context() {
+ delete callback;
+ }
- boost::function<void()>* callback;
- };
+ boost::function<void()>* callback;
+ };
}
namespace Swift {
class NotificationCenterNotifier::Private {
- public:
- std::map<std::string, boost::shared_ptr<Context> > callbacksForNotifications;
- boost::intrusive_ptr<NotificationCenterNotifierDelegate> delegate;
+ public:
+ std::map<std::string, boost::shared_ptr<Context> > callbacksForNotifications;
+ boost::intrusive_ptr<NotificationCenterNotifierDelegate> delegate;
};
NotificationCenterNotifier::NotificationCenterNotifier() {
- p = boost::make_shared<Private>();
- p->delegate = boost::intrusive_ptr<NotificationCenterNotifierDelegate>([[NotificationCenterNotifierDelegate alloc] init], false);
- [p->delegate.get() setNotifier: this];
+ p = boost::make_shared<Private>();
+ p->delegate = boost::intrusive_ptr<NotificationCenterNotifierDelegate>([[NotificationCenterNotifierDelegate alloc] init], false);
+ [p->delegate.get() setNotifier: this];
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: p->delegate.get()];
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: p->delegate.get()];
}
NotificationCenterNotifier::~NotificationCenterNotifier() {
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: nil];
- p->callbacksForNotifications.clear();
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: nil];
+ p->callbacksForNotifications.clear();
}
void NotificationCenterNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void ()> callback) {
- std::vector<Notifier::Type> defaultTypes = getDefaultTypes();
- if (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end()) {
- return;
- }
- NSImage* image = [[NSImage alloc] initWithContentsOfFile: std2NSString(picture.string())];
- NSUserNotification* notification = [[NSUserNotification alloc] init];
- [notification setTitle:std2NSString(typeToString(type))];
- [notification setSubtitle:std2NSString(subject)];
- [notification setInformativeText:std2NSString(description)];
- [notification setContentImage: image];
- [image release];
-
- // The OS X Notification Center API does not allow to attach custom data, like a pointer to a callback function,
- // to the NSUserNotification object. Therefore we maintain a mapping from a NSUserNotification instance's identification
- // to their respective callbacks.
- [notification setIdentifier:[[NSUUID UUID] UUIDString]];
-
- /// \todo Currently the elements are only removed on application exit. Ideally the notifications not required anymore
- /// are removed from the map; e.g. when visiting a chat view, all notifications from that view can be removed from
- /// the map and the NSUserNotificationCenter.
- p->callbacksForNotifications[ns2StdString(notification.identifier)] = boost::make_shared<Context>(callback);
- [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
- [notification release];
+ std::vector<Notifier::Type> defaultTypes = getDefaultTypes();
+ if (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end()) {
+ return;
+ }
+ NSImage* image = [[NSImage alloc] initWithContentsOfFile: std2NSString(picture.string())];
+ NSUserNotification* notification = [[NSUserNotification alloc] init];
+ [notification setTitle:std2NSString(typeToString(type))];
+ [notification setSubtitle:std2NSString(subject)];
+ [notification setInformativeText:std2NSString(description)];
+ [notification setContentImage: image];
+ [image release];
+
+ // The OS X Notification Center API does not allow to attach custom data, like a pointer to a callback function,
+ // to the NSUserNotification object. Therefore we maintain a mapping from a NSUserNotification instance's identification
+ // to their respective callbacks.
+ [notification setIdentifier:[[NSUUID UUID] UUIDString]];
+
+ /// \todo Currently the elements are only removed on application exit. Ideally the notifications not required anymore
+ /// are removed from the map; e.g. when visiting a chat view, all notifications from that view can be removed from
+ /// the map and the NSUserNotificationCenter.
+ p->callbacksForNotifications[ns2StdString(notification.identifier)] = boost::make_shared<Context>(callback);
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ [notification release];
}
void NotificationCenterNotifier::purgeCallbacks() {
- p->callbacksForNotifications.clear();
+ p->callbacksForNotifications.clear();
}
void NotificationCenterNotifier::handleUserNotificationActivated(const std::string& identifier) {
- if (p->callbacksForNotifications.find(identifier) != p->callbacksForNotifications.end()) {
- if (!(*p->callbacksForNotifications[identifier]->callback).empty()) {
- (*p->callbacksForNotifications[identifier]->callback)();
- }
- }
- else {
- SWIFT_LOG(warning) << "Missing callback entry for activated notification. The activate notification may come from another instance." << std::endl;
- }
+ if (p->callbacksForNotifications.find(identifier) != p->callbacksForNotifications.end()) {
+ if (!(*p->callbacksForNotifications[identifier]->callback).empty()) {
+ (*p->callbacksForNotifications[identifier]->callback)();
+ }
+ }
+ else {
+ SWIFT_LOG(warning) << "Missing callback entry for activated notification. The activate notification may come from another instance." << std::endl;
+ }
}
}
diff --git a/SwifTools/Notifier/NotificationCenterNotifierDelegate.h b/SwifTools/Notifier/NotificationCenterNotifierDelegate.h
index ea8fae0..f09c09f 100644
--- a/SwifTools/Notifier/NotificationCenterNotifierDelegate.h
+++ b/SwifTools/Notifier/NotificationCenterNotifierDelegate.h
@@ -9,7 +9,7 @@
#import <Cocoa/Cocoa.h>
namespace Swift {
- class NotificationCenterNotifier;
+ class NotificationCenterNotifier;
}
@interface NotificationCenterNotifierDelegate : NSObject<NSUserNotificationCenterDelegate> {
diff --git a/SwifTools/Notifier/NotificationCenterNotifierDelegate.mm b/SwifTools/Notifier/NotificationCenterNotifierDelegate.mm
index 2b1c2a4..84ec943 100644
--- a/SwifTools/Notifier/NotificationCenterNotifierDelegate.mm
+++ b/SwifTools/Notifier/NotificationCenterNotifierDelegate.mm
@@ -18,9 +18,9 @@ using namespace Swift;
@synthesize notifier;
- (void)userNotificationCenter:(NSUserNotificationCenter *) center didActivateNotification:(NSUserNotification *)notification {
- (void)center;
- std::string identifier = ns2StdString(notification.identifier);
- notifier->handleUserNotificationActivated(identifier);
+ (void)center;
+ std::string identifier = ns2StdString(notification.identifier);
+ notifier->handleUserNotificationActivated(identifier);
}
@end
diff --git a/SwifTools/Notifier/Notifier.cpp b/SwifTools/Notifier/Notifier.cpp
index b8fd1a0..314d39c 100644
--- a/SwifTools/Notifier/Notifier.cpp
+++ b/SwifTools/Notifier/Notifier.cpp
@@ -15,32 +15,32 @@ Notifier::~Notifier() {
}
std::string Notifier::typeToString(Type type) {
- switch (type) {
- case ContactAvailable: return "Contact Becomes Available";
- case ContactUnavailable: return "Contact Becomes Unavailable";
- case ContactStatusChange: return "Contact Changes Status";
- case IncomingMessage: return "Incoming Message";
- case SystemMessage: return "System Message";
- }
- assert(false);
- return "";
+ switch (type) {
+ case ContactAvailable: return "Contact Becomes Available";
+ case ContactUnavailable: return "Contact Becomes Unavailable";
+ case ContactStatusChange: return "Contact Changes Status";
+ case IncomingMessage: return "Incoming Message";
+ case SystemMessage: return "System Message";
+ }
+ assert(false);
+ return "";
}
std::vector<Notifier::Type> Notifier::getAllTypes() {
- std::vector<Type> result;
- result.push_back(ContactAvailable);
- result.push_back(ContactUnavailable);
- result.push_back(ContactStatusChange);
- result.push_back(IncomingMessage);
- result.push_back(SystemMessage);
- return result;
+ std::vector<Type> result;
+ result.push_back(ContactAvailable);
+ result.push_back(ContactUnavailable);
+ result.push_back(ContactStatusChange);
+ result.push_back(IncomingMessage);
+ result.push_back(SystemMessage);
+ return result;
}
std::vector<Notifier::Type> Notifier::getDefaultTypes() {
- std::vector<Type> result;
- result.push_back(IncomingMessage);
- result.push_back(SystemMessage);
- return result;
+ std::vector<Type> result;
+ result.push_back(IncomingMessage);
+ result.push_back(SystemMessage);
+ return result;
}
}
diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h
index b099701..afd596b 100644
--- a/SwifTools/Notifier/Notifier.h
+++ b/SwifTools/Notifier/Notifier.h
@@ -13,39 +13,39 @@
#include <boost/function.hpp>
namespace Swift {
- class Notifier {
- public:
- virtual ~Notifier();
-
- enum Type { ContactAvailable, ContactUnavailable, ContactStatusChange, IncomingMessage, SystemMessage };
-
- /**
- * Picture is a PNG image.
- */
- virtual void showMessage(
- Type type,
- const std::string& subject,
- const std::string& description,
- const boost::filesystem::path& picture,
- boost::function<void()> callback) = 0;
-
- virtual bool isAvailable() const {
- return true;
- }
-
- virtual bool isExternallyConfigured() const {
- return false;
- }
-
- /** Remove any pending callbacks. */
- virtual void purgeCallbacks() = 0;
-
- protected:
- std::string typeToString(Type type);
- static std::vector<Type> getAllTypes();
- static std::vector<Type> getDefaultTypes();
-
- static const int DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
- static const int DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS;
- };
+ class Notifier {
+ public:
+ virtual ~Notifier();
+
+ enum Type { ContactAvailable, ContactUnavailable, ContactStatusChange, IncomingMessage, SystemMessage };
+
+ /**
+ * Picture is a PNG image.
+ */
+ virtual void showMessage(
+ Type type,
+ const std::string& subject,
+ const std::string& description,
+ const boost::filesystem::path& picture,
+ boost::function<void()> callback) = 0;
+
+ virtual bool isAvailable() const {
+ return true;
+ }
+
+ virtual bool isExternallyConfigured() const {
+ return false;
+ }
+
+ /** Remove any pending callbacks. */
+ virtual void purgeCallbacks() = 0;
+
+ protected:
+ std::string typeToString(Type type);
+ static std::vector<Type> getAllTypes();
+ static std::vector<Type> getDefaultTypes();
+
+ static const int DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
+ static const int DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS;
+ };
}
diff --git a/SwifTools/Notifier/NullNotifier.h b/SwifTools/Notifier/NullNotifier.h
index 1f6d7d9..8945a53 100644
--- a/SwifTools/Notifier/NullNotifier.h
+++ b/SwifTools/Notifier/NullNotifier.h
@@ -9,11 +9,11 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class NullNotifier : public Notifier {
- public:
- virtual void showMessage(Type, const std::string&, const std::string&, const boost::filesystem::path&, boost::function<void()>) {
- }
- virtual void purgeCallbacks() {
- }
- };
+ class NullNotifier : public Notifier {
+ public:
+ virtual void showMessage(Type, const std::string&, const std::string&, const boost::filesystem::path&, boost::function<void()>) {
+ }
+ virtual void purgeCallbacks() {
+ }
+ };
}
diff --git a/SwifTools/Notifier/SnarlNotifier.cpp b/SwifTools/Notifier/SnarlNotifier.cpp
index b4e5ef3..e3977a7 100644
--- a/SwifTools/Notifier/SnarlNotifier.cpp
+++ b/SwifTools/Notifier/SnarlNotifier.cpp
@@ -18,56 +18,56 @@
namespace Swift {
SnarlNotifier::SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon) : window(window), available(false) {
- window->onMessageReceived.connect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1));
- available = snarl.RegisterApp(name.c_str(), name.c_str(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID);
- foreach(Notifier::Type type, getAllTypes()) {
- snarl.AddClass(typeToString(type).c_str(), typeToString(type).c_str());
- }
+ window->onMessageReceived.connect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1));
+ available = snarl.RegisterApp(name.c_str(), name.c_str(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID);
+ foreach(Notifier::Type type, getAllTypes()) {
+ snarl.AddClass(typeToString(type).c_str(), typeToString(type).c_str());
+ }
}
SnarlNotifier::~SnarlNotifier() {
- snarl.UnregisterApp();
- window->onMessageReceived.disconnect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1));
- if (!notifications.empty()) {
- std::cerr << "Warning: " << notifications.size() << " Snarl notifications pending" << std::endl;
- }
+ snarl.UnregisterApp();
+ window->onMessageReceived.disconnect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1));
+ if (!notifications.empty()) {
+ std::cerr << "Warning: " << notifications.size() << " Snarl notifications pending" << std::endl;
+ }
}
bool SnarlNotifier::isAvailable() const {
- return available;
+ return available;
}
void SnarlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
- int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
- int notificationID = snarl.EZNotify(
- typeToString(type).c_str(),
- subject.c_str(),
- description.c_str(),
- timeout,
- picture.string().c_str());
- if (notificationID > 0) {
- notifications.insert(std::make_pair(notificationID, callback));
- }
+ int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
+ int notificationID = snarl.EZNotify(
+ typeToString(type).c_str(),
+ subject.c_str(),
+ description.c_str(),
+ timeout,
+ picture.string().c_str());
+ if (notificationID > 0) {
+ notifications.insert(std::make_pair(notificationID, callback));
+ }
}
void SnarlNotifier::handleMessageReceived(MSG* message) {
- if (message->message == SWIFT_SNARLNOTIFIER_MESSAGE_ID) {
- int action = message->wParam;
- if (action == Snarl::V41::SnarlEnums::NotificationTimedOut || action == Snarl::V41::SnarlEnums::NotificationAck || action == Snarl::V41::SnarlEnums::NotificationClosed) {
- int notificationID = message->lParam;
- NotificationsMap::iterator i = notifications.find(notificationID);
- if (i != notifications.end()) {
- if (action == Snarl::V41::SnarlEnums::NotificationAck && !i->second.empty()) {
- i->second();
- }
- notifications.erase(i);
- }
- else {
- std::cerr << "Warning: Orphaned Snarl notification received";
- }
- }
- }
+ if (message->message == SWIFT_SNARLNOTIFIER_MESSAGE_ID) {
+ int action = message->wParam;
+ if (action == Snarl::V41::SnarlEnums::NotificationTimedOut || action == Snarl::V41::SnarlEnums::NotificationAck || action == Snarl::V41::SnarlEnums::NotificationClosed) {
+ int notificationID = message->lParam;
+ NotificationsMap::iterator i = notifications.find(notificationID);
+ if (i != notifications.end()) {
+ if (action == Snarl::V41::SnarlEnums::NotificationAck && !i->second.empty()) {
+ i->second();
+ }
+ notifications.erase(i);
+ }
+ else {
+ std::cerr << "Warning: Orphaned Snarl notification received";
+ }
+ }
+ }
}
}
diff --git a/SwifTools/Notifier/SnarlNotifier.h b/SwifTools/Notifier/SnarlNotifier.h
index b8b9a48..5006185 100644
--- a/SwifTools/Notifier/SnarlNotifier.h
+++ b/SwifTools/Notifier/SnarlNotifier.h
@@ -13,28 +13,28 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class Win32NotifierWindow;
-
- class SnarlNotifier : public Notifier {
- public:
- SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon);
- ~SnarlNotifier();
-
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
- virtual bool isAvailable() const;
-
- virtual void purgeCallbacks() {
- notifications.clear();
- }
-
- private:
- void handleMessageReceived(MSG* message);
-
- private:
- Snarl::V41::SnarlInterface snarl;
- Win32NotifierWindow* window;
- bool available;
- typedef std::map<int, boost::function<void()> > NotificationsMap;
- NotificationsMap notifications;
- };
+ class Win32NotifierWindow;
+
+ class SnarlNotifier : public Notifier {
+ public:
+ SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon);
+ ~SnarlNotifier();
+
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual bool isAvailable() const;
+
+ virtual void purgeCallbacks() {
+ notifications.clear();
+ }
+
+ private:
+ void handleMessageReceived(MSG* message);
+
+ private:
+ Snarl::V41::SnarlInterface snarl;
+ Win32NotifierWindow* window;
+ bool available;
+ typedef std::map<int, boost::function<void()> > NotificationsMap;
+ NotificationsMap notifications;
+ };
}
diff --git a/SwifTools/Notifier/TogglableNotifier.h b/SwifTools/Notifier/TogglableNotifier.h
index 5580322..c537a6f 100644
--- a/SwifTools/Notifier/TogglableNotifier.h
+++ b/SwifTools/Notifier/TogglableNotifier.h
@@ -9,54 +9,54 @@
#include <SwifTools/Notifier/Notifier.h>
namespace Swift {
- class TogglableNotifier : public Notifier {
- public:
- TogglableNotifier(Notifier* notifier) : notifier(notifier), persistentEnabled(true), temporarilyDisabled(false) {
- }
-
- /**
- * Set a long-term (usually user-set) enabled.
- * This may be temporarily overriden by the application, e.g. if the
- * user is marked DND.
- */
- void setPersistentEnabled(bool b) {
- persistentEnabled = b;
- }
-
- /**
- * Set a temporary override to stop notifications without changing the
- * long-term state. e.g. if the user goes DND, but the persistent
- * enabled shouldn't be lost when they become available again.
- */
- void setTemporarilyDisabled(bool b) {
- temporarilyDisabled = b;
- }
-
- /**
- * Get the result of applying the temporary override to the persistent
- * enabledness.
- */
- bool getCurrentlyEnabled() const {
- return persistentEnabled && !temporarilyDisabled;
- }
-
- virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
- if (getCurrentlyEnabled() || notifier->isExternallyConfigured()) {
- notifier->showMessage(type, subject, description, picture, callback);
- }
- }
-
- virtual bool isExternallyConfigured() const {
- return notifier->isExternallyConfigured();
- }
-
- virtual void purgeCallbacks() {
- notifier->purgeCallbacks();
- }
-
- private:
- Notifier* notifier;
- bool persistentEnabled;
- bool temporarilyDisabled;
- };
+ class TogglableNotifier : public Notifier {
+ public:
+ TogglableNotifier(Notifier* notifier) : notifier(notifier), persistentEnabled(true), temporarilyDisabled(false) {
+ }
+
+ /**
+ * Set a long-term (usually user-set) enabled.
+ * This may be temporarily overriden by the application, e.g. if the
+ * user is marked DND.
+ */
+ void setPersistentEnabled(bool b) {
+ persistentEnabled = b;
+ }
+
+ /**
+ * Set a temporary override to stop notifications without changing the
+ * long-term state. e.g. if the user goes DND, but the persistent
+ * enabled shouldn't be lost when they become available again.
+ */
+ void setTemporarilyDisabled(bool b) {
+ temporarilyDisabled = b;
+ }
+
+ /**
+ * Get the result of applying the temporary override to the persistent
+ * enabledness.
+ */
+ bool getCurrentlyEnabled() const {
+ return persistentEnabled && !temporarilyDisabled;
+ }
+
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ if (getCurrentlyEnabled() || notifier->isExternallyConfigured()) {
+ notifier->showMessage(type, subject, description, picture, callback);
+ }
+ }
+
+ virtual bool isExternallyConfigured() const {
+ return notifier->isExternallyConfigured();
+ }
+
+ virtual void purgeCallbacks() {
+ notifier->purgeCallbacks();
+ }
+
+ private:
+ Notifier* notifier;
+ bool persistentEnabled;
+ bool temporarilyDisabled;
+ };
}
diff --git a/SwifTools/Notifier/Win32NotifierWindow.h b/SwifTools/Notifier/Win32NotifierWindow.h
index 8e67146..3f03825 100644
--- a/SwifTools/Notifier/Win32NotifierWindow.h
+++ b/SwifTools/Notifier/Win32NotifierWindow.h
@@ -11,12 +11,12 @@
#include <Swiften/Base/boost_bsignals.h>
namespace Swift {
- class Win32NotifierWindow {
- public:
- virtual ~Win32NotifierWindow() {}
+ class Win32NotifierWindow {
+ public:
+ virtual ~Win32NotifierWindow() {}
- virtual HWND getID() const = 0;
+ virtual HWND getID() const = 0;
- boost::signal<void (MSG*)> onMessageReceived;
- };
+ boost::signal<void (MSG*)> onMessageReceived;
+ };
}
diff --git a/SwifTools/SpellChecker.h b/SwifTools/SpellChecker.h
index e161d20..415d3f6 100644
--- a/SwifTools/SpellChecker.h
+++ b/SwifTools/SpellChecker.h
@@ -20,18 +20,18 @@
#include <SwifTools/SpellParser.h>
namespace Swift {
- class SpellChecker {
- public:
- SpellChecker() {
- parser_ = new SpellParser();
- }
- virtual ~SpellChecker() {
- delete parser_;
- }
- virtual bool isCorrect(const std::string& word) = 0;
- virtual void getSuggestions(const std::string& word, std::vector<std::string>& list) = 0;
- virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) = 0;
- protected:
- SpellParser *parser_;
- };
+ class SpellChecker {
+ public:
+ SpellChecker() {
+ parser_ = new SpellParser();
+ }
+ virtual ~SpellChecker() {
+ delete parser_;
+ }
+ virtual bool isCorrect(const std::string& word) = 0;
+ virtual void getSuggestions(const std::string& word, std::vector<std::string>& list) = 0;
+ virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) = 0;
+ protected:
+ SpellParser *parser_;
+ };
}
diff --git a/SwifTools/SpellCheckerFactory.cpp b/SwifTools/SpellCheckerFactory.cpp
index 428e1a5..e53447e 100644
--- a/SwifTools/SpellCheckerFactory.cpp
+++ b/SwifTools/SpellCheckerFactory.cpp
@@ -24,17 +24,17 @@ SpellCheckerFactory::SpellCheckerFactory() {
#ifdef HAVE_HUNSPELL
SpellChecker* SpellCheckerFactory::createSpellChecker(const std::string& dictFile) {
- std::string affixFile(dictFile);
- boost::replace_all(affixFile, ".dic", ".aff");
- if ((boost::filesystem::exists(dictFile)) && (boost::filesystem::exists(affixFile))) {
- return new HunspellChecker(affixFile.c_str(), dictFile.c_str());
- }
- // If dictionaries don't exist disable the checker
- return NULL;
+ std::string affixFile(dictFile);
+ boost::replace_all(affixFile, ".dic", ".aff");
+ if ((boost::filesystem::exists(dictFile)) && (boost::filesystem::exists(affixFile))) {
+ return new HunspellChecker(affixFile.c_str(), dictFile.c_str());
+ }
+ // If dictionaries don't exist disable the checker
+ return NULL;
}
#elif defined(SWIFTEN_PLATFORM_MACOSX)
SpellChecker* SpellCheckerFactory::createSpellChecker(const std::string& /*dictFile*/) {
- return new MacOSXChecker();
+ return new MacOSXChecker();
}
#endif
diff --git a/SwifTools/SpellCheckerFactory.h b/SwifTools/SpellCheckerFactory.h
index 91118f9..a0de98c 100644
--- a/SwifTools/SpellCheckerFactory.h
+++ b/SwifTools/SpellCheckerFactory.h
@@ -15,10 +15,10 @@
#endif
namespace Swift {
- class SpellChecker;
- class SpellCheckerFactory {
- public:
- SpellCheckerFactory();
- SpellChecker* createSpellChecker(const std::string& dictFile);
- };
+ class SpellChecker;
+ class SpellCheckerFactory {
+ public:
+ SpellCheckerFactory();
+ SpellChecker* createSpellChecker(const std::string& dictFile);
+ };
}
diff --git a/SwifTools/SpellParser.cpp b/SwifTools/SpellParser.cpp
index e60486f..5bafa6e 100644
--- a/SwifTools/SpellParser.cpp
+++ b/SwifTools/SpellParser.cpp
@@ -26,51 +26,51 @@ namespace Swift {
template <typename Lexer>
struct word_count_tokens : lex::lexer<Lexer>
{
- word_count_tokens()
- {
- // define tokens (regular expresions) to match strings
- // order is important
- this->self.add
- ("w{3}.[^ ]+", ID_WWW)
- ("http:\\/\\/[^ ]+", ID_HTTP)
- ("\\w{1,}['?|\\-?]?\\w{1,}", ID_WORD)
- (".", ID_CHAR);
- }
+ word_count_tokens()
+ {
+ // define tokens (regular expresions) to match strings
+ // order is important
+ this->self.add
+ ("w{3}.[^ ]+", ID_WWW)
+ ("http:\\/\\/[^ ]+", ID_HTTP)
+ ("\\w{1,}['?|\\-?]?\\w{1,}", ID_WORD)
+ (".", ID_CHAR);
+ }
};
struct counter
{
- typedef bool result_type;
- // the function operator gets called for each of the matched tokens
- template <typename Token>
- bool operator()(Token const& t, PositionPairList& wordPositions, std::size_t& position) const
- {
- switch (t.id()) {
- case ID_WWW:
- position += boost::numeric_cast<size_t>(t.value().size());
- break;
- case ID_HTTP:
- position += boost::numeric_cast<size_t>(t.value().size());
- break;
- case ID_WORD: // matched a word
- wordPositions.push_back(boost::tuples::make_tuple(position, position + boost::numeric_cast<size_t>(t.value().size())));
- position += boost::numeric_cast<size_t>(t.value().size());
- break;
- case ID_CHAR: // match a simple char
- ++position;
- break;
- }
- return true; // always continue to tokenize
- }
+ typedef bool result_type;
+ // the function operator gets called for each of the matched tokens
+ template <typename Token>
+ bool operator()(Token const& t, PositionPairList& wordPositions, std::size_t& position) const
+ {
+ switch (t.id()) {
+ case ID_WWW:
+ position += boost::numeric_cast<size_t>(t.value().size());
+ break;
+ case ID_HTTP:
+ position += boost::numeric_cast<size_t>(t.value().size());
+ break;
+ case ID_WORD: // matched a word
+ wordPositions.push_back(boost::tuples::make_tuple(position, position + boost::numeric_cast<size_t>(t.value().size())));
+ position += boost::numeric_cast<size_t>(t.value().size());
+ break;
+ case ID_CHAR: // match a simple char
+ ++position;
+ break;
+ }
+ return true; // always continue to tokenize
+ }
};
void SpellParser::check(const std::string& fragment, PositionPairList& wordPositions) {
- std::size_t position = 0;
- // create the token definition instance needed to invoke the lexical analyzer
- word_count_tokens<lex::lexertl::lexer<> > word_count_functor;
- char const* first = fragment.c_str();
- char const* last = &first[fragment.size()];
- lex::tokenize(first, last, word_count_functor, boost::bind(counter(), _1, boost::ref(wordPositions), boost::ref(position)));
+ std::size_t position = 0;
+ // create the token definition instance needed to invoke the lexical analyzer
+ word_count_tokens<lex::lexertl::lexer<> > word_count_functor;
+ char const* first = fragment.c_str();
+ char const* last = &first[fragment.size()];
+ lex::tokenize(first, last, word_count_functor, boost::bind(counter(), _1, boost::ref(wordPositions), boost::ref(position)));
}
}
diff --git a/SwifTools/SpellParser.h b/SwifTools/SpellParser.h
index b37cb48..5b057c9 100644
--- a/SwifTools/SpellParser.h
+++ b/SwifTools/SpellParser.h
@@ -18,19 +18,19 @@
#include <boost/tuple/tuple.hpp>
namespace Swift {
- enum token_ids
- {
- ID_WWW = 1,
- ID_HTTP = 2,
- ID_WORD = 3,
- ID_CHAR = 4
- };
+ enum token_ids
+ {
+ ID_WWW = 1,
+ ID_HTTP = 2,
+ ID_WORD = 3,
+ ID_CHAR = 4
+ };
- typedef boost::tuple<int, int> PositionPair;
- typedef std::vector<PositionPair > PositionPairList;
+ typedef boost::tuple<int, int> PositionPair;
+ typedef std::vector<PositionPair > PositionPairList;
- class SpellParser{
- public:
- void check(const std::string& fragment, PositionPairList& wordPositions);
- };
+ class SpellParser{
+ public:
+ void check(const std::string& fragment, PositionPairList& wordPositions);
+ };
}
diff --git a/SwifTools/TabComplete.cpp b/SwifTools/TabComplete.cpp
index 4796f1b..f158ffa 100644
--- a/SwifTools/TabComplete.cpp
+++ b/SwifTools/TabComplete.cpp
@@ -15,42 +15,42 @@
namespace Swift {
void TabComplete::addWord(const std::string& word) {
- words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
- words_.insert(words_.begin(), word);
- if (boost::starts_with(boost::to_lower_copy(word), lastShort_)) {
- lastCompletionCandidates_.insert(lastCompletionCandidates_.begin(), word);
- }
+ words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
+ words_.insert(words_.begin(), word);
+ if (boost::starts_with(boost::to_lower_copy(word), lastShort_)) {
+ lastCompletionCandidates_.insert(lastCompletionCandidates_.begin(), word);
+ }
}
void TabComplete::removeWord(const std::string& word) {
- words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
- lastCompletionCandidates_.erase(std::remove(lastCompletionCandidates_.begin(), lastCompletionCandidates_.end(), word), lastCompletionCandidates_.end());
+ words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
+ lastCompletionCandidates_.erase(std::remove(lastCompletionCandidates_.begin(), lastCompletionCandidates_.end(), word), lastCompletionCandidates_.end());
}
std::string TabComplete::completeWord(const std::string& word) {
- if (word == lastCompletion_) {
- if (!lastCompletionCandidates_.empty()) {
- size_t match = 0;
- for (match = 0; match < lastCompletionCandidates_.size(); match++) {
- if (lastCompletionCandidates_[match] == lastCompletion_) {
- break;
- }
- }
- size_t nextIndex = match + 1;
- nextIndex = nextIndex >= lastCompletionCandidates_.size() ? 0 : nextIndex;
- lastCompletion_ = lastCompletionCandidates_[nextIndex];
- }
- } else {
- lastShort_ = boost::to_lower_copy(word);
- lastCompletionCandidates_.clear();
- foreach (std::string candidate, words_) {
- if (boost::starts_with(boost::to_lower_copy(candidate), boost::to_lower_copy(word))) {
- lastCompletionCandidates_.push_back(candidate);
- }
- }
- lastCompletion_ = !lastCompletionCandidates_.empty() ? lastCompletionCandidates_[0] : word;
- }
- return lastCompletion_;
+ if (word == lastCompletion_) {
+ if (!lastCompletionCandidates_.empty()) {
+ size_t match = 0;
+ for (match = 0; match < lastCompletionCandidates_.size(); match++) {
+ if (lastCompletionCandidates_[match] == lastCompletion_) {
+ break;
+ }
+ }
+ size_t nextIndex = match + 1;
+ nextIndex = nextIndex >= lastCompletionCandidates_.size() ? 0 : nextIndex;
+ lastCompletion_ = lastCompletionCandidates_[nextIndex];
+ }
+ } else {
+ lastShort_ = boost::to_lower_copy(word);
+ lastCompletionCandidates_.clear();
+ foreach (std::string candidate, words_) {
+ if (boost::starts_with(boost::to_lower_copy(candidate), boost::to_lower_copy(word))) {
+ lastCompletionCandidates_.push_back(candidate);
+ }
+ }
+ lastCompletion_ = !lastCompletionCandidates_.empty() ? lastCompletionCandidates_[0] : word;
+ }
+ return lastCompletion_;
}
}
diff --git a/SwifTools/TabComplete.h b/SwifTools/TabComplete.h
index a1bdc40..ac1e07e 100644
--- a/SwifTools/TabComplete.h
+++ b/SwifTools/TabComplete.h
@@ -10,15 +10,15 @@
#include <vector>
namespace Swift {
- class TabComplete {
- public:
- void addWord(const std::string& word);
- void removeWord(const std::string& word);
- std::string completeWord(const std::string& word);
- private:
- std::vector<std::string> words_;
- std::string lastCompletion_;
- std::string lastShort_;
- std::vector<std::string> lastCompletionCandidates_;
- };
+ class TabComplete {
+ public:
+ void addWord(const std::string& word);
+ void removeWord(const std::string& word);
+ std::string completeWord(const std::string& word);
+ private:
+ std::vector<std::string> words_;
+ std::string lastCompletion_;
+ std::string lastShort_;
+ std::vector<std::string> lastCompletionCandidates_;
+ };
}
diff --git a/SwifTools/URIHandler/MacOSXURIHandler.h b/SwifTools/URIHandler/MacOSXURIHandler.h
index 274f76d..afa4c6c 100644
--- a/SwifTools/URIHandler/MacOSXURIHandler.h
+++ b/SwifTools/URIHandler/MacOSXURIHandler.h
@@ -9,16 +9,16 @@
#include <SwifTools/URIHandler/URIHandler.h>
namespace Swift {
- class MacOSXURIHandler : public URIHandler {
- public:
- MacOSXURIHandler();
- virtual ~MacOSXURIHandler();
+ class MacOSXURIHandler : public URIHandler {
+ public:
+ MacOSXURIHandler();
+ virtual ~MacOSXURIHandler();
- virtual void start();
- virtual void stop();
+ virtual void start();
+ virtual void stop();
- private:
- class Private;
- Private* p;
- };
+ private:
+ class Private;
+ Private* p;
+ };
}
diff --git a/SwifTools/URIHandler/MacOSXURIHandler.mm b/SwifTools/URIHandler/MacOSXURIHandler.mm
index 482be8f..6285e12 100644
--- a/SwifTools/URIHandler/MacOSXURIHandler.mm
+++ b/SwifTools/URIHandler/MacOSXURIHandler.mm
@@ -21,47 +21,47 @@ using namespace Swift;
@end
@implementation MacOSXURIEventHandler
- {
- URIHandler* handler;
- }
-
- - (id) initWithHandler: (URIHandler*) h {
- if ((self = [super init])) {
- handler = h;
- }
- return self;
- }
-
- - (void) getUrl: (NSAppleEventDescriptor*) event withReplyEvent: (NSAppleEventDescriptor*) replyEvent {
- (void) replyEvent;
- NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
- handler->onURI(std::string([url UTF8String]));
- }
+ {
+ URIHandler* handler;
+ }
+
+ - (id) initWithHandler: (URIHandler*) h {
+ if ((self = [super init])) {
+ handler = h;
+ }
+ return self;
+ }
+
+ - (void) getUrl: (NSAppleEventDescriptor*) event withReplyEvent: (NSAppleEventDescriptor*) replyEvent {
+ (void) replyEvent;
+ NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
+ handler->onURI(std::string([url UTF8String]));
+ }
@end
class MacOSXURIHandler::Private {
- public:
- MacOSXURIEventHandler* eventHandler;
+ public:
+ MacOSXURIEventHandler* eventHandler;
};
MacOSXURIHandler::MacOSXURIHandler() {
- p = new Private();
- p->eventHandler = [[MacOSXURIEventHandler alloc] initWithHandler: this];
+ p = new Private();
+ p->eventHandler = [[MacOSXURIEventHandler alloc] initWithHandler: this];
}
MacOSXURIHandler::~MacOSXURIHandler() {
- [p->eventHandler release];
- delete p;
+ [p->eventHandler release];
+ delete p;
}
void MacOSXURIHandler::start() {
- [[NSAppleEventManager sharedAppleEventManager] setEventHandler:p->eventHandler andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
+ [[NSAppleEventManager sharedAppleEventManager] setEventHandler:p->eventHandler andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
- // Register ourselves as default URI handler
- //NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier];
- //LSSetDefaultHandlerForURLScheme((CFStringRef)@"xmpp", (CFStringRef)bundleID);
+ // Register ourselves as default URI handler
+ //NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier];
+ //LSSetDefaultHandlerForURLScheme((CFStringRef)@"xmpp", (CFStringRef)bundleID);
}
void MacOSXURIHandler::stop() {
- [[NSAppleEventManager sharedAppleEventManager] removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
+ [[NSAppleEventManager sharedAppleEventManager] removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
}
diff --git a/SwifTools/URIHandler/NullURIHandler.h b/SwifTools/URIHandler/NullURIHandler.h
index 646fab7..99c01e8 100644
--- a/SwifTools/URIHandler/NullURIHandler.h
+++ b/SwifTools/URIHandler/NullURIHandler.h
@@ -9,12 +9,12 @@
#include <SwifTools/URIHandler/URIHandler.h>
namespace Swift {
- class NullURIHandler : public URIHandler {
- public:
- virtual void start() {
- }
+ class NullURIHandler : public URIHandler {
+ public:
+ virtual void start() {
+ }
- virtual void stop() {
- }
- };
+ virtual void stop() {
+ }
+ };
}
diff --git a/SwifTools/URIHandler/URIHandler.h b/SwifTools/URIHandler/URIHandler.h
index 84bb368..0f85e64 100644
--- a/SwifTools/URIHandler/URIHandler.h
+++ b/SwifTools/URIHandler/URIHandler.h
@@ -11,11 +11,11 @@
#include <Swiften/Base/boost_bsignals.h>
namespace Swift {
- class URIHandler {
- public:
- URIHandler();
- virtual ~URIHandler();
+ class URIHandler {
+ public:
+ URIHandler();
+ virtual ~URIHandler();
- boost::signal<void (const std::string&)> onURI;
- };
+ boost::signal<void (const std::string&)> onURI;
+ };
}
diff --git a/SwifTools/URIHandler/UnitTest/XMPPURITest.cpp b/SwifTools/URIHandler/UnitTest/XMPPURITest.cpp
index 0cafefb..aa0570c 100644
--- a/SwifTools/URIHandler/UnitTest/XMPPURITest.cpp
+++ b/SwifTools/URIHandler/UnitTest/XMPPURITest.cpp
@@ -12,180 +12,180 @@
using namespace Swift;
class XMPPURITest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(XMPPURITest);
- CPPUNIT_TEST(testFromString_Authority);
- CPPUNIT_TEST(testFromString_AuthorityWithPath);
- CPPUNIT_TEST(testFromString_AuthorityWithFragment);
- CPPUNIT_TEST(testFromString_AuthorityWithPathAndFragment);
- CPPUNIT_TEST(testFromString_AuthorityWithIntlChars);
- CPPUNIT_TEST(testFromString_AuthorityWithQueryWithoutParameters);
- CPPUNIT_TEST(testFromString_AuthorityWithQueryWithParameters);
- CPPUNIT_TEST(testFromString_AuthorityWithQueryWithoutParametersWithFragment);
- CPPUNIT_TEST(testFromString_AuthorityWithQueryWithParametersWithFragment);
- CPPUNIT_TEST(testFromString_Path);
- CPPUNIT_TEST(testFromString_PathWithFragment);
- CPPUNIT_TEST(testFromString_PathWithIntlChars);
- CPPUNIT_TEST(testFromString_PathWithInvalidEscapedChar);
- CPPUNIT_TEST(testFromString_PathWithIncompleteEscapedChar);
- CPPUNIT_TEST(testFromString_PathWithIncompleteEscapedChar2);
- CPPUNIT_TEST(testFromString_PathWithQueryWithoutParameters);
- CPPUNIT_TEST(testFromString_PathWithQueryWithParameters);
- CPPUNIT_TEST(testFromString_PathWithQueryWithoutParametersWithFragment);
- CPPUNIT_TEST(testFromString_PathWithQueryWithParametersWithFragment);
- CPPUNIT_TEST(testFromString_NoPrefix);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testFromString_Authority() {
- XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com");
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
- }
-
- void testFromString_AuthorityWithPath() {
- XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com/baz@example.com");
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
- }
-
- void testFromString_AuthorityWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com#myfragment");
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
-
- void testFromString_AuthorityWithPathAndFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com/baz@example.com#myfragment");
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
-
- void testFromString_AuthorityWithIntlChars() {
- XMPPURI testling = XMPPURI::fromString("xmpp://nasty!%23$%25()*+,-.;=%3F%5B%5C%5D%5E_%60%7B%7C%7D~node@example.com");
-
- CPPUNIT_ASSERT_EQUAL(JID("nasty!#$%()*+,-.;=?[\\]^_`{|}~node@example.com"), testling.getAuthority());
- }
-
- void testFromString_AuthorityWithQueryWithoutParameters() {
- XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message");
-
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- }
-
- void testFromString_AuthorityWithQueryWithParameters() {
- XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message");
-
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
- CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
- }
-
- void testFromString_AuthorityWithQueryWithoutParametersWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message#myfragment");
-
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
-
- void testFromString_AuthorityWithQueryWithParametersWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message#myfragment");
-
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
- CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
-
- void testFromString_Path() {
- XMPPURI testling = XMPPURI::fromString("xmpp:baz@example.com");
-
- CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
- }
-
- void testFromString_PathWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp:baz@example.com#myfragment");
-
- CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
-
- void testFromString_PathWithIntlChars() {
- XMPPURI testling = XMPPURI::fromString("xmpp:nasty!%23$%25()*+,-.;=%3F%5B%5C%5D%5E_%60%7B%7C%7D~node@example.com");
+ CPPUNIT_TEST_SUITE(XMPPURITest);
+ CPPUNIT_TEST(testFromString_Authority);
+ CPPUNIT_TEST(testFromString_AuthorityWithPath);
+ CPPUNIT_TEST(testFromString_AuthorityWithFragment);
+ CPPUNIT_TEST(testFromString_AuthorityWithPathAndFragment);
+ CPPUNIT_TEST(testFromString_AuthorityWithIntlChars);
+ CPPUNIT_TEST(testFromString_AuthorityWithQueryWithoutParameters);
+ CPPUNIT_TEST(testFromString_AuthorityWithQueryWithParameters);
+ CPPUNIT_TEST(testFromString_AuthorityWithQueryWithoutParametersWithFragment);
+ CPPUNIT_TEST(testFromString_AuthorityWithQueryWithParametersWithFragment);
+ CPPUNIT_TEST(testFromString_Path);
+ CPPUNIT_TEST(testFromString_PathWithFragment);
+ CPPUNIT_TEST(testFromString_PathWithIntlChars);
+ CPPUNIT_TEST(testFromString_PathWithInvalidEscapedChar);
+ CPPUNIT_TEST(testFromString_PathWithIncompleteEscapedChar);
+ CPPUNIT_TEST(testFromString_PathWithIncompleteEscapedChar2);
+ CPPUNIT_TEST(testFromString_PathWithQueryWithoutParameters);
+ CPPUNIT_TEST(testFromString_PathWithQueryWithParameters);
+ CPPUNIT_TEST(testFromString_PathWithQueryWithoutParametersWithFragment);
+ CPPUNIT_TEST(testFromString_PathWithQueryWithParametersWithFragment);
+ CPPUNIT_TEST(testFromString_NoPrefix);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testFromString_Authority() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com");
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
+ }
+
+ void testFromString_AuthorityWithPath() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com/baz@example.com");
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
+ }
+
+ void testFromString_AuthorityWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com#myfragment");
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
+
+ void testFromString_AuthorityWithPathAndFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://foo@bar.com/baz@example.com#myfragment");
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
+
+ void testFromString_AuthorityWithIntlChars() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://nasty!%23$%25()*+,-.;=%3F%5B%5C%5D%5E_%60%7B%7C%7D~node@example.com");
+
+ CPPUNIT_ASSERT_EQUAL(JID("nasty!#$%()*+,-.;=?[\\]^_`{|}~node@example.com"), testling.getAuthority());
+ }
+
+ void testFromString_AuthorityWithQueryWithoutParameters() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message");
+
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ }
+
+ void testFromString_AuthorityWithQueryWithParameters() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message");
+
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
+ }
+
+ void testFromString_AuthorityWithQueryWithoutParametersWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message#myfragment");
+
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
+
+ void testFromString_AuthorityWithQueryWithParametersWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp://test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message#myfragment");
+
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getAuthority());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
+
+ void testFromString_Path() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:baz@example.com");
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
+ }
+
+ void testFromString_PathWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:baz@example.com#myfragment");
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
+
+ void testFromString_PathWithIntlChars() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:nasty!%23$%25()*+,-.;=%3F%5B%5C%5D%5E_%60%7B%7C%7D~node@example.com");
- CPPUNIT_ASSERT_EQUAL(JID("nasty!#$%()*+,-.;=?[\\]^_`{|}~node@example.com"), testling.getPath());
- }
+ CPPUNIT_ASSERT_EQUAL(JID("nasty!#$%()*+,-.;=?[\\]^_`{|}~node@example.com"), testling.getPath());
+ }
- void testFromString_PathWithInvalidEscapedChar() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test%%@example.com");
+ void testFromString_PathWithInvalidEscapedChar() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test%%@example.com");
- CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
- }
+ CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
+ }
- void testFromString_PathWithIncompleteEscapedChar() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com%");
+ void testFromString_PathWithIncompleteEscapedChar() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com%");
- CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
- }
+ CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
+ }
- void testFromString_PathWithIncompleteEscapedChar2() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com%1");
+ void testFromString_PathWithIncompleteEscapedChar2() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com%1");
- CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
- }
+ CPPUNIT_ASSERT_EQUAL(JID(), testling.getPath());
+ }
- void testFromString_PathWithQueryWithoutParameters() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message");
+ void testFromString_PathWithQueryWithoutParameters() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message");
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- }
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ }
- void testFromString_PathWithQueryWithParameters() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message");
+ void testFromString_PathWithQueryWithParameters() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message");
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
- CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
- }
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
+ }
- void testFromString_PathWithQueryWithoutParametersWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message#myfragment");
+ void testFromString_PathWithQueryWithoutParametersWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message#myfragment");
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
- void testFromString_PathWithQueryWithParametersWithFragment() {
- XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message#myfragment");
+ void testFromString_PathWithQueryWithParametersWithFragment() {
+ XMPPURI testling = XMPPURI::fromString("xmpp:test@example.com?message;subject=Test%20Message;body=Here%27s%20a%20test%20message#myfragment");
- CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
- CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
- CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
- CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
- CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
- }
+ CPPUNIT_ASSERT_EQUAL(JID("test@example.com"), testling.getPath());
+ CPPUNIT_ASSERT_EQUAL(std::string("message"), testling.getQueryType());
+ CPPUNIT_ASSERT_EQUAL(std::string("Test Message"), get(testling.getQueryParameters(), "subject"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Here's a test message"), get(testling.getQueryParameters(), "body"));
+ CPPUNIT_ASSERT_EQUAL(std::string("myfragment"), testling.getFragment());
+ }
- void testFromString_NoPrefix() {
- XMPPURI testling = XMPPURI::fromString("baz@example.com");
+ void testFromString_NoPrefix() {
+ XMPPURI testling = XMPPURI::fromString("baz@example.com");
- CPPUNIT_ASSERT(testling.isNull());
- }
+ CPPUNIT_ASSERT(testling.isNull());
+ }
- private:
- std::string get(const std::map<std::string, std::string>& m, const std::string& k) {
- std::map<std::string, std::string>::const_iterator i = m.find(k);
- return i == m.end() ? "" : i->second;
- }
+ private:
+ std::string get(const std::map<std::string, std::string>& m, const std::string& k) {
+ std::map<std::string, std::string>::const_iterator i = m.find(k);
+ return i == m.end() ? "" : i->second;
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(XMPPURITest);
diff --git a/SwifTools/URIHandler/XMPPURI.cpp b/SwifTools/URIHandler/XMPPURI.cpp
index 38fc72d..8b8b81c 100644
--- a/SwifTools/URIHandler/XMPPURI.cpp
+++ b/SwifTools/URIHandler/XMPPURI.cpp
@@ -26,77 +26,77 @@ XMPPURI::XMPPURI() {
}
XMPPURI XMPPURI::fromString(const std::string& s) {
- XMPPURI result;
- if (boost::starts_with(s, "xmpp:")) {
- std::string uri = s.substr(5, s.npos);
- bool parsePath = true;
- bool parseQuery = true;
- bool parseFragment = true;
+ XMPPURI result;
+ if (boost::starts_with(s, "xmpp:")) {
+ std::string uri = s.substr(5, s.npos);
+ bool parsePath = true;
+ bool parseQuery = true;
+ bool parseFragment = true;
- // Parse authority
- if (boost::starts_with(uri, "//")) {
- size_t i = uri.find_first_of("/#?", 2);
- result.setAuthority(JID(URL::unescape(uri.substr(2, i - 2))));
- if (i == uri.npos) {
- uri = "";
- parsePath = parseQuery = parseFragment = false;
- }
- else {
- if (uri[i] == '?') {
- parsePath = false;
- }
- else if (uri[i] == '#') {
- parseQuery = parsePath = false;
- }
- uri = uri.substr(i + 1, uri.npos);
- }
- }
+ // Parse authority
+ if (boost::starts_with(uri, "//")) {
+ size_t i = uri.find_first_of("/#?", 2);
+ result.setAuthority(JID(URL::unescape(uri.substr(2, i - 2))));
+ if (i == uri.npos) {
+ uri = "";
+ parsePath = parseQuery = parseFragment = false;
+ }
+ else {
+ if (uri[i] == '?') {
+ parsePath = false;
+ }
+ else if (uri[i] == '#') {
+ parseQuery = parsePath = false;
+ }
+ uri = uri.substr(i + 1, uri.npos);
+ }
+ }
- // Parse path
- if (parsePath) {
- size_t i = uri.find_first_of("#?");
- result.setPath(JID(URL::unescape(uri.substr(0, i))));
- if (i == uri.npos) {
- uri = "";
- parseQuery = parseFragment = false;
- }
- else {
- if (uri[i] == '#') {
- parseQuery = false;
- }
- uri = uri.substr(i + 1, uri.npos);
- }
- }
+ // Parse path
+ if (parsePath) {
+ size_t i = uri.find_first_of("#?");
+ result.setPath(JID(URL::unescape(uri.substr(0, i))));
+ if (i == uri.npos) {
+ uri = "";
+ parseQuery = parseFragment = false;
+ }
+ else {
+ if (uri[i] == '#') {
+ parseQuery = false;
+ }
+ uri = uri.substr(i + 1, uri.npos);
+ }
+ }
- // Parse query
- if (parseQuery) {
- size_t end = uri.find_first_of("#");
- std::string query = uri.substr(0, end);
- bool haveType = false;
- typedef boost::split_iterator<std::string::iterator> split_iterator;
- for (split_iterator it = boost::make_split_iterator(query, boost::first_finder(";")); it != split_iterator(); ++it) {
- if (haveType) {
- std::vector<std::string> keyValue;
- boost::split(keyValue, *it, boost::is_any_of("="));
- if (keyValue.size() == 1) {
- result.addQueryParameter(URL::unescape(keyValue[0]), "");
- }
- else if (keyValue.size() >= 2) {
- result.addQueryParameter(URL::unescape(keyValue[0]), URL::unescape(keyValue[1]));
- }
- }
- else {
- result.setQueryType(URL::unescape(boost::copy_range<std::string>(*it)));
- haveType = true;
- }
- }
- uri = (end == uri.npos ? "" : uri.substr(end + 1, uri.npos));
- }
+ // Parse query
+ if (parseQuery) {
+ size_t end = uri.find_first_of("#");
+ std::string query = uri.substr(0, end);
+ bool haveType = false;
+ typedef boost::split_iterator<std::string::iterator> split_iterator;
+ for (split_iterator it = boost::make_split_iterator(query, boost::first_finder(";")); it != split_iterator(); ++it) {
+ if (haveType) {
+ std::vector<std::string> keyValue;
+ boost::split(keyValue, *it, boost::is_any_of("="));
+ if (keyValue.size() == 1) {
+ result.addQueryParameter(URL::unescape(keyValue[0]), "");
+ }
+ else if (keyValue.size() >= 2) {
+ result.addQueryParameter(URL::unescape(keyValue[0]), URL::unescape(keyValue[1]));
+ }
+ }
+ else {
+ result.setQueryType(URL::unescape(boost::copy_range<std::string>(*it)));
+ haveType = true;
+ }
+ }
+ uri = (end == uri.npos ? "" : uri.substr(end + 1, uri.npos));
+ }
- // Parse fragment
- if (parseFragment) {
- result.setFragment(URL::unescape(uri));
- }
- }
- return result;
+ // Parse fragment
+ if (parseFragment) {
+ result.setFragment(URL::unescape(uri));
+ }
+ }
+ return result;
}
diff --git a/SwifTools/URIHandler/XMPPURI.h b/SwifTools/URIHandler/XMPPURI.h
index 275f99a..a8c9f95 100644
--- a/SwifTools/URIHandler/XMPPURI.h
+++ b/SwifTools/URIHandler/XMPPURI.h
@@ -12,62 +12,62 @@
#include <Swiften/JID/JID.h>
namespace Swift {
- // TODO: Implement using Base/URI
- class XMPPURI {
- public:
- XMPPURI();
-
- const JID& getAuthority() const {
- return authority;
- }
-
- void setAuthority(const JID& j) {
- authority = j;
- }
-
- const JID& getPath() const {
- return path;
- }
-
- void setPath(const JID& j) {
- path = j;
- }
-
- const std::string& getQueryType() const {
- return queryType;
- }
-
- void setQueryType(const std::string& q) {
- queryType = q;
- }
-
- const std::map<std::string, std::string>& getQueryParameters() const {
- return queryParameters;
- }
-
- void addQueryParameter(const std::string& key, const std::string& path) {
- queryParameters[key] = path;
- }
-
- const std::string& getFragment() const {
- return fragment;
- }
-
- void setFragment(const std::string& f) {
- fragment = f;
- }
-
- bool isNull() const {
- return !authority.isValid() && !path.isValid();
- }
-
- static XMPPURI fromString(const std::string&);
-
- private:
- JID authority;
- JID path;
- std::string fragment;
- std::string queryType;
- std::map<std::string, std::string> queryParameters;
- };
+ // TODO: Implement using Base/URI
+ class XMPPURI {
+ public:
+ XMPPURI();
+
+ const JID& getAuthority() const {
+ return authority;
+ }
+
+ void setAuthority(const JID& j) {
+ authority = j;
+ }
+
+ const JID& getPath() const {
+ return path;
+ }
+
+ void setPath(const JID& j) {
+ path = j;
+ }
+
+ const std::string& getQueryType() const {
+ return queryType;
+ }
+
+ void setQueryType(const std::string& q) {
+ queryType = q;
+ }
+
+ const std::map<std::string, std::string>& getQueryParameters() const {
+ return queryParameters;
+ }
+
+ void addQueryParameter(const std::string& key, const std::string& path) {
+ queryParameters[key] = path;
+ }
+
+ const std::string& getFragment() const {
+ return fragment;
+ }
+
+ void setFragment(const std::string& f) {
+ fragment = f;
+ }
+
+ bool isNull() const {
+ return !authority.isValid() && !path.isValid();
+ }
+
+ static XMPPURI fromString(const std::string&);
+
+ private:
+ JID authority;
+ JID path;
+ std::string fragment;
+ std::string queryType;
+ std::map<std::string, std::string> queryParameters;
+ };
}
diff --git a/SwifTools/UnitTest/LastLineTrackerTest.cpp b/SwifTools/UnitTest/LastLineTrackerTest.cpp
index 97790e5..0fc77b6 100644
--- a/SwifTools/UnitTest/LastLineTrackerTest.cpp
+++ b/SwifTools/UnitTest/LastLineTrackerTest.cpp
@@ -12,53 +12,53 @@
using namespace Swift;
class LastLineTrackerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(LastLineTrackerTest);
- CPPUNIT_TEST(testFocusNormal);
- CPPUNIT_TEST(testFocusOut);
- CPPUNIT_TEST(testFocusOtherTab);
- CPPUNIT_TEST(testRepeatedFocusOut);
- CPPUNIT_TEST(testRepeatedFocusIn);
- CPPUNIT_TEST_SUITE_END();
- public:
- LastLineTrackerTest () {
- }
- void testFocusNormal() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testFocusOut() {
- LastLineTracker testling;
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testFocusOtherTab() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
+ CPPUNIT_TEST_SUITE(LastLineTrackerTest);
+ CPPUNIT_TEST(testFocusNormal);
+ CPPUNIT_TEST(testFocusOut);
+ CPPUNIT_TEST(testFocusOtherTab);
+ CPPUNIT_TEST(testRepeatedFocusOut);
+ CPPUNIT_TEST(testRepeatedFocusIn);
+ CPPUNIT_TEST_SUITE_END();
+ public:
+ LastLineTrackerTest () {
+ }
+ void testFocusNormal() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testFocusOut() {
+ LastLineTracker testling;
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testFocusOtherTab() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
- void testRepeatedFocusOut() {
- LastLineTracker testling;
- testling.setHasFocus(true);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
- }
- void testRepeatedFocusIn() {
- LastLineTracker testling;
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- testling.setHasFocus(true);
- testling.setHasFocus(false);
- CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
- }
+ void testRepeatedFocusOut() {
+ LastLineTracker testling;
+ testling.setHasFocus(true);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(false, testling.getShouldMoveLastLine());
+ }
+ void testRepeatedFocusIn() {
+ LastLineTracker testling;
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ testling.setHasFocus(true);
+ testling.setHasFocus(false);
+ CPPUNIT_ASSERT_EQUAL(true, testling.getShouldMoveLastLine());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LastLineTrackerTest);
diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp
index 663581d..69a0e23 100644
--- a/SwifTools/UnitTest/LinkifyTest.cpp
+++ b/SwifTools/UnitTest/LinkifyTest.cpp
@@ -12,230 +12,230 @@
using namespace Swift;
class LinkifyTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(LinkifyTest);
- CPPUNIT_TEST(testLinkify_URLWithResource);
- CPPUNIT_TEST(testLinkify_HTTPSURLWithResource);
- CPPUNIT_TEST(testLinkify_URLWithEmptyResource);
- CPPUNIT_TEST(testLinkify_BareURL);
- CPPUNIT_TEST(testLinkify_URLSurroundedByWhitespace);
- CPPUNIT_TEST(testLinkify_MultipleURLs);
- CPPUNIT_TEST(testLinkify_CamelCase);
- CPPUNIT_TEST(testLinkify_HierarchicalResource);
- CPPUNIT_TEST(testLinkify_Anchor);
- CPPUNIT_TEST(testLinkify_Plus);
- CPPUNIT_TEST(testLinkify_Tilde);
- CPPUNIT_TEST(testLinkify_Equal);
- CPPUNIT_TEST(testLinkify_Authentication);
- CPPUNIT_TEST(testLinkify_At);
- CPPUNIT_TEST(testLinkify_Amps);
- CPPUNIT_TEST(testLinkify_UnicodeCharacter);
- CPPUNIT_TEST(testLinkify_NewLine);
- CPPUNIT_TEST(testLinkify_Tab);
- CPPUNIT_TEST(testLinkify_Action);
-
- CPPUNIT_TEST(testLinkify_SplitNone);
- CPPUNIT_TEST(testLinkify_SplitAll);
- CPPUNIT_TEST(testLinkify_SplitFirst);
- CPPUNIT_TEST(testLinkify_SplitSecond);
- CPPUNIT_TEST(testLinkify_SplitMiddle);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testLinkify_URLWithResource() {
- std::string result = Linkify::linkify("http://swift.im/blog");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
- result);
- }
-
- void testLinkify_HTTPSURLWithResource() {
- std::string result = Linkify::linkify("https://swift.im/blog");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
- result);
- }
-
- void testLinkify_URLWithEmptyResource() {
- std::string result = Linkify::linkify("http://swift.im/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"),
- result);
- }
-
-
- void testLinkify_BareURL() {
- std::string result = Linkify::linkify("http://swift.im");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>"),
- result);
- }
-
- void testLinkify_URLSurroundedByWhitespace() {
- std::string result = Linkify::linkify("Foo http://swift.im/blog Bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
- result);
- }
-
- void testLinkify_MultipleURLs() {
- std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"),
- result);
- }
-
- void testLinkify_CamelCase() {
- std::string result = Linkify::linkify("http://fOo.cOm/bAz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
- result);
- }
-
- void testLinkify_HierarchicalResource() {
- std::string result = Linkify::linkify("http://foo.com/bar/baz/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
- result);
- }
-
- void testLinkify_Anchor() {
- std::string result = Linkify::linkify("http://foo.com/bar#baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
- result);
- }
-
- void testLinkify_Plus() {
- std::string result = Linkify::linkify("http://foo.com/bar+baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
- result);
- }
-
- void testLinkify_Tilde() {
- std::string result = Linkify::linkify("http://foo.com/~kev/");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
- result);
- }
-
- void testLinkify_Equal() {
- std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
- result);
- }
-
- void testLinkify_Authentication() {
- std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
- result);
- }
-
- void testLinkify_At() {
- std::string result = Linkify::linkify("http://swift.im/foo@bar");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
- result);
- }
-
- void testLinkify_Amps() {
- std::string result = Linkify::linkify("http://swift.im/foo&bar&baz");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
- result);
- }
-
- void testLinkify_UnicodeCharacter() {
- std::string result = Linkify::linkify("http://\xe2\x98\x83.net");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
- result);
- }
-
- void testLinkify_NewLine() {
- std::string result = Linkify::linkify("http://swift.im\nfoo");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
- result);
- }
-
- void testLinkify_Tab() {
- std::string result = Linkify::linkify("http://swift.im\tfoo");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
- result);
- }
-
- void testLinkify_Action() {
- std::string result = Linkify::linkify("*http://swift.im*");
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("*<a href=\"http://swift.im\">http://swift.im</a>*"),
- result);
- }
-
- void checkResult(const std::string& testling, size_t expectedIndex, std::string expectedSplit[]) {
- std::pair<std::vector<std::string>, size_t> result = Linkify::splitLink(testling);
- CPPUNIT_ASSERT_EQUAL(expectedIndex, result.second);
- for (size_t i = 0; i < result.first.size(); i++) {
- CPPUNIT_ASSERT_EQUAL(expectedSplit[i], result.first[i]);
- }
- }
-
- void testLinkify_SplitNone() {
- std::string testling = "http this ain't";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"http this ain't"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitAll() {
- std::string testling = "http://swift.im";
- size_t expectedIndex = 0;
- std::string expectedSplit[] = {"http://swift.im"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitFirst() {
- std::string testling = "http://swift.im is a link";
- size_t expectedIndex = 0;
- std::string expectedSplit[] = {"http://swift.im", " is a link"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitSecond() {
- std::string testling = "this is a link: http://swift.im";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"this is a link: ", "http://swift.im"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
-
- void testLinkify_SplitMiddle() {
- std::string testling = "Shove a link like http://swift.im in the middle";
- size_t expectedIndex = 1;
- std::string expectedSplit[] = {"Shove a link like ","http://swift.im", " in the middle"};
- checkResult(testling, expectedIndex, expectedSplit);
- }
+ CPPUNIT_TEST_SUITE(LinkifyTest);
+ CPPUNIT_TEST(testLinkify_URLWithResource);
+ CPPUNIT_TEST(testLinkify_HTTPSURLWithResource);
+ CPPUNIT_TEST(testLinkify_URLWithEmptyResource);
+ CPPUNIT_TEST(testLinkify_BareURL);
+ CPPUNIT_TEST(testLinkify_URLSurroundedByWhitespace);
+ CPPUNIT_TEST(testLinkify_MultipleURLs);
+ CPPUNIT_TEST(testLinkify_CamelCase);
+ CPPUNIT_TEST(testLinkify_HierarchicalResource);
+ CPPUNIT_TEST(testLinkify_Anchor);
+ CPPUNIT_TEST(testLinkify_Plus);
+ CPPUNIT_TEST(testLinkify_Tilde);
+ CPPUNIT_TEST(testLinkify_Equal);
+ CPPUNIT_TEST(testLinkify_Authentication);
+ CPPUNIT_TEST(testLinkify_At);
+ CPPUNIT_TEST(testLinkify_Amps);
+ CPPUNIT_TEST(testLinkify_UnicodeCharacter);
+ CPPUNIT_TEST(testLinkify_NewLine);
+ CPPUNIT_TEST(testLinkify_Tab);
+ CPPUNIT_TEST(testLinkify_Action);
+
+ CPPUNIT_TEST(testLinkify_SplitNone);
+ CPPUNIT_TEST(testLinkify_SplitAll);
+ CPPUNIT_TEST(testLinkify_SplitFirst);
+ CPPUNIT_TEST(testLinkify_SplitSecond);
+ CPPUNIT_TEST(testLinkify_SplitMiddle);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testLinkify_URLWithResource() {
+ std::string result = Linkify::linkify("http://swift.im/blog");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
+ result);
+ }
+
+ void testLinkify_HTTPSURLWithResource() {
+ std::string result = Linkify::linkify("https://swift.im/blog");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
+ result);
+ }
+
+ void testLinkify_URLWithEmptyResource() {
+ std::string result = Linkify::linkify("http://swift.im/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"),
+ result);
+ }
+
+
+ void testLinkify_BareURL() {
+ std::string result = Linkify::linkify("http://swift.im");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>"),
+ result);
+ }
+
+ void testLinkify_URLSurroundedByWhitespace() {
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
+ result);
+ }
+
+ void testLinkify_MultipleURLs() {
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"),
+ result);
+ }
+
+ void testLinkify_CamelCase() {
+ std::string result = Linkify::linkify("http://fOo.cOm/bAz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
+ result);
+ }
+
+ void testLinkify_HierarchicalResource() {
+ std::string result = Linkify::linkify("http://foo.com/bar/baz/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
+ result);
+ }
+
+ void testLinkify_Anchor() {
+ std::string result = Linkify::linkify("http://foo.com/bar#baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
+ result);
+ }
+
+ void testLinkify_Plus() {
+ std::string result = Linkify::linkify("http://foo.com/bar+baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
+ result);
+ }
+
+ void testLinkify_Tilde() {
+ std::string result = Linkify::linkify("http://foo.com/~kev/");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
+ result);
+ }
+
+ void testLinkify_Equal() {
+ std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
+ result);
+ }
+
+ void testLinkify_Authentication() {
+ std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
+ result);
+ }
+
+ void testLinkify_At() {
+ std::string result = Linkify::linkify("http://swift.im/foo@bar");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
+ result);
+ }
+
+ void testLinkify_Amps() {
+ std::string result = Linkify::linkify("http://swift.im/foo&bar&baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
+ result);
+ }
+
+ void testLinkify_UnicodeCharacter() {
+ std::string result = Linkify::linkify("http://\xe2\x98\x83.net");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
+ result);
+ }
+
+ void testLinkify_NewLine() {
+ std::string result = Linkify::linkify("http://swift.im\nfoo");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
+ result);
+ }
+
+ void testLinkify_Tab() {
+ std::string result = Linkify::linkify("http://swift.im\tfoo");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
+ result);
+ }
+
+ void testLinkify_Action() {
+ std::string result = Linkify::linkify("*http://swift.im*");
+
+ CPPUNIT_ASSERT_EQUAL(
+ std::string("*<a href=\"http://swift.im\">http://swift.im</a>*"),
+ result);
+ }
+
+ void checkResult(const std::string& testling, size_t expectedIndex, std::string expectedSplit[]) {
+ std::pair<std::vector<std::string>, size_t> result = Linkify::splitLink(testling);
+ CPPUNIT_ASSERT_EQUAL(expectedIndex, result.second);
+ for (size_t i = 0; i < result.first.size(); i++) {
+ CPPUNIT_ASSERT_EQUAL(expectedSplit[i], result.first[i]);
+ }
+ }
+
+ void testLinkify_SplitNone() {
+ std::string testling = "http this ain't";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"http this ain't"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitAll() {
+ std::string testling = "http://swift.im";
+ size_t expectedIndex = 0;
+ std::string expectedSplit[] = {"http://swift.im"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitFirst() {
+ std::string testling = "http://swift.im is a link";
+ size_t expectedIndex = 0;
+ std::string expectedSplit[] = {"http://swift.im", " is a link"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitSecond() {
+ std::string testling = "this is a link: http://swift.im";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"this is a link: ", "http://swift.im"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
+
+ void testLinkify_SplitMiddle() {
+ std::string testling = "Shove a link like http://swift.im in the middle";
+ size_t expectedIndex = 1;
+ std::string expectedSplit[] = {"Shove a link like ","http://swift.im", " in the middle"};
+ checkResult(testling, expectedIndex, expectedSplit);
+ }
};
diff --git a/SwifTools/UnitTest/SpellParserTest.cpp b/SwifTools/UnitTest/SpellParserTest.cpp
index 3747eb1..da233e5 100644
--- a/SwifTools/UnitTest/SpellParserTest.cpp
+++ b/SwifTools/UnitTest/SpellParserTest.cpp
@@ -20,38 +20,38 @@
using namespace Swift;
class SpellParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SpellParserTest);
- CPPUNIT_TEST(testSimpleCheckFragment);
- CPPUNIT_TEST(testWWWCheckFragment);
- CPPUNIT_TEST_SUITE_END();
- public:
- SpellParserTest() {
- parser_ = new SpellParser();
- };
- void tearDown() {
- position_.clear();
- }
- void testSimpleCheckFragment() {
- parser_->check("fragment test", position_);
- int size = position_.size();
- CPPUNIT_ASSERT_EQUAL(2, size);
- CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_.back()));
- CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_.back()));
- }
- void testWWWCheckFragment() {
- parser_->check("www.link.com fragment test", position_);
- int size = position_.size();
- CPPUNIT_ASSERT_EQUAL(2, size);
- CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_.front()));
- CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_.back()));
- CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_.back()));
- }
- private:
- SpellParser *parser_;
- PositionPairList position_;
+ CPPUNIT_TEST_SUITE(SpellParserTest);
+ CPPUNIT_TEST(testSimpleCheckFragment);
+ CPPUNIT_TEST(testWWWCheckFragment);
+ CPPUNIT_TEST_SUITE_END();
+ public:
+ SpellParserTest() {
+ parser_ = new SpellParser();
+ };
+ void tearDown() {
+ position_.clear();
+ }
+ void testSimpleCheckFragment() {
+ parser_->check("fragment test", position_);
+ int size = position_.size();
+ CPPUNIT_ASSERT_EQUAL(2, size);
+ CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_.back()));
+ CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_.back()));
+ }
+ void testWWWCheckFragment() {
+ parser_->check("www.link.com fragment test", position_);
+ int size = position_.size();
+ CPPUNIT_ASSERT_EQUAL(2, size);
+ CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_.front()));
+ CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_.back()));
+ CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_.back()));
+ }
+ private:
+ SpellParser *parser_;
+ PositionPairList position_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(SpellParserTest);
diff --git a/SwifTools/UnitTest/TabCompleteTest.cpp b/SwifTools/UnitTest/TabCompleteTest.cpp
index 2642410..56c91a8 100644
--- a/SwifTools/UnitTest/TabCompleteTest.cpp
+++ b/SwifTools/UnitTest/TabCompleteTest.cpp
@@ -12,254 +12,254 @@
using namespace Swift;
class TabCompleteTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(TabCompleteTest);
- CPPUNIT_TEST(testEmpty);
- CPPUNIT_TEST(testNoMatch);
- CPPUNIT_TEST(testOneMatch);
- CPPUNIT_TEST(testTwoMatch);
- CPPUNIT_TEST(testChangeMatch);
- CPPUNIT_TEST(testRemoveDuringComplete);
- CPPUNIT_TEST(testAddDuringComplete);
- CPPUNIT_TEST(testSwiftRoomSample);
- CPPUNIT_TEST_SUITE_END();
-
+ CPPUNIT_TEST_SUITE(TabCompleteTest);
+ CPPUNIT_TEST(testEmpty);
+ CPPUNIT_TEST(testNoMatch);
+ CPPUNIT_TEST(testOneMatch);
+ CPPUNIT_TEST(testTwoMatch);
+ CPPUNIT_TEST(testChangeMatch);
+ CPPUNIT_TEST(testRemoveDuringComplete);
+ CPPUNIT_TEST(testAddDuringComplete);
+ CPPUNIT_TEST(testSwiftRoomSample);
+ CPPUNIT_TEST_SUITE_END();
+
public:
- TabCompleteTest() {}
-
- void setUp() {
- completer_ = TabComplete();
- }
-
- void testEmpty() {
- std::string blah("Blah");
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- }
-
- void testNoMatch() {
- completer_.addWord("Bleh");
- std::string blah("Blah");
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- CPPUNIT_ASSERT_EQUAL(
- blah,
- completer_.completeWord(blah));
- }
-
- void testOneMatch() {
- std::string short1("Bl");
- std::string long1("Blehling");
- completer_.addWord(long1);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long1));
- }
-
- void testTwoMatch() {
- std::string short1("Hur");
- std::string long1("Hurgle");
- std::string long2("Hurdler");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(long1));
- }
-
- void testChangeMatch() {
- std::string short1("Hur");
- std::string short2("Rub");
- std::string long1("Hurgle");
- std::string long2("Rubbish");
- completer_.addWord(long2);
- completer_.addWord("Blah");
- completer_.addWord(long1);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short2));
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(short1));
- }
-
- void testRemoveDuringComplete() {
- std::string short1("Kev");
- std::string long1("Kevin");
- std::string long2("Kevlar");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- completer_.removeWord(long2);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long1));
- }
-
- void testAddDuringComplete() {
- std::string short1("Rem");
- std::string long1("Remko");
- std::string long2("Remove");
- std::string long3("Remedial");
- completer_.addWord(long1);
- completer_.addWord("Blah");
- completer_.addWord(long2);
- completer_.addWord("Bleh");
- CPPUNIT_ASSERT_EQUAL(
- long2,
- completer_.completeWord(short1));
- completer_.addWord(long3);
- CPPUNIT_ASSERT_EQUAL(
- long1,
- completer_.completeWord(long2));
- CPPUNIT_ASSERT_EQUAL(
- long3,
- completer_.completeWord(long1));
- }
-
- void testSwiftRoomSample() {
- std::string t("t");
- std::string Anpan("Anpan");
- std::string cdubouloz("cdubouloz");
- std::string Tobias("Tobias");
- std::string Zash("Zash");
- std::string lastsky("lastsky");
- std::string Steve("Steve Kille");
- std::string Flo("Flo");
- std::string Test("Test");
- std::string test("test");
- completer_.addWord(Anpan);
- completer_.addWord(cdubouloz);
- completer_.addWord(Tobias);
- completer_.addWord(lastsky);
- completer_.addWord(Steve);
- completer_.addWord(Flo);
- completer_.addWord(Zash);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.addWord(Test);
-
- CPPUNIT_ASSERT_EQUAL(
- Test,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Test));
- CPPUNIT_ASSERT_EQUAL(
- Test,
- completer_.completeWord(Tobias));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Test));
-
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
-
- completer_.removeWord(Test);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.addWord(test);
-
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
- completer_.addWord(Zash);
-
-
- CPPUNIT_ASSERT_EQUAL(
- test,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(test));
- CPPUNIT_ASSERT_EQUAL(
- test,
- completer_.completeWord(Tobias));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(test));
-
- completer_.removeWord(test);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- completer_.removeWord(Tobias);
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- t,
- completer_.completeWord(t));
-
- completer_.addWord(Tobias);
-
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(t));
- CPPUNIT_ASSERT_EQUAL(
- Tobias,
- completer_.completeWord(Tobias));
-
- }
+ TabCompleteTest() {}
+
+ void setUp() {
+ completer_ = TabComplete();
+ }
+
+ void testEmpty() {
+ std::string blah("Blah");
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ }
+
+ void testNoMatch() {
+ completer_.addWord("Bleh");
+ std::string blah("Blah");
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ CPPUNIT_ASSERT_EQUAL(
+ blah,
+ completer_.completeWord(blah));
+ }
+
+ void testOneMatch() {
+ std::string short1("Bl");
+ std::string long1("Blehling");
+ completer_.addWord(long1);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long1));
+ }
+
+ void testTwoMatch() {
+ std::string short1("Hur");
+ std::string long1("Hurgle");
+ std::string long2("Hurdler");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(long1));
+ }
+
+ void testChangeMatch() {
+ std::string short1("Hur");
+ std::string short2("Rub");
+ std::string long1("Hurgle");
+ std::string long2("Rubbish");
+ completer_.addWord(long2);
+ completer_.addWord("Blah");
+ completer_.addWord(long1);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short2));
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(short1));
+ }
+
+ void testRemoveDuringComplete() {
+ std::string short1("Kev");
+ std::string long1("Kevin");
+ std::string long2("Kevlar");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ completer_.removeWord(long2);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long1));
+ }
+
+ void testAddDuringComplete() {
+ std::string short1("Rem");
+ std::string long1("Remko");
+ std::string long2("Remove");
+ std::string long3("Remedial");
+ completer_.addWord(long1);
+ completer_.addWord("Blah");
+ completer_.addWord(long2);
+ completer_.addWord("Bleh");
+ CPPUNIT_ASSERT_EQUAL(
+ long2,
+ completer_.completeWord(short1));
+ completer_.addWord(long3);
+ CPPUNIT_ASSERT_EQUAL(
+ long1,
+ completer_.completeWord(long2));
+ CPPUNIT_ASSERT_EQUAL(
+ long3,
+ completer_.completeWord(long1));
+ }
+
+ void testSwiftRoomSample() {
+ std::string t("t");
+ std::string Anpan("Anpan");
+ std::string cdubouloz("cdubouloz");
+ std::string Tobias("Tobias");
+ std::string Zash("Zash");
+ std::string lastsky("lastsky");
+ std::string Steve("Steve Kille");
+ std::string Flo("Flo");
+ std::string Test("Test");
+ std::string test("test");
+ completer_.addWord(Anpan);
+ completer_.addWord(cdubouloz);
+ completer_.addWord(Tobias);
+ completer_.addWord(lastsky);
+ completer_.addWord(Steve);
+ completer_.addWord(Flo);
+ completer_.addWord(Zash);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.addWord(Test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Test,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Test));
+ CPPUNIT_ASSERT_EQUAL(
+ Test,
+ completer_.completeWord(Tobias));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Test));
+
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+
+ completer_.removeWord(Test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.addWord(test);
+
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+ completer_.addWord(Zash);
+
+
+ CPPUNIT_ASSERT_EQUAL(
+ test,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(test));
+ CPPUNIT_ASSERT_EQUAL(
+ test,
+ completer_.completeWord(Tobias));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(test));
+
+ completer_.removeWord(test);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ completer_.removeWord(Tobias);
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ t,
+ completer_.completeWord(t));
+
+ completer_.addWord(Tobias);
+
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(t));
+ CPPUNIT_ASSERT_EQUAL(
+ Tobias,
+ completer_.completeWord(Tobias));
+
+ }
private:
- TabComplete completer_;
+ TabComplete completer_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(TabCompleteTest);