Transfer needs a nick attribute
[quassel.git] / src / common / transfer.cpp
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 #include "transfer.h"
22
23 INIT_SYNCABLE_OBJECT(Transfer)
24 Transfer::Transfer(const QUuid &uuid, QObject *parent)
25     : SyncableObject(parent),
26     _state(New),
27     _direction(Receive),
28     _port(0),
29     _fileSize(0),
30     _uuid(uuid)
31 {
32     renameObject(QString("Transfer/%1").arg(_uuid.toString()));
33 }
34
35 Transfer::Transfer(Direction direction, const QString &nick, const QString &fileName, const QHostAddress &address, quint16 port, quint64 fileSize, QObject *parent)
36     : SyncableObject(parent),
37     _state(New),
38     _direction(direction),
39     _fileName(fileName),
40     _address(address),
41     _port(port),
42     _fileSize(fileSize),
43     _nick(nick),
44     _uuid(QUuid::createUuid())
45 {
46     renameObject(QString("Transfer/%1").arg(_uuid.toString()));
47 }
48
49
50 QUuid Transfer::uuid() const
51 {
52     return _uuid;
53 }
54
55
56 Transfer::State Transfer::state() const
57 {
58     return _state;
59 }
60
61
62 void Transfer::setState(Transfer::State state)
63 {
64     if (_state != state) {
65         _state = state;
66         SYNC(ARG(state));
67         emit stateChanged(state);
68     }
69 }
70
71
72
73 Transfer::Direction Transfer::direction() const
74 {
75     return _direction;
76 }
77
78
79 void Transfer::setDirection(Transfer::Direction direction)
80 {
81     if (_direction != direction) {
82         _direction = direction;
83         SYNC(ARG(direction));
84         emit directionChanged(direction);
85     }
86 }
87
88
89 QHostAddress Transfer::address() const
90 {
91     return _address;
92 }
93
94
95 void Transfer::setAddress(const QHostAddress &address)
96 {
97     if (_address != address) {
98         _address = address;
99         SYNC(ARG(address));
100         emit addressChanged(address);
101     }
102 }
103
104
105 quint16 Transfer::port() const
106 {
107     return _port;
108 }
109
110
111 void Transfer::setPort(quint16 port)
112 {
113     if (_port != port) {
114         _port = port;
115         SYNC(ARG(port));
116         emit portChanged(port);
117     }
118 }
119
120
121 QString Transfer::fileName() const
122 {
123     return _fileName;
124 }
125
126
127 void Transfer::setFileName(const QString &fileName)
128 {
129     if (_fileName != fileName) {
130         _fileName = fileName;
131         SYNC(ARG(fileName));
132         emit fileNameChanged(fileName);
133     }
134 }
135
136
137 quint64 Transfer::fileSize() const
138 {
139     return _fileSize;
140 }
141
142
143 void Transfer::setFileSize(quint64 fileSize)
144 {
145     if (_fileSize != fileSize) {
146         _fileSize = fileSize;
147         SYNC(ARG(fileSize));
148         emit fileSizeChanged(fileSize);
149     }
150 }
151
152
153 QString Transfer::nick() const
154 {
155     return _nick;
156 }
157
158
159 void Transfer::setNick(const QString &nick)
160 {
161     if (_nick != nick) {
162         _nick = nick;
163         SYNC(ARG(nick));
164         emit nickChanged(nick);
165     }
166 }