ManaPlus
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
UpdaterWindow Class Reference

#include <updaterwindow.h>

Inheritance diagram for UpdaterWindow:
Window ActionListener KeyListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 UpdaterWindow (const std::string &updateHost, const std::string &updatesDir, const bool applyUpdates, const UpdateTypeT updateType)
 
 ~UpdaterWindow ()
 
void postInit ()
 
void setProgress (const float p)
 
void setLabel (const std::string &)
 
void enable ()
 
void loadNews ()
 
void loadPatch ()
 
void action (const ActionEvent &event)
 
void keyPressed (KeyEvent &event)
 
void logic ()
 
void loadFile (std::string file)
 
void deleteSelf ()
 
- Public Member Functions inherited from Window
 Window (const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX=0, int offsetY=0)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
virtual ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
virtual ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget *> &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
virtual ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha=255U) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 

Static Public Member Functions

static void loadLocalUpdates (const std::string &dir)
 
static void unloadUpdates (const std::string &dir)
 
static void addUpdateFile (const std::string &path, const std::string &fixPath, const std::string &file, const Append append)
 
static void removeUpdateFile (const std::string &path, const std::string &fixPath, const std::string &filerestrict)
 
static void loadManaPlusUpdates (const std::string &dir)
 
static void unloadManaPlusUpdates (const std::string &dir)
 
static unsigned long getFileHash (const std::string &filePath)
 
static void loadMods (const std::string &dir, const std::vector< UpdateFile > &updateFiles)
 
static void loadDirMods (const std::string &dir)
 
static void unloadMods (const std::string &dir)
 
- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 

Private Member Functions

void download ()
 
void loadUpdates ()
 

Static Private Member Functions

static int updateProgress (void *ptr, const DownloadStatusT status, size_t dt, const size_t dn)
 
static size_t memoryWrite (void *ptr, size_t size, size_t nmemb, void *stream)
 
static bool validateFile (const std::string &filePath, const unsigned long hash)
 

Private Attributes

float mDownloadProgress
 
std::string mUpdateHost
 
std::string mUpdatesDir
 
std::string mUpdatesDirReal
 
std::string mCurrentFile
 
std::string mNewLabelCaption
 
Mutex mDownloadMutex
 
unsigned long mCurrentChecksum
 
char * mMemoryBuffer
 
Net::DownloadmDownload
 
std::vector< UpdateFilemUpdateFiles
 
std::vector< UpdateFilemTempUpdateFiles
 
std::string mUpdateServerPath
 
ItemLinkHandlermItemLinkHandler
 
LabelmLabel
 
ButtonmCancelButton
 
ButtonmPlayButton
 
ProgressBarmProgressBar
 
StaticBrowserBoxmBrowserBox
 
ScrollAreamScrollArea
 
UpdateDownloadStatusT mDownloadStatus
 
int mDownloadedBytes
 
unsigned int mUpdateIndex
 
unsigned int mUpdateIndexOffset
 
UpdateTypeT mUpdateType
 
bool mStoreInMemory
 
bool mDownloadComplete
 
bool mUserCancel
 
bool mLoadUpdates
 
bool mValidateXml
 
bool mSkipPatches
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from KeyListener
 KeyListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Update progress window GUI

Definition at line 59 of file updaterwindow.h.

Constructor & Destructor Documentation

◆ UpdaterWindow()

UpdaterWindow::UpdaterWindow ( const std::string &  updateHost,
const std::string &  updatesDir,
const bool  applyUpdates,
const UpdateTypeT  updateType 
)

Constructor.

Parameters
updateHostHost where to get the updated files.
updatesDirDirectory where to store updates (should be absolute and already created).
applyUpdatesIf true, the update window will pass the updates to teh resource manager.

Definition at line 168 of file updaterwindow.cpp.

References Widget::addKeyListener(), ImagePosition::CENTER, Window::getLayout(), Window::getPlacer(), Window::loadWindowState(), mBrowserBox, mCancelButton, mItemLinkHandler, mLabel, mPlayButton, mProgressBar, mScrollArea, mSkipPatches, mUpdateHost, Opaque_false, LayoutType::SET, Window::setDefaultSize(), Widget::setEnabled(), StaticBrowserBox::setEnableKeys(), StaticBrowserBox::setEnableTabs(), StaticBrowserBox::setLinkHandler(), Window::setMinHeight(), Window::setMinWidth(), StaticBrowserBox::setOpaque(), StaticBrowserBox::setProcessVars(), Window::setResizable(), LayoutCell::setRowHeight(), ProgressBar::setSmoothProgress(), settings, Window::setWindowName(), and Settings::updateMirrors.

171  :
172  // TRANSLATORS: updater window name
173  Window(_("Updating..."), Modal_false, nullptr, "update.xml"),
174  ActionListener(),
175  KeyListener(),
176  mDownloadProgress(0.0F),
177  mUpdateHost(updateHost),
178  mUpdatesDir(updatesDir),
179  mUpdatesDirReal(updatesDir),
180  mCurrentFile("news.txt"),
182  mDownloadMutex(),
183  mCurrentChecksum(0),
184  mMemoryBuffer(nullptr),
185  mDownload(nullptr),
186  mUpdateFiles(),
190  // TRANSLATORS: updater window label
191  mLabel(new Label(this, _("Connecting..."))),
192  // TRANSLATORS: updater window button
193  mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
194  // TRANSLATORS: updater window button
195  mPlayButton(new Button(this, _("Play"), "play", this)),
196  mProgressBar(new ProgressBar(this, 0.0, 310, 0,
198  "updateprogressbar.xml", "updateprogressbar_fill.xml")),
200  "browserbox.xml")),
202  Opaque_true, "update_background.xml")),
204  mDownloadedBytes(0),
205  mUpdateIndex(0),
207  mUpdateType(updateType),
208  mStoreInMemory(true),
209  mDownloadComplete(true),
210  mUserCancel(false),
211  mLoadUpdates(applyUpdates),
212  mValidateXml(false),
213  mSkipPatches(false)
214 {
215  setWindowName("UpdaterWindow");
216  setResizable(true);
218  setMinWidth(310);
219  setMinHeight(220);
220 
225  mBrowserBox->setEnableKeys(true);
226  mBrowserBox->setEnableTabs(true);
227  mPlayButton->setEnabled(false);
228 
229  ContainerPlacer placer;
230  placer = getPlacer(0, 0);
231 
232  placer(0, 0, mScrollArea, 5, 3).setPadding(3);
233  placer(0, 3, mLabel, 5);
234  placer(0, 4, mProgressBar, 5);
235  placer(3, 5, mCancelButton);
236  placer(4, 5, mPlayButton);
237 
238  Layout &layout = getLayout();
239  layout.setRowHeight(0, LayoutType::SET);
240 
241  addKeyListener(this);
242 
243  if (mUpdateHost.empty())
244  {
245  const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
246  if (mirrors.begin() != mirrors.end())
247  mUpdateHost = *mirrors.begin();
248  mSkipPatches = true;
249  }
250 
251  loadWindowState();
252 }
void setDefaultSize()
Definition: window.cpp:1186
#define _(s)
Definition: gettext.h:34
std::string mUpdatesDir
void loadWindowState()
Definition: window.cpp:1075
std::string mUpdateServerPath
void setProcessVars(const bool n)
UpdateTypeT mUpdateType
void setMinWidth(const int width)
Definition: window.cpp:579
void setEnableKeys(const bool n)
std::vector< UpdateFile > mTempUpdateFiles
Definition: button.h:94
unsigned int mUpdateIndex
StaticBrowserBox * mBrowserBox
UpdateDownloadStatusT mDownloadStatus
void setSmoothProgress(bool smoothProgress)
Definition: progressbar.h:124
std::vector< std::string > updateMirrors
Definition: settings.h:127
Mutex mDownloadMutex
unsigned long mCurrentChecksum
Button * mPlayButton
Settings settings
Definition: settings.cpp:31
void setLinkHandler(LinkHandler *linkHandler)
std::string mUpdatesDirReal
Definition: label.h:87
float mDownloadProgress
const bool Opaque_false
Definition: opaque.h:29
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
Button * mCancelButton
void setMinHeight(const int height)
Definition: window.cpp:592
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1379
void setEnabled(const bool enabled)
Definition: widget.h:351
ProgressBar * mProgressBar
ItemLinkHandler * mItemLinkHandler
Layout & getLayout()
Definition: window.cpp:1353
ScrollArea * mScrollArea
void setOpaque(Opaque opaque)
char * mMemoryBuffer
bool mDownloadComplete
const bool Opaque_true
Definition: opaque.h:29
void setEnableTabs(const bool n)
unsigned int mUpdateIndexOffset
void setResizable(const bool resize)
Definition: window.cpp:615
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
std::string mUpdateHost
std::vector< UpdateFile > mUpdateFiles
Definition: layout.h:43
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
std::string mCurrentFile
std::string mNewLabelCaption
void setWindowName(const std::string &name)
Definition: window.h:353
Net::Download * mDownload

