1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/***************************************************************************
* slave.h
* -------------------
*
* Revision : $Id$
* begin : Tue Jan 29 2002
* copyright : (C) 2002 by Patrick Charbonnier
* email : [email protected]
*
****************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
***************************************************************************/
#ifndef SLAVE_H
#define SLAVE_H
#include <tqthread.h>
#include <kurl.h>
#include <tqvaluestack.h>
#include <tqwaitcondition.h>
#include <tqmutex.h>
#include <tqobject.h>
#include "common.h"
namespace TDEIO
{
class GetFileJob;
}
class Transfer;
class Slave:public TQObject, public TQThread
{
Q_OBJECT
public:
enum SlaveCommand {
RETR, RETR_CACHE, PAUSE, RESTART, ABORT, DELAY,
SCHEDULE, REMOVE, KILL, NOOP
};
enum SlaveResult {
SLV_TOTAL_SIZE, SLV_PROGRESS_SIZE, SLV_PROGRESS_SPEED,
SLV_CAN_RESUME, SLV_CONNECTED,
SLV_RESUMED, SLV_PAUSED, SLV_ERROR, SLV_BROKEN, SLV_SCHEDULED, SLV_DELAYED,
SLV_FINISHED, SLV_INFO, SLV_REMOVED, SLV_KILLED, SLV_NOTINCACHE
};
public:
Slave(Transfer * _parent, const KURL & _src, const KURL & _dest);
~Slave();
void Op(SlaveCommand _cmd);
protected:
virtual void run();
private slots:
void slotCanceled(TDEIO::Job *);
void slotConnected(TDEIO::Job *);
void slotResult(TDEIO::Job *);
void slotTotalSize(TDEIO::Job *, TDEIO::filesize_t);
void slotProcessedSize(TDEIO::Job *, TDEIO::filesize_t);
void slotSpeed(TDEIO::Job *, unsigned long);
void slotInfoMessage(TDEIO::Job *, const TQString &);
private:
void Connect();
void PostMessage(SlaveResult _event, TQ_ULLONG _data = 0L);
void PostMessage(SlaveResult _event, const TQString & _msg);
void InfoMessage(const TQString & _msg);
Transfer * m_parent;
KURL m_src;
KURL m_dest;
Slave::SlaveCommand fetch_cmd();
int nPendingCommand;
TQValueStack < SlaveCommand > stack;
TQWaitCondition worker;
TQMutex mutex;
TDEIO::GetFileJob * copyjob;
};
#endif
|