diff options
Diffstat (limited to 'Swiften')
32 files changed, 300 insertions, 300 deletions
diff --git a/Swiften/Application/UnitTest/ApplicationTest.cpp b/Swiften/Application/UnitTest/ApplicationTest.cpp index e13c94b..0196755 100644 --- a/Swiften/Application/UnitTest/ApplicationTest.cpp +++ b/Swiften/Application/UnitTest/ApplicationTest.cpp @@ -20,7 +20,7 @@ class ApplicationTest : public CppUnit::TestFixture } void tearDown() { - delete testling_; + delete testling_; } void testGetSettingsDir() { diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h index 336a663..c4a44a3 100644 --- a/Swiften/Base/String.h +++ b/Swiften/Base/String.h @@ -40,7 +40,7 @@ namespace Swift { std::vector<String> split(char c) const; size_t getLength() const; - String getLowerCase() const; + String getLowerCase() const; void removeAll(char c); diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index 1dd44fb..6ad12fd 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -23,7 +23,7 @@ class StringTest : public CppUnit::TestFixture CPPUNIT_TEST(testReplaceAll_LastChar); CPPUNIT_TEST(testReplaceAll_ConsecutiveChars); CPPUNIT_TEST(testReplaceAll_MatchingReplace); - CPPUNIT_TEST(testGetLowerCase); + CPPUNIT_TEST(testGetLowerCase); CPPUNIT_TEST(testSplit); CPPUNIT_TEST_SUITE_END(); @@ -144,11 +144,11 @@ class StringTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(String("abbbc"), testling); } - void testGetLowerCase() { + void testGetLowerCase() { String testling("aBcD e"); - CPPUNIT_ASSERT_EQUAL(String("abcd e"), testling.getLowerCase()); - } + CPPUNIT_ASSERT_EQUAL(String("abcd e"), testling.getLowerCase()); + } void testSplit() { std::vector<String> result = String("abc def ghi").split(' '); diff --git a/Swiften/Base/sleep.cpp b/Swiften/Base/sleep.cpp index cecfd72..99d0fe6 100644 --- a/Swiften/Base/sleep.cpp +++ b/Swiften/Base/sleep.cpp @@ -5,10 +5,10 @@ namespace Swift { void sleep(unsigned int msecs) { - boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); - xt.nsec += msecs*1000000; - boost::thread::sleep(xt); + boost::xtime xt; + boost::xtime_get(&xt, boost::TIME_UTC); + xt.nsec += msecs*1000000; + boost::thread::sleep(xt); } } diff --git a/Swiften/Base/sleep.h b/Swiften/Base/sleep.h index b2a4ef1..bcebc4c 100644 --- a/Swiften/Base/sleep.h +++ b/Swiften/Base/sleep.h @@ -2,7 +2,7 @@ #define SWIFTEN_sleep_H namespace Swift { - void sleep(unsigned int msecs); + void sleep(unsigned int msecs); } #endif diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h index 4b66a9d..211a4ab 100644 --- a/Swiften/Client/DummyStanzaChannel.h +++ b/Swiften/Client/DummyStanzaChannel.h @@ -13,17 +13,17 @@ namespace Swift { sentStanzas_.push_back(stanza); } - virtual void sendIQ(boost::shared_ptr<IQ> iq) { - sentStanzas_.push_back(iq); - } + virtual void sendIQ(boost::shared_ptr<IQ> iq) { + sentStanzas_.push_back(iq); + } - virtual void sendMessage(boost::shared_ptr<Message> message) { - sentStanzas_.push_back(message); - } + virtual void sendMessage(boost::shared_ptr<Message> message) { + sentStanzas_.push_back(message); + } - virtual void sendPresence(boost::shared_ptr<Presence> presence) { - sentStanzas_.push_back(presence); - } + virtual void sendPresence(boost::shared_ptr<Presence> presence) { + sentStanzas_.push_back(presence); + } virtual String getNewIQID() { return "test-id"; diff --git a/Swiften/Client/StanzaChannel.h b/Swiften/Client/StanzaChannel.h index 719ed10..13e7ed4 100644 --- a/Swiften/Client/StanzaChannel.h +++ b/Swiften/Client/StanzaChannel.h @@ -15,7 +15,7 @@ namespace Swift { virtual void sendPresence(boost::shared_ptr<Presence>) = 0; boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived; - boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; + boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; }; } diff --git a/Swiften/Elements/IQ.cpp b/Swiften/Elements/IQ.cpp index 51f4745..3f47182 100644 --- a/Swiften/Elements/IQ.cpp +++ b/Swiften/Elements/IQ.cpp @@ -5,9 +5,9 @@ namespace Swift { boost::shared_ptr<IQ> IQ::createRequest( Type type, const JID& to, const String& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(type)); - if (to.isValid()) { - iq->setTo(to); - } + if (to.isValid()) { + iq->setTo(to); + } iq->setID(id); if (payload) { iq->addPayload(payload); diff --git a/Swiften/Elements/RosterPayload.cpp b/Swiften/Elements/RosterPayload.cpp index 8e2fd87..1aecde9 100644 --- a/Swiften/Elements/RosterPayload.cpp +++ b/Swiften/Elements/RosterPayload.cpp @@ -5,9 +5,9 @@ namespace Swift { boost::optional<RosterItemPayload> RosterPayload::getItem(const JID& jid) const { foreach(const RosterItemPayload& item, items_) { - // FIXME: MSVC rejects this. Find out why. + // FIXME: MSVC rejects this. Find out why. //if (item.getJID() == jid) { - if (item.getJID().equals(jid, JID::WithResource)) { + if (item.getJID().equals(jid, JID::WithResource)) { return boost::optional<RosterItemPayload>(item); } } diff --git a/Swiften/EventLoop/Qt/QtEventLoop.h b/Swiften/EventLoop/Qt/QtEventLoop.h index 9c7d2f1..40e927e 100644 --- a/Swiften/EventLoop/Qt/QtEventLoop.h +++ b/Swiften/EventLoop/Qt/QtEventLoop.h @@ -17,7 +17,7 @@ class QtEventLoop : public QObject, public Swift::EventLoop { virtual bool event(QEvent* qevent) { Event* event = dynamic_cast<Event*>(qevent); if (event) { - handleEvent(event->event_); + handleEvent(event->event_); //event->deleteLater(); FIXME: Leak? return true; } diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index 357e158..8191747 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -33,7 +33,7 @@ void SimpleEventLoop::stop() { } void SimpleEventLoop::doStop() { - isRunning_ = false; + isRunning_ = false; } void SimpleEventLoop::post(const Event& event) { diff --git a/Swiften/EventLoop/SimpleEventLoop.h b/Swiften/EventLoop/SimpleEventLoop.h index 45eaae1..01afdb2 100644 --- a/Swiften/EventLoop/SimpleEventLoop.h +++ b/Swiften/EventLoop/SimpleEventLoop.h @@ -18,8 +18,8 @@ namespace Swift { virtual void post(const Event& event); - private: - void doStop(); + private: + void doStop(); private: bool isRunning_; diff --git a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp b/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp index b6c2da8..14f24c7 100644 --- a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp +++ b/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp @@ -41,7 +41,7 @@ class SimpleEventLoopTest : public CppUnit::TestFixture private: void runIncrementingThread(SimpleEventLoop* loop) { for (unsigned int i = 0; i < 10; ++i) { - Swift::sleep(1); + Swift::sleep(1); loop->postEvent(boost::bind(&SimpleEventLoopTest::incrementCounter, this)); } loop->stop(); diff --git a/Swiften/Events/MessageEvent.h b/Swiften/Events/MessageEvent.h index 0f061d1..412b199 100644 --- a/Swiften/Events/MessageEvent.h +++ b/Swiften/Events/MessageEvent.h @@ -10,7 +10,7 @@ namespace Swift { class MessageEvent { - public: + public: MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza){} boost::shared_ptr<Message> getStanza() {return stanza_;} boost::signal<void()> onRead; diff --git a/Swiften/History/UnitTest/SQLiteHistoryManagerTest.cpp b/Swiften/History/UnitTest/SQLiteHistoryManagerTest.cpp index f4f122a..e738a6e 100644 --- a/Swiften/History/UnitTest/SQLiteHistoryManagerTest.cpp +++ b/Swiften/History/UnitTest/SQLiteHistoryManagerTest.cpp @@ -10,12 +10,12 @@ class SQLiteHistoryManagerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(SQLiteHistoryManagerTest); CPPUNIT_TEST(testAddMessage); CPPUNIT_TEST(testAddMessage_TwoMessages); - CPPUNIT_TEST(testGetIDForJID_SameJID); - CPPUNIT_TEST(testGetIDForJID_DifferentJIDs); - CPPUNIT_TEST(getJIDFromID); - CPPUNIT_TEST(getJIDFromID_UnexistingID); - CPPUNIT_TEST(getIDFromJID); - CPPUNIT_TEST(getIDFromJID_UnexistingJID); + CPPUNIT_TEST(testGetIDForJID_SameJID); + CPPUNIT_TEST(testGetIDForJID_DifferentJIDs); + CPPUNIT_TEST(getJIDFromID); + CPPUNIT_TEST(getJIDFromID_UnexistingID); + CPPUNIT_TEST(getIDFromJID); + CPPUNIT_TEST(getIDFromJID_UnexistingJID); CPPUNIT_TEST_SUITE_END(); public: @@ -28,82 +28,82 @@ class SQLiteHistoryManagerTest : public CppUnit::TestFixture { } void testAddMessage() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - HistoryMessage testMessage("Test", JID("foo@bar.com"), JID("fum@baz.org"), boost::posix_time::time_from_string("1980-01-21 22:03")); - testling->addMessage(testMessage); + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + HistoryMessage testMessage("Test", JID("foo@bar.com"), JID("fum@baz.org"), boost::posix_time::time_from_string("1980-01-21 22:03")); + testling->addMessage(testMessage); - std::vector<HistoryMessage> messages = testling->getMessages(); - CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(messages.size())); - CPPUNIT_ASSERT(testMessage == messages[0]); + std::vector<HistoryMessage> messages = testling->getMessages(); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(messages.size())); + CPPUNIT_ASSERT(testMessage == messages[0]); } void testAddMessage_TwoMessages() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - HistoryMessage testMessage1("Test1", JID("foo@bar.com"), JID("fum@baz.org"), boost::posix_time::time_from_string("1980-01-21 22:03")); - testling->addMessage(testMessage1); - HistoryMessage testMessage2("Test2", JID("fum@baz.org"), JID("foo@bar.com"), boost::posix_time::time_from_string("1975-03-09 22:04")); - testling->addMessage(testMessage2); - - std::vector<HistoryMessage> messages = testling->getMessages(); - CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(messages.size())); - CPPUNIT_ASSERT(testMessage1 == messages[0]); - CPPUNIT_ASSERT(testMessage2 == messages[1]); + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + HistoryMessage testMessage1("Test1", JID("foo@bar.com"), JID("fum@baz.org"), boost::posix_time::time_from_string("1980-01-21 22:03")); + testling->addMessage(testMessage1); + HistoryMessage testMessage2("Test2", JID("fum@baz.org"), JID("foo@bar.com"), boost::posix_time::time_from_string("1975-03-09 22:04")); + testling->addMessage(testMessage2); + + std::vector<HistoryMessage> messages = testling->getMessages(); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(messages.size())); + CPPUNIT_ASSERT(testMessage1 == messages[0]); + CPPUNIT_ASSERT(testMessage2 == messages[1]); } - void testGetIDForJID_SameJID() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - int id1 = testling->getIDForJID(JID("foo@bar.com")); - int id2 = testling->getIDForJID(JID("foo@bar.com")); + void testGetIDForJID_SameJID() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + int id1 = testling->getIDForJID(JID("foo@bar.com")); + int id2 = testling->getIDForJID(JID("foo@bar.com")); - CPPUNIT_ASSERT_EQUAL(id1, id2); - } + CPPUNIT_ASSERT_EQUAL(id1, id2); + } - void testGetIDForJID_DifferentJIDs() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - int id1 = testling->getIDForJID(JID("foo@bar.com")); - int id2 = testling->getIDForJID(JID("foo@baz.com")); + void testGetIDForJID_DifferentJIDs() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + int id1 = testling->getIDForJID(JID("foo@bar.com")); + int id2 = testling->getIDForJID(JID("foo@baz.com")); - CPPUNIT_ASSERT(id1 != id2); - } + CPPUNIT_ASSERT(id1 != id2); + } - void getJIDFromID() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - int id = testling->addJID(JID("foo@bar.com")); + void getJIDFromID() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + int id = testling->addJID(JID("foo@bar.com")); - boost::optional<JID> result(testling->getJIDFromID(id)); - CPPUNIT_ASSERT(result); - CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), *result); - } + boost::optional<JID> result(testling->getJIDFromID(id)); + CPPUNIT_ASSERT(result); + CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), *result); + } - void getJIDFromID_UnexistingID() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + void getJIDFromID_UnexistingID() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - boost::optional<JID> result(testling->getJIDFromID(1)); + boost::optional<JID> result(testling->getJIDFromID(1)); - CPPUNIT_ASSERT(!result); - } + CPPUNIT_ASSERT(!result); + } - void getIDFromJID() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - int id = testling->addJID(JID("foo@bar.com")); + void getIDFromJID() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + int id = testling->addJID(JID("foo@bar.com")); - boost::optional<int> result(testling->getIDFromJID(JID("foo@bar.com"))); - CPPUNIT_ASSERT(result); - CPPUNIT_ASSERT_EQUAL(id, *result); - } + boost::optional<int> result(testling->getIDFromJID(JID("foo@bar.com"))); + CPPUNIT_ASSERT(result); + CPPUNIT_ASSERT_EQUAL(id, *result); + } - void getIDFromJID_UnexistingJID() { - std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); + void getIDFromJID_UnexistingJID() { + std::auto_ptr<SQLiteHistoryManager> testling(createHistoryManager()); - boost::optional<int> result(testling->getIDFromJID(JID("foo@bar.com"))); + boost::optional<int> result(testling->getIDFromJID(JID("foo@bar.com"))); - CPPUNIT_ASSERT(!result); - } + CPPUNIT_ASSERT(!result); + } - private: - SQLiteHistoryManager* createHistoryManager() { - return new SQLiteHistoryManager(":memory:"); - } + private: + SQLiteHistoryManager* createHistoryManager() { + return new SQLiteHistoryManager(":memory:"); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(SQLiteHistoryManagerTest); diff --git a/Swiften/Network/DomainNameResolver.cpp b/Swiften/Network/DomainNameResolver.cpp index d2bbf0d..44b3ecf 100644 --- a/Swiften/Network/DomainNameResolver.cpp +++ b/Swiften/Network/DomainNameResolver.cpp @@ -30,15 +30,15 @@ DomainNameResolver::~DomainNameResolver() { } HostAddressPort DomainNameResolver::resolve(const String& domain) { - char* output; - if (idna_to_ascii_8z(domain.getUTF8Data(), &output, 0) == IDNA_SUCCESS) { - std::string outputString(output); - free(output); - return resolveDomain(outputString); - } - else { - return resolveDomain(domain.getUTF8String()); - } + char* output; + if (idna_to_ascii_8z(domain.getUTF8Data(), &output, 0) == IDNA_SUCCESS) { + std::string outputString(output); + free(output); + return resolveDomain(outputString); + } + else { + return resolveDomain(domain.getUTF8String()); + } } HostAddressPort DomainNameResolver::resolveDomain(const std::string& domain) { @@ -51,14 +51,14 @@ HostAddressPort DomainNameResolver::resolveDomain(const std::string& domain) { } HostAddressPort DomainNameResolver::resolveXMPPService(const std::string& domain) { - std::string srvQuery = "_xmpp-client._tcp." + domain; + std::string srvQuery = "_xmpp-client._tcp." + domain; #if defined(SWIFTEN_PLATFORM_WINDOWS) DNS_RECORD* responses; // FIXME: This conversion doesn't work if unicode is deffed above - if (DnsQuery(srvQuery.c_str(), DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &responses, NULL) != ERROR_SUCCESS) { + if (DnsQuery(srvQuery.c_str(), DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &responses, NULL) != ERROR_SUCCESS) { throw DomainNameResolveException(); - } + } DNS_RECORD* currentEntry = responses; while (currentEntry) { @@ -83,10 +83,10 @@ HostAddressPort DomainNameResolver::resolveXMPPService(const std::string& domain #else - ByteArray response; - response.resize(NS_PACKETSZ); - int responseLength = res_query(const_cast<char*>(srvQuery.c_str()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize()); - if (responseLength == -1) { + ByteArray response; + response.resize(NS_PACKETSZ); + int responseLength = res_query(const_cast<char*>(srvQuery.c_str()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize()); + if (responseLength == -1) { throw DomainNameResolveException(); } diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp index ea324cb..8ac66bb 100644 --- a/Swiften/Network/HostAddress.cpp +++ b/Swiften/Network/HostAddress.cpp @@ -12,9 +12,9 @@ namespace Swift { HostAddress::HostAddress() { - for (int i = 0; i < 4; ++i) { - address_.push_back(0); - } + for (int i = 0; i < 4; ++i) { + address_.push_back(0); + } } HostAddress::HostAddress(const String& address) { @@ -54,7 +54,7 @@ std::string HostAddress::toString() const { } else { assert(false); - return ""; + return ""; } } diff --git a/Swiften/Network/HostAddress.h b/Swiften/Network/HostAddress.h index fa34df4..bf6d2f8 100644 --- a/Swiften/Network/HostAddress.h +++ b/Swiften/Network/HostAddress.h @@ -8,7 +8,7 @@ namespace Swift { class HostAddress { public: - HostAddress(); + HostAddress(); HostAddress(const String&); HostAddress(const unsigned char* address, int length); diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp index d571f0b..e4da756 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp +++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp @@ -5,44 +5,44 @@ namespace Swift { SecurityLabelsCatalogParser::SecurityLabelsCatalogParser() : level_(TopLevel), labelParser_(0) { - labelParserFactory_ = new SecurityLabelParserFactory(); + labelParserFactory_ = new SecurityLabelParserFactory(); } SecurityLabelsCatalogParser::~SecurityLabelsCatalogParser() { - delete labelParserFactory_; + delete labelParserFactory_; } void SecurityLabelsCatalogParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { ++level_; if (level_ == PayloadLevel) { - getPayloadInternal()->setTo(JID(attributes.getAttribute("to"))); - getPayloadInternal()->setName(attributes.getAttribute("name")); - getPayloadInternal()->setDescription(attributes.getAttribute("desc")); - } - else if (level_ == LabelLevel) { - assert(!labelParser_); - if (labelParserFactory_->canParse(element, ns, attributes)) { - labelParser_ = dynamic_cast<SecurityLabelParser*>(labelParserFactory_->createPayloadParser()); - assert(labelParser_); - } - } - - if (labelParser_) { - labelParser_->handleStartElement(element, ns, attributes); - } + getPayloadInternal()->setTo(JID(attributes.getAttribute("to"))); + getPayloadInternal()->setName(attributes.getAttribute("name")); + getPayloadInternal()->setDescription(attributes.getAttribute("desc")); + } + else if (level_ == LabelLevel) { + assert(!labelParser_); + if (labelParserFactory_->canParse(element, ns, attributes)) { + labelParser_ = dynamic_cast<SecurityLabelParser*>(labelParserFactory_->createPayloadParser()); + assert(labelParser_); + } + } + + if (labelParser_) { + labelParser_->handleStartElement(element, ns, attributes); + } } void SecurityLabelsCatalogParser::handleEndElement(const String& element, const String& ns) { - if (labelParser_) { - labelParser_->handleEndElement(element, ns); - } - if (level_ == LabelLevel && labelParser_) { - SecurityLabel* label = dynamic_cast<SecurityLabel*>(labelParser_->getPayload().get()); - assert(label); - getPayloadInternal()->addLabel(SecurityLabel(*label)); - delete labelParser_; - labelParser_ = 0; - } + if (labelParser_) { + labelParser_->handleEndElement(element, ns); + } + if (level_ == LabelLevel && labelParser_) { + SecurityLabel* label = dynamic_cast<SecurityLabel*>(labelParser_->getPayload().get()); + assert(label); + getPayloadInternal()->addLabel(SecurityLabel(*label)); + delete labelParser_; + labelParser_ = 0; + } --level_; } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h index ec31235..799e43a 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h +++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h @@ -5,13 +5,13 @@ #include "Swiften/Parser/GenericPayloadParser.h" namespace Swift { - class SecurityLabelParserFactory; - class SecurityLabelParser; + class SecurityLabelParserFactory; + class SecurityLabelParser; class SecurityLabelsCatalogParser : public GenericPayloadParser<SecurityLabelsCatalog> { public: SecurityLabelsCatalogParser(); - ~SecurityLabelsCatalogParser(); + ~SecurityLabelsCatalogParser(); virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); virtual void handleEndElement(const String& element, const String&); @@ -21,11 +21,11 @@ namespace Swift { enum Level { TopLevel = 0, PayloadLevel = 1, - LabelLevel = 2 + LabelLevel = 2 }; int level_; - SecurityLabelParserFactory* labelParserFactory_; - SecurityLabelParser* labelParser_; + SecurityLabelParserFactory* labelParserFactory_; + SecurityLabelParser* labelParser_; }; } diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp index 5da3fbd..325309f 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp @@ -21,17 +21,17 @@ class SecurityLabelParserTest : public CppUnit::TestFixture CPPUNIT_ASSERT(parser.parse( "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" - "<displaymarking fgcolor=\"black\" bgcolor=\"red\">SECRET</displaymarking>" - "<label>" + "<displaymarking fgcolor=\"black\" bgcolor=\"red\">SECRET</displaymarking>" + "<label>" "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>" "</label>" - "<equivalentlabel>" + "<equivalentlabel>" "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>" "</equivalentlabel>" - "<equivalentlabel>" + "<equivalentlabel>" "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>" "</equivalentlabel>" - "</securitylabel>")); + "</securitylabel>")); SecurityLabel* payload = dynamic_cast<SecurityLabel*>(testling.getPayload().get()); CPPUNIT_ASSERT_EQUAL(String("SECRET"), payload->getDisplayMarking()); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp index 0021c0d..2f3f47a 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp @@ -29,7 +29,7 @@ class SecurityLabelsCatalogParserTest : public CppUnit::TestFixture "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>" "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>" "</securitylabel>" - "</catalog>")); + "</catalog>")); SecurityLabelsCatalog* payload = dynamic_cast<SecurityLabelsCatalog*>(testling.getPayload().get()); CPPUNIT_ASSERT_EQUAL(String("Default"), payload->getName()); diff --git a/Swiften/Parser/UnitTest/XMLParserTest.cpp b/Swiften/Parser/UnitTest/XMLParserTest.cpp index 4785317..6ef1899 100644 --- a/Swiften/Parser/UnitTest/XMLParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMLParserTest.cpp @@ -62,7 +62,7 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(testling.parse( "<query xmlns='jabber:iq:version'>" - "<name>Swift</name>" + "<name>Swift</name>" "</query>")); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), client_.events.size()); @@ -191,7 +191,7 @@ class XMLParserTest : public CppUnit::TestFixture { Event( Type type, const String& data, - const String& ns, + const String& ns, const AttributeMap& attributes) : type(type), data(data), ns(ns), attributes(attributes) {} Event(Type type, const String& data, const String& ns = String()) @@ -199,7 +199,7 @@ class XMLParserTest : public CppUnit::TestFixture { Type type; String data; - String ns; + String ns; AttributeMap attributes; }; diff --git a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp b/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp index 44db138..6ed7b9e 100644 --- a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp +++ b/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp @@ -19,66 +19,66 @@ class DiscoInfoResponderTest : public CppUnit::TestFixture { DiscoInfoResponderTest() {} void setUp() { - channel_ = new DummyIQChannel(); - router_ = new IQRouter(channel_); + channel_ = new DummyIQChannel(); + router_ = new IQRouter(channel_); } void tearDown() { - delete router_; - delete channel_; + delete router_; + delete channel_; } void testHandleRequest_GetToplevelInfo() { - DiscoInfoResponder testling(router_); + DiscoInfoResponder testling(router_); DiscoInfo discoInfo; discoInfo.addFeature("foo"); - testling.setDiscoInfo(discoInfo); + testling.setDiscoInfo(discoInfo); - boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); - channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); + boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); + channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); - CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); - boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); - CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); - CPPUNIT_ASSERT(payload->hasFeature("foo")); - } + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); + boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); + CPPUNIT_ASSERT(payload); + CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); + CPPUNIT_ASSERT(payload->hasFeature("foo")); + } void testHandleRequest_GetNodeInfo() { - DiscoInfoResponder testling(router_); + DiscoInfoResponder testling(router_); DiscoInfo discoInfo; discoInfo.addFeature("foo"); - testling.setDiscoInfo(discoInfo); + testling.setDiscoInfo(discoInfo); DiscoInfo discoInfoBar; discoInfoBar.addFeature("bar"); - testling.setDiscoInfo("bar-node", discoInfoBar); + testling.setDiscoInfo("bar-node", discoInfoBar); - boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); - query->setNode("bar-node"); - channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); + boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); + query->setNode("bar-node"); + channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); - CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); - boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); - CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); - CPPUNIT_ASSERT(payload->hasFeature("bar")); - } + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); + boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); + CPPUNIT_ASSERT(payload); + CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); + CPPUNIT_ASSERT(payload->hasFeature("bar")); + } void testHandleRequest_GetInvalidNodeInfo() { - DiscoInfoResponder testling(router_); + DiscoInfoResponder testling(router_); - boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); - query->setNode("bar-node"); - channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); + boost::shared_ptr<DiscoInfo> query(new DiscoInfo()); + query->setNode("bar-node"); + channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query)); - CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); - boost::shared_ptr<Error> payload(channel_->iqs_[0]->getPayload<Error>()); - CPPUNIT_ASSERT(payload); - } + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); + boost::shared_ptr<Error> payload(channel_->iqs_[0]->getPayload<Error>()); + CPPUNIT_ASSERT(payload); + } - private: - IQRouter* router_; - DummyIQChannel* channel_; + private: + IQRouter* router_; + DummyIQChannel* channel_; }; CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoResponderTest); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index e53c6b7..f155f22 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -13,12 +13,12 @@ String SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel XMLElement element("securitylabel", "urn:xmpp:sec-label:0"); if (!label->getDisplayMarking().isEmpty()) { boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking")); - if (!label->getForegroundColor().isEmpty()) { - displayMarking->setAttribute("fgcolor", label->getForegroundColor()); - } - if (!label->getBackgroundColor().isEmpty()) { - displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); - } + if (!label->getForegroundColor().isEmpty()) { + displayMarking->setAttribute("fgcolor", label->getForegroundColor()); + } + if (!label->getBackgroundColor().isEmpty()) { + displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); + } displayMarking->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(label->getDisplayMarking()))); element.addNode(displayMarking); } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp index e8b89ad..c95ae10 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp @@ -26,17 +26,17 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(String( "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" - "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>" - "<label>" + "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>" + "<label>" "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>" "</label>" - "<equivalentlabel>" + "<equivalentlabel>" "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>" "</equivalentlabel>" - "<equivalentlabel>" + "<equivalentlabel>" "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>" "</equivalentlabel>" - "</securitylabel>"), testling.serialize(securityLabel)); + "</securitylabel>"), testling.serialize(securityLabel)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp index acea1e4..3055aca 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp @@ -45,7 +45,7 @@ class SecurityLabelsCatalogSerializerTest : public CppUnit::TestFixture "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>" "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>" "</securitylabel>" - "</catalog>"), testling.serialize(catalog)); + "</catalog>"), testling.serialize(catalog)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp index fc7e442..23988d7 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp @@ -20,9 +20,9 @@ class VCardUpdateSerializerTest : public CppUnit::TestFixture update->setPhotoHash("sha1-hash-of-image"); String expectedResult = - "<x xmlns=\"vcard-temp:x:update\">" - "<photo>sha1-hash-of-image</photo>" - "</x>"; + "<x xmlns=\"vcard-temp:x:update\">" + "<photo>sha1-hash-of-image</photo>" + "</x>"; CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(update)); } diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp index af2cb34..71f4d0c 100644 --- a/Swiften/Serializer/XML/XMLElement.cpp +++ b/Swiften/Serializer/XML/XMLElement.cpp @@ -16,7 +16,7 @@ String XMLElement::serialize() { result += "<" + tag_; typedef std::pair<String,String> Pair; foreach(const Pair& p, attributes_) { - result += " " + p.first + "=\"" + p.second + "\""; + result += " " + p.first + "=\"" + p.second + "\""; } if (childNodes_.size() > 0) { diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp index 625b7ad..6f528c1 100644 --- a/Swiften/Session/Session.cpp +++ b/Swiften/Session/Session.cpp @@ -14,7 +14,7 @@ Session::Session( connection(connection), payloadParserFactories(payloadParserFactories), payloadSerializers(payloadSerializers), - streamStack(0), + streamStack(0), initialized(false), finishing(false) { } diff --git a/Swiften/StringCodecs/SHA1.cpp b/Swiften/StringCodecs/SHA1.cpp index e59836c..70256e9 100644 --- a/Swiften/StringCodecs/SHA1.cpp +++ b/Swiften/StringCodecs/SHA1.cpp @@ -13,11 +13,11 @@ By Steve Reid <steve@edmweb.com> Test Vectors (from FIPS PUB 180-1) "abc" - A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" - 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 A million repetitions of "a" - 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ /* #define LITTLE_ENDIAN * This should be #define'd if true. */ @@ -28,9 +28,9 @@ A million repetitions of "a" #include <string.h> typedef struct { - boost::uint32_t state[5]; - boost::uint32_t count[2]; - boost::uint8_t buffer[64]; + boost::uint32_t state[5]; + boost::uint32_t count[2]; + boost::uint8_t buffer[64]; } SHA1_CTX; void SHA1Transform(boost::uint32_t state[5], boost::uint8_t buffer[64]); @@ -44,12 +44,12 @@ void SHA1Final(boost::uint8_t digest[20], SHA1_CTX* context); /* I got the idea of expanding during the round function from SSLeay */ #ifdef SWIFTEN_LITTLE_ENDIAN #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) + |(rol(block->l[i],8)&0x00FF00FF)) #else #define blk0(i) block->l[i] #endif #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) + ^block->l[(i+2)&15]^block->l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); @@ -65,52 +65,52 @@ void SHA1Transform(boost::uint32_t state[5], boost::uint8_t buffer[64]) { boost::uint32_t a, b, c, d, e; typedef union { - boost::uint8_t c[64]; - boost::uint32_t l[16]; + boost::uint8_t c[64]; + boost::uint32_t l[16]; } CHAR64LONG16; CHAR64LONG16* block; #ifdef SHA1HANDSOFF static boost::uint8_t workspace[64]; - block = (CHAR64LONG16*)workspace; - memcpy(block, buffer, 64); + block = (CHAR64LONG16*)workspace; + memcpy(block, buffer, 64); #else - block = reinterpret_cast<CHAR64LONG16*>(buffer); + block = reinterpret_cast<CHAR64LONG16*>(buffer); #endif - /* Copy context->state[] to working vars */ - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); - /* Add the working vars back into context.state[] */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - /* Wipe variables */ - a = b = c = d = e = 0; + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; } @@ -118,13 +118,13 @@ static boost::uint8_t workspace[64]; void SHA1Init(SHA1_CTX* context) { - /* SHA1 initialization constants */ - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; - context->count[0] = context->count[1] = 0; + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; } @@ -134,19 +134,19 @@ void SHA1Update(SHA1_CTX* context, boost::uint8_t* data, unsigned int len) { unsigned int i, j; - j = (context->count[0] >> 3) & 63; - if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; - context->count[1] += (len >> 29); - if ((j + len) > 63) { - memcpy(&context->buffer[j], data, (i = 64-j)); - SHA1Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) { - SHA1Transform(context->state, &data[i]); - } - j = 0; - } - else i = 0; - memcpy(&context->buffer[j], &data[i], len - i); + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); } @@ -157,27 +157,27 @@ void SHA1Final(boost::uint8_t digest[20], SHA1_CTX* context) boost::uint32_t i, j; boost::uint8_t finalcount[8]; - for (i = 0; i < 8; i++) { - finalcount[i] = (boost::uint8_t) ((context->count[(i >= 4 ? 0 : 1)] - >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ - } - SHA1Update(context, (boost::uint8_t *)("\200"), 1); - while ((context->count[0] & 504) != 448) { - SHA1Update(context, (boost::uint8_t *)("\0"), 1); - } - SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ - for (i = 0; i < 20; i++) { - digest[i] = (boost::uint8_t) - ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); - } - /* Wipe variables */ - i = j = 0; - memset(context->buffer, 0, 64); - memset(context->state, 0, 20); - memset(context->count, 0, 8); - memset(&finalcount, 0, 8); + for (i = 0; i < 8; i++) { + finalcount[i] = (boost::uint8_t) ((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + SHA1Update(context, (boost::uint8_t *)("\200"), 1); + while ((context->count[0] & 504) != 448) { + SHA1Update(context, (boost::uint8_t *)("\0"), 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++) { + digest[i] = (boost::uint8_t) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + /* Wipe variables */ + i = j = 0; + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(&finalcount, 0, 8); #ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ - SHA1Transform(context->state, context->buffer); + SHA1Transform(context->state, context->buffer); #endif } diff --git a/Swiften/StringCodecs/UnitTest/Base64Test.cpp b/Swiften/StringCodecs/UnitTest/Base64Test.cpp index 22f3020..fb05c90 100644 --- a/Swiften/StringCodecs/UnitTest/Base64Test.cpp +++ b/Swiften/StringCodecs/UnitTest/Base64Test.cpp @@ -24,7 +24,7 @@ class Base64Test : public CppUnit::TestFixture void testEncode_NonAscii() { String result(Base64::encode(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"))); CPPUNIT_ASSERT_EQUAL(String("QgayPKawpkPSDYmwT/WM94uAlu0="), result); - } + } void testDecode() { ByteArray result(Base64::decode("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA=")); |