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 /Swiften/Queries/Request.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 'Swiften/Queries/Request.cpp')
-rw-r--r--Swiften/Queries/Request.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp
index 8d2c9c4..a8dff24 100644
--- a/Swiften/Queries/Request.cpp
+++ b/Swiften/Queries/Request.cpp
@@ -25,69 +25,69 @@ Request::Request(IQ::Type type, const JID& sender, const JID& receiver, IQRouter
}
std::string Request::send() {
- assert(payload_);
- assert(!sent_);
- sent_ = true;
+ assert(payload_);
+ assert(!sent_);
+ sent_ = true;
- boost::shared_ptr<IQ> iq(new IQ(type_));
- iq->setTo(receiver_);
- iq->setFrom(sender_);
- iq->addPayload(payload_);
- id_ = router_->getNewIQID();
- iq->setID(id_);
+ boost::shared_ptr<IQ> iq(new IQ(type_));
+ iq->setTo(receiver_);
+ iq->setFrom(sender_);
+ iq->addPayload(payload_);
+ id_ = router_->getNewIQID();
+ iq->setID(id_);
- try {
- router_->addHandler(shared_from_this());
- }
- catch (const std::exception&) {
- router_->addHandler(this);
- }
+ try {
+ router_->addHandler(shared_from_this());
+ }
+ catch (const std::exception&) {
+ router_->addHandler(this);
+ }
- router_->sendIQ(iq);
- return id_;
+ router_->sendIQ(iq);
+ return id_;
}
bool Request::handleIQ(boost::shared_ptr<IQ> iq) {
- bool handled = false;
- if (iq->getType() == IQ::Result || iq->getType() == IQ::Error) {
- if (sent_ && iq->getID() == id_) {
- if (isCorrectSender(iq->getFrom())) {
- if (iq->getType() == IQ::Result) {
- boost::shared_ptr<Payload> payload = iq->getPayloadOfSameType(payload_);
- if (!payload && boost::dynamic_pointer_cast<RawXMLPayload>(payload_) && !iq->getPayloads().empty()) {
- payload = iq->getPayloads().front();
- }
- handleResponse(payload, ErrorPayload::ref());
- }
- else {
- ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>();
- if (errorPayload) {
- handleResponse(boost::shared_ptr<Payload>(), errorPayload);
- }
- else {
- handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition)));
- }
- }
- router_->removeHandler(this);
- handled = true;
- }
- }
- }
- return handled;
+ bool handled = false;
+ if (iq->getType() == IQ::Result || iq->getType() == IQ::Error) {
+ if (sent_ && iq->getID() == id_) {
+ if (isCorrectSender(iq->getFrom())) {
+ if (iq->getType() == IQ::Result) {
+ boost::shared_ptr<Payload> payload = iq->getPayloadOfSameType(payload_);
+ if (!payload && boost::dynamic_pointer_cast<RawXMLPayload>(payload_) && !iq->getPayloads().empty()) {
+ payload = iq->getPayloads().front();
+ }
+ handleResponse(payload, ErrorPayload::ref());
+ }
+ else {
+ ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>();
+ if (errorPayload) {
+ handleResponse(boost::shared_ptr<Payload>(), errorPayload);
+ }
+ else {
+ handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition)));
+ }
+ }
+ router_->removeHandler(this);
+ handled = true;
+ }
+ }
+ }
+ return handled;
}
bool Request::isCorrectSender(const JID& jid) {
- if (router_->isAccountJID(receiver_)) {
- if (jid.isValid() && jid.equals(router_->getJID(), JID::WithResource)) {
- // This unspecified behavior seems to happen in ejabberd versions (e.g. 2.0.5)
- SWIFT_LOG(warning) << "Server responded to an account request with a full JID, which is not allowed. Handling it anyway.";
- return true;
- }
- return router_->isAccountJID(jid);
- }
- else {
- return jid.equals(receiver_, JID::WithResource);
- }
+ if (router_->isAccountJID(receiver_)) {
+ if (jid.isValid() && jid.equals(router_->getJID(), JID::WithResource)) {
+ // This unspecified behavior seems to happen in ejabberd versions (e.g. 2.0.5)
+ SWIFT_LOG(warning) << "Server responded to an account request with a full JID, which is not allowed. Handling it anyway.";
+ return true;
+ }
+ return router_->isAccountJID(jid);
+ }
+ else {
+ return jid.equals(receiver_, JID::WithResource);
+ }
}