blob: a25abee1b8a375747bd7fc0eff79ecc54e3dfc26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <string>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include <Swiften/FileTransfer/FileReadBytestream.h>
#include <Swiften/FileTransfer/FileTransfer.h>
#include <Swiften/FileTransfer/FileWriteBytestream.h>
#include <Swiften/FileTransfer/IncomingFileTransfer.h>
#include <Swiften/JID/JID.h>
#include <Swift/Controllers/FileTransfer/FileTransferProgressInfo.h>
namespace Swift {
class FileTransferManager;
class ChatWindow;
class FileTransferController {
public:
/**
* For outgoing file transfers. It'll create a file transfer via FileTransferManager as soon as the descriptive information is available.
*/
FileTransferController(const JID&, const std::string&, FileTransferManager*);
/**
* For incoming file transfers.
*/
FileTransferController(IncomingFileTransfer::ref transfer);
~FileTransferController();
std::string setChatWindow(ChatWindow*, std::string nickname);
void setReceipient(const JID& otherParty);
void start(std::string& description);
void accept(std::string& file);
void cancel();
const JID &getOtherParty() const;
bool isIncoming() const;
FileTransfer::State getState() const;
int getProgress() const;
boost::uintmax_t getSize() const;
boost::signal<void ()> onStateChanged;
boost::signal<void ()> onProgressChange;
private:
void handleFileTransferStateChange(FileTransfer::State);
void handleProgressPercentageChange(int percentage);
private:
bool sending;
JID otherParty;
std::string filename;
FileTransfer::ref transfer;
boost::shared_ptr<FileReadBytestream> fileReadStream;
boost::shared_ptr<FileWriteBytestream> fileWriteStream;
FileTransferManager* ftManager;
FileTransferProgressInfo* ftProgressInfo;
ChatWindow* chatWindow;
std::string uiID;
FileTransfer::State currentState;
};
}
|