aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/memstream.h3
-rw-r--r--common/module.mk5
-rw-r--r--common/platform.cpp1
-rw-r--r--common/platform.h1
-rw-r--r--common/updates.cpp68
-rw-r--r--common/updates.h34
6 files changed, 106 insertions, 6 deletions
diff --git a/common/memstream.h b/common/memstream.h
index 5ecc553454..a01973c6fa 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -25,6 +25,7 @@
#include "common/stream.h"
#include "common/types.h"
+#include "common/util.h"
namespace Common {
@@ -170,7 +171,7 @@ private:
byte *old_data = _data;
- _capacity = new_len + 32;
+ _capacity = MAX(new_len + 32, _capacity * 2);
_data = (byte *)malloc(_capacity);
_ptr = _data + _pos;
diff --git a/common/module.mk b/common/module.mk
index 67c498df00..570040c8e1 100644
--- a/common/module.mk
+++ b/common/module.mk
@@ -56,5 +56,10 @@ MODULE_OBJS += \
recorderfile.o
endif
+ifdef USE_UPDATES
+MODULE_OBJS += \
+ updates.o
+endif
+
# Include common rules
include $(srcdir)/rules.mk
diff --git a/common/platform.cpp b/common/platform.cpp
index 636c1ddb52..280185d862 100644
--- a/common/platform.cpp
+++ b/common/platform.cpp
@@ -27,6 +27,7 @@ namespace Common {
const PlatformDescription g_platforms[] = {
{ "2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS },
+ { "apple2", "apple2", "apple2", "Apple II", kPlatformApple2 },
{ "3do", "3do", "3do", "3DO", kPlatform3DO },
{ "acorn", "acorn", "acorn", "Acorn", kPlatformAcorn },
{ "amiga", "ami", "amiga", "Amiga", kPlatformAmiga },
diff --git a/common/platform.h b/common/platform.h
index 17a332b851..15bcddb62e 100644
--- a/common/platform.h
+++ b/common/platform.h
@@ -50,6 +50,7 @@ enum Platform {
kPlatformSegaCD,
kPlatform3DO,
kPlatformPCEngine,
+ kPlatformApple2,
kPlatformApple2GS,
kPlatformPC98,
kPlatformWii,
diff --git a/common/updates.cpp b/common/updates.cpp
new file mode 100644
index 0000000000..4174a96c56
--- /dev/null
+++ b/common/updates.cpp
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 (at your option) 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/system.h"
+#include "common/updates.h"
+#include "common/translation.h"
+
+namespace Common {
+
+static const int updateIntervals[] = {
+ UpdateManager::kUpdateIntervalNotSupported,
+ UpdateManager::kUpdateIntervalOneDay,
+ UpdateManager::kUpdateIntervalOneWeek,
+ UpdateManager::kUpdateIntervalOneMonth,
+ -1
+};
+
+const int *UpdateManager::getUpdateIntervals() {
+ return updateIntervals;
+}
+
+int UpdateManager::normalizeInterval(int interval) {
+ const int *val = updateIntervals;
+
+ while (*val != -1) {
+ if (*val > interval)
+ return *val;
+ val++;
+ }
+
+ return val[-1]; // Return maximal acceptable value
+}
+
+const char *UpdateManager::updateIntervalToString(int interval) {
+ switch (interval) {
+ case kUpdateIntervalNotSupported:
+ return _("Never");
+ case kUpdateIntervalOneDay:
+ return _("Daily");
+ case kUpdateIntervalOneWeek:
+ return _("Weekly");
+ case kUpdateIntervalOneMonth:
+ return _("Monthly");
+ default:
+ return _("<Bad value>");
+ }
+}
+
+} // End of namespace Common
diff --git a/common/updates.h b/common/updates.h
index 4c30987c38..65eb5ac095 100644
--- a/common/updates.h
+++ b/common/updates.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef BACKENDS_UPDATES_ABSTRACT_H
-#define BACKENDS_UPDATES_ABSTRACT_H
+#ifndef COMMON_UPDATES_H
+#define COMMON_UPDATES_H
#if defined(USE_UPDATES)
@@ -85,18 +85,42 @@ public:
*
* @param interval The interval.
*/
- virtual void setUpdateCheckInterval(UpdateInterval interval) {}
+ virtual void setUpdateCheckInterval(int interval) {}
/**
* Gets the update check interval.
*
* @return the update check interval.
*/
- virtual UpdateInterval getUpdateCheckInterval() { return kUpdateIntervalNotSupported; }
+ virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; }
+
+ /**
+ * Returns list of supported uptate intervals.
+ * Ending with '-1' which is not acceptable value.
+ *
+ * @return list of integer values representing update intervals in seconds.
+ */
+ static const int *getUpdateIntervals();
+
+ /**
+ * Returns string representation of a given interval.
+ *
+ * @param interval The interval.
+ * @return pointer to localized string of given interval.
+ */
+ static const char *updateIntervalToString(int interval);
+
+ /**
+ * Rounds up the given interval to acceptable value.
+ *
+ * @param interval The interval.
+ * @return rounded up interval
+ */
+ static int normalizeInterval(int interval);
};
} // End of namespace Common
#endif
-#endif // BACKENDS_UPDATES_ABSTRACT_H
+#endif // COMMON_UPDATES_H