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 /Limber/main.cpp
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 'Limber/main.cpp')
-rw-r--r--Limber/main.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/Limber/main.cpp b/Limber/main.cpp
index e4bac77..52f9347 100644
--- a/Limber/main.cpp
+++ b/Limber/main.cpp
@@ -31,76 +31,76 @@
using namespace Swift;
class Server {
- public:
- Server(UserRegistry* userRegistry, EventLoop* eventLoop) : userRegistry_(userRegistry) {
- serverFromClientConnectionServer_ = BoostConnectionServer::create(5222, boostIOServiceThread_.getIOService(), eventLoop);
- serverFromClientConnectionServer_->onNewConnection.connect(boost::bind(&Server::handleNewConnection, this, _1));
- serverFromClientConnectionServer_->start();
- }
+ public:
+ Server(UserRegistry* userRegistry, EventLoop* eventLoop) : userRegistry_(userRegistry) {
+ serverFromClientConnectionServer_ = BoostConnectionServer::create(5222, boostIOServiceThread_.getIOService(), eventLoop);
+ serverFromClientConnectionServer_->onNewConnection.connect(boost::bind(&Server::handleNewConnection, this, _1));
+ serverFromClientConnectionServer_->start();
+ }
- private:
- void handleNewConnection(boost::shared_ptr<Connection> c) {
- boost::shared_ptr<ServerFromClientSession> session(new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, &xmlParserFactory, userRegistry_));
- serverFromClientSessions_.push_back(session);
- session->onElementReceived.connect(boost::bind(&Server::handleElementReceived, this, _1, session));
- session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session));
- session->startSession();
- }
+ private:
+ void handleNewConnection(boost::shared_ptr<Connection> c) {
+ boost::shared_ptr<ServerFromClientSession> session(new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, &xmlParserFactory, userRegistry_));
+ serverFromClientSessions_.push_back(session);
+ session->onElementReceived.connect(boost::bind(&Server::handleElementReceived, this, _1, session));
+ session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session));
+ session->startSession();
+ }
- void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
- serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end());
- }
+ void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
+ serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end());
+ }
- void handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session) {
- boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
- if (!stanza) {
- return;
- }
- stanza->setFrom(session->getRemoteJID());
- if (!stanza->getTo().isValid()) {
- stanza->setTo(JID(session->getLocalJID()));
- }
- if (!stanza->getTo().isValid() || stanza->getTo() == session->getLocalJID() || stanza->getTo() == session->getRemoteJID().toBare()) {
- if (boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza)) {
- if (iq->getPayload<RosterPayload>()) {
- session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::make_shared<RosterPayload>()));
- }
- if (iq->getPayload<VCard>()) {
- if (iq->getType() == IQ::Get) {
- boost::shared_ptr<VCard> vcard(new VCard());
- vcard->setNickname(iq->getFrom().getNode());
- session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vcard));
- }
- else {
- session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::Forbidden, ErrorPayload::Cancel));
- }
- }
- else {
- session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::FeatureNotImplemented, ErrorPayload::Cancel));
- }
- }
- }
- }
+ void handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session) {
+ boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
+ if (!stanza) {
+ return;
+ }
+ stanza->setFrom(session->getRemoteJID());
+ if (!stanza->getTo().isValid()) {
+ stanza->setTo(JID(session->getLocalJID()));
+ }
+ if (!stanza->getTo().isValid() || stanza->getTo() == session->getLocalJID() || stanza->getTo() == session->getRemoteJID().toBare()) {
+ if (boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza)) {
+ if (iq->getPayload<RosterPayload>()) {
+ session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::make_shared<RosterPayload>()));
+ }
+ if (iq->getPayload<VCard>()) {
+ if (iq->getType() == IQ::Get) {
+ boost::shared_ptr<VCard> vcard(new VCard());
+ vcard->setNickname(iq->getFrom().getNode());
+ session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vcard));
+ }
+ else {
+ session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::Forbidden, ErrorPayload::Cancel));
+ }
+ }
+ else {
+ session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::FeatureNotImplemented, ErrorPayload::Cancel));
+ }
+ }
+ }
+ }
- private:
- IDGenerator idGenerator_;
- PlatformXMLParserFactory xmlParserFactory;
- UserRegistry* userRegistry_;
- BoostIOServiceThread boostIOServiceThread_;
- boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_;
- std::vector< boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions_;
- FullPayloadParserFactoryCollection payloadParserFactories_;
- FullPayloadSerializerCollection payloadSerializers_;
+ private:
+ IDGenerator idGenerator_;
+ PlatformXMLParserFactory xmlParserFactory;
+ UserRegistry* userRegistry_;
+ BoostIOServiceThread boostIOServiceThread_;
+ boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_;
+ std::vector< boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions_;
+ FullPayloadParserFactoryCollection payloadParserFactories_;
+ FullPayloadSerializerCollection payloadSerializers_;
};
int main() {
- SimpleEventLoop eventLoop;
- SimpleUserRegistry userRegistry;
- userRegistry.addUser(JID("remko@localhost"), "remko");
- userRegistry.addUser(JID("kevin@localhost"), "kevin");
- userRegistry.addUser(JID("remko@limber.swift.im"), "remko");
- userRegistry.addUser(JID("kevin@limber.swift.im"), "kevin");
- Server server(&userRegistry, &eventLoop);
- eventLoop.run();
- return 0;
+ SimpleEventLoop eventLoop;
+ SimpleUserRegistry userRegistry;
+ userRegistry.addUser(JID("remko@localhost"), "remko");
+ userRegistry.addUser(JID("kevin@localhost"), "kevin");
+ userRegistry.addUser(JID("remko@limber.swift.im"), "remko");
+ userRegistry.addUser(JID("kevin@limber.swift.im"), "kevin");
+ Server server(&userRegistry, &eventLoop);
+ eventLoop.run();
+ return 0;
}