aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/EventDispatcher.cpp17
-rw-r--r--common/EventRecorder.cpp5
-rw-r--r--common/EventRecorder.h4
-rw-r--r--common/algorithm.h5
-rw-r--r--common/archive.cpp3
-rw-r--r--common/archive.h2
-rw-r--r--common/array.h4
-rw-r--r--common/config-file.cpp2
-rw-r--r--common/config-file.h2
-rw-r--r--common/config-manager.cpp11
-rw-r--r--common/config-manager.h8
-rw-r--r--common/dcl.cpp11
-rw-r--r--common/dcl.h1
-rw-r--r--common/events.h20
-rw-r--r--common/file.cpp2
-rw-r--r--common/file.h2
-rw-r--r--common/fs.cpp16
-rw-r--r--common/func.h5
-rw-r--r--common/huffman.h6
-rw-r--r--common/iff_container.cpp6
-rw-r--r--common/iff_container.h28
-rw-r--r--common/memorypool.cpp1
-rw-r--r--common/ptr.h41
-rw-r--r--common/quicktime.cpp35
-rw-r--r--common/quicktime.h31
-rw-r--r--common/rational.cpp4
-rw-r--r--common/serializer.h8
-rw-r--r--common/str.h8
-rw-r--r--common/stream.cpp9
-rw-r--r--common/substream.h11
-rw-r--r--common/system.cpp9
-rw-r--r--common/system.h29
-rw-r--r--common/taskbar.h14
-rw-r--r--common/timer.h4
-rw-r--r--common/tokenizer.cpp1
-rw-r--r--common/unarj.cpp20
-rw-r--r--common/unzip.cpp8
-rw-r--r--common/updates.h102
-rw-r--r--common/util.cpp3
-rw-r--r--common/util.h13
-rw-r--r--common/winexe_pe.cpp2
-rw-r--r--common/xmlparser.cpp2
-rw-r--r--common/xmlparser.h2
-rw-r--r--common/zlib.cpp26
44 files changed, 354 insertions, 189 deletions
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp
index e97068c0d0..ce1ef0c1c8 100644
--- a/common/EventDispatcher.cpp
+++ b/common/EventDispatcher.cpp
@@ -28,12 +28,12 @@ EventDispatcher::EventDispatcher() : _mapper(0) {
}
EventDispatcher::~EventDispatcher() {
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
if (i->autoFree)
delete i->source;
}
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->autoFree)
delete i->observer;
}
@@ -43,9 +43,9 @@ EventDispatcher::~EventDispatcher() {
}
void EventDispatcher::dispatch() {
- Common::Event event;
+ Event event;
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
const bool allowMapping = i->source->allowMapping();
while (i->source->pollEvent(event)) {
@@ -83,7 +83,7 @@ void EventDispatcher::registerSource(EventSource *source, bool autoFree) {
}
void EventDispatcher::unregisterSource(EventSource *source) {
- for (Common::List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
if (i->source == source) {
if (i->autoFree)
delete source;
@@ -101,7 +101,7 @@ void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool a
newEntry.priority = priority;
newEntry.autoFree = autoFree;
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->priority < priority) {
_observers.insert(i, newEntry);
return;
@@ -112,7 +112,7 @@ void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool a
}
void EventDispatcher::unregisterObserver(EventObserver *obs) {
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->observer == obs) {
if (i->autoFree)
delete obs;
@@ -124,11 +124,10 @@ void EventDispatcher::unregisterObserver(EventObserver *obs) {
}
void EventDispatcher::dispatchEvent(const Event &event) {
- for (Common::List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
+ for (List<ObserverEntry>::iterator i = _observers.begin(); i != _observers.end(); ++i) {
if (i->observer->notifyEvent(event))
break;
}
}
} // End of namespace Common
-
diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp
index 4441070050..201043f52e 100644
--- a/common/EventRecorder.cpp
+++ b/common/EventRecorder.cpp
@@ -304,6 +304,10 @@ void EventRecorder::processMillis(uint32 &millis) {
g_system->unlockMutex(_timeMutex);
}
+bool EventRecorder::processDelayMillis(uint &msecs) {
+ return false;
+}
+
bool EventRecorder::notifyEvent(const Event &ev) {
if (_recordMode != kRecorderRecord)
return false;
@@ -360,4 +364,3 @@ bool EventRecorder::pollEvent(Event &ev) {
}
} // End of namespace Common
-
diff --git a/common/EventRecorder.h b/common/EventRecorder.h
index 8377d9e8bd..e20419695a 100644
--- a/common/EventRecorder.h
+++ b/common/EventRecorder.h
@@ -56,6 +56,9 @@ public:
/** TODO: Add documentation, this is only used by the backend */
void processMillis(uint32 &millis);
+ /** TODO: Add documentation, this is only used by the backend */
+ bool processDelayMillis(uint &msecs);
+
private:
bool notifyEvent(const Event &ev);
bool pollEvent(Event &ev);
@@ -103,4 +106,3 @@ private:
} // End of namespace Common
#endif
-
diff --git a/common/algorithm.h b/common/algorithm.h
index 00c0e1c98f..e7ccef4840 100644
--- a/common/algorithm.h
+++ b/common/algorithm.h
@@ -226,12 +226,12 @@ void sort(T first, T last, StrictWeakOrdering comp) {
*/
template<typename T>
void sort(T *first, T *last) {
- sort(first, last, Common::Less<T>());
+ sort(first, last, Less<T>());
}
template<class T>
void sort(T first, T last) {
- sort(first, last, Common::Less<typename T::ValueType>());
+ sort(first, last, Less<typename T::ValueType>());
}
// MSVC is complaining about the minus operator being applied to an unsigned type
@@ -269,4 +269,3 @@ T gcd(T a, T b) {
} // End of namespace Common
#endif
-
diff --git a/common/archive.cpp b/common/archive.cpp
index 102d7aaa3f..954de8bcaa 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -147,7 +147,7 @@ void SearchSet::addSubDirectoriesMatching(const FSNode &directory, String origPa
for (FSList::const_iterator i = subDirs.begin(); i != subDirs.end(); ++i) {
String name = i->getName();
- if (Common::matchString(name.c_str(), pattern.c_str(), ignoreCase)) {
+ if (matchString(name.c_str(), pattern.c_str(), ignoreCase)) {
matchIter = multipleMatches.find(name);
if (matchIter == multipleMatches.end()) {
multipleMatches[name] = true;
@@ -288,4 +288,3 @@ void SearchManager::clear() {
DECLARE_SINGLETON(SearchManager);
} // namespace Common
-
diff --git a/common/archive.h b/common/archive.h
index 8400c56d69..c8e78f9bc8 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -254,7 +254,7 @@ public:
virtual void clear();
private:
- friend class Common::Singleton<SingletonBaseType>;
+ friend class Singleton<SingletonBaseType>;
SearchManager();
};
diff --git a/common/array.h b/common/array.h
index e5434091fb..18cecfb98f 100644
--- a/common/array.h
+++ b/common/array.h
@@ -42,7 +42,7 @@ namespace Common {
* management scheme. There, only elements that 'live' are actually constructed
* (i.e., have their constructor called), and objects that are removed are
* immediately destructed (have their destructor called).
- * With Common::Array, this is not the case; instead, it simply uses new[] and
+ * With Array, this is not the case; instead, it simply uses new[] and
* delete[] to allocate whole blocks of objects, possibly more than are
* currently 'alive'. This simplifies memory management, but may have
* undesirable side effects when one wants to use an Array of complex
@@ -274,7 +274,7 @@ protected:
if (capacity) {
_storage = new T[capacity];
if (!_storage)
- ::error("Common::Array: failure to allocate %d bytes", capacity);
+ ::error("Common::Array: failure to allocate %u bytes", capacity * (uint)sizeof(T));
} else {
_storage = 0;
}
diff --git a/common/config-file.cpp b/common/config-file.cpp
index ea3feff8ae..1ebd9b5701 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -36,7 +36,7 @@ namespace Common {
* underscores. In particular, white space and "#", "=", "[", "]"
* are not valid!
*/
-bool ConfigFile::isValidName(const Common::String &name) {
+bool ConfigFile::isValidName(const String &name) {
const char *p = name.c_str();
while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_' || *p == '.'))
p++;
diff --git a/common/config-file.h b/common/config-file.h
index d28ad34036..7bc5604b4c 100644
--- a/common/config-file.h
+++ b/common/config-file.h
@@ -93,7 +93,7 @@ public:
* underscores. In particular, white space and "#", "=", "[", "]"
* are not valid!
*/
- static bool isValidName(const Common::String &name);
+ static bool isValidName(const String &name);
/** Reset everything stored in this config file. */
void clear();
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index fbdb611f3c..c62dee8bea 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -38,11 +38,11 @@ namespace Common {
DECLARE_SINGLETON(ConfigManager);
-const char *ConfigManager::kApplicationDomain = "scummvm";
-const char *ConfigManager::kTransientDomain = "__TRANSIENT";
+char const *const ConfigManager::kApplicationDomain = "scummvm";
+char const *const ConfigManager::kTransientDomain = "__TRANSIENT";
#ifdef ENABLE_KEYMAPPER
-const char *ConfigManager::kKeymapperDomain = "keymapper";
+char const *const ConfigManager::kKeymapperDomain = "keymapper";
#endif
#pragma mark -
@@ -112,7 +112,7 @@ void ConfigManager::loadConfigFile(const String &filename) {
* Add a ready-made domain based on its name and contents
* The domain name should not already exist in the ConfigManager.
**/
-void ConfigManager::addDomain(const Common::String &domainName, const ConfigManager::Domain &domain) {
+void ConfigManager::addDomain(const String &domainName, const ConfigManager::Domain &domain) {
if (domainName.empty())
return;
if (domainName == kApplicationDomain) {
@@ -492,7 +492,7 @@ int ConfigManager::getInt(const String &key, const String &domName) const {
bool ConfigManager::getBool(const String &key, const String &domName) const {
String value(get(key, domName));
bool val;
- if (Common::parseBool(value, val))
+ if (parseBool(value, val))
return val;
error("ConfigManager::getBool(%s,%s): '%s' is not a valid bool",
@@ -696,4 +696,3 @@ bool ConfigManager::Domain::hasKVComment(const String &key) const {
}
} // End of namespace Common
-
diff --git a/common/config-manager.h b/common/config-manager.h
index 78a62b9808..02d4ec3438 100644
--- a/common/config-manager.h
+++ b/common/config-manager.h
@@ -64,14 +64,14 @@ public:
typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap;
/** The name of the application domain (normally 'scummvm'). */
- static const char *kApplicationDomain;
+ static char const *const kApplicationDomain;
/** The transient (pseudo) domain. */
- static const char *kTransientDomain;
+ static char const *const kTransientDomain;
#ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */
- static const char *kKeymapperDomain;
+ static char const *const kKeymapperDomain;
#endif
void loadDefaultConfigFile();
@@ -153,7 +153,7 @@ private:
ConfigManager();
void loadFromStream(SeekableReadStream &stream);
- void addDomain(const Common::String &domainName, const Domain &domain);
+ void addDomain(const String &domainName, const Domain &domain);
void writeDomain(WriteStream &stream, const String &name, const Domain &domain);
void renameDomain(const String &oldName, const String &newName, DomainMap &map);
diff --git a/common/dcl.cpp b/common/dcl.cpp
index b75f7f3fa6..1879be992d 100644
--- a/common/dcl.cpp
+++ b/common/dcl.cpp
@@ -30,7 +30,7 @@ namespace Common {
class DecompressorDCL {
public:
- bool unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked);
+ bool unpack(ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked);
protected:
/**
@@ -41,7 +41,7 @@ protected:
* @param nUnpacket size of unpacked data
* @return 0 on success, non-zero on error
*/
- void init(Common::ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked);
+ void init(ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked);
/**
* Get a number of bits from _src stream, starting with the least
@@ -73,12 +73,11 @@ protected:
uint32 _szUnpacked; ///< size of the decompressed data
uint32 _dwRead; ///< number of bytes read from _src
uint32 _dwWrote; ///< number of bytes written to _dest
- Common::ReadStream *_src;
+ ReadStream *_src;
byte *_dest;
};
-void DecompressorDCL::init(Common::ReadStream *src, byte *dest, uint32 nPacked,
- uint32 nUnpacked) {
+void DecompressorDCL::init(ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked) {
_src = src;
_dest = dest;
_szPacked = nPacked;
@@ -333,7 +332,7 @@ int DecompressorDCL::huffman_lookup(const int *tree) {
#define DCL_BINARY_MODE 0
#define DCL_ASCII_MODE 1
-bool DecompressorDCL::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked) {
+bool DecompressorDCL::unpack(ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked) {
init(src, dest, nPacked, nUnpacked);
int value;
diff --git a/common/dcl.h b/common/dcl.h
index 12c4e12772..78ffa631ed 100644
--- a/common/dcl.h
+++ b/common/dcl.h
@@ -52,4 +52,3 @@ SeekableReadStream *decompressDCL(ReadStream *src, uint32 packedSize, uint32 unp
} // End of namespace Common
#endif
-
diff --git a/common/events.h b/common/events.h
index 371080c1b2..7df2731687 100644
--- a/common/events.h
+++ b/common/events.h
@@ -97,7 +97,7 @@ struct Event {
* Virtual screen coordinates means: the coordinate system of the
* screen area as defined by the most recent call to initSize().
*/
- Common::Point mouse;
+ Point mouse;
Event() : type(EVENT_INVALID), synthetic(false) {}
};
@@ -139,13 +139,13 @@ public:
*/
class ArtificialEventSource : public EventSource {
protected:
- Common::Queue<Common::Event> _artificialEventQueue;
+ Queue<Event> _artificialEventQueue;
public:
- void addEvent(const Common::Event &ev) {
+ void addEvent(const Event &ev) {
_artificialEventQueue.push(ev);
}
- bool pollEvent(Common::Event &ev) {
+ bool pollEvent(Event &ev) {
if (!_artificialEventQueue.empty()) {
ev = _artificialEventQueue.pop();
return true;
@@ -275,14 +275,14 @@ private:
EventSource *source;
};
- Common::List<SourceEntry> _sources;
+ List<SourceEntry> _sources;
struct ObserverEntry : public Entry {
uint priority;
EventObserver *observer;
};
- Common::List<ObserverEntry> _observers;
+ List<ObserverEntry> _observers;
void dispatchEvent(const Event &event);
};
@@ -315,15 +315,15 @@ public:
* @param event point to an Event struct, which will be filled with the event data.
* @return true if an event was retrieved.
*/
- virtual bool pollEvent(Common::Event &event) = 0;
+ virtual bool pollEvent(Event &event) = 0;
/**
* Pushes a "fake" event into the event queue
*/
- virtual void pushEvent(const Common::Event &event) = 0;
+ virtual void pushEvent(const Event &event) = 0;
/** Return the current mouse position */
- virtual Common::Point getMousePos() const = 0;
+ virtual Point getMousePos() const = 0;
/**
* Return a bitmask with the button states:
@@ -362,7 +362,7 @@ public:
// TODO: Consider removing OSystem::getScreenChangeID and
// replacing it by a generic getScreenChangeID method here
#ifdef ENABLE_KEYMAPPER
- virtual Common::Keymapper *getKeymapper() = 0;
+ virtual Keymapper *getKeymapper() = 0;
#endif
enum {
diff --git a/common/file.cpp b/common/file.cpp
index 381bf12ecf..12d73c9973 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -72,7 +72,7 @@ bool File::open(const FSNode &node) {
return open(stream, node.getPath());
}
-bool File::open(SeekableReadStream *stream, const Common::String &name) {
+bool File::open(SeekableReadStream *stream, const String &name) {
assert(!_handle);
if (stream) {
diff --git a/common/file.h b/common/file.h
index 86c67c077c..b6319dfc3c 100644
--- a/common/file.h
+++ b/common/file.h
@@ -97,7 +97,7 @@ public:
* @param name a string describing the 'file' corresponding to stream
* @return true if stream was non-zero, false otherwise
*/
- virtual bool open(SeekableReadStream *stream, const Common::String &name);
+ virtual bool open(SeekableReadStream *stream, const String &name);
/**
* Close the file, if open.
diff --git a/common/fs.cpp b/common/fs.cpp
index 3dc8c289aa..8aa1115f9d 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -33,7 +33,7 @@ FSNode::FSNode(AbstractFSNode *realNode)
: _realNode(realNode) {
}
-FSNode::FSNode(const Common::String &p) {
+FSNode::FSNode(const String &p) {
assert(g_system);
FilesystemFactory *factory = g_system->getFilesystemFactory();
AbstractFSNode *tmp = 0;
@@ -42,7 +42,7 @@ FSNode::FSNode(const Common::String &p) {
tmp = factory->makeCurrentDirectoryFileNode();
else
tmp = factory->makeFileNodePath(p);
- _realNode = Common::SharedPtr<AbstractFSNode>(tmp);
+ _realNode = SharedPtr<AbstractFSNode>(tmp);
}
bool FSNode::operator<(const FSNode& node) const {
@@ -59,7 +59,7 @@ bool FSNode::exists() const {
return _realNode && _realNode->exists();
}
-FSNode FSNode::getChild(const Common::String &n) const {
+FSNode FSNode::getChild(const String &n) const {
// If this node is invalid or not a directory, return an invalid node
if (_realNode == 0 || !_realNode->isDirectory())
return FSNode();
@@ -85,12 +85,12 @@ bool FSNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
return true;
}
-Common::String FSNode::getDisplayName() const {
+String FSNode::getDisplayName() const {
assert(_realNode);
return _realNode->getDisplayName();
}
-Common::String FSNode::getName() const {
+String FSNode::getName() const {
assert(_realNode);
return _realNode->getName();
}
@@ -107,7 +107,7 @@ FSNode FSNode::getParent() const {
}
}
-Common::String FSNode::getPath() const {
+String FSNode::getPath() const {
assert(_realNode);
return _realNode->getPath();
}
@@ -124,7 +124,7 @@ bool FSNode::isWritable() const {
return _realNode && _realNode->isWritable();
}
-Common::SeekableReadStream *FSNode::createReadStream() const {
+SeekableReadStream *FSNode::createReadStream() const {
if (_realNode == 0)
return 0;
@@ -139,7 +139,7 @@ Common::SeekableReadStream *FSNode::createReadStream() const {
return _realNode->createReadStream();
}
-Common::WriteStream *FSNode::createWriteStream() const {
+WriteStream *FSNode::createWriteStream() const {
if (_realNode == 0)
return 0;
diff --git a/common/func.h b/common/func.h
index e09ab1a438..db57d73668 100644
--- a/common/func.h
+++ b/common/func.h
@@ -424,7 +424,7 @@ private:
* are interesting for that matter.
*/
template<class Arg, class Res>
-struct Functor1 : public Common::UnaryFunction<Arg, Res> {
+struct Functor1 : public UnaryFunction<Arg, Res> {
virtual ~Functor1() {}
virtual bool isValid() const = 0;
@@ -460,7 +460,7 @@ private:
* @see Functor1
*/
template<class Arg1, class Arg2, class Res>
-struct Functor2 : public Common::BinaryFunction<Arg1, Arg2, Res> {
+struct Functor2 : public BinaryFunction<Arg1, Arg2, Res> {
virtual ~Functor2() {}
virtual bool isValid() const = 0;
@@ -538,4 +538,3 @@ GENERATE_TRIVIAL_HASH_FUNCTOR(unsigned long);
} // End of namespace Common
#endif
-
diff --git a/common/huffman.h b/common/huffman.h
index 9a8b712c23..4175d0d309 100644
--- a/common/huffman.h
+++ b/common/huffman.h
@@ -66,9 +66,9 @@ private:
Symbol(uint32 c, uint32 s);
};
- typedef Common::List<Symbol> CodeList;
- typedef Common::Array<CodeList> CodeLists;
- typedef Common::Array<Symbol *> SymbolList;
+ typedef List<Symbol> CodeList;
+ typedef Array<CodeList> CodeLists;
+ typedef Array<Symbol*> SymbolList;
/** Lists of codes and their symbols, sorted by code length. */
CodeLists _codes;
diff --git a/common/iff_container.cpp b/common/iff_container.cpp
index 02b445ae05..7bcbf86e0f 100644
--- a/common/iff_container.cpp
+++ b/common/iff_container.cpp
@@ -25,7 +25,7 @@
namespace Common {
-IFFParser::IFFParser(Common::ReadStream *stream, bool disposeStream) : _stream(stream), _disposeStream(disposeStream) {
+IFFParser::IFFParser(ReadStream *stream, bool disposeStream) : _stream(stream), _disposeStream(disposeStream) {
setInputStream(stream);
}
@@ -36,7 +36,7 @@ IFFParser::~IFFParser() {
_stream = 0;
}
-void IFFParser::setInputStream(Common::ReadStream *stream) {
+void IFFParser::setInputStream(ReadStream *stream) {
assert(stream);
_formChunk.setInputStream(stream);
_chunk.setInputStream(stream);
@@ -63,7 +63,7 @@ void IFFParser::parse(IFFCallback &callback) {
_chunk.readHeader();
// invoke the callback
- Common::SubReadStream stream(&_chunk, _chunk.size);
+ SubReadStream stream(&_chunk, _chunk.size);
IFFChunk chunk(_chunk.id, _chunk.size, &stream);
stop = callback(chunk);
diff --git a/common/iff_container.h b/common/iff_container.h
index 1b12ef70e5..104ecf0f36 100644
--- a/common/iff_container.h
+++ b/common/iff_container.h
@@ -146,11 +146,11 @@ page 376) */
* Client code must *not* deallocate _stream when done.
*/
struct IFFChunk {
- Common::IFF_ID _type;
- uint32 _size;
- Common::ReadStream *_stream;
+ IFF_ID _type;
+ uint32 _size;
+ ReadStream *_stream;
- IFFChunk(Common::IFF_ID type, uint32 size, Common::ReadStream *stream) : _type(type), _size(size), _stream(stream) {
+ IFFChunk(IFF_ID type, uint32 size, ReadStream *stream) : _type(type), _size(size), _stream(stream) {
assert(_stream);
}
};
@@ -163,17 +163,17 @@ class IFFParser {
/**
* This private class implements IFF chunk navigation.
*/
- class IFFChunkNav : public Common::ReadStream {
+ class IFFChunkNav : public ReadStream {
protected:
- Common::ReadStream *_input;
+ ReadStream *_input;
uint32 _bytesRead;
public:
- Common::IFF_ID id;
+ IFF_ID id;
uint32 size;
IFFChunkNav() : _input(0) {
}
- void setInputStream(Common::ReadStream *input) {
+ void setInputStream(ReadStream *input) {
_input = input;
size = _bytesRead = 0;
}
@@ -199,7 +199,7 @@ class IFFParser {
readByte();
}
}
- // Common::ReadStream implementation
+ // ReadStream implementation
bool eos() const { return _input->eos(); }
bool err() const { return _input->err(); }
void clearErr() { _input->clearErr(); }
@@ -215,21 +215,21 @@ protected:
IFFChunkNav _chunk; ///< The current chunk.
uint32 _formSize;
- Common::IFF_ID _formType;
+ IFF_ID _formType;
- Common::ReadStream *_stream;
+ ReadStream *_stream;
bool _disposeStream;
- void setInputStream(Common::ReadStream *stream);
+ void setInputStream(ReadStream *stream);
public:
- IFFParser(Common::ReadStream *stream, bool disposeStream = false);
+ IFFParser(ReadStream *stream, bool disposeStream = false);
~IFFParser();
/**
* Callback type for the parser.
*/
- typedef Common::Functor1< IFFChunk&, bool > IFFCallback;
+ typedef Functor1< IFFChunk&, bool > IFFCallback;
/**
* Parse the IFF container, invoking the callback on each chunk encountered.
diff --git a/common/memorypool.cpp b/common/memorypool.cpp
index 3a570ac50e..19adc54d00 100644
--- a/common/memorypool.cpp
+++ b/common/memorypool.cpp
@@ -180,4 +180,3 @@ void MemoryPool::freeUnusedPages() {
}
} // End of namespace Common
-
diff --git a/common/ptr.h b/common/ptr.h
index fc272d3d41..2b0670caae 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -24,6 +24,7 @@
#include "common/scummsys.h"
#include "common/noncopyable.h"
+#include "common/types.h"
namespace Common {
@@ -185,12 +186,12 @@ public:
}
template<class T2>
- bool operator==(const Common::SharedPtr<T2> &r) const {
+ bool operator==(const SharedPtr<T2> &r) const {
return _pointer == r.get();
}
template<class T2>
- bool operator!=(const Common::SharedPtr<T2> &r) const {
+ bool operator!=(const SharedPtr<T2> &r) const {
return _pointer != r.get();
}
@@ -231,7 +232,6 @@ public:
ReferenceType operator*() const { return *_pointer; }
PointerType operator->() const { return _pointer; }
- operator PointerType() const { return _pointer; }
/**
* Implicit conversion operator to bool for convenience, to make
@@ -274,6 +274,41 @@ private:
PointerType _pointer;
};
+
+template<typename T>
+class DisposablePtr : NonCopyable {
+public:
+ typedef T ValueType;
+ typedef T *PointerType;
+ typedef T &ReferenceType;
+
+ explicit DisposablePtr(PointerType o, DisposeAfterUse::Flag dispose) : _pointer(o), _dispose(dispose) {}
+
+ ~DisposablePtr() {
+ if (_dispose) delete _pointer;
+ }
+
+ ReferenceType operator*() const { return *_pointer; }
+ PointerType operator->() const { return _pointer; }
+
+ /**
+ * Implicit conversion operator to bool for convenience, to make
+ * checks like "if (scopedPtr) ..." possible.
+ */
+ operator bool() const { return _pointer; }
+
+ /**
+ * Returns the plain pointer value.
+ *
+ * @return the pointer the DisposablePtr manages
+ */
+ PointerType get() const { return _pointer; }
+
+private:
+ PointerType _pointer;
+ DisposeAfterUse::Flag _dispose;
+};
+
} // End of namespace Common
#endif
diff --git a/common/quicktime.cpp b/common/quicktime.cpp
index ee49b092a4..9ea8c229ea 100644
--- a/common/quicktime.cpp
+++ b/common/quicktime.cpp
@@ -8,19 +8,16 @@
* 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.
*
- * $URL$
- * $Id$
- *
*/
//
@@ -51,7 +48,7 @@ QuickTimeParser::QuickTimeParser() {
_fd = 0;
_scaleFactorX = 1;
_scaleFactorY = 1;
- _resFork = new Common::MacResManager();
+ _resFork = new MacResManager();
_disposeFileHandle = DisposeAfterUse::YES;
initParseTable();
@@ -62,7 +59,7 @@ QuickTimeParser::~QuickTimeParser() {
delete _resFork;
}
-bool QuickTimeParser::parseFile(const Common::String &filename) {
+bool QuickTimeParser::parseFile(const String &filename) {
if (!_resFork->open(filename) || !_resFork->hasDataFork())
return false;
@@ -73,7 +70,7 @@ bool QuickTimeParser::parseFile(const Common::String &filename) {
if (_resFork->hasResFork()) {
// Search for a 'moov' resource
- Common::MacResIDArray idArray = _resFork->getResIDArray(MKTAG('m', 'o', 'o', 'v'));
+ MacResIDArray idArray = _resFork->getResIDArray(MKTAG('m', 'o', 'o', 'v'));
if (!idArray.empty())
_fd = _resFork->getResource(MKTAG('m', 'o', 'o', 'v'), idArray[0]);
@@ -99,7 +96,7 @@ bool QuickTimeParser::parseFile(const Common::String &filename) {
return true;
}
-bool QuickTimeParser::parseStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
+bool QuickTimeParser::parseStream(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
_fd = stream;
_foundMOOV = false;
_disposeFileHandle = disposeFileHandle;
@@ -277,7 +274,7 @@ int QuickTimeParser::readCMOV(Atom atom) {
// Uncompress the data
unsigned long dstLen = uncompressedSize;
- if (!Common::uncompress(uncompressedData, &dstLen, compressedData, compressedSize)) {
+ if (!uncompress(uncompressedData, &dstLen, compressedData, compressedSize)) {
warning ("Could not uncompress cmov chunk");
free(compressedData);
free(uncompressedData);
@@ -285,8 +282,8 @@ int QuickTimeParser::readCMOV(Atom atom) {
}
// Load data into a new MemoryReadStream and assign _fd to be that
- Common::SeekableReadStream *oldStream = _fd;
- _fd = new Common::MemoryReadStream(uncompressedData, uncompressedSize, DisposeAfterUse::YES);
+ SeekableReadStream *oldStream = _fd;
+ _fd = new MemoryReadStream(uncompressedData, uncompressedSize, DisposeAfterUse::YES);
// Read the contents of the uncompressed data
Atom a = { MKTAG('m', 'o', 'o', 'v'), 0, uncompressedSize };
@@ -336,8 +333,8 @@ int QuickTimeParser::readMVHD(Atom atom) {
uint32 yMod = _fd->readUint32BE();
_fd->skip(16);
- _scaleFactorX = Common::Rational(0x10000, xMod);
- _scaleFactorY = Common::Rational(0x10000, yMod);
+ _scaleFactorX = Rational(0x10000, xMod);
+ _scaleFactorY = Rational(0x10000, yMod);
_scaleFactorX.debugPrint(1, "readMVHD(): scaleFactorX =");
_scaleFactorY.debugPrint(1, "readMVHD(): scaleFactorY =");
@@ -406,8 +403,8 @@ int QuickTimeParser::readTKHD(Atom atom) {
uint32 yMod = _fd->readUint32BE();
_fd->skip(16);
- track->scaleFactorX = Common::Rational(0x10000, xMod);
- track->scaleFactorY = Common::Rational(0x10000, yMod);
+ track->scaleFactorX = Rational(0x10000, xMod);
+ track->scaleFactorY = Rational(0x10000, yMod);
track->scaleFactorX.debugPrint(1, "readTKHD(): scaleFactorX =");
track->scaleFactorY.debugPrint(1, "readTKHD(): scaleFactorY =");
@@ -434,7 +431,7 @@ int QuickTimeParser::readELST(Atom atom) {
for (uint32 i = 0; i < track->editCount; i++){
track->editList[i].trackDuration = _fd->readUint32BE();
track->editList[i].mediaTime = _fd->readSint32BE();
- track->editList[i].mediaRate = Common::Rational(_fd->readUint32BE(), 0x10000);
+ track->editList[i].mediaRate = Rational(_fd->readUint32BE(), 0x10000);
debugN(3, "\tDuration = %d, Media Time = %d, ", track->editList[i].trackDuration, track->editList[i].mediaTime);
track->editList[i].mediaRate.debugPrint(3, "Media Rate =");
}
@@ -698,7 +695,7 @@ enum {
kMP4DecSpecificDescTag = 5
};
-static int readMP4DescLength(Common::SeekableReadStream *stream) {
+static int readMP4DescLength(SeekableReadStream *stream) {
int length = 0;
int count = 4;
@@ -713,7 +710,7 @@ static int readMP4DescLength(Common::SeekableReadStream *stream) {
return length;
}
-static void readMP4Desc(Common::SeekableReadStream *stream, byte &tag, int &length) {
+static void readMP4Desc(SeekableReadStream *stream, byte &tag, int &length) {
tag = stream->readByte();
length = readMP4DescLength(stream);
}
diff --git a/common/quicktime.h b/common/quicktime.h
index cb2bed1202..e4c821e209 100644
--- a/common/quicktime.h
+++ b/common/quicktime.h
@@ -8,19 +8,16 @@
* 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.
*
- * $URL$
- * $Id$
- *
*/
//
@@ -59,14 +56,14 @@ public:
* Load a QuickTime file
* @param filename the filename to load
*/
- bool parseFile(const Common::String &filename);
+ bool parseFile(const String &filename);
/**
* Load a QuickTime file from a SeekableReadStream
* @param stream the stream to load
* @param disposeFileHandle whether to delete the stream after use
*/
- bool parseStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES);
+ bool parseStream(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES);
/**
* Close a QuickTime file
@@ -84,7 +81,7 @@ public:
protected:
// This is the file handle from which data is read from. It can be the actual file handle or a decompressed stream.
- Common::SeekableReadStream *_fd;
+ SeekableReadStream *_fd;
DisposeAfterUse::Flag _disposeFileHandle;
@@ -113,7 +110,7 @@ protected:
struct EditListEntry {
uint32 trackDuration;
int32 mediaTime;
- Common::Rational mediaRate;
+ Rational mediaRate;
};
struct Track;
@@ -157,18 +154,18 @@ protected:
uint16 height;
CodecType codecType;
- Common::Array<SampleDesc *> sampleDescs;
+ Array<SampleDesc*> sampleDescs;
uint32 editCount;
EditListEntry *editList;
- Common::SeekableReadStream *extraData;
+ SeekableReadStream *extraData;
uint32 frameCount;
uint32 duration;
uint32 startTime;
- Common::Rational scaleFactorX;
- Common::Rational scaleFactorY;
+ Rational scaleFactorX;
+ Rational scaleFactorY;
byte objectTypeMP4;
};
@@ -179,11 +176,11 @@ protected:
bool _foundMOOV;
uint32 _timeScale;
uint32 _duration;
- Common::Rational _scaleFactorX;
- Common::Rational _scaleFactorY;
- Common::Array<Track *> _tracks;
+ Rational _scaleFactorX;
+ Rational _scaleFactorY;
+ Array<Track*> _tracks;
uint32 _beginOffset;
- Common::MacResManager *_resFork;
+ MacResManager *_resFork;
void initParseTable();
void init();
diff --git a/common/rational.cpp b/common/rational.cpp
index cb287869bb..f5495da3a9 100644
--- a/common/rational.cpp
+++ b/common/rational.cpp
@@ -107,8 +107,8 @@ Rational &Rational::operator-=(const Rational &right) {
Rational &Rational::operator*=(const Rational &right) {
// Cross-cancel to avoid unnecessary overflow;
// the result then is automatically normalized
- const int gcd1 = Common::gcd(_num, right._denom);
- const int gcd2 = Common::gcd(right._num, _denom);
+ const int gcd1 = gcd(_num, right._denom);
+ const int gcd2 = gcd(right._num, _denom);
_num = (_num / gcd1) * (right._num / gcd2);
_denom = (_denom / gcd2) * (right._denom / gcd1);
diff --git a/common/serializer.h b/common/serializer.h
index b874624d38..5b08a9a9fa 100644
--- a/common/serializer.h
+++ b/common/serializer.h
@@ -68,15 +68,15 @@ public:
static const Version kLastVersion = 0xFFFFFFFF;
protected:
- Common::SeekableReadStream *_loadStream;
- Common::WriteStream *_saveStream;
+ SeekableReadStream *_loadStream;
+ WriteStream *_saveStream;
uint _bytesSynced;
Version _version;
public:
- Serializer(Common::SeekableReadStream *in, Common::WriteStream *out)
+ Serializer(SeekableReadStream *in, WriteStream *out)
: _loadStream(in), _saveStream(out), _bytesSynced(0), _version(0) {
assert(in || out);
}
@@ -214,7 +214,7 @@ public:
* Sync a C-string, by treating it as a zero-terminated byte sequence.
* @todo Replace this method with a special Syncer class for Common::String
*/
- void syncString(Common::String &str, Version minVersion = 0, Version maxVersion = kLastVersion) {
+ void syncString(String &str, Version minVersion = 0, Version maxVersion = kLastVersion) {
if (_version < minVersion || _version > maxVersion)
return; // Ignore anything which is not supposed to be present in this save game version
diff --git a/common/str.h b/common/str.h
index 8e07b6233d..5039130707 100644
--- a/common/str.h
+++ b/common/str.h
@@ -219,14 +219,14 @@ public:
* except that it stores the result in (variably sized) String
* instead of a fixed size buffer.
*/
- static Common::String format(const char *fmt, ...) GCC_PRINTF(1,2);
+ static String format(const char *fmt, ...) GCC_PRINTF(1,2);
/**
* Print formatted data into a String object. Similar to vsprintf,
* except that it stores the result in (variably sized) String
* instead of a fixed size buffer.
*/
- static Common::String vformat(const char *fmt, va_list args);
+ static String vformat(const char *fmt, va_list args);
public:
typedef char * iterator;
@@ -293,7 +293,7 @@ extern char *trim(char *t);
* @param sep character used to separate path components
* @return The last component of the path.
*/
-Common::String lastPathComponent(const Common::String &path, const char sep);
+String lastPathComponent(const String &path, const char sep);
/**
* Normalize a given path to a canonical form. In particular:
@@ -307,7 +307,7 @@ Common::String lastPathComponent(const Common::String &path, const char sep);
* @param sep the separator token (usually '/' on Unix-style systems, or '\\' on Windows based stuff)
* @return the normalized path
*/
-Common::String normalizePath(const Common::String &path, const char sep);
+String normalizePath(const String &path, const char sep);
/**
diff --git a/common/stream.cpp b/common/stream.cpp
index 60b40d0df2..30b3bca497 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/substream.h"
@@ -258,8 +259,7 @@ namespace {
*/
class BufferedReadStream : virtual public ReadStream {
protected:
- ReadStream *_parentStream;
- DisposeAfterUse::Flag _disposeParentStream;
+ DisposablePtr<ReadStream> _parentStream;
byte *_buf;
uint32 _pos;
bool _eos; // end of stream
@@ -278,8 +278,7 @@ public:
};
BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream)
- : _parentStream(parentStream),
- _disposeParentStream(disposeParentStream),
+ : _parentStream(parentStream, disposeParentStream),
_pos(0),
_eos(false),
_bufSize(0),
@@ -291,8 +290,6 @@ BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize,
}
BufferedReadStream::~BufferedReadStream() {
- if (_disposeParentStream)
- delete _parentStream;
delete[] _buf;
}
diff --git a/common/substream.h b/common/substream.h
index f4f79ff02f..7e67389da1 100644
--- a/common/substream.h
+++ b/common/substream.h
@@ -23,6 +23,7 @@
#ifndef COMMON_SUBSTREAM_H
#define COMMON_SUBSTREAM_H
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/types.h"
@@ -38,24 +39,18 @@ namespace Common {
*/
class SubReadStream : virtual public ReadStream {
protected:
- ReadStream *_parentStream;
- DisposeAfterUse::Flag _disposeParentStream;
+ DisposablePtr<ReadStream> _parentStream;
uint32 _pos;
uint32 _end;
bool _eos;
public:
SubReadStream(ReadStream *parentStream, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
- : _parentStream(parentStream),
- _disposeParentStream(disposeParentStream),
+ : _parentStream(parentStream, disposeParentStream),
_pos(0),
_end(end),
_eos(false) {
assert(parentStream);
}
- ~SubReadStream() {
- if (_disposeParentStream)
- delete _parentStream;
- }
virtual bool eos() const { return _eos | _parentStream->eos(); }
virtual bool err() const { return _parentStream->err(); }
diff --git a/common/system.cpp b/common/system.cpp
index 8d5bfd39cd..59210544ab 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -28,6 +28,7 @@
#include "common/savefile.h"
#include "common/str.h"
#include "common/taskbar.h"
+#include "common/updates.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -44,6 +45,9 @@ OSystem::OSystem() {
#if defined(USE_TASKBAR)
_taskbarManager = 0;
#endif
+#if defined(USE_UPDATES)
+ _updateManager = 0;
+#endif
_fsFactory = 0;
}
@@ -62,6 +66,11 @@ OSystem::~OSystem() {
_taskbarManager = 0;
#endif
+#if defined(USE_UPDATES)
+ delete _updateManager;
+ _updateManager = 0;
+#endif
+
delete _savefileManager;
_savefileManager = 0;
diff --git a/common/system.h b/common/system.h
index 9b833c5b1a..413fe326a7 100644
--- a/common/system.h
+++ b/common/system.h
@@ -45,6 +45,9 @@ class String;
#if defined(USE_TASKBAR)
class TaskbarManager;
#endif
+#if defined(USE_UPDATES)
+class UpdateManager;
+#endif
class TimerManager;
class SeekableReadStream;
class WriteStream;
@@ -161,6 +164,15 @@ protected:
Common::TaskbarManager *_taskbarManager;
#endif
+#if defined(USE_UPDATES)
+ /**
+ * No default value is provided for _updateManager by OSystem.
+ *
+ * @note _updateManager is deleted by the OSystem destructor.
+ */
+ Common::UpdateManager *_updateManager;
+#endif
+
/**
* No default value is provided for _fsFactory by OSystem.
*
@@ -391,6 +403,11 @@ public:
* factor 2x, too, just like the game graphics. But if it has a
* cursorTargetScale of 2, then it shouldn't be scaled again by
* the game graphics scaler.
+ *
+ * On a note for OSystem users here. We do not require our graphics
+ * to be thread safe and in fact most/all backends using OpenGL are
+ * not. So do *not* try to call any of these functions from a timer
+ * and/or audio callback (like readBuffer of AudioStreams).
*/
//@{
@@ -1071,6 +1088,18 @@ public:
}
#endif
+#if defined(USE_UPDATES)
+ /**
+ * Returns the UpdateManager, used to handle auto-updating,
+ * and updating of ScummVM in general.
+ *
+ * @return the UpdateManager for the current architecture
+ */
+ virtual Common::UpdateManager *getUpdateManager() {
+ return _updateManager;
+ }
+#endif
+
/**
* Returns the FilesystemFactory object, depending on the current architecture.
*
diff --git a/common/taskbar.h b/common/taskbar.h
index 023227e5e0..ba99d4e487 100644
--- a/common/taskbar.h
+++ b/common/taskbar.h
@@ -18,8 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
*/
#ifndef COMMON_TASKBAR_MANAGER_H
@@ -124,6 +122,18 @@ public:
*/
virtual void addRecent(const String &name, const String &description) {}
+ /**
+ * Notifies the user an error occured through the taskbar icon
+ *
+ * This will for example show the taskbar icon as red (using progress of 100% and an error state)
+ * on Windows, and set the launcher icon in the urgent state on Unity
+ */
+ virtual void notifyError() {}
+
+ /**
+ * Clears the error notification
+ */
+ virtual void clearError() {}
};
} // End of namespace Common
diff --git a/common/timer.h b/common/timer.h
index 40438f078c..3db32df76a 100644
--- a/common/timer.h
+++ b/common/timer.h
@@ -23,6 +23,7 @@
#define COMMON_TIMER_H
#include "common/scummsys.h"
+#include "common/str.h"
#include "common/noncopyable.h"
namespace Common {
@@ -43,9 +44,10 @@ public:
* @param proc the callback
* @param interval the interval in which the timer shall be invoked (in microseconds)
* @param refCon an arbitrary void pointer; will be passed to the timer callback
+ * @param id unique string id of the installed timer. Used by the event recorder
* @return true if the timer was installed successfully, false otherwise
*/
- virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon) = 0;
+ virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon, const Common::String &id) = 0;
/**
* Remove the given timer callback. It will not be invoked anymore,
diff --git a/common/tokenizer.cpp b/common/tokenizer.cpp
index 395ff0767a..46ba7a8d8b 100644
--- a/common/tokenizer.cpp
+++ b/common/tokenizer.cpp
@@ -53,4 +53,3 @@ String StringTokenizer::nextToken() {
}
} // End of namespace Common
-
diff --git a/common/unarj.cpp b/common/unarj.cpp
index f45dddaa38..cccc330bb5 100644
--- a/common/unarj.cpp
+++ b/common/unarj.cpp
@@ -293,8 +293,8 @@ ArjHeader *readHeader(SeekableReadStream &stream) {
return NULL;
}
- Common::strlcpy(header.filename, (const char *)&headData[header.firstHdrSize], ARJ_FILENAME_MAX);
- Common::strlcpy(header.comment, (const char *)&headData[header.firstHdrSize + strlen(header.filename) + 1], ARJ_COMMENT_MAX);
+ strlcpy(header.filename, (const char *)&headData[header.firstHdrSize], ARJ_FILENAME_MAX);
+ strlcpy(header.comment, (const char *)&headData[header.firstHdrSize + strlen(header.filename) + 1], ARJ_COMMENT_MAX);
// Process extended headers, if any
uint16 extHeaderSize;
@@ -692,15 +692,15 @@ void ArjDecoder::decode_f(int32 origsize) {
typedef HashMap<String, ArjHeader*, IgnoreCase_Hash, IgnoreCase_EqualTo> ArjHeadersMap;
-class ArjArchive : public Common::Archive {
+class ArjArchive : public Archive {
ArjHeadersMap _headers;
- Common::String _arjFilename;
+ String _arjFilename;
public:
ArjArchive(const String &name);
virtual ~ArjArchive();
- // Common::Archive implementation
+ // Archive implementation
virtual bool hasFile(const String &name);
virtual int listMembers(ArchiveMemberList &list);
virtual ArchiveMemberPtr getMember(const String &name);
@@ -708,7 +708,7 @@ public:
};
ArjArchive::ArjArchive(const String &filename) : _arjFilename(filename) {
- Common::File arjFile;
+ File arjFile;
if (!arjFile.open(_arjFilename)) {
warning("ArjArchive::ArjArchive(): Could not find the archive file");
@@ -775,7 +775,7 @@ SeekableReadStream *ArjArchive::createReadStreamForMember(const String &name) co
ArjHeader *hdr = _headers[name];
- Common::File archiveFile;
+ File archiveFile;
archiveFile.open(_arjFilename);
archiveFile.seek(hdr->pos, SEEK_SET);
@@ -794,8 +794,8 @@ SeekableReadStream *ArjArchive::createReadStreamForMember(const String &name) co
// If reading from archiveFile directly is too slow to be usable,
// maybe the filesystem code should instead wrap its files
// in a BufferedReadStream.
- decoder->_compressed = Common::wrapBufferedReadStream(&archiveFile, 4096, DisposeAfterUse::NO);
- decoder->_outstream = new Common::MemoryWriteStream(uncompressedData, hdr->origSize);
+ decoder->_compressed = wrapBufferedReadStream(&archiveFile, 4096, DisposeAfterUse::NO);
+ decoder->_outstream = new MemoryWriteStream(uncompressedData, hdr->origSize);
if (hdr->method == 1 || hdr->method == 2 || hdr->method == 3)
decoder->decode(hdr->origSize);
@@ -805,7 +805,7 @@ SeekableReadStream *ArjArchive::createReadStreamForMember(const String &name) co
delete decoder;
}
- return new Common::MemoryReadStream(uncompressedData, hdr->origSize, DisposeAfterUse::YES);
+ return new MemoryReadStream(uncompressedData, hdr->origSize, DisposeAfterUse::YES);
}
Archive *makeArjArchive(const String &name) {
diff --git a/common/unzip.cpp b/common/unzip.cpp
index 91f352f40a..8650c91866 100644
--- a/common/unzip.cpp
+++ b/common/unzip.cpp
@@ -1458,11 +1458,11 @@ ZipArchive::~ZipArchive() {
unzClose(_zipFile);
}
-bool ZipArchive::hasFile(const Common::String &name) {
+bool ZipArchive::hasFile(const String &name) {
return (unzLocateFile(_zipFile, name.c_str(), 2) == UNZ_OK);
}
-int ZipArchive::listMembers(Common::ArchiveMemberList &list) {
+int ZipArchive::listMembers(ArchiveMemberList &list) {
int matches = 0;
int err = unzGoToFirstFile(_zipFile);
@@ -1488,7 +1488,7 @@ ArchiveMemberPtr ZipArchive::getMember(const String &name) {
return ArchiveMemberPtr(new GenericArchiveMember(name, this));
}
-Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common::String &name) const {
+SeekableReadStream *ZipArchive::createReadStreamForMember(const String &name) const {
if (unzLocateFile(_zipFile, name.c_str(), 2) != UNZ_OK)
return 0;
@@ -1512,7 +1512,7 @@ Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common::
return 0;
}
- return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size, DisposeAfterUse::YES);
+ return new MemoryReadStream(buffer, fileInfo.uncompressed_size, DisposeAfterUse::YES);
// FIXME: instead of reading all into a memory stream, we could
// instead create a new ZipStream class. But then we have to be
diff --git a/common/updates.h b/common/updates.h
new file mode 100644
index 0000000000..1e0babdf6d
--- /dev/null
+++ b/common/updates.h
@@ -0,0 +1,102 @@
+/* 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.
+ *
+ */
+
+#ifndef BACKENDS_UPDATES_ABSTRACT_H
+#define BACKENDS_UPDATES_ABSTRACT_H
+
+#if defined(USE_UPDATES)
+
+namespace Common {
+
+/**
+ * The UpdateManager allows configuring of the automatic update checking
+ * for systems that support it:
+ * - using Sparkle on MacOSX
+ * - using WinSparkle on Windows
+ *
+ * Most of the update checking is completely automated and this class only
+ * gives access to basic settings. It is mostly used by the GUI to set
+ * widgets state on the update page and for manually checking for updates
+ *
+ */
+class UpdateManager {
+public:
+ enum UpdateState {
+ kUpdateStateDisabled = 0,
+ kUpdateStateEnabled = 1,
+ kUpdateStateNotSupported = 2
+ };
+
+ enum UpdateInterval {
+ kUpdateIntervalNotSupported = 0,
+ kUpdateIntervalOneDay = 86400,
+ kUpdateIntervalOneWeek = 604800,
+ kUpdateIntervalOneMonth = 2628000 // average seconds per month (60*60*24*365)/12
+ };
+
+ UpdateManager() {}
+ virtual ~UpdateManager() {}
+
+ /**
+ * Checks manually if an update is available, showing progress UI to the user.
+ *
+ * By default, update checks are done silently on start.
+ * This allows to manually start an update check.
+ */
+ virtual void checkForUpdates() {}
+
+ /**
+ * Sets the automatic update checking state
+ *
+ * @param state The state.
+ */
+ virtual void setAutomaticallyChecksForUpdates(UpdateState state) {}
+
+ /**
+ * Gets the automatic update checking state
+ *
+ * @return kUpdateStateDisabled if automatic update checking is disabled,
+ * kUpdateStateEnabled if automatic update checking is enabled,
+ * kUpdateStateNotSupported if automatic update checking is not available
+ */
+ virtual UpdateState getAutomaticallyChecksForUpdates() { return kUpdateStateNotSupported; }
+
+ /**
+ * Sets the update checking interval.
+ *
+ * @param interval The interval.
+ */
+ virtual void setUpdateCheckInterval(UpdateInterval interval) {}
+
+ /**
+ * Gets the update check interval.
+ *
+ * @return the update check interval.
+ */
+ virtual UpdateInterval getUpdateCheckInterval() { return kUpdateIntervalNotSupported; }
+};
+
+} // End of namespace Common
+
+#endif
+
+#endif // BACKENDS_UPDATES_ABSTRACT_H
diff --git a/common/util.cpp b/common/util.cpp
index a7ec1a9de7..6bde6a6555 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -82,7 +82,7 @@ void hexdump(const byte *data, int len, int bytesPerLine, int startOffset) {
#pragma mark -
-bool parseBool(const Common::String &val, bool &valAsBool) {
+bool parseBool(const String &val, bool &valAsBool) {
if (val.equalsIgnoreCase("true") ||
val.equalsIgnoreCase("yes") ||
val.equals("1")) {
@@ -402,4 +402,3 @@ void updateGameGUIOptions(const uint32 options, const String &langOption) {
}
} // End of namespace Common
-
diff --git a/common/util.h b/common/util.h
index cd890c970f..a96c7a60c6 100644
--- a/common/util.h
+++ b/common/util.h
@@ -58,6 +58,11 @@ template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
*/
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
+/**
+ * Compute a pointer to one past the last element of an array.
+ */
+#define ARRAYEND(x) ((x) + ARRAYSIZE((x)))
+
/**
* @def SCUMMVM_CURRENT_FUNCTION
@@ -96,7 +101,7 @@ extern void hexdump(const byte * data, int len, int bytesPerLine = 16, int start
* @param[out] valAsBool the parsing result
* @return true if the string parsed correctly, false if an error occurred.
*/
-bool parseBool(const Common::String &val, bool &valAsBool);
+bool parseBool(const String &val, bool &valAsBool);
/**
* List of game language.
@@ -131,7 +136,7 @@ struct LanguageDescription {
const char *code;
//const char *unixLocale;
const char *description;
- Common::Language id;
+ Language id;
};
extern const LanguageDescription g_languages[];
@@ -182,7 +187,7 @@ struct PlatformDescription {
const char *code2;
const char *abbrev;
const char *description;
- Common::Platform id;
+ Platform id;
};
extern const PlatformDescription g_platforms[];
@@ -211,7 +216,7 @@ enum RenderMode {
struct RenderModeDescription {
const char *code;
const char *description;
- Common::RenderMode id;
+ RenderMode id;
};
extern const RenderModeDescription g_renderModes[];
diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp
index e5f6a24bcd..6c0f9c9962 100644
--- a/common/winexe_pe.cpp
+++ b/common/winexe_pe.cpp
@@ -133,7 +133,7 @@ void PEResources::parseResourceLevel(Section &section, uint32 offset, int level)
_exe->seek(section.offset + (value & 0x7fffffff));
// Read in the name, truncating from unicode to ascii
- Common::String name;
+ String name;
uint16 nameLength = _exe->readUint16LE();
while (nameLength--)
name += (char)(_exe->readUint16LE() & 0xff);
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 623619914a..f768e44382 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -81,7 +81,7 @@ void XMLParser::close() {
_stream = 0;
}
-bool XMLParser::parserError(const Common::String &errStr) {
+bool XMLParser::parserError(const String &errStr) {
_state = kParserError;
const int startPosition = _stream->pos();
diff --git a/common/xmlparser.h b/common/xmlparser.h
index d75dc0e4a9..93433b7132 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -275,7 +275,7 @@ protected:
* Parser error always returns "false" so we can pass the return value
* directly and break down the parsing.
*/
- bool parserError(const Common::String &errStr);
+ bool parserError(const String &errStr);
/**
* Skips spaces/whitelines etc.
diff --git a/common/zlib.cpp b/common/zlib.cpp
index b047586af0..86c618830e 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -24,6 +24,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/zlib.h"
+#include "common/ptr.h"
#include "common/util.h"
#include "common/stream.h"
@@ -53,7 +54,7 @@ bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long
* other SeekableReadStream and will then provide on-the-fly decompression support.
* Assumes the compressed data to be in gzip format.
*/
-class GZipReadStream : public Common::SeekableReadStream {
+class GZipReadStream : public SeekableReadStream {
protected:
enum {
BUFSIZE = 16384 // 1 << MAX_WBITS
@@ -61,7 +62,7 @@ protected:
byte _buf[BUFSIZE];
- Common::SeekableReadStream *_wrapped;
+ ScopedPtr<SeekableReadStream> _wrapped;
z_stream _stream;
int _zlibErr;
uint32 _pos;
@@ -70,13 +71,9 @@ protected:
public:
- GZipReadStream(Common::SeekableReadStream *w) : _wrapped(w) {
+ GZipReadStream(SeekableReadStream *w) : _wrapped(w), _stream() {
assert(w != 0);
- _stream.zalloc = Z_NULL;
- _stream.zfree = Z_NULL;
- _stream.opaque = Z_NULL;
-
// Verify file header is correct
w->seek(0, SEEK_SET);
uint16 header = w->readUint16BE();
@@ -111,7 +108,6 @@ public:
~GZipReadStream() {
inflateEnd(&_stream);
- delete _wrapped;
}
bool err() const { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); }
@@ -201,14 +197,14 @@ public:
* other WriteStream and will then provide on-the-fly compression support.
* The compressed data is written in the gzip format.
*/
-class GZipWriteStream : public Common::WriteStream {
+class GZipWriteStream : public WriteStream {
protected:
enum {
BUFSIZE = 16384 // 1 << MAX_WBITS
};
byte _buf[BUFSIZE];
- Common::WriteStream *_wrapped;
+ ScopedPtr<WriteStream> _wrapped;
z_stream _stream;
int _zlibErr;
@@ -228,11 +224,8 @@ protected:
}
public:
- GZipWriteStream(Common::WriteStream *w) : _wrapped(w) {
+ GZipWriteStream(WriteStream *w) : _wrapped(w), _stream() {
assert(w != 0);
- _stream.zalloc = Z_NULL;
- _stream.zfree = Z_NULL;
- _stream.opaque = Z_NULL;
// Adding 16 to windowBits indicates to zlib that it is supposed to
// write gzip headers. This feature was added in zlib 1.2.0.4,
@@ -255,7 +248,6 @@ public:
~GZipWriteStream() {
finalize();
deflateEnd(&_stream);
- delete _wrapped;
}
bool err() const {
@@ -308,7 +300,7 @@ public:
#endif // USE_ZLIB
-Common::SeekableReadStream *wrapCompressedReadStream(Common::SeekableReadStream *toBeWrapped) {
+SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped) {
#if defined(USE_ZLIB)
if (toBeWrapped) {
uint16 header = toBeWrapped->readUint16BE();
@@ -323,7 +315,7 @@ Common::SeekableReadStream *wrapCompressedReadStream(Common::SeekableReadStream
return toBeWrapped;
}
-Common::WriteStream *wrapCompressedWriteStream(Common::WriteStream *toBeWrapped) {
+WriteStream *wrapCompressedWriteStream(WriteStream *toBeWrapped) {
#if defined(USE_ZLIB)
if (toBeWrapped)
return new GZipWriteStream(toBeWrapped);