|
1
|
|
|
<?php |
|
2
|
|
|
namespace Transmission\Model; |
|
3
|
|
|
|
|
4
|
|
|
use Transmission\Util\ResponseValidator; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @author Joysen Chellem |
|
8
|
|
|
* @author Ramon Kleiss <[email protected]> |
|
9
|
|
|
*/ |
|
10
|
|
|
class Session extends AbstractModel |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var integer |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $altSpeedDown; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var boolean |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $altSpeedEnabled; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $downloadDir; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var boolean |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $downloadQueueEnabled; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var integer |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $downloadQueueSize; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $incompleteDir; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var boolean |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $incompleteDirEnabled; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $torrentDoneScript; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var boolean |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $torrentDoneScriptEnabled; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var double |
|
59
|
|
|
*/ |
|
60
|
|
|
protected $seedRatioLimit; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @var boolean |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $seedRatioLimited; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @var integer |
|
69
|
|
|
*/ |
|
70
|
|
|
protected $seedQueueSize; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var boolean |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $seedQueueEnabled; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var integer |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $downloadSpeedLimit; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @var boolean |
|
84
|
|
|
*/ |
|
85
|
|
|
protected $downloadSpeedLimitEnabled; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @var integer |
|
89
|
|
|
*/ |
|
90
|
|
|
protected $uploadSpeedLimit; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @var boolean |
|
94
|
|
|
*/ |
|
95
|
|
|
protected $uploadSpeedLimitEnabled; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param integer $speed |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setAltSpeedDown($speed) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->altSpeedDown = (integer) $speed; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return integer |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getAltSpeedDown() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->altSpeedDown; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param boolean $enabled |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setAltSpeedEnabled($enabled) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->altSpeedEnabled = (boolean) $enabled; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return boolean |
|
123
|
|
|
*/ |
|
124
|
|
|
public function isAltSpeedEnabled() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->altSpeedEnabled; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @param string $downloadDir |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setDownloadDir($downloadDir) |
|
133
|
|
|
{ |
|
134
|
|
|
$this->downloadDir = (string) $downloadDir; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return string |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getDownloadDir() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->downloadDir; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @param boolean $enabled |
|
147
|
|
|
*/ |
|
148
|
|
|
public function setDownloadQueueEnabled($enabled) |
|
149
|
|
|
{ |
|
150
|
|
|
$this->downloadQueueEnabled = (boolean) $enabled; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @return boolean |
|
155
|
|
|
*/ |
|
156
|
|
|
public function isDownloadQueueEnabled() |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->downloadQueueEnabled; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @param integer $size |
|
163
|
|
|
*/ |
|
164
|
|
|
public function setDownloadQueueSize($size) |
|
165
|
|
|
{ |
|
166
|
|
|
$this->downloadQueueSize = (integer) $size; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @return integer |
|
171
|
|
|
*/ |
|
172
|
|
|
public function getDownloadQueueSize() |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->downloadQueueSize; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @param string $directory |
|
179
|
|
|
*/ |
|
180
|
|
|
public function setIncompleteDir($directory) |
|
181
|
|
|
{ |
|
182
|
|
|
$this->incompleteDir = (string) $directory; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getIncompleteDir() |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->incompleteDir; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @param boolean $enabled |
|
195
|
|
|
*/ |
|
196
|
|
|
public function setIncompleteDirEnabled($enabled) |
|
197
|
|
|
{ |
|
198
|
|
|
$this->incompleteDirEnabled = (boolean) $enabled; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @return boolean |
|
203
|
|
|
*/ |
|
204
|
|
|
public function isIncompleteDirEnabled() |
|
205
|
|
|
{ |
|
206
|
|
|
return $this->incompleteDirEnabled; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @param string $filename |
|
211
|
|
|
*/ |
|
212
|
|
|
public function setTorrentDoneScript($filename) |
|
213
|
|
|
{ |
|
214
|
|
|
$this->torrentDoneScript = (string) $filename; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @return string |
|
219
|
|
|
*/ |
|
220
|
|
|
public function getTorrentDoneScript() |
|
221
|
|
|
{ |
|
222
|
|
|
return $this->torrentDoneScript; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @param boolean $enabled |
|
227
|
|
|
*/ |
|
228
|
|
|
public function setTorrentDoneScriptEnabled($enabled) |
|
229
|
|
|
{ |
|
230
|
|
|
$this->torrentDoneScriptEnabled = (boolean) $enabled; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @return boolean |
|
235
|
|
|
*/ |
|
236
|
|
|
public function isTorrentDoneScriptEnabled() |
|
237
|
|
|
{ |
|
238
|
|
|
return $this->torrentDoneScriptEnabled; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @param double $limit |
|
243
|
|
|
*/ |
|
244
|
|
|
public function setSeedRatioLimit($limit) |
|
245
|
|
|
{ |
|
246
|
|
|
$this->seedRatioLimit = (double) $limit; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @return double |
|
251
|
|
|
*/ |
|
252
|
|
|
public function getSeedRatioLimit() |
|
253
|
|
|
{ |
|
254
|
|
|
return $this->seedRatioLimit; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* @param boolean $limited |
|
259
|
|
|
*/ |
|
260
|
|
|
public function setSeedRatioLimited($limited) |
|
261
|
|
|
{ |
|
262
|
|
|
$this->seedRatioLimited = (boolean) $limited; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* @return boolean |
|
267
|
|
|
*/ |
|
268
|
|
|
public function isSeedRatioLimited() |
|
269
|
|
|
{ |
|
270
|
|
|
return $this->seedRatioLimited; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @param integer $size |
|
275
|
|
|
*/ |
|
276
|
|
|
public function setSeedQueueSize($size) |
|
277
|
|
|
{ |
|
278
|
|
|
$this->seedQueueSize = (integer) $size; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* @return integer |
|
283
|
|
|
*/ |
|
284
|
|
|
public function getSeedQueueSize() |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->seedQueueSize; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @param boolean $enabled |
|
291
|
|
|
*/ |
|
292
|
|
|
public function setSeedQueueEnabled($enabled) |
|
293
|
|
|
{ |
|
294
|
|
|
$this->seedQueueEnabled = (boolean) $enabled; |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @return boolean |
|
299
|
|
|
*/ |
|
300
|
|
|
public function isSeedQueueEnabled() |
|
301
|
|
|
{ |
|
302
|
|
|
return $this->seedQueueEnabled; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* @param integer $limit |
|
307
|
|
|
*/ |
|
308
|
|
|
public function setDownloadSpeedLimit($limit) |
|
309
|
|
|
{ |
|
310
|
|
|
$this->downloadSpeedLimit = (integer) $limit; |
|
311
|
|
|
} |
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* @return integer |
|
315
|
|
|
*/ |
|
316
|
|
|
public function getDownloadSpeedLimit() |
|
317
|
|
|
{ |
|
318
|
|
|
return $this->downloadSpeedLimit; |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* @param boolean $enabled |
|
323
|
|
|
*/ |
|
324
|
|
|
public function setDownloadSpeedLimitEnabled($enabled) |
|
325
|
|
|
{ |
|
326
|
|
|
$this->downloadSpeedLimitEnabled = (boolean) $enabled; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* @return boolean |
|
331
|
|
|
*/ |
|
332
|
|
|
public function isDownloadSpeedLimitEnabled() |
|
333
|
|
|
{ |
|
334
|
|
|
return $this->downloadSpeedLimitEnabled; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* @param integer $limit |
|
339
|
|
|
*/ |
|
340
|
|
|
public function setUploadSpeedLimit($limit) |
|
341
|
|
|
{ |
|
342
|
|
|
$this->uploadSpeedLimit = (integer) $limit; |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @return integer |
|
347
|
|
|
*/ |
|
348
|
|
|
public function getUploadSpeedLimit() |
|
349
|
|
|
{ |
|
350
|
|
|
return $this->uploadSpeedLimit; |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* @param boolean $enabled |
|
355
|
|
|
*/ |
|
356
|
|
|
public function setUploadSpeedLimitEnabled($enabled) |
|
357
|
|
|
{ |
|
358
|
|
|
$this->uploadSpeedLimitEnabled = (boolean) $enabled; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* @return boolean |
|
363
|
|
|
*/ |
|
364
|
|
|
public function isUploadSpeedLimitEnabled() |
|
365
|
|
|
{ |
|
366
|
|
|
return $this->uploadSpeedLimitEnabled; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* {@inheritDoc} |
|
371
|
|
|
*/ |
|
372
|
|
|
public static function getMapping() |
|
373
|
|
|
{ |
|
374
|
|
|
return array( |
|
375
|
|
|
'alt-speed-down' => 'altSpeedDown', |
|
376
|
|
|
'alt-speed-enabled' => 'altSpeedEnabled', |
|
377
|
|
|
'download-dir' => 'downloadDir', |
|
378
|
|
|
'download-queue-enabled' => 'downloadQueueEnabled', |
|
379
|
|
|
'download-queue-size' => 'downloadQueueSize', |
|
380
|
|
|
'incomplete-dir' => 'incompleteDir', |
|
381
|
|
|
'incomplete-dir-enabled' => 'incompleteDirEnabled', |
|
382
|
|
|
'script-torrent-done-filename' => 'torrentDoneScript', |
|
383
|
|
|
'script-torrent-done-enabled' => 'torrentDoneScriptEnabled', |
|
384
|
|
|
'seedRatioLimit' => 'seedRatioLimit', |
|
385
|
|
|
'seedRatioLimited' => 'seedRatioLimited', |
|
386
|
|
|
'seed-queue-size' => 'seedQueueSize', |
|
387
|
|
|
'seed-queue-enabled' => 'seedQueueEnabled', |
|
388
|
|
|
'speed-limit-down' => 'downloadSpeedLimit', |
|
389
|
|
|
'speed-limit-down-enabled' => 'downloadSpeedLimitEnabled', |
|
390
|
|
|
'speed-limit-up' => 'uploadSpeedLimit', |
|
391
|
|
|
'speed-limit-up-enabled' => 'uploadSpeedLimitEnabled', |
|
392
|
|
|
); |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
public function save() |
|
396
|
|
|
{ |
|
397
|
|
|
$arguments = array(); |
|
398
|
|
|
|
|
399
|
|
|
foreach ($this->getMapping() as $key => $value) { |
|
400
|
|
|
$arguments[$key] = $this->{$value}; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
if (!empty($arguments) && $this->getClient()) { |
|
404
|
|
|
ResponseValidator::validate( |
|
405
|
|
|
'session-set', |
|
406
|
|
|
$this->getClient()->call('session-set', $arguments) |
|
407
|
|
|
); |
|
408
|
|
|
} |
|
409
|
|
|
} |
|
410
|
|
|
} |
|
411
|
|
|
|