◆ ~UpdaterWindow()

UpdaterWindow::~UpdaterWindow ( )

Destructor

Definition at line 264 of file updaterwindow.cpp.

References Net::Download::cancel, delete2, loadUpdates(), mDownload, mItemLinkHandler, mLoadUpdates, and mMemoryBuffer.

265 {
266  if (mLoadUpdates)
267  loadUpdates();
268 
269  if (mDownload != nullptr)
270  {
271  mDownload->cancel();
272 
274  }
275  free(mMemoryBuffer);
277 }
unsigned cancel
Definition: download.h:123
#define delete2(var)
Definition: delete2.h:24
ItemLinkHandler * mItemLinkHandler
char * mMemoryBuffer
Net::Download * mDownload

Member Function Documentation

◆ action()

void UpdaterWindow::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 310 of file updaterwindow.cpp.

References Net::Download::cancel, client, deleteSelf(), State::GAME, Client::getState(), State::LOAD_DATA, mDownload, mDownloadStatus, mUserCancel, Client::setState(), UpdateDownloadStatus::UPDATE_COMPLETE, and UpdateDownloadStatus::UPDATE_ERROR.

Referenced by keyPressed().

311 {
312  const std::string &eventId = event.getId();
313  if (eventId == "cancel")
314  {
315  // Register the user cancel
316  mUserCancel = true;
317  // Skip the updating process
319  {
320  if (mDownload != nullptr)
321  mDownload->cancel();
323  }
324  }
325  else if (eventId == "play")
326  {
327  if (client->getState() != State::GAME)
329  else
330  deleteSelf();
331  }
332 }
void setState(const StateT state)
Definition: client.h:65
unsigned cancel
Definition: download.h:123
Client * client
Definition: client.cpp:113
UpdateDownloadStatusT mDownloadStatus
StateT getState() const
Definition: client.h:68
Net::Download * mDownload

◆ addUpdateFile()

void UpdaterWindow::addUpdateFile ( const std::string &  path,
const std::string &  fixPath,
const std::string &  file,
const Append  append 
)
static

Definition at line 796 of file updaterwindow.cpp.

References Append_false, Append_true, VirtFs::mountZip(), and pathJoin().

Referenced by loadLocalUpdates(), loadMods(), and loadUpdates().

800 {
801  const std::string tmpPath = pathJoin(path, file);
802  if (append == Append_false)
803  VirtFs::mountZip(tmpPath, append);
804 
805  const std::string fixFile = pathJoin(fixPath, file);
806  struct stat statbuf;
807  if (stat(fixFile.c_str(), &statbuf) == 0)
808  VirtFs::mountZip(fixFile, append);
809 
810  if (append == Append_true)
811  VirtFs::mountZip(tmpPath, append);
812 }
const bool Append_true
Definition: append.h:29
std::string pathJoin(std::string str1, const std::string &str2)
const bool Append_false
Definition: append.h:29
bool mountZip(std::string newDir, const Append append)
Definition: fs.cpp:589

◆ deleteSelf()

void UpdaterWindow::deleteSelf ( )

Definition at line 1213 of file updaterwindow.cpp.

References Window::scheduleDelete().

Referenced by action(), enable(), keyPressed(), and Actions::showHideWindow().

1214 {
1215  scheduleDelete();
1216  updaterWindow = nullptr;
1217 }
UpdaterWindow * updaterWindow
virtual void scheduleDelete()
Definition: window.cpp:819

◆ download()

void UpdaterWindow::download ( )
private

Definition at line 578 of file updaterwindow.cpp.

References Net::Download::addMirror(), branding, Net::Download::cancel, FOR_EACH, Configuration::getStringValue(), mCurrentChecksum, mCurrentFile, mDownload, mDownloadComplete, mDownloadStatus, memoryWrite(), mStoreInMemory, mUpdateHost, mUpdatesDir, mUpdateServerPath, mValidateXml, Net::Download::noCache(), pathJoin(), Net::Download::setFile(), setLabel(), settings, Net::Download::setWriteFunction(), Net::Download::start(), ServerCommandType::str, Catch::toString(), UpdateDownloadStatus::UPDATE_LIST2, UpdateDownloadStatus::UPDATE_PATCH, UpdateDownloadStatus::UPDATE_RESOURCES, UpdateDownloadStatus::UPDATE_RESOURCES2, Settings::updateMirrors, updateProgress(), updateServer3(), updateServer4(), updateServer5(), Actions::url(), and urlJoin().

Referenced by logic(), and postInit().

579 {
580  if (mDownload != nullptr)
581  {
582  mDownload->cancel();
583  delete mDownload;
584  }
586  {
587  mDownload = new Net::Download(this,
588  branding.getStringValue("updateMirror1") + mCurrentFile,
590  true, false, mValidateXml);
591  for (int f = 2; f < 8; f ++)
592  {
593  const std::string url = branding.getStringValue(
594  "updateMirror" + toString(f));
595  if (!url.empty())
597  }
598  }
599  else
600  {
601  mDownload = new Net::Download(this,
603  &updateProgress,
604  false, false, mValidateXml);
605 
608  {
609  const std::string str = urlJoin(mUpdateServerPath, mCurrentFile);
613  }
614  else
615  {
616  const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
617  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mirrors)
618  {
620  mCurrentFile));
621  }
622  }
623  }
624 
625  if (mStoreInMemory)
626  {
628  }
629  else
630  {
632  {
635  }
636  else
637  {
639  mCurrentFile));
640  }
641  }
642 
644  mDownload->noCache();
645 
646  setLabel(mCurrentFile + " (0%)");
647  mDownloadComplete = false;
648 
649  mDownload->start();
650 }
Configuration branding
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
std::string getStringValue(const std::string &key) const
std::string mUpdatesDir
void addMirror(const std::string &str)
Definition: download.h:86
const std::string updateServer3("http://download2.manaplus.org/manaplus/updates/")
std::string mUpdateServerPath
unsigned cancel
Definition: download.h:123
std::string pathJoin(std::string str1, const std::string &str2)
void setWriteFunction(WriteFunction write)
Definition: download.cpp:180
void setLabel(const std::string &)
UpdateDownloadStatusT mDownloadStatus
std::string urlJoin(std::string str1, const std::string &str2)
std::vector< std::string > updateMirrors
Definition: settings.h:127
unsigned long mCurrentChecksum
Settings settings
Definition: settings.cpp:31
const std::string updateServer5("http://download3.manaplus.org/manaplus/updates/")
void setFile(const std::string &filename, const int64_t adler32=-1)
Definition: download.cpp:164
static int updateProgress(void *ptr, const DownloadStatusT status, size_t dt, const size_t dn)
const std::string updateServer4("http://download.evolonline.org/manaplus/updates/")
bool start()
Definition: download.cpp:186
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
void noCache()
Definition: download.cpp:158
bool mDownloadComplete
std::string mUpdateHost
static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream)
std::string mCurrentFile
bool url(InputEvent &event)
Definition: commands.cpp:63
Net::Download * mDownload

◆ enable()

void UpdaterWindow::enable ( )

Enables play button

Definition at line 293 of file updaterwindow.cpp.

