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, const Modal modal, Window *const parent, std::string skin)
 
 ~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, int offsetY)
 
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, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
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)
 
 ~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)
 
 ~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)
 
 ~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) 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) const
 
bool getOptionBool (const std::string &name, const bool def) 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 169 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.

172  :
173  // TRANSLATORS: updater window name
174  Window(_("Updating..."), Modal_false, nullptr, "update.xml"),
175  ActionListener(),
176  KeyListener(),
177  mDownloadProgress(0.0F),
178  mUpdateHost(updateHost),
179  mUpdatesDir(updatesDir),
180  mUpdatesDirReal(updatesDir),
181  mCurrentFile("news.txt"),
183  mDownloadMutex(),
184  mCurrentChecksum(0),
185  mMemoryBuffer(nullptr),
186  mDownload(nullptr),
187  mUpdateFiles(),
191  // TRANSLATORS: updater window label
192  mLabel(new Label(this, _("Connecting..."))),
193  // TRANSLATORS: updater window button
194  mCancelButton(new Button(this, _("Cancel"), "cancel", BUTTON_SKIN, this)),
195  // TRANSLATORS: updater window button
196  mPlayButton(new Button(this, _("Play"), "play", BUTTON_SKIN, this)),
197  mProgressBar(new ProgressBar(this, 0.0, 310, 0,
199  "updateprogressbar.xml", "updateprogressbar_fill.xml")),
201  "browserbox.xml")),
203  Opaque_true, "update_background.xml")),
205  mDownloadedBytes(0),
206  mUpdateIndex(0),
208  mUpdateType(updateType),
209  mStoreInMemory(true),
210  mDownloadComplete(true),
211  mUserCancel(false),
212  mLoadUpdates(applyUpdates),
213  mValidateXml(false),
214  mSkipPatches(false)
215 {
216  setWindowName("UpdaterWindow");
217  setResizable(true);
218  setDefaultSize(450, 400, ImagePosition::CENTER, 0, 0);
219  setMinWidth(310);
220  setMinHeight(220);
221 
226  mBrowserBox->setEnableKeys(true);
227  mBrowserBox->setEnableTabs(true);
228  mPlayButton->setEnabled(false);
229 
230  ContainerPlacer placer(nullptr, nullptr);
231  placer = getPlacer(0, 0);
232 
233  placer(0, 0, mScrollArea, 5, 3).setPadding(3);
234  placer(0, 3, mLabel, 5, 1);
235  placer(0, 4, mProgressBar, 5, 1);
236  placer(3, 5, mCancelButton, 1, 1);
237  placer(4, 5, mPlayButton, 1, 1);
238 
239  Layout &layout = getLayout();
240  layout.setRowHeight(0, LayoutType::SET);
241 
242  addKeyListener(this);
243 
244  if (mUpdateHost.empty())
245  {
246  const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
247  if (mirrors.begin() != mirrors.end())
248  mUpdateHost = *mirrors.begin();
249  mSkipPatches = true;
250  }
251 
252  loadWindowState();
253 }
void setDefaultSize()
Definition: window.cpp:1193
#define _(s)
Definition: gettext.h:34
std::string mUpdatesDir
void loadWindowState()
Definition: window.cpp:1082
std::string mUpdateServerPath
void setProcessVars(const bool n)
UpdateTypeT mUpdateType
void setMinWidth(const int width)
Definition: window.cpp:586
void setEnableKeys(const bool n)
std::vector< UpdateFile > mTempUpdateFiles
Definition: button.h:96
unsigned int mUpdateIndex
StaticBrowserBox * mBrowserBox
UpdateDownloadStatusT mDownloadStatus
void setSmoothProgress(bool smoothProgress)
Definition: progressbar.h:124
std::vector< std::string > updateMirrors
Definition: settings.h:126
Mutex mDownloadMutex
unsigned long mCurrentChecksum
Button * mPlayButton
Settings settings
Definition: settings.cpp:31
void setLinkHandler(LinkHandler *linkHandler)
std::string mUpdatesDirReal
const std::string BUTTON_SKIN
Definition: button.h:88
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:599
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1386
void setEnabled(const bool enabled)
Definition: widget.h:351
ProgressBar * mProgressBar
ItemLinkHandler * mItemLinkHandler
Layout & getLayout()
Definition: window.cpp:1360
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:622
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
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:108
std::string mNewLabelCaption
void setWindowName(const std::string &name)
Definition: window.h:354
Net::Download * mDownload

