summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/SluiftComponent.h')
-rw-r--r--Sluift/SluiftComponent.h158
1 files changed, 79 insertions, 79 deletions
diff --git a/Sluift/SluiftComponent.h b/Sluift/SluiftComponent.h
index 7a8254c..fd1b97a 100644
--- a/Sluift/SluiftComponent.h
+++ b/Sluift/SluiftComponent.h
@@ -27,83 +27,83 @@
#include <Sluift/Watchdog.h>
namespace Swift {
- struct SluiftGlobals;
- class ComponentXMLTracer;
- class Component;
- class Stanza;
- class Payload;
- class ErrorPayload;
- class JID;
-
- class SluiftComponent {
- public:
- struct Event {
- enum Type {
- MessageType,
- PresenceType
- };
-
- Event(boost::shared_ptr<Message> stanza) : type(MessageType), stanza(stanza) {}
- Event(boost::shared_ptr<Presence> stanza) : type(PresenceType), stanza(stanza) {}
-
- Type type;
-
- // Message & Presence
- boost::shared_ptr<Stanza> stanza;
- };
-
- SluiftComponent(
- const JID& jid,
- const std::string& password,
- NetworkFactories* networkFactories,
- SimpleEventLoop* eventLoop);
- ~SluiftComponent();
-
- Component* getComponent() {
- return component;
- }
-
- void connect(const std::string& host, int port);
- void waitConnected(int timeout);
- bool isConnected() const;
- void setTraceEnabled(bool b);
-
- template<typename REQUEST_TYPE>
- Sluift::Response sendRequest(REQUEST_TYPE request, int timeout) {
- boost::signals::scoped_connection c = request->onResponse.connect(
- boost::bind(&SluiftComponent::handleRequestResponse, this, _1, _2));
- return doSendRequest(request, timeout);
- }
-
- template<typename REQUEST_TYPE>
- Sluift::Response sendVoidRequest(REQUEST_TYPE request, int timeout) {
- boost::signals::scoped_connection c = request->onResponse.connect(
- boost::bind(&SluiftComponent::handleRequestResponse, this, boost::shared_ptr<Payload>(), _1));
- return doSendRequest(request, timeout);
- }
-
- void disconnect();
- void setSoftwareVersion(const std::string& name, const std::string& version, const std::string& os);
- boost::optional<SluiftComponent::Event> getNextEvent(int timeout,
- boost::function<bool (const Event&)> condition = 0);
-
- private:
- Sluift::Response doSendRequest(boost::shared_ptr<Request> request, int timeout);
-
- void handleIncomingMessage(boost::shared_ptr<Message> stanza);
- void handleIncomingPresence(boost::shared_ptr<Presence> stanza);
- void handleRequestResponse(boost::shared_ptr<Payload> response, boost::shared_ptr<ErrorPayload> error);
- void handleError(const boost::optional<ComponentError>& error);
-
- private:
- NetworkFactories* networkFactories;
- SimpleEventLoop* eventLoop;
- Component* component;
- ComponentXMLTracer* tracer;
- std::deque<Event> pendingEvents;
- boost::optional<ComponentError> disconnectedError;
- bool requestResponseReceived;
- boost::shared_ptr<Payload> requestResponse;
- boost::shared_ptr<ErrorPayload> requestError;
- };
+ struct SluiftGlobals;
+ class ComponentXMLTracer;
+ class Component;
+ class Stanza;
+ class Payload;
+ class ErrorPayload;
+ class JID;
+
+ class SluiftComponent {
+ public:
+ struct Event {
+ enum Type {
+ MessageType,
+ PresenceType
+ };
+
+ Event(boost::shared_ptr<Message> stanza) : type(MessageType), stanza(stanza) {}
+ Event(boost::shared_ptr<Presence> stanza) : type(PresenceType), stanza(stanza) {}
+
+ Type type;
+
+ // Message & Presence
+ boost::shared_ptr<Stanza> stanza;
+ };
+
+ SluiftComponent(
+ const JID& jid,
+ const std::string& password,
+ NetworkFactories* networkFactories,
+ SimpleEventLoop* eventLoop);
+ ~SluiftComponent();
+
+ Component* getComponent() {
+ return component;
+ }
+
+ void connect(const std::string& host, int port);
+ void waitConnected(int timeout);
+ bool isConnected() const;
+ void setTraceEnabled(bool b);
+
+ template<typename REQUEST_TYPE>
+ Sluift::Response sendRequest(REQUEST_TYPE request, int timeout) {
+ boost::signals::scoped_connection c = request->onResponse.connect(
+ boost::bind(&SluiftComponent::handleRequestResponse, this, _1, _2));
+ return doSendRequest(request, timeout);
+ }
+
+ template<typename REQUEST_TYPE>
+ Sluift::Response sendVoidRequest(REQUEST_TYPE request, int timeout) {
+ boost::signals::scoped_connection c = request->onResponse.connect(
+ boost::bind(&SluiftComponent::handleRequestResponse, this, boost::shared_ptr<Payload>(), _1));
+ return doSendRequest(request, timeout);
+ }
+
+ void disconnect();
+ void setSoftwareVersion(const std::string& name, const std::string& version, const std::string& os);
+ boost::optional<SluiftComponent::Event> getNextEvent(int timeout,
+ boost::function<bool (const Event&)> condition = 0);
+
+ private:
+ Sluift::Response doSendRequest(boost::shared_ptr<Request> request, int timeout);
+
+ void handleIncomingMessage(boost::shared_ptr<Message> stanza);
+ void handleIncomingPresence(boost::shared_ptr<Presence> stanza);
+ void handleRequestResponse(boost::shared_ptr<Payload> response, boost::shared_ptr<ErrorPayload> error);
+ void handleError(const boost::optional<ComponentError>& error);
+
+ private:
+ NetworkFactories* networkFactories;
+ SimpleEventLoop* eventLoop;
+ Component* component;
+ ComponentXMLTracer* tracer;
+ std::deque<Event> pendingEvents;
+ boost::optional<ComponentError> disconnectedError;
+ bool requestResponseReceived;
+ boost::shared_ptr<Payload> requestResponse;
+ boost::shared_ptr<ErrorPayload> requestError;
+ };
}