References client, UpdateType::Close, deleteSelf(), State::GAME, Client::getState(), State::LOAD_DATA, mCancelButton, mPlayButton, mUpdateType, Widget::requestFocus(), Widget::setEnabled(), and Client::setState().

Referenced by logic().

294 {
295  mCancelButton->setEnabled(false);
296  mPlayButton->setEnabled(true);
298 
299  if (client->getState() != State::GAME)
300  {
301  if ((mUpdateType & UpdateType::Close) != 0)
303  }
304  else
305  {
306  deleteSelf();
307  }
308 }
void setState(const StateT state)
Definition: client.h:65
UpdateTypeT mUpdateType
Client * client
Definition: client.cpp:113
Button * mPlayButton
virtual void requestFocus()
Definition: widget.cpp:203
Button * mCancelButton
void setEnabled(const bool enabled)
Definition: widget.h:351
StateT getState() const
Definition: client.h:68

◆ getFileHash()

unsigned long UpdaterWindow::getFileHash ( const std::string &  filePath)
static

Definition at line 1078 of file updaterwindow.cpp.

References Net::Download::adlerBuffer(), VirtFs::loadFile(), and ServerCommandType::size.

Referenced by LocalPlayer::setTestParticle(), and LocalPlayer::slowLogic().

1079 {
1080  int size = 0;
1081  const char *const buf = VirtFs::loadFile(filePath, size);
1082  if (buf == nullptr)
1083  return 0;
1084  unsigned long res = Net::Download::adlerBuffer(buf, size);
1085  delete [] buf;
1086  return res;
1087 }
const char * loadFile(std::string filename, int &fileSize)
Definition: fs.cpp:858
static unsigned long adlerBuffer(const char *const buffer, int size)
Definition: download.cpp:145

◆ keyPressed()

void UpdaterWindow::keyPressed ( KeyEvent event)
virtual

Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.

Parameters
eventDiscribes the event.

Reimplemented from KeyListener.

Definition at line 334 of file updaterwindow.cpp.

References action(), client, deleteSelf(), State::GAME, Widget::getActionEventId(), Client::getState(), InputAction::GUI_CANCEL, InputAction::GUI_SELECT, InputAction::GUI_SELECT2, State::LOGIN, mCancelButton, mDownloadStatus, mPlayButton, Client::setState(), UpdateDownloadStatus::UPDATE_COMPLETE, UpdateDownloadStatus::UPDATE_ERROR, and UpdateDownloadStatus::UPDATE_IDLE.

335 {
336  const InputActionT actionId = event.getActionId();
337  if (actionId == InputAction::GUI_CANCEL)
338  {
340  if (client->getState() != State::GAME)
342  else
343  deleteSelf();
344  }
345  else if (actionId == InputAction::GUI_SELECT ||
346  actionId == InputAction::GUI_SELECT2)
347  {
351  {
353  }
354  else
355  {
357  }
358  }
359 }
void action(const ActionEvent &event)
void setState(const StateT state)
Definition: client.h:65
const std::string & getActionEventId() const
Definition: widget.h:604
Client * client
Definition: client.cpp:113
UpdateDownloadStatusT mDownloadStatus
Button * mPlayButton
InputAction ::T InputActionT
Definition: inputaction.h:714
Button * mCancelButton
StateT getState() const
Definition: client.h:68

◆ loadDirMods()

void UpdaterWindow::loadDirMods ( const std::string &  dir)
static

Definition at line 1164 of file updaterwindow.cpp.

References Append_false, FOR_EACH, ModDB::getAll(), ModInfo::getLocalDir(), ConfigurationObject::getValue(), ModDB::load(), VirtFs::mountDir(), pathJoin(), serverConfig, and splitToStringVector().

Referenced by loadMods(), and Client::stateSwitchLogin1().

1165 {
1166  ModDB::load();
1167  const ModInfos &mods = ModDB::getAll();
1168 
1169  std::string modsString = serverConfig.getValue("mods", "");
1170  StringVect modsList;
1171  splitToStringVector(modsList, modsString, '|');
1172  FOR_EACH (StringVectCIter, it, modsList)
1173  {
1174  const std::string &name = *it;
1175  const ModInfoCIterator modIt = mods.find(name);
1176  if (modIt == mods.end())
1177  continue;
1178  const ModInfo *const mod = (*modIt).second;
1179  if (mod != nullptr)
1180  {
1181  const std::string &localDir = mod->getLocalDir();
1182  if (!localDir.empty())
1183  {
1184  VirtFs::mountDir(pathJoin(dir, localDir),
1185  Append_false);
1186  }
1187  }
1188  }
1189 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
bool mountDir(std::string newDir, const Append append)
Definition: fs.cpp:392
std::string pathJoin(std::string str1, const std::string &str2)
const ModInfos & getAll()
Definition: moddb.cpp:115
std::vector< std::string > StringVect
Definition: stringvector.h:28
Configuration serverConfig
const std::string & getLocalDir() const
Definition: modinfo.h:57
void load()
Definition: moddb.cpp:41
ModInfos::const_iterator ModInfoCIterator
Definition: modinfo.h:69
const bool Append_false
Definition: append.h:29
std::string getValue(const std::string &key, const std::string &deflt) const
std::map< std::string, ModInfo * > ModInfos
Definition: modinfo.h:67

◆ loadFile()

void UpdaterWindow::loadFile ( std::string  file)

Definition at line 1089 of file updaterwindow.cpp.

References StaticBrowserBox::addRow(), StaticBrowserBox::clearRows(), Files::loadTextFileLocal(), mBrowserBox, mUpdatesDir, Catch::trim(), and StaticBrowserBox::updateHeight().

1090 {
1092  trim(file);
1093 
1094  StringVect lines;
1095  Files::loadTextFileLocal(mUpdatesDir + "/local/help/news.txt", lines);
1096 
1097  for (size_t i = 0, sz = lines.size(); i < sz; ++i)
1098  mBrowserBox->addRow(lines[i]);
1100 }
std::string mUpdatesDir
bool loadTextFileLocal(const std::string &fileName, StringVect &lines)
Definition: files.cpp:227
StaticBrowserBox * mBrowserBox
std::vector< std::string > StringVect
Definition: stringvector.h:28
std::string trim(std::string const &str)
void addRow(const std::string &row, const bool atTop=false)

◆ loadLocalUpdates()

void UpdaterWindow::loadLocalUpdates ( const std::string &  dir)
static

Definition at line 684 of file updaterwindow.cpp.

References addUpdateFile(), Append_false, CAST_U32, UpdateFile::group, loadManaPlusUpdates(), loadMods(), loadTxtFile(), loadXMLFile(), Logger::log(), logger, UpdateFile::name, pathJoin(), txtUpdateFile(), and xmlUpdateFile().

Referenced by Client::stateSwitchLogin1().

685 {
686  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
687  pathJoin(dir, xmlUpdateFile),
688  false);
689 
690  if (updateFiles.empty())
691  {
692  logger->log("Warning this server does not have a"
693  " %s file falling back to %s", xmlUpdateFile.c_str(),
694  txtUpdateFile.c_str());
695  updateFiles = loadTxtFile(pathJoin(dir,
696  txtUpdateFile));
697  }
698 
699  const std::string fixPath = dir + "/fix";
700  for (unsigned int updateIndex = 0,
701  fsz = CAST_U32(updateFiles.size());
702  updateIndex < fsz;
703  updateIndex++)
704  {
705  const UpdateFile &file = updateFiles[updateIndex];
706  if (!file.group.empty())
707  continue;
709  fixPath,
710  file.name,
711  Append_false);
712  }
713  loadManaPlusUpdates(dir);
714  loadMods(dir, updateFiles);
715 }
#define CAST_U32
Definition: cast.h:30
std::string pathJoin(std::string str1, const std::string &str2)
static void addUpdateFile(const std::string &path, const std::string &fixPath, const std::string &file, const Append append)
std::string group
Definition: updatefile.h:49
const std::string xmlUpdateFile("resources.xml")
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
Logger * logger
Definition: logger.cpp:95
static void loadManaPlusUpdates(const std::string &dir)
static std::vector< UpdateFile > loadTxtFile(const std::string &fileName)
const bool Append_false
Definition: append.h:29
const std::string txtUpdateFile("resources2.txt")
static void loadMods(const std::string &dir, const std::vector< UpdateFile > &updateFiles)
void log(const char *const log_text,...)
Definition: logger.cpp:243
std::string name
Definition: updatefile.h:45

