Transfer needs a nick attribute
[quassel.git] / src / common / transfer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2013 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #ifndef TRANSFER_H
22 #define TRANSFER_H
23
24 #include <QHostAddress>
25 #include <QUuid>
26
27 #include "syncableobject.h"
28
29 class Transfer : public SyncableObject
30 {
31     Q_OBJECT
32     SYNCABLE_OBJECT
33
34     Q_PROPERTY(QUuid uuid READ uuid);
35     Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged);
36     Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged);
37     Q_PROPERTY(QHostAddress address READ address WRITE setAddress NOTIFY addressChanged);
38     Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged);
39     Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged);
40     Q_PROPERTY(quint64 fileSize READ fileSize WRITE setFileSize NOTIFY fileSizeChanged);
41     Q_PROPERTY(QString nick READ nick WRITE setNick NOTIFY nickChanged);
42
43 public:
44     enum State {
45         New,
46         Pending,
47         Transferring,
48         Paused,
49         Completed,
50         Failed,
51         Rejected
52     };
53     Q_ENUMS(State)
54
55     enum Direction {
56         Send,
57         Receive
58     };
59     Q_ENUMS(Direction)
60
61     Transfer(const QUuid &uuid, QObject *parent = 0); // for creating a syncable object client-side
62     Transfer(Direction direction, const QString &nick, const QString &fileName, const QHostAddress &address, quint16 port, quint64 size = 0, QObject *parent = 0);
63
64     QUuid uuid() const;
65     State state() const;
66     Direction direction() const;
67     QString fileName() const;
68     QHostAddress address() const;
69     quint16 port() const;
70     quint64 fileSize() const;
71     QString nick() const;
72
73 signals:
74     void stateChanged(State state);
75     void directionChanged(Direction direction);
76     void addressChanged(const QHostAddress &address);
77     void portChanged(quint16 port);
78     void fileNameChanged(const QString &fileName);
79     void fileSizeChanged(quint64 fileSize);
80     void nickChanged(const QString &nick);
81
82 protected:
83     void setState(State state);
84
85 private:
86     void setDirection(Direction direction);
87     void setAddress(const QHostAddress &address);
88     void setPort(quint16 port);
89     void setFileName(const QString &fileName);
90     void setFileSize(quint64 fileSize);
91     void setNick(const QString &nick);
92
93
94     State _state;
95     Direction _direction;
96     QString _fileName;
97     QHostAddress _address;
98     quint16 _port;
99     quint64 _fileSize;
100     QString _nick;
101     QUuid _uuid;
102 };
103
104 #endif