Now the systrayicon change it's color when a download is in progress. I simply change...
[kdenetwork.git] / kget / slave.h
blob5c0323f3a2405603c57c1ce6873b4299f33fe432
1 /***************************************************************************
2 * slave.h
3 * -------------------
5 * Revision : $Id$
6 * begin : Tue Jan 29 2002
7 * copyright : (C) 2002 by Patrick Charbonnier
8 * email : pch@freeshell.org
10 ****************************************************************************/
12 /***************************************************************************
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 ***************************************************************************/
27 #ifndef SLAVE_H
28 #define SLAVE_H
30 #include <qthread.h>
31 #include <kurl.h>
32 #include <qvaluestack.h>
33 #include <qwaitcondition.h>
34 #include <qmutex.h>
35 #include <qobject.h>
37 #include "common.h"
39 namespace KIO
41 class GetFileJob;
44 class Transfer;
46 class Slave:public QObject, public QThread
48 Q_OBJECT
50 public:
51 enum SlaveCommand {
52 RETR, RETR_CACHE, PAUSE, RESTART, ABORT, DELAY,
53 SCHEDULE, REMOVE, KILL, NOOP
56 enum SlaveResult {
58 SLV_TOTAL_SIZE, SLV_PROGRESS_SIZE, SLV_PROGRESS_SPEED,
59 SLV_CAN_RESUME, SLV_CONNECTED,
61 SLV_RESUMED, SLV_PAUSED, SLV_ERROR, SLV_BROKEN, SLV_SCHEDULED, SLV_DELAYED,
62 SLV_FINISHED, SLV_INFO, SLV_REMOVED, SLV_KILLED, SLV_NOTINCACHE
65 public:
66 Slave(Transfer * _parent, const KURL & _src, const KURL & _dest);
67 ~Slave();
68 void Op(SlaveCommand _cmd);
70 protected:
71 virtual void run();
73 private slots:
74 void slotCanceled(KIO::Job *);
75 void slotConnected(KIO::Job *);
76 void slotResult(KIO::Job *);
77 void slotTotalSize(KIO::Job *, KIO::filesize_t);
78 void slotProcessedSize(KIO::Job *, KIO::filesize_t);
79 void slotSpeed(KIO::Job *, unsigned long);
80 void slotInfoMessage(KIO::Job *, const QString &);
82 private:
83 void Connect();
85 void PostMessage(SlaveResult _event, unsigned long _data = 0L);
86 void PostMessage(SlaveResult _event, const QString & _msg);
87 void InfoMessage(const QString & _msg);
89 Transfer * m_parent;
91 KURL m_src;
92 KURL m_dest;
94 Slave::SlaveCommand fetch_cmd();
95 int nPendingCommand;
97 QValueStack < SlaveCommand > stack;
98 QWaitCondition worker;
99 QMutex mutex;
100 KIO::GetFileJob * copyjob;
104 #endif