◆ ~UpdaterWindow()

UpdaterWindow::~UpdaterWindow ( )

Destructor

Definition at line 265 of file updaterwindow.cpp.

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

266 {
267  if (mLoadUpdates)
268  loadUpdates();
269 
270  if (mDownload != nullptr)
271  {
272  mDownload->cancel();
273 
275  }
276  free(mMemoryBuffer);
278 }
unsigned cancel
Definition: download.h:124
#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 311 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().

312 {
313  const std::string &eventId = event.getId();
314  if (eventId == "cancel")
315  {
316  // Register the user cancel
317  mUserCancel = true;
318  // Skip the updating process
320  {
321  if (mDownload != nullptr)
322  mDownload->cancel();
324  }
325  }
326  else if (eventId == "play")
327  {
328  if (client->getState() != State::GAME)
330  else
331  deleteSelf();
332  }
333 }
void setState(const StateT state)
Definition: client.h:65
unsigned cancel
Definition: download.h:124
Client * client
Definition: client.cpp:117
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 798 of file updaterwindow.cpp.

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

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

802 {
803  const std::string tmpPath = pathJoin(path, file);
804  if (append == Append_false)
805  VirtFs::mountZip(tmpPath, append);
806 
807  const std::string fixFile = pathJoin(fixPath, file);
808  struct stat statbuf;
809  if (stat(fixFile.c_str(), &statbuf) == 0)
810  VirtFs::mountZip(fixFile, append);
811 
812  if (append == Append_true)
813  VirtFs::mountZip(tmpPath, append);
814 }
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 1218 of file updaterwindow.cpp.

References Window::scheduleDelete().

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

1219 {
1220  scheduleDelete();
1221  updaterWindow = nullptr;
1222 }
UpdaterWindow * updaterWindow
virtual void scheduleDelete()
Definition: window.cpp:826

◆ download()

void UpdaterWindow::download ( )
private

Definition at line 579 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().

580 {
581  if (mDownload != nullptr)
582  {
583  mDownload->cancel();
584  delete mDownload;
585  }
587  {
588  mDownload = new Net::Download(this,
589  branding.getStringValue("updateMirror1") + mCurrentFile,
591  true, false, mValidateXml);
592  for (int f = 2; f < 8; f ++)
593  {
594  const std::string url = branding.getStringValue(
595  "updateMirror" + toString(f));
596  if (!url.empty())
598  }
599  }
600  else
601  {
602  mDownload = new Net::Download(this,
604  &updateProgress,
605  false, false, mValidateXml);
606 
609  {
610  const std::string str = urlJoin(mUpdateServerPath, mCurrentFile);
614  }
615  else
616  {
617  const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
618  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mirrors)
619  {
621  mCurrentFile));
622  }
623  }
624  }
625 
626  if (mStoreInMemory)
627  {
629  }
630  else
631  {
633  {
636  }
637  else
638  {
640  mCurrentFile),
641  -1);
642  }
643  }
644 
646  mDownload->noCache();
647 
648  setLabel(mCurrentFile + " (0%)");
649  mDownloadComplete = false;
650 
651  mDownload->start();
652 }
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:87
const std::string updateServer3("http://download2.manaplus.org/manaplus/updates/")
std::string mUpdateServerPath
unsigned cancel
Definition: download.h:124
std::string pathJoin(std::string str1, const std::string &str2)
void setWriteFunction(WriteFunction write)
Definition: download.cpp:181
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:126
unsigned long mCurrentChecksum
void setFile(const std::string &filename, const int64_t adler32)
Definition: download.cpp:165
Settings settings
Definition: settings.cpp:31
const std::string updateServer5("http://download3.manaplus.org/manaplus/updates/")
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:187
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
void noCache()
Definition: download.cpp:159
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 294 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().

