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/URIHandler
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/URIHandler')
-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
7 files changed, 333 insertions, 333 deletions
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;
+ };
}