1
|
|
|
<?php |
2
|
|
|
namespace Transmission\Model; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* @author Ramon Kleiss <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
class Peer extends AbstractModel |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
protected $address; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var integer |
16
|
|
|
*/ |
17
|
|
|
protected $port; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $clientName; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var boolean |
26
|
|
|
*/ |
27
|
|
|
protected $clientChoked; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var boolean |
31
|
|
|
*/ |
32
|
|
|
protected $clientInterested; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var boolean |
36
|
|
|
*/ |
37
|
|
|
protected $downloading; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var boolean |
41
|
|
|
*/ |
42
|
|
|
protected $encrypted; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var boolean |
46
|
|
|
*/ |
47
|
|
|
protected $incoming; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var boolean |
51
|
|
|
*/ |
52
|
|
|
protected $uploading; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var boolean |
56
|
|
|
*/ |
57
|
|
|
protected $utp; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var boolean |
61
|
|
|
*/ |
62
|
|
|
protected $peerChoked; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var boolean |
66
|
|
|
*/ |
67
|
|
|
protected $peerInterested; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var double |
71
|
|
|
*/ |
72
|
|
|
protected $progress; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var integer |
76
|
|
|
*/ |
77
|
|
|
protected $uploadRate; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var integer |
81
|
|
|
*/ |
82
|
|
|
protected $downloadRate; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $address |
86
|
|
|
*/ |
87
|
|
|
public function setAddress($address) |
88
|
|
|
{ |
89
|
|
|
$this->address = (string) $address; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getAddress() |
96
|
|
|
{ |
97
|
|
|
return $this->address; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param integer $port |
102
|
|
|
*/ |
103
|
|
|
public function setPort($port) |
104
|
|
|
{ |
105
|
|
|
$this->port = (integer) $port; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return integer |
110
|
|
|
*/ |
111
|
|
|
public function getPort() |
112
|
|
|
{ |
113
|
|
|
return $this->port; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $clientName |
118
|
|
|
*/ |
119
|
|
|
public function setClientName($clientName) |
120
|
|
|
{ |
121
|
|
|
$this->clientName = (string) $clientName; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getClientName() |
128
|
|
|
{ |
129
|
|
|
return $this->clientName; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param boolean $choked |
134
|
|
|
*/ |
135
|
|
|
public function setClientChoked($choked) |
136
|
|
|
{ |
137
|
|
|
$this->clientChoked = (boolean) $choked; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return boolean |
142
|
|
|
*/ |
143
|
|
|
public function isClientChoked() |
144
|
|
|
{ |
145
|
|
|
return $this->clientChoked; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param boolean $interested |
150
|
|
|
*/ |
151
|
|
|
public function setClientInterested($interested) |
152
|
|
|
{ |
153
|
|
|
$this->clientInterested = (boolean) $interested; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return boolean |
158
|
|
|
*/ |
159
|
|
|
public function isClientInterested() |
160
|
|
|
{ |
161
|
|
|
return $this->clientInterested; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param boolean $downloading |
166
|
|
|
*/ |
167
|
|
|
public function setDownloading($downloading) |
168
|
|
|
{ |
169
|
|
|
$this->downloading = (boolean) $downloading; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return boolean |
174
|
|
|
*/ |
175
|
|
|
public function isDownloading() |
176
|
|
|
{ |
177
|
|
|
return $this->downloading; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param boolean $encrypted |
182
|
|
|
*/ |
183
|
|
|
public function setEncrypted($encrypted) |
184
|
|
|
{ |
185
|
|
|
$this->encrypted = (boolean) $encrypted; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return boolean |
190
|
|
|
*/ |
191
|
|
|
public function isEncrypted() |
192
|
|
|
{ |
193
|
|
|
return $this->encrypted; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param boolean $incoming |
198
|
|
|
*/ |
199
|
|
|
public function setIncoming($incoming) |
200
|
|
|
{ |
201
|
|
|
$this->incoming = (boolean) $incoming; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return boolean |
206
|
|
|
*/ |
207
|
|
|
public function isIncoming() |
208
|
|
|
{ |
209
|
|
|
return $this->incoming; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param boolean $uploading |
214
|
|
|
*/ |
215
|
|
|
public function setUploading($uploading) |
216
|
|
|
{ |
217
|
|
|
$this->uploading = (boolean) $uploading; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return boolean |
222
|
|
|
*/ |
223
|
|
|
public function isUploading() |
224
|
|
|
{ |
225
|
|
|
return $this->uploading; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param boolean $utp |
230
|
|
|
*/ |
231
|
|
|
public function setUtp($utp) |
232
|
|
|
{ |
233
|
|
|
$this->utp = (boolean) $utp; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return boolean |
238
|
|
|
*/ |
239
|
|
|
public function isUtp() |
240
|
|
|
{ |
241
|
|
|
return $this->utp; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param boolean $choked |
246
|
|
|
*/ |
247
|
|
|
public function setPeerChoked($choked) |
248
|
|
|
{ |
249
|
|
|
$this->peerChoked = (boolean) $choked; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return boolean |
254
|
|
|
*/ |
255
|
|
|
public function isPeerChoked() |
256
|
|
|
{ |
257
|
|
|
return $this->peerChoked; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @param boolean $interested |
262
|
|
|
*/ |
263
|
|
|
public function setPeerInterested($interested) |
264
|
|
|
{ |
265
|
|
|
$this->peerInterested = (boolean) $interested; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return boolean |
270
|
|
|
*/ |
271
|
|
|
public function isPeerInterested() |
272
|
|
|
{ |
273
|
|
|
return $this->peerInterested; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param double $progress |
278
|
|
|
*/ |
279
|
|
|
public function setProgress($progress) |
280
|
|
|
{ |
281
|
|
|
$this->progress = (double) $progress; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @return double |
286
|
|
|
*/ |
287
|
|
|
public function getProgress() |
288
|
|
|
{ |
289
|
|
|
return $this->progress; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @param integer $rate |
294
|
|
|
*/ |
295
|
|
|
public function setUploadRate($rate) |
296
|
|
|
{ |
297
|
|
|
$this->uploadRate = (integer) $rate; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @return integer |
302
|
|
|
*/ |
303
|
|
|
public function getUploadRate() |
304
|
|
|
{ |
305
|
|
|
return $this->uploadRate; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* @param integer $rate |
310
|
|
|
*/ |
311
|
|
|
public function setDownloadRate($rate) |
312
|
|
|
{ |
313
|
|
|
$this->downloadRate = (integer) $rate; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @return integer |
318
|
|
|
*/ |
319
|
|
|
public function getDownloadRate() |
320
|
|
|
{ |
321
|
|
|
return $this->downloadRate; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* {@inheritDoc} |
326
|
|
|
*/ |
327
|
|
|
public static function getMapping() |
328
|
|
|
{ |
329
|
|
|
return array( |
330
|
|
|
'address' => 'address', |
331
|
|
|
'port' => 'port', |
332
|
|
|
'clientName' => 'clientName', |
333
|
|
|
'clientIsChoked' => 'clientChoked', |
334
|
|
|
'clientIsInterested' => 'clientInterested', |
335
|
|
|
'isDownloadingFrom' => 'downloading', |
336
|
|
|
'isEncrypted' => 'encrypted', |
337
|
|
|
'isIncoming' => 'incoming', |
338
|
|
|
'isUploadingTo' => 'uploading', |
339
|
|
|
'isUTP' => 'utp', |
340
|
|
|
'peerIsChoked' => 'peerChoked', |
341
|
|
|
'peerIsInterested' => 'peerInterested', |
342
|
|
|
'progress' => 'progress', |
343
|
|
|
'rateToClient' => 'uploadRate', |
344
|
|
|
'rateFromClient' => 'downloadRate' |
345
|
|
|
); |
346
|
|
|
} |
347
|
|
|
} |
348
|
|
|
|