295 {
296  mCancelButton->setEnabled(false);
297  mPlayButton->setEnabled(true);
299 
300  if (client->getState() != State::GAME)
301  {
302  if ((mUpdateType & UpdateType::Close) != 0)
304  }
305  else
306  {
307  deleteSelf();
308  }
309 }
void setState(const StateT state)
Definition: client.h:65
UpdateTypeT mUpdateType
Client * client
Definition: client.cpp:117
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 1083 of file updaterwindow.cpp.

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

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

1084 {
1085  int size = 0;
1086  const char *const buf = VirtFs::loadFile(filePath, size);
1087  if (buf == nullptr)
1088  return 0;
1089  unsigned long res = Net::Download::adlerBuffer(buf, size);
1090  delete [] buf;
1091  return res;
1092 }
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:146

◆ 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 335 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.

336 {
337  const InputActionT actionId = event.getActionId();
338  if (actionId == InputAction::GUI_CANCEL)
339  {
341  if (client->getState() != State::GAME)
343  else
344  deleteSelf();
345  }
346  else if (actionId == InputAction::GUI_SELECT ||
347  actionId == InputAction::GUI_SELECT2)
348  {
352  {
354  }
355  else
356  {
358  }
359  }
360 }
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:117
UpdateDownloadStatusT mDownloadStatus
Button * mPlayButton
InputAction ::T InputActionT
Definition: inputaction.h:715
Button * mCancelButton
StateT getState() const
Definition: client.h:68

◆ loadDirMods()

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

Definition at line 1169 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().

1170 {
1171  ModDB::load();
1172  const ModInfos &mods = ModDB::getAll();
1173 
1174  std::string modsString = serverConfig.getValue("mods", "");
1175  StringVect modsList;
1176  splitToStringVector(modsList, modsString, '|');
1177  FOR_EACH (StringVectCIter, it, modsList)
1178  {
1179  const std::string &name = *it;
1180  const ModInfoCIterator modIt = mods.find(name);
1181  if (modIt == mods.end())
1182  continue;
1183  const ModInfo *const mod = (*modIt).second;
1184  if (mod != nullptr)
1185  {
1186  const std::string &localDir = mod->getLocalDir();
1187  if (!localDir.empty())
1188  {
1189  VirtFs::mountDir(pathJoin(dir, localDir),
1190  Append_false);
1191  }
1192  }
1193  }
1194 }
#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 1094 of file updaterwindow.cpp.

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

1095 {
1097  trim(file);
1098 
1099  StringVect lines;
1100  Files::loadTextFileLocal(mUpdatesDir + "/local/help/news.txt", lines);
1101 
1102  for (size_t i = 0, sz = lines.size(); i < sz; ++i)
1103  mBrowserBox->addRow(lines[i], false);
1105 }
std::string mUpdatesDir
bool loadTextFileLocal(const std::string &fileName, StringVect &lines)
Definition: files.cpp:228
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)

◆ loadLocalUpdates()

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

Definition at line 686 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().

687 {
688  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
689  pathJoin(dir, xmlUpdateFile),
690  false);
691 
692  if (updateFiles.empty())
693  {
694  logger->log("Warning this server does not have a"
695  " %s file falling back to %s", xmlUpdateFile.c_str(),
696  txtUpdateFile.c_str());
697  updateFiles = loadTxtFile(pathJoin(dir,
698  txtUpdateFile));
699  }
700 
701  const std::string fixPath = dir + "/fix";
702  for (unsigned int updateIndex = 0,
703  fsz = CAST_U32(updateFiles.size());
704  updateIndex < fsz;
705  updateIndex++)
706  {
707  const UpdateFile &file = updateFiles[updateIndex];
708  if (!file.group.empty())
709  continue;
711  fixPath,
712  file.name,
713  Append_false);
714  }
715  loadManaPlusUpdates(dir);
716  loadMods(dir, updateFiles);
717 }
#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:88
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:264
std::string name
Definition: updatefile.h:45

