OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4DownloadDlg.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2007-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // HTTP download dialog; downloads a file
17 // (like, e.g., a .ocu update group)
18 
19 #ifndef INC_C4DownloadDlg
20 #define INC_C4DownloadDlg
21 
22 #include "gui/C4Gui.h"
23 #include "network/C4Network2Reference.h" // includes HTTP client
24 
25 // dialog to download a file
27 {
28 private:
29  C4Network2HTTPClient HTTPClient;
30 
31  C4GUI::Icon *pIcon;
32  C4GUI::Label *pStatusLabel;
33  C4GUI::ProgressBar *pProgressBar;
34  C4GUI::CancelButton *pCancelBtn;
35  const char *szError;
36 #ifdef HAVE_WINSOCK
37  bool fWinSock;
38 #endif
39 
40 protected:
41  C4DownloadDlg(const char *szDLType);
42  virtual ~C4DownloadDlg();
43 
44 private:
45  // updates the displayed status text and progress bar - repositions elements if necessary
46  void SetStatus(const char *szNewText, int32_t iProgressPercent);
47 
48 protected:
49  // idle proc: Continue download; close when finished
50  virtual void OnIdle();
51 
52  // user presses cancel button: Abort download
53  virtual void UserClose(bool fOK);
54 
55  // downloads the specified file to the specified location. Returns whether successful
56  bool ShowModal(C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename);
57 
58  const char *GetError();
59 
60 public:
61  // download file showing download dialog; display error if download failed
62  static bool DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage = nullptr);
63 };
64 
65 
66 #endif // INC_C4DownloadDlg
virtual void UserClose(bool fOK)
virtual void OnIdle()
bool fOK
Definition: C4Gui.h:2082
static bool DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage=nullptr)
virtual ~C4DownloadDlg()
C4DownloadDlg(const char *szDLType)
bool ShowModal(C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename)
const char * GetError()