00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00020 #ifndef CACHED_URL_HH
00021 #define CACHED_URL_HH
00022
00023 #include <config.h>
00024
00025 #include <glib.h>
00026 #include <set>
00027
00028 #include <bstream.hh>
00029 #include <datasource.hh>
00030 #include <nocopy.hh>
00031 #include <progress.hh>
00032
00033
00034 namespace Job {
00035 class CachedUrl;
00036 }
00037
00039 class Job::CachedUrl : public Job::DataSource {
00040 public:
00046 CachedUrl(const string& filename, uint64 prio);
00047 virtual ~CachedUrl();
00048
00049 virtual void run();
00050
00052 virtual bool paused() const;
00054 virtual void pause();
00056 virtual void cont();
00057
00058
00060 virtual const Progress* progress() const;
00062 virtual const string& location() const;
00063
00064
00065
00066 private:
00067
00068
00069 struct Cmp {
00070 inline bool operator()(const CachedUrl* a, const CachedUrl* b) const;
00071 };
00072 friend struct Cmp;
00073 typedef set<CachedUrl*, Cmp> Set;
00074 static Set active;
00075 static unsigned readSpeed;
00076
00077
00078 static gboolean spoolDataCallback(gpointer);
00079 static int spoolDataCallbackId;
00080
00081 string filenameVal;
00082 uint64 priority;
00083 Progress progressVal;
00084 bifstream* file;
00085 };
00086
00087
00088
00089
00090 bool Job::CachedUrl::Cmp::operator()(const CachedUrl* a, const CachedUrl* b)
00091 const {
00092 if (a->priority == b->priority) return (a < b);
00093 else return (a->priority < b->priority);
00094 }
00095
00096 #endif