◆ loadManaPlusUpdates()

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

Definition at line 744 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().

745 {
746  std::string fixPath = dir + "/fix";
747  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
748  pathJoin(fixPath, xmlUpdateFile),
749  false);
750 
751  for (unsigned int updateIndex = 0,
752  fsz = CAST_U32(updateFiles.size());
753  updateIndex < fsz;
754  updateIndex++)
755  {
756  const UpdateFile &file = updateFiles[updateIndex];
757  if (!file.group.empty())
758  continue;
759  const std::string name = file.name;
760  if (strStartWith(name, "manaplus_"))
761  {
762  struct stat statbuf;
763  std::string fileName = pathJoin(fixPath,
764  name);
765  if (stat(fileName.c_str(), &statbuf) == 0)
766  {
767  VirtFs::mountZip(fileName,
768  Append_false);
769  }
770  }
771  }
772 }
#define CAST_U32
Definition: cast.h:30
bool strStartWith(const std::string &str1, const std::string &str2)
std::string fileName
Definition: testmain.cpp:38
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 1107 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().

1109 {
1110  ModDB::load();
1111  std::string modsString = serverConfig.getValue("mods", "");
1112  std::set<std::string> modsList;
1113  splitToStringSet(modsList, modsString, '|');
1114 
1115  const std::string fixPath = dir + "/fix";
1116  for (unsigned int updateIndex = 0,
1117  fsz = CAST_U32(updateFiles.size());
1118  updateIndex < fsz;
1119  updateIndex ++)
1120  {
1121  const UpdateFile &file = updateFiles[updateIndex];
1122  if (file.group.empty())
1123  continue;
1124  const std::set<std::string>::const_iterator
1125  it = modsList.find(file.group);
1126  if (it != modsList.end())
1127  {
1129  fixPath,
1130  file.name,
1131  Append_false);
1132  }
1133  }
1134 
1135  STD_VECTOR<UpdateFile> updateFiles2 = loadXMLFile(
1136  pathJoin(fixPath, xmlUpdateFile),
1137  true);
1138 
1139  for (unsigned int updateIndex = 0,
1140  fsz = CAST_U32(updateFiles2.size());
1141  updateIndex < fsz;
1142  updateIndex++)
1143  {
1144  const UpdateFile &file = updateFiles2[updateIndex];
1145  if (file.group.empty())
1146  continue;
1147  std::string name = file.name;
1148  if (strStartWith(name, "manaplus_"))
1149  {
1150  const std::set<std::string>::const_iterator
1151  it = modsList.find(file.group);
1152  if (it != modsList.end())
1153  {
1154  struct stat statbuf;
1155  std::string fileName = pathJoin(fixPath,
1156  name);
1157  if (stat(fileName.c_str(), &statbuf) == 0)
1158  {
1159  VirtFs::mountZip(fileName,
1160  Append_false);
1161  }
1162  }
1163  }
1164  }
1165 
1166  loadDirMods(dir + "/local/");
1167 }
#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:38
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 362 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().

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

◆ loadPatch()

void UpdaterWindow::loadPatch ( )

Definition at line 431 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().

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

◆ loadUpdates()

void UpdaterWindow::loadUpdates ( )
private

Loads the updates this window has gotten into the resource manager

Definition at line 654 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().

655 {
656  if (mUpdateFiles.empty())
657  { // updates not downloaded
659  false);
660  if (mUpdateFiles.empty())
661  {
662  logger->log("Warning this server does not have a"
663  " %s file falling back to %s", xmlUpdateFile.c_str(),
664  txtUpdateFile.c_str());
666  txtUpdateFile));
667  }
668  }
669 
670  std::string fixPath = mUpdatesDir + "/fix";
671  const unsigned sz = CAST_U32(mUpdateFiles.size());
672  for (mUpdateIndex = 0; mUpdateIndex < sz; mUpdateIndex++)
673  {
674  const UpdateFile &file = mUpdateFiles[mUpdateIndex];
675  if (!file.group.empty())
676  continue;
678  fixPath,
679  file.name,
680  Append_false);
681  }
684 }
#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:88
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:264
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 827 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().