◆ loadManaPlusUpdates()

void UpdaterWindow::loadManaPlusUpdates ( const std::string &  dir)
static

Definition at line 742 of file updaterwindow.cpp.

References Append_false, CAST_U32, fileName, UpdateFile::group, loadXMLFile(), VirtFs::mountZip(), UpdateFile::name, pathJoin(), strStartWith(), and xmlUpdateFile().

Referenced by loadLocalUpdates(), and loadUpdates().

743 {
744  std::string fixPath = dir + "/fix";
745  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
746  pathJoin(fixPath, xmlUpdateFile),
747  false);
748 
749  for (unsigned int updateIndex = 0,
750  fsz = CAST_U32(updateFiles.size());
751  updateIndex < fsz;
752  updateIndex++)
753  {
754  const UpdateFile &file = updateFiles[updateIndex];
755  if (!file.group.empty())
756  continue;
757  const std::string name = file.name;
758  if (strStartWith(name, "manaplus_"))
759  {
760  struct stat statbuf;
761  std::string fileName = pathJoin(fixPath,
762  name);
763  if (stat(fileName.c_str(), &statbuf) == 0)
764  {
765  VirtFs::mountZip(fileName,
766  Append_false);
767  }
768  }
769  }
770 }
#define CAST_U32
Definition: cast.h:30
bool strStartWith(const std::string &str1, const std::string &str2)
std::string fileName
Definition: testmain.cpp:36
std::string pathJoin(std::string str1, const std::string &str2)
std::string group
Definition: updatefile.h:49
const std::string xmlUpdateFile("resources.xml")
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
const bool Append_false
Definition: append.h:29
bool mountZip(std::string newDir, const Append append)
Definition: fs.cpp:589
std::string name
Definition: updatefile.h:45

◆ loadMods()

void UpdaterWindow::loadMods ( const std::string &  dir,
const std::vector< UpdateFile > &  updateFiles 
)
static

Definition at line 1102 of file updaterwindow.cpp.

References addUpdateFile(), Append_false, CAST_U32, fileName, ConfigurationObject::getValue(), UpdateFile::group, ModDB::load(), loadDirMods(), loadXMLFile(), VirtFs::mountZip(), UpdateFile::name, pathJoin(), serverConfig, splitToStringSet(), strStartWith(), and xmlUpdateFile().

Referenced by loadLocalUpdates(), and loadUpdates().

1104 {
1105  ModDB::load();
1106  std::string modsString = serverConfig.getValue("mods", "");
1107  std::set<std::string> modsList;
1108  splitToStringSet(modsList, modsString, '|');
1109 
1110  const std::string fixPath = dir + "/fix";
1111  for (unsigned int updateIndex = 0,
1112  fsz = CAST_U32(updateFiles.size());
1113  updateIndex < fsz;
1114  updateIndex ++)
1115  {
1116  const UpdateFile &file = updateFiles[updateIndex];
1117  if (file.group.empty())
1118  continue;
1119  const std::set<std::string>::const_iterator
1120  it = modsList.find(file.group);
1121  if (it != modsList.end())
1122  {
1124  fixPath,
1125  file.name,
1126  Append_false);
1127  }
1128  }
1129 
1130  STD_VECTOR<UpdateFile> updateFiles2 = loadXMLFile(
1131  pathJoin(fixPath, xmlUpdateFile),
1132  true);
1133 
1134  for (unsigned int updateIndex = 0,
1135  fsz = CAST_U32(updateFiles2.size());
1136  updateIndex < fsz;
1137  updateIndex++)
1138  {
1139  const UpdateFile &file = updateFiles2[updateIndex];
1140  if (file.group.empty())
1141  continue;
1142  std::string name = file.name;
1143  if (strStartWith(name, "manaplus_"))
1144  {
1145  const std::set<std::string>::const_iterator
1146  it = modsList.find(file.group);
1147  if (it != modsList.end())
1148  {
1149  struct stat statbuf;
1150  std::string fileName = pathJoin(fixPath,
1151  name);
1152  if (stat(fileName.c_str(), &statbuf) == 0)
1153  {
1154  VirtFs::mountZip(fileName,
1155  Append_false);
1156  }
1157  }
1158  }
1159  }
1160 
1161  loadDirMods(dir + "/local/");
1162 }
#define CAST_U32
Definition: cast.h:30
bool strStartWith(const std::string &str1, const std::string &str2)
void splitToStringSet(std::set< std::string > &tokens, const std::string &text, const char separator)
std::string fileName
Definition: testmain.cpp:36
std::string pathJoin(std::string str1, const std::string &str2)
static void addUpdateFile(const std::string &path, const std::string &fixPath, const std::string &file, const Append append)
std::string group
Definition: updatefile.h:49
const std::string xmlUpdateFile("resources.xml")
static void loadDirMods(const std::string &dir)
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
Configuration serverConfig
void load()
Definition: moddb.cpp:41
const bool Append_false
Definition: append.h:29
std::string getValue(const std::string &key, const std::string &deflt) const
bool mountZip(std::string newDir, const Append append)
Definition: fs.cpp:589
std::string name
Definition: updatefile.h:45

◆ loadNews()

void UpdaterWindow::loadNews ( )

Loads and display news. Assumes the news file contents have been loaded into the memory buffer.

Definition at line 361 of file updaterwindow.cpp.

References _, StaticBrowserBox::addRow(), StaticBrowserBox::clearRows(), Logger::log1(), logger, mBrowserBox, mDownloadedBytes, mkdir_r(), mMemoryBuffer, mScrollArea, mUpdatesDir, ScrollArea::setVerticalScrollAmount(), and StaticBrowserBox::updateHeight().

Referenced by logic().

