summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Limber/Makefile.inc15
-rw-r--r--Limber/SConscript10
-rw-r--r--Limber/main.cpp24
3 files changed, 24 insertions, 25 deletions
diff --git a/Limber/Makefile.inc b/Limber/Makefile.inc
deleted file mode 100644
index fe0e7d2..0000000
--- a/Limber/Makefile.inc
+++ /dev/null
@@ -1,15 +0,0 @@
-LIMBER_TARGET = Limber/limber
-LIMBER_SOURCES = \
- Limber/main.cpp
-LIMBER_OBJECTS = \
- $(LIMBER_SOURCES:.cpp=.o) \
-
-.PHONY: limber
-limber: $(LIMBER_TARGET)
-
-$(LIMBER_TARGET): $(SWIFTEN_TARGET) $(LIMBER_OBJECTS)
- $(QUIET_LINK)$(CXX) -o $(LIMBER_TARGET) $(LIMBER_OBJECTS) $(LDFLAGS) $(SWIFTEN_TARGET) $(LIBS)
-
-#TARGETS += $(LIMBER_TARGET)
-DEPS += \
- $(LIMBER_SOURCES:.cpp=.dep) \
diff --git a/Limber/SConscript b/Limber/SConscript
new file mode 100644
index 0000000..77e0c50
--- /dev/null
+++ b/Limber/SConscript
@@ -0,0 +1,10 @@
+Import("env")
+
+myenv = env.Clone()
+myenv.MergeFlags(env["SWIFTEN_FLAGS"])
+myenv.MergeFlags(env["LIBIDN_FLAGS"])
+myenv.MergeFlags(env["EXPAT_FLAGS"])
+myenv.MergeFlags(env["OPENSSL_FLAGS"])
+myenv.MergeFlags(env["BOOST_FLAGS"])
+
+myenv.Program("limber", ["main.cpp"])
diff --git a/Limber/main.cpp b/Limber/main.cpp
index 2a2197d..686df3c 100644
--- a/Limber/main.cpp
+++ b/Limber/main.cpp
@@ -33,37 +33,41 @@ class Server {
void handleNewConnection(boost::shared_ptr<Connection> c) {
boost::shared_ptr<ServerFromClientSession> session(new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, userRegistry_));
serverFromClientSessions_.push_back(session);
- session->onStanzaReceived.connect(boost::bind(&Server::handleStanzaReceived, this, _1, session));
+ session->onElementReceived.connect(boost::bind(&Server::handleElementReceived, this, _1, session));
session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session));
- session->start();
+ session->startSession();
}
void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end());
}
- void handleStanzaReceived(boost::shared_ptr<Stanza> stanza, boost::shared_ptr<ServerFromClientSession> session) {
- stanza->setFrom(session->getJID());
+ void handleElementReceived(boost::shared_ptr<Element> 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->getDomain()));
+ stanza->setTo(JID(session->getLocalJID()));
}
- if (!stanza->getTo().isValid() || stanza->getTo() == session->getDomain() || stanza->getTo() == session->getJID().toBare()) {
+ 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->sendStanza(IQ::createResult(iq->getFrom(), iq->getID(), boost::shared_ptr<RosterPayload>(new RosterPayload())));
+ session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::shared_ptr<RosterPayload>(new RosterPayload())));
}
if (iq->getPayload<VCard>()) {
if (iq->getType() == IQ::Get) {
boost::shared_ptr<VCard> vcard(new VCard());
vcard->setNickname(iq->getFrom().getNode());
- session->sendStanza(IQ::createResult(iq->getFrom(), iq->getID(), vcard));
+ session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vcard));
}
else {
- session->sendStanza(IQ::createError(iq->getFrom(), iq->getID(), Error::Forbidden, Error::Cancel));
+ session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), Error::Forbidden, Error::Cancel));
}
}
else {
- session->sendStanza(IQ::createError(iq->getFrom(), iq->getID(), Error::FeatureNotImplemented, Error::Cancel));
+ session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), Error::FeatureNotImplemented, Error::Cancel));
}
}
}