summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-20 13:18:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-20 13:18:47 +0300
commit0369cb5dc2e5dae4acdb0753c3b309ef874c96ae (patch)
treead49bd867bc44ad953c49b43df9c4e2c2705aa34
parent0ad3a821e42471a052027419336df2132613e9f3 (diff)
downloadmanaplus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.gz
manaplus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.bz2
manaplus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.xz
manaplus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.zip
Move downloadstatus into separate file.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/commands.cpp6
-rw-r--r--src/gui/windows/serverdialog.cpp6
-rw-r--r--src/gui/windows/serverdialog.h2
-rw-r--r--src/gui/windows/updaterwindow.cpp8
-rw-r--r--src/gui/windows/updaterwindow.h2
-rw-r--r--src/net/download.cpp14
-rw-r--r--src/net/download.h15
-rw-r--r--src/net/downloadstatus.h38
10 files changed, 62 insertions, 31 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a7c41865e..8d3762bc9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -479,6 +479,7 @@ SET(SRCS
net/chathandler.h
net/download.cpp
net/download.h
+ net/downloadstatus.h
net/gamehandler.h
net/generalhandler.h
net/guildhandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 00b56811a..fcfad6e59 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -591,6 +591,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
net/chathandler.h \
net/download.cpp \
net/download.h \
+ net/downloadstatus.h \
net/gamehandler.h \
net/generalhandler.h \
net/guildhandler.h \
diff --git a/src/commands.cpp b/src/commands.cpp
index b434ba9ca..f4ead27e7 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1303,15 +1303,15 @@ struct UploadChatInfo
};
static int uploadUpdate(void *ptr,
- DownloadStatus status,
+ DownloadStatus::Type status,
size_t total A_UNUSED,
size_t remaining A_UNUSED)
{
- if (status == DOWNLOAD_STATUS_IDLE || status == DOWNLOAD_STATUS_STARTING)
+ if (status == DownloadStatus::IDLE || status == DownloadStatus::STARTING)
return 0;
UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr);
- if (status == DOWNLOAD_STATUS_COMPLETE)
+ if (status == DownloadStatus::COMPLETE)
{
ChatTab *const tab = info->tab;
if (chatWindow && (!tab || chatWindow->isTabPresent(tab)))
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index cc0a4f184..a56c79a3b 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -680,10 +680,10 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
config.setValue("MostUsedServerName" + toString(savedServerCount), "");
}
-int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,
+int ServerDialog::downloadUpdate(void *ptr, DownloadStatus::Type status,
size_t total, size_t remaining)
{
- if (!ptr || status == DOWNLOAD_STATUS_CANCELLED)
+ if (!ptr || status == DownloadStatus::CANCELLED)
return -1;
ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
@@ -692,7 +692,7 @@ int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,
if (!sd->mDownload)
return -1;
- if (status == DOWNLOAD_STATUS_COMPLETE)
+ if (status == DownloadStatus::COMPLETE)
{
finished = true;
}
diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h
index 88b6a7caf..e2ab64ada 100644
--- a/src/gui/windows/serverdialog.h
+++ b/src/gui/windows/serverdialog.h
@@ -114,7 +114,7 @@ class ServerDialog final : public Window,
bool needUpdateServers() const;
- static int downloadUpdate(void *ptr, DownloadStatus status,
+ static int downloadUpdate(void *ptr, DownloadStatus::Type status,
size_t total, size_t remaining);
Mutex mMutex;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 2735f85dc..4e0f609ac 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -456,19 +456,19 @@ void UpdaterWindow::loadPatch()
mScrollArea->setVerticalScrollAmount(0);
}
-int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status,
+int UpdaterWindow::updateProgress(void *ptr, DownloadStatus::Type status,
size_t dt, size_t dn)
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
if (!uw)
return -1;
- if (status == DOWNLOAD_STATUS_COMPLETE)
+ if (status == DownloadStatus::COMPLETE)
{
uw->mDownloadComplete = true;
}
- else if (status == DOWNLOAD_STATUS_ERROR ||
- status == DOWNLOAD_STATUS_CANCELLED)
+ else if (status == DownloadStatus::ERROR ||
+ status == DownloadStatus::CANCELLED)
{
if (uw->mDownloadStatus == UPDATE_COMPLETE)
{ // ignoring error in last state (was UPDATE_PATCH)
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index 144e0903a..332f0d629 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -155,7 +155,7 @@ private:
/**
* A download callback for progress updates.
*/
- static int updateProgress(void *ptr, DownloadStatus status,
+ static int updateProgress(void *ptr, DownloadStatus::Type status,
size_t dt, size_t dn);
/**
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 4a9cbf0ea..c61e42e0c 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -202,7 +202,7 @@ bool Download::start()
logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD);
if (mError)
strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD);
- mUpdateFunction(mPtr, DOWNLOAD_STATUS_THREAD_ERROR, 0, 0);
+ mUpdateFunction(mPtr, DownloadStatus::THREAD_ERROR, 0, 0);
if (!mIgnoreError)
return false;
}
@@ -239,12 +239,12 @@ int Download::downloadProgress(void *clientp, double dltotal, double dlnow,
if (d->mOptions.cancel)
{
- return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_CANCELLED,
+ return d->mUpdateFunction(d->mPtr, DownloadStatus::CANCELLED,
static_cast<size_t>(dltotal),
static_cast<size_t>(dlnow));
}
- return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_IDLE,
+ return d->mUpdateFunction(d->mPtr, DownloadStatus::IDLE,
static_cast<size_t>(dltotal),
static_cast<size_t>(dlnow));
}
@@ -283,7 +283,7 @@ int Download::downloadThread(void *ptr)
logger->log_r("selected url: %s", d->mUrl.c_str());
while (attempts < 3 && !complete && !d->mOptions.cancel)
{
- d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_STARTING, 0, 0);
+ d->mUpdateFunction(d->mPtr, DownloadStatus::STARTING, 0, 0);
if (d->mOptions.cancel)
{
@@ -372,7 +372,7 @@ int Download::downloadThread(void *ptr)
if (d->mOptions.cancel)
break;
-// d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0);
+// d->mUpdateFunction(d->mPtr, DownloadStatus::ERROR, 0, 0);
if (file)
{
@@ -495,11 +495,11 @@ int Download::downloadThread(void *ptr)
}
else if (!complete || attempts >= 3)
{
- d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0);
+ d->mUpdateFunction(d->mPtr, DownloadStatus::ERROR, 0, 0);
}
else
{
- d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_COMPLETE, 0, 0);
+ d->mUpdateFunction(d->mPtr, DownloadStatus::COMPLETE, 0, 0);
}
return 0;
diff --git a/src/net/download.h b/src/net/download.h
index bc12a8f7c..0d2997b22 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -19,26 +19,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef NET_DOWNLOAD_H
#define NET_DOWNLOAD_H
+#include "net/downloadstatus.h"
+
#include <string>
#include <queue>
#include "localconsts.h"
-enum DownloadStatus
-{
- DOWNLOAD_STATUS_CANCELLED = -3,
- DOWNLOAD_STATUS_THREAD_ERROR = -2,
- DOWNLOAD_STATUS_ERROR = -1,
- DOWNLOAD_STATUS_STARTING = 0,
- DOWNLOAD_STATUS_IDLE,
- DOWNLOAD_STATUS_COMPLETE
-};
-
-typedef int (*DownloadUpdate)(void *ptr, DownloadStatus status,
+typedef int (*DownloadUpdate)(void *ptr, DownloadStatus::Type status,
size_t total, size_t remaining);
// Matches what CURL expects
diff --git a/src/net/downloadstatus.h b/src/net/downloadstatus.h
new file mode 100644
index 000000000..8c5066915
--- /dev/null
+++ b/src/net/downloadstatus.h
@@ -0,0 +1,38 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_DOWNLOADSTATUS_H
+#define NET_DOWNLOADSTATUS_H
+
+namespace DownloadStatus
+{
+ enum Type
+ {
+ CANCELLED = -3,
+ THREAD_ERROR = -2,
+ ERROR = -1,
+ STARTING = 0,
+ IDLE,
+ COMPLETE
+ };
+} // namespace Net
+
+#endif // NET_DOWNLOADSTATUS_H