diff options
Diffstat (limited to 'Sluift/SluiftClient.cpp')
-rw-r--r-- | Sluift/SluiftClient.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp index 257eec1..8c0213e 100644 --- a/Sluift/SluiftClient.cpp +++ b/Sluift/SluiftClient.cpp @@ -24,9 +24,7 @@ SluiftClient::SluiftClient( const std::string& password, NetworkFactories* networkFactories, - SimpleEventLoop* eventLoop, - SluiftGlobals* globals) : + SimpleEventLoop* eventLoop) : networkFactories(networkFactories), eventLoop(eventLoop), - globals(globals), tracer(NULL) { client = new Client(jid, password, networkFactories); @@ -47,7 +45,4 @@ void SluiftClient::connect() { rosterReceived = false; disconnectedError = boost::optional<ClientError>(); - if (globals->debug) { - tracer = new ClientXMLTracer(client, options.boshURL.isEmpty()? false: true); - } client->connect(options); } @@ -58,12 +53,19 @@ void SluiftClient::connect(const std::string& host, int port) { options.manualPort = port; disconnectedError = boost::optional<ClientError>(); - if (globals->debug) { + client->connect(options); +} + +void SluiftClient::setTraceEnabled(bool b) { + if (b && !tracer) { tracer = new ClientXMLTracer(client, options.boshURL.isEmpty()? false: true); } - client->connect(options); + else if (!b && tracer) { + delete tracer; + tracer = NULL; + } } -void SluiftClient::waitConnected() { - Watchdog watchdog(globals->timeout, networkFactories->getTimerFactory()); +void SluiftClient::waitConnected(int timeout) { + Watchdog watchdog(timeout, networkFactories->getTimerFactory()); while (!watchdog.getTimedOut() && client->isActive() && !client->isAvailable()) { eventLoop->runUntilEvents(); |