Files
@ 2836f390b953
Branch filter:
Location: libtransport.git/tests/login_bad_name/main.cpp - annotation
2836f390b953
1.1 KiB
text/x-c++hdr
Receive VCard from PurpleAccount and fixed crash on disconnect
2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 33587d6fc128 33587d6fc128 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 2a40419b2bc4 | #include <iostream>
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
#include <Swiften/Client/ClientOptions.h>
using namespace Swift;
using namespace boost;
Client* client;
static void handleDisconnected(const boost::optional<ClientError> &error) {
exit(error->getType() != ClientError::AuthenticationFailedError);
}
static void handleConnected() {
exit(1);
}
static void handleMessageReceived(Message::ref message) {
// Echo back the incoming message
message->setTo(message->getFrom());
message->setFrom(JID());
client->sendMessage(message);
}
int main(int, char **argv) {
SimpleEventLoop eventLoop;
BoostNetworkFactories networkFactories(&eventLoop);
JID jid(JID(argv[1]).getNode() + "something", JID(argv[1]).getDomain());
client = new Client(jid, argv[2], &networkFactories);
client->setAlwaysTrustCertificates();
client->onConnected.connect(&handleConnected);
client->onDisconnected.connect(bind(&handleDisconnected, _1));
client->onMessageReceived.connect(bind(&handleMessageReceived, _1));
Swift::ClientOptions opt;
opt.allowPLAINWithoutTLS = true;
client->connect(opt);
eventLoop.run();
delete client;
return 0;
}
|