summaryrefslogtreecommitdiff
path: root/src/net
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 /src/net
parent0ad3a821e42471a052027419336df2132613e9f3 (diff)
downloadplus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.gz
plus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.bz2
plus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.tar.xz
plus-0369cb5dc2e5dae4acdb0753c3b309ef874c96ae.zip
Move downloadstatus into separate file.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/download.cpp14
-rw-r--r--src/net/download.h15
-rw-r--r--src/net/downloadstatus.h38
3 files changed, 48 insertions, 19 deletions
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