362 {
363  if (mMemoryBuffer == nullptr)
364  {
365  logger->log1("Couldn't load news");
366  return;
367  }
368 
369  // Reallocate and include terminating 0 character
370  mMemoryBuffer = static_cast<char*>(realloc(
372  if (mMemoryBuffer == nullptr)
373  {
374  logger->log1("Couldn't load news");
375  return;
376  }
379 
380  std::string newsName = mUpdatesDir + "/local/help/news.txt";
381  mkdir_r((mUpdatesDir + "/local/help/").c_str());
382  bool firstLine(true);
383  std::ofstream file;
384  std::stringstream ss(mMemoryBuffer);
385  std::string line;
386  file.open(newsName.c_str(), std::ios::out);
387  int cnt = 0;
388  const int maxNews = 50;
389  while (std::getline(ss, line, '\n'))
390  {
391  cnt ++;
392  if (firstLine)
393  {
394  firstLine = false;
395  const size_t i = line.find("##9 Latest client version: ##6");
396  if (i == 0u)
397  continue;
398 
399  if (file.is_open())
400  file << line << std::endl;
401  if (cnt < maxNews)
402  mBrowserBox->addRow(line);
403  }
404  else
405  {
406  if (file.is_open())
407  file << line << std::endl;
408  if (cnt < maxNews)
409  mBrowserBox->addRow(line);
410  }
411  }
412 
413  file.close();
414  if (cnt > maxNews)
415  {
416  mBrowserBox->addRow("");
417  // TRANSLATORS: updater window checkbox
418  mBrowserBox->addRow("news", _("Show all news (can be slow)"));
419  mBrowserBox->addRow("");
420  }
421  // Free the memory buffer now that we don't need it anymore
422  free(mMemoryBuffer);
423  mMemoryBuffer = nullptr;
424  mDownloadedBytes = 0;
425 
428 }
#define _(s)
Definition: gettext.h:34
std::string mUpdatesDir
void log1(const char *const log_text)
Definition: logger.cpp:222
int mkdir_r(const char *const pathname)
Create a directory, making leading components first if necessary.
Definition: mkdir.cpp:108
StaticBrowserBox * mBrowserBox
void setVerticalScrollAmount(const int vScroll)
Logger * logger
Definition: logger.cpp:95
ScrollArea * mScrollArea
char * mMemoryBuffer
void addRow(const std::string &row, const bool atTop=false)

◆ loadPatch()

void UpdaterWindow::loadPatch ( )

Definition at line 430 of file updaterwindow.cpp.

References StaticBrowserBox::addRow(), branding, CHECK_VERSION, Configuration::getStringValue(), Logger::log1(), logger, mBrowserBox, mDownloadedBytes, mMemoryBuffer, mScrollArea, serverVersion, ScrollArea::setVerticalScrollAmount(), strprintf(), StaticBrowserBox::updateHeight(), Actions::url(), and ServerCommandType::version.

Referenced by logic().

431 {
432  if (mMemoryBuffer == nullptr)
433  {
434  logger->log1("Couldn't load patch");
435  return;
436  }
437 
438  // Reallocate and include terminating 0 character
439  mMemoryBuffer = static_cast<char*>(
440  realloc(mMemoryBuffer, mDownloadedBytes + 1));
441  if (mMemoryBuffer == nullptr)
442  {
443  logger->log1("Couldn't load patch");
444  return;
445  }
447 
448  std::string version;
449 
450  // Tokenize and add each line separately
451  char *line = strtok(mMemoryBuffer, "\n");
452  if (line != nullptr)
453  {
454  version = line;
455  if (serverVersion < 1)
456  {
457  line = strtok(nullptr, "\n");
458  if (line != nullptr)
459  {
460  mBrowserBox->addRow(strprintf("##9 Latest client version: "
461  "##6ManaPlus %s##0", line), true);
462  }
463  }
464  if (version > CHECK_VERSION)
465  {
466  mBrowserBox->addRow("", true);
467 #if defined(ANDROID)
468  const std::string url = "androidDownloadUrl";
469  const std::string text = "androidDownloadUrl";
470 #elif defined(WIN32)
471  const std::string url = "windowsDownloadUrl";
472  const std::string text = "windowsDownloadUrl";
473 #else // defined(ANDROID)
474 
475  const std::string url = "otherDownloadUrl";
476  const std::string text = "otherDownloadUrl";
477 #endif // defined(ANDROID)
478 
479  mBrowserBox->addRow(std::string(" ##1[@@").append(
480  branding.getStringValue(url)).append("|").append(
481  branding.getStringValue(text)).append("@@]"), true);
482  mBrowserBox->addRow("##1You can download it from", true);
483  mBrowserBox->addRow("##1ManaPlus updated.", true);
484  }
485  else
486  {
487  mBrowserBox->addRow("You have latest client version.", true);
488  }
489  }
490 
491  // Free the memory buffer now that we don't need it anymore
492  free(mMemoryBuffer);
493  mMemoryBuffer = nullptr;
494  mDownloadedBytes = 0;
495 
498 }
Configuration branding
std::string getStringValue(const std::string &key) const
void log1(const char *const log_text)
Definition: logger.cpp:222
int serverVersion
Definition: client.cpp:119
StaticBrowserBox * mBrowserBox
void setVerticalScrollAmount(const int vScroll)
Logger * logger
Definition: logger.cpp:95
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
#define CHECK_VERSION
Definition: main.h:44
ScrollArea * mScrollArea
char * mMemoryBuffer
bool url(InputEvent &event)
Definition: commands.cpp:63
void addRow(const std::string &row, const bool atTop=false)

◆ loadUpdates()

void UpdaterWindow::loadUpdates ( )
private

Loads the updates this window has gotten into the resource manager

Definition at line 652 of file updaterwindow.cpp.

References addUpdateFile(), Append_false, CAST_U32, UpdateFile::group, loadManaPlusUpdates(), loadMods(), loadTxtFile(), loadXMLFile(), Logger::log(), logger, mUpdateFiles, mUpdateIndex, mUpdatesDir, UpdateFile::name, pathJoin(), txtUpdateFile(), and xmlUpdateFile().

Referenced by ~UpdaterWindow().

653 {
654  if (mUpdateFiles.empty())
655  { // updates not downloaded
657  false);
658  if (mUpdateFiles.empty())
659  {
660  logger->log("Warning this server does not have a"
661  " %s file falling back to %s", xmlUpdateFile.c_str(),
662  txtUpdateFile.c_str());
664  txtUpdateFile));
665  }
666  }
667 
668  std::string fixPath = mUpdatesDir + "/fix";
669  const unsigned sz = CAST_U32(mUpdateFiles.size());
670  for (mUpdateIndex = 0; mUpdateIndex < sz; mUpdateIndex++)
671  {
672  const UpdateFile &file = mUpdateFiles[mUpdateIndex];
673  if (!file.group.empty())
674  continue;
676  fixPath,
677  file.name,
678  Append_false);
679  }
682 }
#define CAST_U32
Definition: cast.h:30
std::string mUpdatesDir
std::string pathJoin(std::string str1, const std::string &str2)
static void addUpdateFile(const std::string &path, const std::string &fixPath, const std::string &file, const Append append)
std::string group
Definition: updatefile.h:49
const std::string xmlUpdateFile("resources.xml")
unsigned int mUpdateIndex
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
Logger * logger
Definition: logger.cpp:95
static void loadManaPlusUpdates(const std::string &dir)
static std::vector< UpdateFile > loadTxtFile(const std::string &fileName)
const bool Append_false
Definition: append.h:29
const std::string txtUpdateFile("resources2.txt")
static void loadMods(const std::string &dir, const std::vector< UpdateFile > &updateFiles)
void log(const char *const log_text,...)
Definition: logger.cpp:243
std::vector< UpdateFile > mUpdateFiles
std::string name
Definition: updatefile.h:45

◆ logic()

void UpdaterWindow::logic ( )
virtual

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented from BasicContainer.

Definition at line 825 of file updaterwindow.cpp.

References _, StaticBrowserBox::addRow(), Label::adjustSize(), BLOCK_END, BLOCK_START, CAST_S32, CAST_SIZE, CAST_U32, config, download(), enable(), Configuration::getBoolValue(), Label::getCaption(), Net::Download::getError(), ScrollArea::getVerticalMaxScroll(), UpdateFile::hash, loadNews(), loadPatch(), loadTxtFile(), loadXMLFile(), Logger::log(), logger, ScrollArea::logic(), mBrowserBox, mCurrentChecksum, mCurrentFile, mDownload, mDownloadComplete, mDownloadMutex, mDownloadProgress, mDownloadStatus, mLabel, mNewLabelCaption, mProgressBar, mScrollArea, mSkipPatches, mStoreInMemory, mTempUpdateFiles, mUpdateFiles, mUpdateHost, mUpdateIndex, mUpdateIndexOffset, mUpdatesDir, mUpdatesDirReal, mUpdateServerPath, mValidateXml, UpdateFile::name, pathJoin(), Label::setCaption(), setLabel(), ProgressBar::setProgress(), ProgressBar::setText(), ScrollArea::setVerticalScrollAmount(), strprintf(), Catch::toString(), txtUpdateFile(), UpdateFile::type, UpdateDownloadStatus::UPDATE_COMPLETE, UpdateDownloadStatus::UPDATE_ERROR, UpdateDownloadStatus::UPDATE_IDLE, UpdateDownloadStatus::UPDATE_LIST, UpdateDownloadStatus::UPDATE_LIST2, UpdateDownloadStatus::UPDATE_NEWS, UpdateDownloadStatus::UPDATE_PATCH, UpdateDownloadStatus::UPDATE_RESOURCES, UpdateDownloadStatus::UPDATE_RESOURCES2, StaticBrowserBox::updateHeight(), updateServer2(), validateFile(), and xmlUpdateFile().

