summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-05 12:44:38 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-05 12:45:53 (GMT)
commit5b974445a8ce78ca73bdfae9a8114857e4fc3d36 (patch)
treeb4743fc1f2c34472ab56e1a7b58d1e81666dbce2 /Swiften/Examples
parentc9ab4b6c41eef3ccfe6627f62e7bc085c6743a41 (diff)
downloadswift-5b974445a8ce78ca73bdfae9a8114857e4fc3d36.zip
swift-5b974445a8ce78ca73bdfae9a8114857e4fc3d36.tar.bz2
Added EchoBot.
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/EchoBot/EchoBot.cpp17
-rw-r--r--Swiften/Examples/EchoBot/SConscript13
-rw-r--r--Swiften/Examples/SConscript1
3 files changed, 23 insertions, 8 deletions
diff --git a/Swiften/Examples/EchoBot/EchoBot.cpp b/Swiften/Examples/EchoBot/EchoBot.cpp
index 9d11c61..1c576c9 100644
--- a/Swiften/Examples/EchoBot/EchoBot.cpp
+++ b/Swiften/Examples/EchoBot/EchoBot.cpp
@@ -5,9 +5,9 @@
*/
#include <boost/bind.hpp>
+#include <iostream>
#include "Swiften/Client/Client.h"
-#include "Swiften/Client/ClientXMLTracer.h"
#include "Swiften/EventLoop/SimpleEventLoop.h"
#include "Swiften/Queries/Requests/GetRosterRequest.h"
@@ -16,16 +16,14 @@ using namespace boost;
class EchoBot {
public:
- EchoBot(const JID& jid, const String& pass) : tracer(0) {
+ EchoBot(const JID& jid, const String& pass) {
client = new Client(jid, pass);
- tracer = new ClientXMLTracer(client);
client->onConnected.connect(bind(&EchoBot::handleConnected, this));
client->onMessageReceived.connect(bind(&EchoBot::handleMessageReceived, this, _1));
client->connect();
}
~EchoBot() {
- delete tracer;
delete client;
}
@@ -36,7 +34,7 @@ class EchoBot {
rosterRequest->send();
}
- void handleRosterReceived(const optional<Error>& error) {
+ void handleRosterReceived(const optional<ErrorPayload>& error) {
if (error) {
std::cerr << "Error receiving roster. Continuing anyway.";
}
@@ -51,12 +49,15 @@ class EchoBot {
private:
Client* client;
- ClientXMLTracer* tracer;
};
-int main(int, char**) {
+int main(int argc, char* argv[]) {
+ if (argc != 3) {
+ std::cerr << "Usage: " << argv[0] << " <jid> <pass>" << std::endl;
+ return -1;
+ }
SimpleEventLoop eventLoop;
- EchoBot bot(JID("echobot@wonderland.lit"), "mypass");
+ EchoBot bot(JID(argv[1]), argv[2]);
eventLoop.run();
return 0;
}
diff --git a/Swiften/Examples/EchoBot/SConscript b/Swiften/Examples/EchoBot/SConscript
new file mode 100644
index 0000000..711d8ea
--- /dev/null
+++ b/Swiften/Examples/EchoBot/SConscript
@@ -0,0 +1,13 @@
+Import("env")
+
+myenv = env.Clone()
+myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
+myenv.MergeFlags(myenv["LIBIDN_FLAGS"])
+myenv.MergeFlags(myenv["BOOST_FLAGS"])
+myenv.MergeFlags(myenv.get("SQLITE_FLAGS", {}))
+myenv.MergeFlags(myenv["ZLIB_FLAGS"])
+myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
+myenv.MergeFlags(myenv.get("LIBXML_FLAGS", ""))
+myenv.MergeFlags(myenv.get("EXPAT_FLAGS", ""))
+myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
+tester = myenv.Program("EchoBot", ["EchoBot.cpp"])
diff --git a/Swiften/Examples/SConscript b/Swiften/Examples/SConscript
index 1a06df2..1c95e85 100644
--- a/Swiften/Examples/SConscript
+++ b/Swiften/Examples/SConscript
@@ -6,4 +6,5 @@ SConscript(dirs = [
"SendMessage",
"ConnectivityTest",
"LinkLocalTool",
+ "EchoBot",
])