1106ae4ecSCodeforEvolution /* 2106ae4ecSCodeforEvolution * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de> 3106ae4ecSCodeforEvolution * Copyright 2013, Rene Gollent <rene@gollent.com> 4106ae4ecSCodeforEvolution * Copyright 2015, Axel Dörfler <axeld@pinc-software.de> 5106ae4ecSCodeforEvolution * Distributed under the terms of the MIT License. 6106ae4ecSCodeforEvolution */ 7106ae4ecSCodeforEvolution #ifndef _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_ 8106ae4ecSCodeforEvolution #define _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_ 9106ae4ecSCodeforEvolution 10106ae4ecSCodeforEvolution 11106ae4ecSCodeforEvolution #include <Entry.h> 12106ae4ecSCodeforEvolution #include <File.h> 13106ae4ecSCodeforEvolution #include <String.h> 14106ae4ecSCodeforEvolution 15106ae4ecSCodeforEvolution #ifdef HAIKU_TARGET_PLATFORM_HAIKU 16106ae4ecSCodeforEvolution # include <UrlProtocolListener.h> 17106ae4ecSCodeforEvolution #endif 18106ae4ecSCodeforEvolution 19106ae4ecSCodeforEvolution #include <package/Job.h> 20106ae4ecSCodeforEvolution 218579c7faSNiels Sascha Reedijk #ifdef HAIKU_TARGET_PLATFORM_HAIKU 228579c7faSNiels Sascha Reedijk using BPrivate::Network::BUrlProtocolListener; 238579c7faSNiels Sascha Reedijk using BPrivate::Network::BUrlRequest; 248579c7faSNiels Sascha Reedijk #endif 258579c7faSNiels Sascha Reedijk 26106ae4ecSCodeforEvolution 27106ae4ecSCodeforEvolution namespace BPackageKit { 28106ae4ecSCodeforEvolution 29106ae4ecSCodeforEvolution namespace BPrivate { 30106ae4ecSCodeforEvolution 31106ae4ecSCodeforEvolution 32106ae4ecSCodeforEvolution #ifdef HAIKU_TARGET_PLATFORM_HAIKU 33106ae4ecSCodeforEvolution class FetchFileJob : public BJob, public BUrlProtocolListener { 34106ae4ecSCodeforEvolution #else // HAIKU_TARGET_PLATFORM_HAIKU 35106ae4ecSCodeforEvolution class FetchFileJob : public BJob { 36106ae4ecSCodeforEvolution #endif // HAIKU_TARGET_PLATFORM_HAIKU 37106ae4ecSCodeforEvolution 38106ae4ecSCodeforEvolution typedef BJob inherited; 39106ae4ecSCodeforEvolution 40106ae4ecSCodeforEvolution public: 41106ae4ecSCodeforEvolution FetchFileJob(const BContext& context, 42106ae4ecSCodeforEvolution const BString& title, 43106ae4ecSCodeforEvolution const BString& fileURL, 44106ae4ecSCodeforEvolution const BEntry& targetEntry); 45106ae4ecSCodeforEvolution virtual ~FetchFileJob(); 46106ae4ecSCodeforEvolution 47106ae4ecSCodeforEvolution float DownloadProgress() const; 48106ae4ecSCodeforEvolution const char* DownloadURL() const; 49106ae4ecSCodeforEvolution const char* DownloadFileName() const; 50106ae4ecSCodeforEvolution off_t DownloadBytes() const; 51106ae4ecSCodeforEvolution off_t DownloadTotalBytes() const; 52106ae4ecSCodeforEvolution 53106ae4ecSCodeforEvolution #ifdef HAIKU_TARGET_PLATFORM_HAIKU 548579c7faSNiels Sascha Reedijk virtual void DownloadProgress(BUrlRequest*, 55*1a0b4125SNiels Sascha Reedijk off_t bytesReceived, off_t bytesTotal); 568579c7faSNiels Sascha Reedijk virtual void RequestCompleted(BUrlRequest* request, 578579c7faSNiels Sascha Reedijk bool success); 58106ae4ecSCodeforEvolution #endif 59106ae4ecSCodeforEvolution 60106ae4ecSCodeforEvolution protected: 61106ae4ecSCodeforEvolution virtual status_t Execute(); 62106ae4ecSCodeforEvolution virtual void Cleanup(status_t jobResult); 63106ae4ecSCodeforEvolution 64106ae4ecSCodeforEvolution private: 65106ae4ecSCodeforEvolution BString fFileURL; 66106ae4ecSCodeforEvolution BEntry fTargetEntry; 67106ae4ecSCodeforEvolution BFile fTargetFile; 680ef0921dSFrançois Revol status_t fError; 69106ae4ecSCodeforEvolution float fDownloadProgress; 70106ae4ecSCodeforEvolution off_t fBytes; 71106ae4ecSCodeforEvolution off_t fTotalBytes; 72106ae4ecSCodeforEvolution }; 73106ae4ecSCodeforEvolution 74106ae4ecSCodeforEvolution 75106ae4ecSCodeforEvolution } // namespace BPrivate 76106ae4ecSCodeforEvolution 77106ae4ecSCodeforEvolution } // namespace BPackageKit 78106ae4ecSCodeforEvolution 79106ae4ecSCodeforEvolution 80106ae4ecSCodeforEvolution #endif // _PACKAGE__PRIVATE__FETCH_FILE_JOB_H_ 81