826 {
827  BLOCK_START("UpdaterWindow::logic")
828  // Update Scroll logic
829  mScrollArea->logic();
830 
831  // Synchronize label caption when necessary
832  {
834 
836  {
838  mLabel->adjustSize();
839  }
840 
842  if (!mUpdateFiles.empty() &&
844  {
847  mUpdateFiles.size()) + CAST_S32(
848  mTempUpdateFiles.size()) + 1));
849  }
850  else
851  {
852  mProgressBar->setText("");
853  }
854  }
855 
856  switch (mDownloadStatus)
857  {
859  mBrowserBox->addRow("");
860  // TRANSLATORS: update message
861  mBrowserBox->addRow(_("##1 The update process is incomplete."));
862  // TRANSLATORS: Continues "The update process is incomplete.".
863  mBrowserBox->addRow(_("##1 It is strongly recommended that"));
864  // TRANSLATORS: Begins "It is strongly recommended that".
865  mBrowserBox->addRow(_("##1 you try again later."));
866  if (mDownload != nullptr)
872  break;
874  if (mDownloadComplete)
875  {
876  // Parse current memory buffer as news and dispose of the data
877  loadNews();
878 
879  mValidateXml = true;
881  mStoreInMemory = false;
883  download(); // download() changes mDownloadComplete to false
884  }
885  break;
887  if (mDownloadComplete)
888  {
889  // Parse current memory buffer as news and dispose of the data
890  loadPatch();
891 
893  mUpdatesDir = pathJoin(mUpdatesDir, "fix");
895  mValidateXml = true;
896  mStoreInMemory = false;
898  download();
899  }
900  break;
901 
903  if (mDownloadComplete)
904  {
906  {
909  true);
910 
911  if (mUpdateFiles.empty())
912  {
913  logger->log("Warning this server does not have a %s"
914  " file falling back to %s",
915  xmlUpdateFile.c_str(),
916  txtUpdateFile.c_str());
917 
918  // If the resources.xml file fails,
919  // fall back onto a older version
921  mValidateXml = false;
922  mStoreInMemory = false;
924  download();
925  break;
926  }
927  }
928  else if (mCurrentFile == txtUpdateFile)
929  {
930  mValidateXml = true;
932  txtUpdateFile));
933  }
934  mStoreInMemory = false;
936  }
937  break;
939  if (mDownloadComplete)
940  {
941  if (CAST_SIZE(mUpdateIndex) < mUpdateFiles.size())
942  {
944  if (thisFile.type == "music"
945  && !config.getBoolValue("download-music"))
946  {
947  mUpdateIndex++;
948  break;
949  }
950  mCurrentFile = thisFile.name;
951  std::string checksum;
952  checksum = thisFile.hash;
953  std::stringstream ss(checksum);
954  ss >> std::hex >> mCurrentChecksum;
955 
956  std::ifstream temp(pathJoin(mUpdatesDir,
957  mCurrentFile).c_str());
958 
959  mValidateXml = false;
960  if (!temp.is_open() || !validateFile(pathJoin(
962  mCurrentChecksum))
963  {
964  temp.close();
965  download();
966  }
967  else
968  {
969  temp.close();
970  logger->log("%s already here", mCurrentFile.c_str());
971  }
972  mUpdateIndex++;
973  }
974  else
975  {
976  if (!mSkipPatches)
977  {
978  // Download of updates completed
979  mCurrentFile = "latest.txt";
980  mStoreInMemory = true;
982  mValidateXml = false;
983  download(); // download() changes
984  // mDownloadComplete to false
985  }
986  else
987  {
990  }
991  }
992  }
993  break;
995  if (mDownloadComplete)
996  {
998  {
1001  true);
1002  }
1004  mUpdateIndex = 0;
1005  mValidateXml = true;
1006  mStoreInMemory = false;
1008  download();
1009  }
1010  break;
1012  if (mDownloadComplete)
1013  {
1014  mValidateXml = false;
1015  if (CAST_SIZE(mUpdateIndex)
1016  < mTempUpdateFiles.size())
1017  {
1018  const UpdateFile thisFile = mTempUpdateFiles[mUpdateIndex];
1019  mCurrentFile = thisFile.name;
1020  std::string checksum;
1021  checksum = thisFile.hash;
1022  std::stringstream ss(checksum);
1023  ss >> std::hex >> mCurrentChecksum;
1024 
1025  std::ifstream temp((pathJoin(mUpdatesDir,
1026  mCurrentFile)).c_str());
1027 
1028  if (!temp.is_open() || !validateFile(pathJoin(
1030  mCurrentChecksum))
1031  {
1032  temp.close();
1033  download();
1034  }
1035  else
1036  {
1037  temp.close();
1038  logger->log("%s already here", mCurrentFile.c_str());
1039  }
1040  mUpdateIndex++;
1041  }
1042  else
1043  {
1046  }
1047  }
1048  break;
1051  enable();
1052  // TRANSLATORS: updater window label
1053  setLabel(_("Completed"));
1055  break;
1057  break;
1058  default:
1059  logger->log("UpdaterWindow::logic unknown status: "
1061  break;
1062  }
1063  BLOCK_END("UpdaterWindow::logic")
1064 }
#define CAST_U32
Definition: cast.h:30
#define _(s)
Definition: gettext.h:34
std::string mUpdatesDir
static bool validateFile(const std::string &filePath, const unsigned long hash)
std::string mUpdateServerPath
std::string pathJoin(std::string str1, const std::string &str2)
void setLabel(const std::string &)
#define BLOCK_START(name)
Definition: perfomance.h:78
std::vector< UpdateFile > mTempUpdateFiles
Configuration config
const std::string xmlUpdateFile("resources.xml")
unsigned int mUpdateIndex
StaticBrowserBox * mBrowserBox
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
#define BLOCK_END(name)
Definition: perfomance.h:79
void setVerticalScrollAmount(const int vScroll)
UpdateDownloadStatusT mDownloadStatus
Mutex mDownloadMutex
unsigned long mCurrentChecksum
int getVerticalMaxScroll()
Logger * logger
Definition: logger.cpp:95
static std::vector< UpdateFile > loadTxtFile(const std::string &fileName)
bool getBoolValue(const std::string &key) const
std::string mUpdatesDirReal
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setCaption(const std::string &caption)
Definition: label.cpp:256
const char * getError() const
Definition: download.cpp:213
float mDownloadProgress
std::string hash
Definition: updatefile.h:46
ProgressBar * mProgressBar
void setText(const std::string &str)
ScrollArea * mScrollArea
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string type
Definition: updatefile.h:47
bool mDownloadComplete
const std::string txtUpdateFile("resources2.txt")
unsigned int mUpdateIndexOffset
#define CAST_SIZE
Definition: cast.h:33
void log(const char *const log_text,...)
Definition: logger.cpp:243
std::string mUpdateHost
std::vector< UpdateFile > mUpdateFiles
const std::string updateServer2("http://download.manaplus.org/manaplus/updates/")
void adjustSize()
Definition: label.cpp:192
std::string mCurrentFile
std::string mNewLabelCaption
void setProgress(const float progress)
std::string name
Definition: updatefile.h:45
const std::string & getCaption() const
Definition: label.h:132
Net::Download * mDownload
void addRow(const std::string &row, const bool atTop=false)

◆ memoryWrite()

size_t UpdaterWindow::memoryWrite ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  stream 
)
staticprivate

A libcurl callback for writing to memory.

Definition at line 560 of file updaterwindow.cpp.

References CAST_S32, CAST_SIZE, mDownloadedBytes, and mMemoryBuffer.

Referenced by download().

562 {
563  UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
564  const size_t totalMem = size * nmemb;
565  if (uw == nullptr)
566  return 0;
567  uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
568  CAST_SIZE(uw->mDownloadedBytes) + totalMem));
569  if (uw->mMemoryBuffer != nullptr)
570  {
571  memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
572  uw->mDownloadedBytes += CAST_S32(totalMem);
573  }
574 
575  return totalMem;
576 }
#define CAST_S32
Definition: cast.h:29
char * mMemoryBuffer
#define CAST_SIZE
Definition: cast.h:33

◆ postInit()

void UpdaterWindow::postInit ( )
virtual

Reimplemented from Window.

Definition at line 254 of file updaterwindow.cpp.

References download(), mCancelButton, mUpdateServerPath, Window::postInit(), removeProtocol(), Widget::requestFocus(), Window::setVisible(), and Visible_true.