828 {
829  BLOCK_START("UpdaterWindow::logic")
830  // Update Scroll logic
831  mScrollArea->logic();
832 
833  // Synchronize label caption when necessary
834  {
836 
838  {
840  mLabel->adjustSize();
841  }
842 
844  if (!mUpdateFiles.empty() &&
846  {
849  mUpdateFiles.size()) + CAST_S32(
850  mTempUpdateFiles.size()) + 1));
851  }
852  else
853  {
854  mProgressBar->setText("");
855  }
856  }
857 
858  switch (mDownloadStatus)
859  {
861  mBrowserBox->addRow("", false);
862  // TRANSLATORS: update message
863  mBrowserBox->addRow(_("##1 The update process is incomplete."),
864  false);
865  // TRANSLATORS: Continues "The update process is incomplete.".
866  mBrowserBox->addRow(_("##1 It is strongly recommended that"),
867  false);
868  // TRANSLATORS: Begins "It is strongly recommended that".
869  mBrowserBox->addRow(_("##1 you try again later."),
870  false);
871  if (mDownload != nullptr)
872  mBrowserBox->addRow(mDownload->getError(), false);
877  break;
879  if (mDownloadComplete)
880  {
881  // Parse current memory buffer as news and dispose of the data
882  loadNews();
883 
884  mValidateXml = true;
886  mStoreInMemory = false;
888  download(); // download() changes mDownloadComplete to false
889  }
890  break;
892  if (mDownloadComplete)
893  {
894  // Parse current memory buffer as news and dispose of the data
895  loadPatch();
896 
898  mUpdatesDir = pathJoin(mUpdatesDir, "fix");
900  mValidateXml = true;
901  mStoreInMemory = false;
903  download();
904  }
905  break;
906 
908  if (mDownloadComplete)
909  {
911  {
914  true);
915 
916  if (mUpdateFiles.empty())
917  {
918  logger->log("Warning this server does not have a %s"
919  " file falling back to %s",
920  xmlUpdateFile.c_str(),
921  txtUpdateFile.c_str());
922 
923  // If the resources.xml file fails,
924  // fall back onto a older version
926  mValidateXml = false;
927  mStoreInMemory = false;
929  download();
930  break;
931  }
932  }
933  else if (mCurrentFile == txtUpdateFile)
934  {
935  mValidateXml = true;
937  txtUpdateFile));
938  }
939  mStoreInMemory = false;
941  }
942  break;
944  if (mDownloadComplete)
945  {
946  if (CAST_SIZE(mUpdateIndex) < mUpdateFiles.size())
947  {
949  if (thisFile.type == "music"
950  && !config.getBoolValue("download-music"))
951  {
952  mUpdateIndex++;
953  break;
954  }
955  mCurrentFile = thisFile.name;
956  std::string checksum;
957  checksum = thisFile.hash;
958  std::stringstream ss(checksum);
959  ss >> std::hex >> mCurrentChecksum;
960 
961  std::ifstream temp(pathJoin(mUpdatesDir,
962  mCurrentFile).c_str());
963 
964  mValidateXml = false;
965  if (!temp.is_open() || !validateFile(pathJoin(
967  mCurrentChecksum))
968  {
969  temp.close();
970  download();
971  }
972  else
973  {
974  temp.close();
975  logger->log("%s already here", mCurrentFile.c_str());
976  }
977  mUpdateIndex++;
978  }
979  else
980  {
981  if (!mSkipPatches)
982  {
983  // Download of updates completed
984  mCurrentFile = "latest.txt";
985  mStoreInMemory = true;
987  mValidateXml = false;
988  download(); // download() changes
989  // mDownloadComplete to false
990  }
991  else
992  {
995  }
996  }
997  }
998  break;
1000  if (mDownloadComplete)
1001  {
1002  if (mCurrentFile == xmlUpdateFile)
1003  {
1006  true);
1007  }
1009  mUpdateIndex = 0;
1010  mValidateXml = true;
1011  mStoreInMemory = false;
1013  download();
1014  }
1015  break;
1017  if (mDownloadComplete)
1018  {
1019  mValidateXml = false;
1020  if (CAST_SIZE(mUpdateIndex)
1021  < mTempUpdateFiles.size())
1022  {
1023  const UpdateFile thisFile = mTempUpdateFiles[mUpdateIndex];
1024  mCurrentFile = thisFile.name;
1025  std::string checksum;
1026  checksum = thisFile.hash;
1027  std::stringstream ss(checksum);
1028  ss >> std::hex >> mCurrentChecksum;
1029 
1030  std::ifstream temp((pathJoin(mUpdatesDir,
1031  mCurrentFile)).c_str());
1032 
1033  if (!temp.is_open() || !validateFile(pathJoin(
1035  mCurrentChecksum))
1036  {
1037  temp.close();
1038  download();
1039  }
1040  else
1041  {
1042  temp.close();
1043  logger->log("%s already here", mCurrentFile.c_str());
1044  }
1045  mUpdateIndex++;
1046  }
1047  else
1048  {
1051  }
1052  }
1053  break;
1056  enable();
1057  // TRANSLATORS: updater window label
1058  setLabel(_("Completed"));
1060  break;
1062  break;
1063  default:
1064  logger->log("UpdaterWindow::logic unknown status: "
1066  break;
1067  }
1068  BLOCK_END("UpdaterWindow::logic")
1069 }
#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:88
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:261
const char * getError() const
Definition: download.cpp:217
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:264
std::string mUpdateHost
std::vector< UpdateFile > mUpdateFiles
const std::string updateServer2("http://download.manaplus.org/manaplus/updates/")
void adjustSize()
Definition: label.cpp:197
std::string mCurrentFile
std::string mNewLabelCaption
void setProgress(const float progress)
std::string name
Definition: updatefile.h:45
void addRow(const std::string &row, const bool atTop)
const std::string & getCaption() const
Definition: label.h:132
Net::Download * mDownload

