Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / bg_downloader_access.h
blob5b4e7094b620715e08a09a1a4b455ced6e64ac7a
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifdef RYZOM_BG_DOWNLOADER
18 #ifndef CL_BG_DOWNLOADER_ACCESS
19 #define CL_BG_DOWNLOADER_ACCESS
21 #include "nel/misc/singleton.h"
22 #include "nel/misc/ucstring.h" // OLD
23 #include "nel/misc/inter_window_msg_queue.h"
24 #include "nel/misc/co_task.h"
26 #include "game_share/bg_downloader_msg.h"
27 #include "game_share/bnp_patch.h"
29 // communication with bg downloader
30 class CBGDownloaderAccess : public NLMISC::CSingleton<CBGDownloaderAccess>
32 public:
33 CBGDownloaderAccess();
34 ~CBGDownloaderAccess();
35 // Init the background downloader access.
36 void init();
37 void release();
38 // jobs
39 void startTask(const BGDownloader::CTaskDesc &taskDesc, const std::string &commandLine, bool showDownloader);
40 bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; // OLD
41 // The following flag will be true after a 'patch' task has been completed successfully
42 bool getPatchCompletionFlag(bool clearFlag);
44 BGDownloader::TTaskResult getLastTaskResult() const { return _TaskResult; }
45 bool mustLaunchBatFile() const { return _MustLaunchBatFile; }
46 void reboot();
47 // Valid after a task has ended. If this was a check task, then contain a bitfield indexed by
48 // BGDownloader::TDownloadID that indicate the part that need to be patched
49 uint32 getAvailablePatchs() const { return _AvailablePatchs; }
50 void resumeBackgroundDownload();
52 void update(); // call this at each frame to update the download process
53 // Get last displayed message by the background downloader
54 const ucstring &getCurrentMessage() const { return _CurrentMessage; } // OLD
55 uint32 getCurrentFilesToGet() const { return _CurrentFilesToGet; }
56 uint32 getTotalFilesToGet() const { return _TotalFilesToGet; }
58 uint32 getPatchingSize() const { return _PatchingSize; }
59 uint32 getTotalSize() const { return _TotalSize; }
60 float getCurrentFileProgress() const { return _CurrentFileProgress; }
62 void showDownloader();
63 void hideDownloader();
65 // download thread
66 BGDownloader::TThreadPriority getDownloadThreadPriority() const { return _DownloadThreadPriority; }
67 bool isDownloaderUIFrozen() const { return _FrozenUI; }
68 void requestDownloadThreadPriority(BGDownloader::TThreadPriority newPriority, bool freezeUI);
70 const ucstring &getLastErrorMessage() const { return _ErrorMsg; } // OLD
72 private:
73 enum TState { State_Idle, State_Patching, State_Finished };
74 TState _State;
76 ucstring _CurrentMessage; // OLD
77 #ifdef NL_OS_WINDOWS
78 NLMISC::CInterWindowMsgQueue _DownloaderMsgQueue;
79 #endif
80 ucstring _ErrorMsg; // OLD
81 std::string _CommandLine;
82 BGDownloader::TTaskResult _TaskResult;
83 uint32 _AvailablePatchs;
84 BGDownloader::CTaskDesc _WantedTask;
85 uint32 _CurrentFilesToGet;
86 uint32 _TotalFilesToGet;
87 uint32 _PatchingSize;
88 uint32 _TotalSize;
89 float _CurrentFileProgress;
90 CProductDescriptionForClient _DescFile;
91 BGDownloader::TThreadPriority _DownloadThreadPriority;
92 void *_RyzomInstPIDPtr;
93 bool _ShowDownloader;
94 bool _FrozenUI;
95 bool _MustLaunchBatFile;
96 bool _PatchCompletionFlag;
97 bool _WaitBalloonDisplay;
98 // The download task, implemented as a coroutine
99 class CDownloadCoTask : public NLMISC::CCoTask
101 public:
102 CBGDownloaderAccess *Parent;
103 BGDownloader::TDownloadID DownloadID;
104 public:
105 virtual void run();
106 void restartDownloader();
107 void createDownloaderProcess();
108 void waitMsg(BGDownloader::TMsgType wantedMsgType, NLMISC::CMemStream &msg, NLMISC::TTime timeOutInMs = 6000000);
109 void sendMsg(NLMISC::CMemStream &msg);
110 void sendSimpleMsg(BGDownloader::TMsgType msgType);
111 bool defaultMessageHandling(BGDownloader::TMsgType msgType, NLMISC::CMemStream &msg);
112 void setDownloaderMode(BGDownloader::TDownloaderMode mode);
113 void setDownloaderVerbosity(bool verbose);
114 bool isDownloaderProcessRunning();
115 BGDownloader::CTaskDesc getDownloaderState();
116 void doTask(const BGDownloader::CTaskDesc &taskDesc); // return value may indicate 'idle' or 'want reboot'
117 void stopTask();
118 void startTask(const BGDownloader::CTaskDesc &taskDesc);
119 void waitIdle();
120 void checkDownloaderAlive();
121 void yieldDownload(); // same as yield, but also handle the isTerminationRequested() case
122 void shutdownDownloader();
123 void getTaskResult(BGDownloader::TTaskResult &result,
124 uint32 &availablePatchs,
125 bool &mustLaunchBatFile,
126 ucstring &errorMsg // OLD
128 void getDescFile();
129 BGDownloader::TDownloaderMode getDownloaderMode();
131 CDownloadCoTask *_DownloadCoTask;
132 friend class CDownloadCoTask;
133 private:
134 void setDownloaderVerbosity(bool verbose);
135 void clearCurrentMessage();
136 void sendSimpleMsg(BGDownloader::TMsgType msgType);
137 void resetDownloadTask();
141 bool isBGDownloadEnabled();
144 // helpers to pause / unpause downloader & retore its previous state
145 void pauseBGDownloader();
146 void unpauseBGDownloader();
149 #endif
150 #endif