255 {
260 
261  download();
262 }
std::string & removeProtocol(std::string &url)
const bool Visible_true
Definition: visible.h:29
std::string mUpdateServerPath
virtual void requestFocus()
Definition: widget.cpp:203
Button * mCancelButton
virtual void setVisible(Visible visible)
Definition: window.cpp:766
void postInit()
Definition: window.cpp:241

◆ removeUpdateFile()

void UpdaterWindow::removeUpdateFile ( const std::string &  path,
const std::string &  fixPath,
const std::string &  filerestrict 
)
static

Definition at line 814 of file updaterwindow.cpp.

References pathJoin(), and VirtFs::unmountZip().

Referenced by unloadUpdates().

817 {
818  VirtFs::unmountZip(pathJoin(path, file));
819  const std::string fixFile = pathJoin(fixPath, file);
820  struct stat statbuf;
821  if (stat(fixFile.c_str(), &statbuf) == 0)
822  VirtFs::unmountZip(fixFile);
823 }
std::string pathJoin(std::string str1, const std::string &str2)
bool unmountZip(std::string oldDir)
Definition: fs.cpp:674

◆ setLabel()

void UpdaterWindow::setLabel ( const std::string &  str)

Set's label above progress

Definition at line 286 of file updaterwindow.cpp.

References mDownloadMutex, mNewLabelCaption, and ServerCommandType::str.

Referenced by download(), logic(), and updateProgress().

287 {
288  // Do delayed label text update, since Guichan isn't thread-safe
291 }
Mutex mDownloadMutex
std::string mNewLabelCaption

◆ setProgress()

void UpdaterWindow::setProgress ( const float  p)

Set's progress bar status

Definition at line 279 of file updaterwindow.cpp.

References mDownloadMutex, and mDownloadProgress.

Referenced by updateProgress().

280 {
281  // Do delayed progress bar update, since Guichan isn't thread-safe
283  mDownloadProgress = p;
284 }
Mutex mDownloadMutex
float mDownloadProgress

◆ unloadManaPlusUpdates()

void UpdaterWindow::unloadManaPlusUpdates ( const std::string &  dir)
static

Definition at line 772 of file updaterwindow.cpp.

References CAST_U32, loadXMLFile(), pathJoin(), strStartWith(), VirtFs::unmountZip(), and xmlUpdateFile().

Referenced by unloadUpdates().

773 {
774  const std::string fixPath = dir + "/fix";
775  const STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
776  pathJoin(fixPath, xmlUpdateFile),
777  true);
778 
779  for (unsigned int updateIndex = 0,
780  fsz = CAST_U32(updateFiles.size());
781  updateIndex < fsz;
782  updateIndex++)
783  {
784  std::string name = updateFiles[updateIndex].name;
785  if (strStartWith(name, "manaplus_"))
786  {
787  struct stat statbuf;
788  const std::string file = pathJoin(
789  fixPath, name);
790  if (stat(file.c_str(), &statbuf) == 0)
791  VirtFs::unmountZip(file);
792  }
793  }
794 }
#define CAST_U32
Definition: cast.h:30
bool strStartWith(const std::string &str1, const std::string &str2)
std::string pathJoin(std::string str1, const std::string &str2)
const std::string xmlUpdateFile("resources.xml")
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
bool unmountZip(std::string oldDir)
Definition: fs.cpp:674

◆ unloadMods()

void UpdaterWindow::unloadMods ( const std::string &  dir)
static

Definition at line 1191 of file updaterwindow.cpp.

References FOR_EACH, ModDB::getAll(), ModInfo::getLocalDir(), ConfigurationObject::getValue(), pathJoin(), serverConfig, splitToStringVector(), and VirtFs::unmountDir().

Referenced by Client::stateSwitchLogin1().

1192 {
1193  const ModInfos &mods = ModDB::getAll();
1194  std::string modsString = serverConfig.getValue("mods", "");
1195  StringVect modsList;
1196  splitToStringVector(modsList, modsString, '|');
1197  FOR_EACH (StringVectCIter, it, modsList)
1198  {
1199  const std::string &name = *it;
1200  const ModInfoCIterator modIt = mods.find(name);
1201  if (modIt == mods.end())
1202  continue;
1203  const ModInfo *const mod = (*modIt).second;
1204  if (mod != nullptr)
1205  {
1206  const std::string &localDir = mod->getLocalDir();
1207  if (!localDir.empty())
1208  VirtFs::unmountDir(pathJoin(dir, localDir));
1209  }
1210  }
1211 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
bool unmountDir(std::string oldDir)
Definition: fs.cpp:517
std::string pathJoin(std::string str1, const std::string &str2)
const ModInfos & getAll()
Definition: moddb.cpp:115
std::vector< std::string > StringVect
Definition: stringvector.h:28
Configuration serverConfig
const std::string & getLocalDir() const
Definition: modinfo.h:57
ModInfos::const_iterator ModInfoCIterator
Definition: modinfo.h:69
std::string getValue(const std::string &key, const std::string &deflt) const
std::map< std::string, ModInfo * > ModInfos
Definition: modinfo.h:67

◆ unloadUpdates()

void UpdaterWindow::unloadUpdates ( const std::string &  dir)
static

Definition at line 717 of file updaterwindow.cpp.

References CAST_U32, loadTxtFile(), loadXMLFile(), pathJoin(), removeUpdateFile(), txtUpdateFile(), unloadManaPlusUpdates(), and xmlUpdateFile().

Referenced by Client::stateSwitchLogin1(), and Client::unloadData().

718 {
719  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
720  pathJoin(dir, xmlUpdateFile),
721  true);
722 
723  if (updateFiles.empty())
724  {
725  updateFiles = loadTxtFile(pathJoin(dir,
726  txtUpdateFile));
727  }
728 
729  const std::string fixPath = dir + "/fix";
730  for (unsigned int updateIndex = 0,
731  fsz = CAST_U32(updateFiles.size());
732  updateIndex < fsz;
733  updateIndex++)
734  {
736  fixPath,
737  updateFiles[updateIndex].name);
738  }
740 }
#define CAST_U32
Definition: cast.h:30
std::string pathJoin(std::string str1, const std::string &str2)
const std::string xmlUpdateFile("resources.xml")
static std::vector< UpdateFile > loadXMLFile(const std::string &fileName, const bool loadMods)
static void unloadManaPlusUpdates(const std::string &dir)
static std::vector< UpdateFile > loadTxtFile(const std::string &fileName)
static void removeUpdateFile(const std::string &path, const std::string &fixPath, const std::string &filerestrict)
const std::string txtUpdateFile("resources2.txt")

◆ updateProgress()

int UpdaterWindow::updateProgress ( void *  ptr,
const DownloadStatusT  status,
size_t  dt,
const size_t  dn 
)
staticprivate

A download callback for progress updates.

Definition at line 500 of file updaterwindow.cpp.

References DownloadStatus::Cancelled, CAST_S32, client, DownloadStatus::Complete, DownloadStatus::Error, State::GAME, Client::getState(), mCurrentFile, mDownloadComplete, mDownloadStatus, mMemoryBuffer, setLabel(), setProgress(), Catch::toString(), State::UPDATE, UpdateDownloadStatus::UPDATE_COMPLETE, UpdateDownloadStatus::UPDATE_ERROR, and UpdateDownloadStatus::UPDATE_NEWS.

Referenced by download().