◆ 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 561 of file updaterwindow.cpp.

References CAST_S32, CAST_SIZE, mDownloadedBytes, and mMemoryBuffer.

Referenced by download().

563 {
564  UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
565  const size_t totalMem = size * nmemb;
566  if (uw == nullptr)
567  return 0;
568  uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
569  CAST_SIZE(uw->mDownloadedBytes) + totalMem));
570  if (uw->mMemoryBuffer != nullptr)
571  {
572  memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
573  uw->mDownloadedBytes += CAST_S32(totalMem);
574  }
575 
576  return totalMem;
577 }
#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 255 of file updaterwindow.cpp.

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

256 {
261 
262  download();
263 }
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:773
void postInit()
Definition: window.cpp:248

◆ removeUpdateFile()

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

Definition at line 816 of file updaterwindow.cpp.

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

Referenced by unloadUpdates().

819 {
820  VirtFs::unmountZip(pathJoin(path, file));
821  const std::string fixFile = pathJoin(fixPath, file);
822  struct stat statbuf;
823  if (stat(fixFile.c_str(), &statbuf) == 0)
824  VirtFs::unmountZip(fixFile);
825 }
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 287 of file updaterwindow.cpp.

References mDownloadMutex, mNewLabelCaption, and ServerCommandType::str.

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

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

◆ setProgress()

void UpdaterWindow::setProgress ( const float  p)

Set's progress bar status

Definition at line 280 of file updaterwindow.cpp.

References mDownloadMutex, and mDownloadProgress.

Referenced by updateProgress().

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

◆ unloadManaPlusUpdates()

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

Definition at line 774 of file updaterwindow.cpp.

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

Referenced by unloadUpdates().

