include/job.h

Idź do dokumentacji tego pliku.
00001 /*
00002  * Getrap
00003  * Copyright 2008(C) Grzegorz 'milyges' Glinski
00004  *
00005  *
00006  *  This program is free software; you can redistribute it and/or modify it
00007  *  under the terms of the GNU General Public License as published by the Free
00008  *  Software Foundation; either version 2 of the License, or (at your option)
00009  *  any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful, but
00012  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013  *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
00014  *  for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  *
00020 */
00021 #ifndef __JOB_H
00022 #define __JOB_H
00023 
00024 #include <QTreeWidgetItem>
00025 #include <QObject>
00026 #include <QHttp>
00027 #include <QUrl>
00028 #include <QTimer>
00029 #include <QFile>
00030 #include <QBuffer>
00031 
00033 enum jobStatus { jsStopped = 0, jsQueue, jsReadyWait, jsRunning, jsDone, jsError };
00034 
00036 class Job : public QObject, public QTreeWidgetItem
00037 {
00038  Q_OBJECT
00039  private:
00041    static char * mStatusTable[];
00043    static int mActiveJobs;
00048    static QString size2str(int size);
00053    static QString time2str(int secs);
00055    QString mFile;
00057    QUrl mLink;
00059    int mStatus;
00061    int mTimeout;
00063    int mDone;
00065    int mDoneOld;
00067    int mTotal;
00069    int mSpeed;
00071    QHttp * mHttp;
00073    QTimer * mTimer;
00075    QFile * mOutputFile;
00077    void httpError(void);
00082    void setStatus(int status, QString msg = "");
00084    void startNextJob(void);
00085  private slots:
00086    void prepareDone(bool error, bool restart = false);
00087    void freeSelected(bool error);
00088    void freeWait(void);
00089    void downloadDone(bool error);
00090    void progressUpdate(int done, int total);
00091    void updateStatus(void);
00092    void waitForRestart(void);
00093  public:
00094    Job(QTreeWidget * parent, QString link);
00095    ~Job();
00097    void start(void);
00099    void stop(void);
00101    static int activeJobs(void);
00105    int status(void);
00106  signals:
00110    void done(QString fileName);
00114    void fatalError(QString msg);
00115 };
00116 
00117 #endif

Wygenerowano Wed Jan 14 10:00:50 2009 dla Getrap programem  doxygen 1.5.4