504 {
505  UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
506  if (uw == nullptr)
507  return -1;
508 
509  if (status == DownloadStatus::Complete)
510  {
511  uw->mDownloadComplete = true;
512  }
513  else if (status == DownloadStatus::Error ||
514  status == DownloadStatus::Cancelled)
515  {
518  { // ignoring error in last state (was UPDATE_PATCH)
520  uw->mDownloadComplete = true;
521  free(uw->mMemoryBuffer);
522  uw->mMemoryBuffer = nullptr;
523  }
524  else
525  {
527  }
528  }
529 
530  if (dt == 0u)
531  dt = 1;
532 
533  float progress = static_cast<float>(dn) /
534  static_cast<float>(dt);
535 
536  if (progress != progress)
537  progress = 0.0F; // check for NaN
538  if (progress < 0.0F)
539  progress = 0.0F; // no idea how this could ever happen,
540  // but why not check for it anyway.
541  if (progress > 1.0F)
542  progress = 1.0F;
543 
544  uw->setLabel(std::string(uw->mCurrentFile).append(" (")
545  .append(toString(CAST_S32(progress * 100))).append("%)"));
546 
547  uw->setProgress(progress);
548 
549  if ((client->getState() != State::UPDATE &&
550  client->getState() != State::GAME) ||
552  {
553  // If the action was canceled return an error code to stop the mThread
554  return -1;
555  }
556 
557  return 0;
558 }
void setLabel(const std::string &)
Client * client
Definition: client.cpp:113
UpdateDownloadStatusT mDownloadStatus
#define CAST_S32
Definition: cast.h:29
char * mMemoryBuffer
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
bool mDownloadComplete
StateT getState() const
Definition: client.h:68
std::string mCurrentFile
void setProgress(const float p)

◆ validateFile()

bool UpdaterWindow::validateFile ( const std::string &  filePath,
const unsigned long  hash 
)
staticprivate

Definition at line 1066 of file updaterwindow.cpp.

References Net::Download::fadler32().

Referenced by logic().

1068 {
1069  FILE *const file = fopen(filePath.c_str(), "rb");
1070  if (file == nullptr)
1071  return false;
1072 
1073  const unsigned long adler = Net::Download::fadler32(file);
1074  fclose(file);
1075  return adler == hash;
1076 }
static unsigned long fadler32(FILE *const file)
Definition: download.cpp:121

Field Documentation

◆ mBrowserBox

StaticBrowserBox* UpdaterWindow::mBrowserBox
private

Definition at line 214 of file updaterwindow.h.

Referenced by loadFile(), loadNews(), loadPatch(), logic(), and UpdaterWindow().

◆ mCancelButton

Button* UpdaterWindow::mCancelButton
private

Definition at line 211 of file updaterwindow.h.

Referenced by enable(), keyPressed(), postInit(), and UpdaterWindow().

◆ mCurrentChecksum

unsigned long UpdaterWindow::mCurrentChecksum
private

The Adler32 checksum of the file currently downloading.

Definition at line 193 of file updaterwindow.h.

Referenced by download(), and logic().

◆ mCurrentFile

std::string UpdaterWindow::mCurrentFile
private

The file currently downloading.

Definition at line 183 of file updaterwindow.h.

Referenced by download(), logic(), and updateProgress().

◆ mDownload

Net::Download* UpdaterWindow::mDownload
private

Download handle.

Definition at line 199 of file updaterwindow.h.

Referenced by action(), download(), logic(), and ~UpdaterWindow().

◆ mDownloadComplete

bool UpdaterWindow::mDownloadComplete
private

Flag that show if current download is complete.

Definition at line 237 of file updaterwindow.h.

Referenced by download(), logic(), and updateProgress().

◆ mDownloadedBytes

int UpdaterWindow::mDownloadedBytes
private

Byte count currently downloaded in mMemoryBuffer.

Definition at line 221 of file updaterwindow.h.

Referenced by loadNews(), loadPatch(), and memoryWrite().

◆ mDownloadMutex

Mutex UpdaterWindow::mDownloadMutex
private

Definition at line 190 of file updaterwindow.h.

Referenced by logic(), setLabel(), and setProgress().

◆ mDownloadProgress

float UpdaterWindow::mDownloadProgress
private

The new progress value to be set in the logic method.

Definition at line 172 of file updaterwindow.h.

Referenced by logic(), and setProgress().

◆ mDownloadStatus

UpdateDownloadStatusT UpdaterWindow::mDownloadStatus
private

Status of the current download.

Definition at line 218 of file updaterwindow.h.

Referenced by action(), download(), keyPressed(), logic(), and updateProgress().

◆ mItemLinkHandler

ItemLinkHandler* UpdaterWindow::mItemLinkHandler
private

Definition at line 209 of file updaterwindow.h.

Referenced by UpdaterWindow(), and ~UpdaterWindow().

◆ mLabel

Label* UpdaterWindow::mLabel
private

Definition at line 210 of file updaterwindow.h.

Referenced by logic(), and UpdaterWindow().

◆ mLoadUpdates

bool UpdaterWindow::mLoadUpdates
private

Tells ~UpdaterWindow() if it should load updates

Definition at line 243 of file updaterwindow.h.

Referenced by ~UpdaterWindow().

◆ mMemoryBuffer

char* UpdaterWindow::mMemoryBuffer
private

Buffer for files downloaded to memory.

Definition at line 196 of file updaterwindow.h.

Referenced by loadNews(), loadPatch(), memoryWrite(), updateProgress(), and ~UpdaterWindow().

◆ mNewLabelCaption

std::string UpdaterWindow::mNewLabelCaption
private

The new label caption to be set in the logic method.

Definition at line 186 of file updaterwindow.h.

Referenced by logic(), and setLabel().

◆ mPlayButton

Button* UpdaterWindow::mPlayButton
private

Definition at line 212 of file updaterwindow.h.

Referenced by enable(), keyPressed(), and UpdaterWindow().

◆ mProgressBar

ProgressBar* UpdaterWindow::mProgressBar
private

Definition at line 213 of file updaterwindow.h.

Referenced by logic(), and UpdaterWindow().

◆ mScrollArea

ScrollArea* UpdaterWindow::mScrollArea
private

Definition at line 215 of file updaterwindow.h.

Referenced by loadNews(), loadPatch(), logic(), and UpdaterWindow().

◆ mSkipPatches

bool UpdaterWindow::mSkipPatches
private

Definition at line 247 of file updaterwindow.h.

Referenced by logic(), and UpdaterWindow().

◆ mStoreInMemory

bool UpdaterWindow::mStoreInMemory
private

A flag to indicate whether to use a memory buffer or a regular file.

Definition at line 234 of file updaterwindow.h.

Referenced by download(), and logic().

◆ mTempUpdateFiles

std::vector<UpdateFile> UpdaterWindow::mTempUpdateFiles
private

List of temp files to download.

Definition at line 205 of file updaterwindow.h.

Referenced by logic().

◆ mUpdateFiles

std::vector<UpdateFile> UpdaterWindow::mUpdateFiles
private

List of files to download.

Definition at line 202 of file updaterwindow.h.

Referenced by loadUpdates(), and logic().

◆ mUpdateHost

std::string UpdaterWindow::mUpdateHost
private

Host where we get the updated files.

Definition at line 175 of file updaterwindow.h.

Referenced by download(), logic(), and UpdaterWindow().

◆ mUpdateIndex

unsigned int UpdaterWindow::mUpdateIndex
private

Index of the file to be downloaded.

Definition at line 224 of file updaterwindow.h.

Referenced by loadUpdates(), and logic().

◆ mUpdateIndexOffset

unsigned int UpdaterWindow::mUpdateIndexOffset
private

Index offset for disaplay downloaded file.

Definition at line 227 of file updaterwindow.h.

Referenced by logic().

◆ mUpdatesDir

std::string UpdaterWindow::mUpdatesDir
private

Place where the updates are stored (absolute path).

Definition at line 178 of file updaterwindow.h.

Referenced by download(), loadFile(), loadNews(), loadUpdates(), and logic().

◆ mUpdatesDirReal

std::string UpdaterWindow::mUpdatesDirReal
private

Definition at line 180 of file updaterwindow.h.

Referenced by logic().

◆ mUpdateServerPath

std::string UpdaterWindow::mUpdateServerPath
private

Definition at line 207 of file updaterwindow.h.

Referenced by download(), logic(), and postInit().

◆ mUpdateType

UpdateTypeT UpdaterWindow::mUpdateType
private

Definition at line 229 of file updaterwindow.h.

Referenced by enable().

◆ mUserCancel

bool UpdaterWindow::mUserCancel
private

Flag that show if the user has canceled the update.

Definition at line 240 of file updaterwindow.h.

Referenced by action().

◆ mValidateXml

bool UpdaterWindow::mValidateXml
private

Definition at line 245 of file updaterwindow.h.

Referenced by download(), and logic().


The documentation for this class was generated from the following files: