summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index 9b2105b..df3cea4 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.cpp
@@ -47,71 +47,71 @@ class FileSender {
client = new Swift::Client(jid, password, &networkFactories);
client->onConnected.connect(boost::bind(&FileSender::handleConnected, this));
client->onDisconnected.connect(boost::bind(&FileSender::handleDisconnected, this, _1));
tracer = new ClientXMLTracer(client);
client->getEntityCapsProvider()->onCapsChanged.connect(boost::bind(&FileSender::handleCapsChanged, this, _1));
}
~FileSender() {
delete tracer;
client->onDisconnected.disconnect(boost::bind(&FileSender::handleDisconnected, this, _1));
client->onConnected.disconnect(boost::bind(&FileSender::handleConnected, this));
delete client;
}
void start() {
client->connect();
}
private:
void handleConnected() {
client->sendPresence(Presence::create());
client->getFileTransferManager()->startListeningOnPort(19999);
//ByteArray fileData;
//readByteArrayFromFile(fileData, file.string());
// gather file information
/*StreamInitiationFileInfo fileInfo;
fileInfo.setName(file.filename());
fileInfo.setSize(boost::filesystem::file_size(file));
fileInfo.setDescription("Some file!");
fileInfo.setDate(boost::posix_time::from_time_t(boost::filesystem::last_write_time(file)));*/
//fileInfo.setHash(Hexify::hexify(MD5::getHash(fileData)));
/*
- transfer = new OutgoingSIFileTransfer("myid", client->getJID(), recipient, file.filename(), boost::filesystem::file_size(file), "A file", boost::shared_ptr<FileReadBytestream>(new FileReadBytestream(file)), client->getIQRouter(), socksBytestreamServer);
+ transfer = new OutgoingSIFileTransfer("myid", client->getJID(), recipient, file.filename(), boost::filesystem::file_size(file), "A file", boost::make_shared<FileReadBytestream>(file)), client->getIQRouter(), socksBytestreamServer);
transfer->onFinished.connect(boost::bind(&FileSender::handleFileTransferFinished, this, _1));
transfer->start();
*/
}
void handleCapsChanged(JID jid) {
if (jid.toBare() == recipient) {
// create ReadBytestream from file
boost::shared_ptr<FileReadBytestream> fileStream = boost::make_shared<FileReadBytestream>(file);
outgoingFileTransfer = client->getFileTransferManager()->createOutgoingFileTransfer(recipient, file, "Some File!", fileStream);
if (outgoingFileTransfer) {
std::cout << "started FT" << std::endl;
outgoingFileTransfer->start();
// TODO: getting notified about FT status and end
} else {
std::cout << "[ ERROR ] " << recipient << " doesn't support any kind of file transfer!" << std::endl;
//client->disconnect();
}
}
}
void handleDisconnected(const boost::optional<ClientError>&) {
std::cerr << "Error!" << std::endl;
exit(-1);
}
void handleFileTransferFinished(const boost::optional<FileTransferError>& error) {
std::cout << "File transfer finished" << std::endl;
if (error) {
exit(-1);
}
else {
exit(0);