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 /Sluift/SluiftComponent.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 'Sluift/SluiftComponent.cpp')
-rw-r--r--Sluift/SluiftComponent.cpp164
1 files changed, 82 insertions, 82 deletions
diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp
index 9d0a92e..c0dcd3c 100644
--- a/Sluift/SluiftComponent.cpp
+++ b/Sluift/SluiftComponent.cpp
@@ -22,125 +22,125 @@
using namespace Swift;
SluiftComponent::SluiftComponent(
- const JID& jid,
- const std::string& password,
- NetworkFactories* networkFactories,
- SimpleEventLoop* eventLoop):
- networkFactories(networkFactories),
- eventLoop(eventLoop),
- tracer(NULL) {
- component = new Component(jid, password, networkFactories);
- component->onError.connect(boost::bind(&SluiftComponent::handleError, this, _1));
- component->onMessageReceived.connect(boost::bind(&SluiftComponent::handleIncomingMessage, this, _1));
- component->onPresenceReceived.connect(boost::bind(&SluiftComponent::handleIncomingPresence, this, _1));
+ const JID& jid,
+ const std::string& password,
+ NetworkFactories* networkFactories,
+ SimpleEventLoop* eventLoop):
+ networkFactories(networkFactories),
+ eventLoop(eventLoop),
+ tracer(NULL) {
+ component = new Component(jid, password, networkFactories);
+ component->onError.connect(boost::bind(&SluiftComponent::handleError, this, _1));
+ component->onMessageReceived.connect(boost::bind(&SluiftComponent::handleIncomingMessage, this, _1));
+ component->onPresenceReceived.connect(boost::bind(&SluiftComponent::handleIncomingPresence, this, _1));
}
SluiftComponent::~SluiftComponent() {
- delete tracer;
- delete component;
+ delete tracer;
+ delete component;
}
void SluiftComponent::connect(const std::string& host, int port) {
- disconnectedError = boost::optional<ComponentError>();
- component->connect(host, port);
+ disconnectedError = boost::optional<ComponentError>();
+ component->connect(host, port);
}
void SluiftComponent::setTraceEnabled(bool b) {
- if (b && !tracer) {
- tracer = new ComponentXMLTracer(component);
- }
- else if (!b && tracer) {
- delete tracer;
- tracer = NULL;
- }
+ if (b && !tracer) {
+ tracer = new ComponentXMLTracer(component);
+ }
+ else if (!b && tracer) {
+ delete tracer;
+ tracer = NULL;
+ }
}
void SluiftComponent::waitConnected(int timeout) {
- Watchdog watchdog(timeout, networkFactories->getTimerFactory());
- while (!watchdog.getTimedOut() && !disconnectedError && !component->isAvailable()) {
- eventLoop->runUntilEvents();
- }
- if (watchdog.getTimedOut()) {
- component->disconnect();
- throw Lua::Exception("Timeout while connecting");
- }
- if (disconnectedError) {
- throw Lua::Exception(getErrorString(*disconnectedError));
- }
+ Watchdog watchdog(timeout, networkFactories->getTimerFactory());
+ while (!watchdog.getTimedOut() && !disconnectedError && !component->isAvailable()) {
+ eventLoop->runUntilEvents();
+ }
+ if (watchdog.getTimedOut()) {
+ component->disconnect();
+ throw Lua::Exception("Timeout while connecting");
+ }
+ if (disconnectedError) {
+ throw Lua::Exception(getErrorString(*disconnectedError));
+ }
}
bool SluiftComponent::isConnected() const {
- return component->isAvailable();
+ return component->isAvailable();
}
void SluiftComponent::disconnect() {
- component->disconnect();
- while (component->isAvailable()) {
- eventLoop->runUntilEvents();
- }
+ component->disconnect();
+ while (component->isAvailable()) {
+ eventLoop->runUntilEvents();
+ }
}
void SluiftComponent::setSoftwareVersion(const std::string& name, const std::string& version, const std::string& /* os */) {
- component->setSoftwareVersion(name, version);
+ component->setSoftwareVersion(name, version);
}
boost::optional<SluiftComponent::Event> SluiftComponent::getNextEvent(
- int timeout, boost::function<bool (const Event&)> condition) {
- Watchdog watchdog(timeout, networkFactories->getTimerFactory());
- size_t currentIndex = 0;
- while (true) {
- // Look for pending events in the queue
- while (currentIndex < pendingEvents.size()) {
- Event event = pendingEvents[currentIndex];
- if (!condition || condition(event)) {
- pendingEvents.erase(
- pendingEvents.begin()
- + boost::numeric_cast<int>(currentIndex));
- return event;
- }
- ++currentIndex;
- }
-
- // Wait for new events
- while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isAvailable()) {
- eventLoop->runUntilEvents();
- }
-
- // Finish if we're disconnected or timed out
- if (watchdog.getTimedOut() || !component->isAvailable()) {
- return boost::optional<Event>();
- }
- }
+ int timeout, boost::function<bool (const Event&)> condition) {
+ Watchdog watchdog(timeout, networkFactories->getTimerFactory());
+ size_t currentIndex = 0;
+ while (true) {
+ // Look for pending events in the queue
+ while (currentIndex < pendingEvents.size()) {
+ Event event = pendingEvents[currentIndex];
+ if (!condition || condition(event)) {
+ pendingEvents.erase(
+ pendingEvents.begin()
+ + boost::numeric_cast<int>(currentIndex));
+ return event;
+ }
+ ++currentIndex;
+ }
+
+ // Wait for new events
+ while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isAvailable()) {
+ eventLoop->runUntilEvents();
+ }
+
+ // Finish if we're disconnected or timed out
+ if (watchdog.getTimedOut() || !component->isAvailable()) {
+ return boost::optional<Event>();
+ }
+ }
}
void SluiftComponent::handleIncomingMessage(boost::shared_ptr<Message> stanza) {
- pendingEvents.push_back(Event(stanza));
+ pendingEvents.push_back(Event(stanza));
}
void SluiftComponent::handleIncomingPresence(boost::shared_ptr<Presence> stanza) {
- pendingEvents.push_back(Event(stanza));
+ pendingEvents.push_back(Event(stanza));
}
void SluiftComponent::handleRequestResponse(boost::shared_ptr<Payload> response, boost::shared_ptr<ErrorPayload> error) {
- requestResponse = response;
- requestError = error;
- requestResponseReceived = true;
+ requestResponse = response;
+ requestError = error;
+ requestResponseReceived = true;
}
void SluiftComponent::handleError(const boost::optional<ComponentError>& error) {
- disconnectedError = error;
+ disconnectedError = error;
}
Sluift::Response SluiftComponent::doSendRequest(boost::shared_ptr<Request> request, int timeout) {
- requestResponse.reset();
- requestError.reset();
- requestResponseReceived = false;
- request->send();
-
- Watchdog watchdog(timeout, networkFactories->getTimerFactory());
- while (!watchdog.getTimedOut() && !requestResponseReceived) {
- eventLoop->runUntilEvents();
- }
- return Sluift::Response(requestResponse, watchdog.getTimedOut() ?
- boost::make_shared<ErrorPayload>(ErrorPayload::RemoteServerTimeout) : requestError);
+ requestResponse.reset();
+ requestError.reset();
+ requestResponseReceived = false;
+ request->send();
+
+ Watchdog watchdog(timeout, networkFactories->getTimerFactory());
+ while (!watchdog.getTimedOut() && !requestResponseReceived) {
+ eventLoop->runUntilEvents();
+ }
+ return Sluift::Response(requestResponse, watchdog.getTimedOut() ?
+ boost::make_shared<ErrorPayload>(ErrorPayload::RemoteServerTimeout) : requestError);
}