775 {
776  const std::string fixPath = dir + "/fix";
777  const STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
778  pathJoin(fixPath, xmlUpdateFile),
779  true);
780 
781  for (unsigned int updateIndex = 0,
782  fsz = CAST_U32(updateFiles.size());
783  updateIndex < fsz;
784  updateIndex++)
785  {
786  std::string name = updateFiles[updateIndex].name;
787  if (strStartWith(name, "manaplus_"))
788  {
789  struct stat statbuf;
790  const std::string file = pathJoin(
791  fixPath, name);
792  if (stat(file.c_str(), &statbuf) == 0)
793  VirtFs::unmountZip(file);
794  }
795  }
796 }
#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 1196 of file updaterwindow.cpp.

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

Referenced by Client::stateSwitchLogin1().

1197 {
1198  const ModInfos &mods = ModDB::getAll();
1199  std::string modsString = serverConfig.getValue("mods", "");
1200  StringVect modsList;
1201  splitToStringVector(modsList, modsString, '|');
1202  FOR_EACH (StringVectCIter, it, modsList)
1203  {
1204  const std::string &name = *it;
1205  const ModInfoCIterator modIt = mods.find(name);
1206  if (modIt == mods.end())
1207  continue;
1208  const ModInfo *const mod = (*modIt).second;
1209  if (mod != nullptr)
1210  {
1211  const std::string &localDir = mod->getLocalDir();
1212  if (!localDir.empty())
1213  VirtFs::unmountDir(pathJoin(dir, localDir));
1214  }
1215  }
1216 }
#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 719 of file updaterwindow.cpp.

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

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

720 {
721  STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
722  pathJoin(dir, xmlUpdateFile),
723  true);
724 
725  if (updateFiles.empty())
726  {
727  updateFiles = loadTxtFile(pathJoin(dir,
728  txtUpdateFile));
729  }
730 
731  const std::string fixPath = dir + "/fix";
732  for (unsigned int updateIndex = 0,
733  fsz = CAST_U32(updateFiles.size());
734  updateIndex < fsz;
735  updateIndex++)
736  {
738  fixPath,
739  updateFiles[updateIndex].name);
740  }
742 }
#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 501 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().

505 {
506  UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
507  if (uw == nullptr)
508  return -1;
509 
510  if (status == DownloadStatus::Complete)
511  {
512  uw->mDownloadComplete = true;
513  }
514  else if (status == DownloadStatus::Error ||
515  status == DownloadStatus::Cancelled)
516  {
519  { // ignoring error in last state (was UPDATE_PATCH)
521  uw->mDownloadComplete = true;
522  free(uw->mMemoryBuffer);
523  uw->mMemoryBuffer = nullptr;
524  }
525  else
526  {
528  }
529  }
530 
531  if (dt == 0u)
532  dt = 1;
533 
534  float progress = static_cast<float>(dn) /
535  static_cast<float>(dt);
536 
537  if (progress != progress)
538  progress = 0.0F; // check for NaN
539  if (progress < 0.0F)
540  progress = 0.0F; // no idea how this could ever happen,
541  // but why not check for it anyway.
542  if (progress > 1.0F)
543  progress = 1.0F;
544 
545  uw->setLabel(std::string(uw->mCurrentFile).append(" (")
546  .append(toString(CAST_S32(progress * 100))).append("%)"));
547 
548  uw->setProgress(progress);
549 
550  if ((client->getState() != State::UPDATE &&
551  client->getState() != State::GAME) ||
553  {
554  // If the action was canceled return an error code to stop the mThread
555  return -1;
556  }
557 
558  return 0;
559 }
void setLabel(const std::string &)
Client * client
Definition: client.cpp:117
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 1071 of file updaterwindow.cpp.

References Net::Download::fadler32().

Referenced by logic().

1073 {
1074  FILE *const file = fopen(filePath.c_str(), "rb");
1075  if (file == nullptr)
1076  return false;
1077 
1078  const unsigned long adler = Net::Download::fadler32(file);
1079  fclose(file);
1080  return adler == hash;
1081 }
static unsigned long fadler32(FILE *const file)
Definition: download.cpp:122

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: