X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Ftransfer.h;h=ce24b8b7589cd43d7306da278c03815457071fae;hp=88cf6f1c2aaa41e61ee6595c81b08348983f3694;hb=e3c42d072b2b8f39c8c9ea44dfc3bded87ae43b0;hpb=100a2678adf2016b7b4753d09d868929de83294e diff --git a/src/common/transfer.h b/src/common/transfer.h index 88cf6f1c..ce24b8b7 100644 --- a/src/common/transfer.h +++ b/src/common/transfer.h @@ -25,6 +25,7 @@ #include #include "syncableobject.h" +#include "types.h" class Transfer : public SyncableObject { @@ -38,11 +39,13 @@ class Transfer : public SyncableObject Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged); Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged); Q_PROPERTY(quint64 fileSize READ fileSize WRITE setFileSize NOTIFY fileSizeChanged); + Q_PROPERTY(QString nick READ nick WRITE setNick NOTIFY nickChanged); public: enum State { New, Pending, + Connecting, Transferring, Paused, Completed, @@ -58,7 +61,8 @@ public: Q_ENUMS(Direction) Transfer(const QUuid &uuid, QObject *parent = 0); // for creating a syncable object client-side - Transfer(Direction direction, const QString &fileName, const QHostAddress &address, quint16 port, quint64 size = 0, QObject *parent = 0); + Transfer(Direction direction, const QString &nick, const QString &fileName, const QHostAddress &address, quint16 port, quint64 size = 0, QObject *parent = 0); + inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; } QUuid uuid() const; State state() const; @@ -67,6 +71,16 @@ public: QHostAddress address() const; quint16 port() const; quint64 fileSize() const; + QString nick() const; + +public slots: + // called on the client side + virtual void accept(const QString &savePath) const { Q_UNUSED(savePath); } + virtual void reject() const {} + + // called on the core side through sync calls + virtual void requestAccepted(PeerPtr peer) { Q_UNUSED(peer); } + virtual void requestRejected(PeerPtr peer) { Q_UNUSED(peer); } signals: void stateChanged(State state); @@ -75,16 +89,31 @@ signals: void portChanged(quint16 port); void fileNameChanged(const QString &fileName); void fileSizeChanged(quint64 fileSize); + void nickChanged(const QString &nick); + + void error(const QString &errorString); + + void accepted(PeerPtr peer = 0) const; + void rejected(PeerPtr peer = 0) const; -protected: +protected slots: void setState(State state); + void setError(const QString &errorString); + + // called on the client side through sync calls + virtual void dataReceived(PeerPtr, const QByteArray &data) { Q_UNUSED(data); } + + virtual void cleanUp() = 0; private: + void init(); + void setDirection(Direction direction); void setAddress(const QHostAddress &address); void setPort(quint16 port); void setFileName(const QString &fileName); void setFileSize(quint64 fileSize); + void setNick(const QString &nick); State _state; @@ -93,6 +122,7 @@ private: QHostAddress _address; quint16 _port; quint64 _fileSize; + QString _nick; QUuid _uuid; };