00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _PRODUCTPATCHER_H_
00012 #define _PRODUCTPATCHER_H_
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 #include <string>
00015 #include <list>
00016 #include <stddef.h>
00017
00018 #include <windows.h>
00019 #include <wininet.h>
00020 #include "RNPlatform/Inc/ThreadClass.h"
00021 #include "RNPlatform/Inc/Thread.h"
00022
00023 namespace RNReplicaNet
00024 {
00025
00026 namespace RNLobby
00027 {
00028
00031 class ProductPatcher : private ThreadClass , private Thread
00032 {
00033 public:
00034 ProductPatcher();
00035 virtual ~ProductPatcher();
00036
00037 enum Status
00038 {
00039 kSuccess = 0,
00040 kErrorEncountered,
00041 kAborted
00042 };
00043
00049 bool Start(const char *productPath,const char *patchIndexURL,const char *patchDataURL,const bool multiThread = false,const size_t chunkSize = 1024*1024);
00050
00053 bool Stop(void);
00054
00057 bool GetCompleted(void);
00058
00061 virtual bool CallbackUpdateProgressProduct(const size_t fileIndex,const size_t maxFileIndex);
00064 virtual bool CallbackUpdateDownloadPatch(const char *patchingFile,const size_t filePosition,const size_t fileLength);
00067 virtual bool CallbackUpdateProgressFile(const char *patchingFile,const size_t filePosition,const size_t fileLength);
00068
00070 virtual void CallbackComplete(const Status status);
00071
00073 virtual void CallbackFailedToReadFile(const char *file);
00074
00075 protected:
00076 void Tidy(void);
00077
00078 private:
00079
00080 int ThreadEntry(void);
00081 int RealThreadEntry(const char *productPath,const char *patchIndexURL,const char *patchDataURL);
00082 std::string GetRealFilePath(const char *url,const char *patchingFile,const char *tempName = 0);
00083
00084 std::string mProductPath;
00085 std::string mPatchIndexURL;
00086 std::string mPatchDataURL;
00087
00088 HINTERNET mInternet;
00089 void *mTempBuffer;
00090 size_t mChunkSize;
00091 HINTERNET mFile;
00092 FILE *mFP;
00093 volatile bool mCallCompleteRequired;
00094 };
00095
00096 }
00097
00098 }
00099
00100 #endif