diff options
| author | Max Horn | 2008-05-06 15:21:46 +0000 | 
|---|---|---|
| committer | Max Horn | 2008-05-06 15:21:46 +0000 | 
| commit | ba6c4a6239d5496f0f218d8fa76c11e77bf9139e (patch) | |
| tree | 8c7c9d3d32b38e8ddd10499ab10e2b63b5eb8f36 /backends/plugins | |
| parent | 4331411ebea61072ff0189d7d61ac57199a120af (diff) | |
| parent | 397e04d0b1ff6d96502c4eca42c1ab4a31b2dbcd (diff) | |
| download | scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.tar.gz scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.tar.bz2 scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.zip  | |
Merge with trunk, using the svnmerge tool
svn-id: r31898
Diffstat (limited to 'backends/plugins')
| -rw-r--r-- | backends/plugins/dc/dc-provider.cpp | 43 | ||||
| -rw-r--r-- | backends/plugins/dc/dc-provider.h | 13 | ||||
| -rw-r--r-- | backends/plugins/posix/posix-provider.cpp | 41 | ||||
| -rw-r--r-- | backends/plugins/posix/posix-provider.h | 6 | ||||
| -rw-r--r-- | backends/plugins/sdl/sdl-provider.cpp | 43 | ||||
| -rw-r--r-- | backends/plugins/sdl/sdl-provider.h | 6 | ||||
| -rw-r--r-- | backends/plugins/win32/win32-provider.cpp | 44 | ||||
| -rw-r--r-- | backends/plugins/win32/win32-provider.h | 11 | 
8 files changed, 37 insertions, 170 deletions
diff --git a/backends/plugins/dc/dc-provider.cpp b/backends/plugins/dc/dc-provider.cpp index 6ca524150b..1cae4bbd32 100644 --- a/backends/plugins/dc/dc-provider.cpp +++ b/backends/plugins/dc/dc-provider.cpp @@ -27,12 +27,8 @@  #include "backends/plugins/dc/dc-provider.h"  #include "backends/plugins/dynamic-plugin.h" -#include "common/fs.h"  #include "dcloader.h" -#define PLUGIN_DIRECTORY	"/" -#define PLUGIN_PREFIX		"" -#define PLUGIN_SUFFIX		".PLG"  class DCPlugin : public DynamicPlugin { @@ -75,6 +71,7 @@ public:  		return ret;  	} +  	void unloadPlugin() {  		DynamicPlugin::unloadPlugin();  		if (_dlHandle) { @@ -86,42 +83,8 @@ public:  }; -PluginList DCPluginProvider::getPlugins() { -	PluginList pl; - - -	// Load dynamic plugins -	// TODO... this is right now just a nasty hack. -	// This should search one or multiple directories for all plugins it can -	// find (to this end, we maybe should use a special prefix/suffix; e.g. -	// instead of libscumm.so, use scumm.engine or scumm.plugin etc.). -	// -	// The list of directories to search could be e.g.: -	// User specified (via config file), ".", "./plugins", "$(prefix)/lib". -	// -	// We also need to add code which ensures what we are looking at is -	// a) a ScummVM engine and b) matches the version of the executable. -	// Hence one more symbol should be exported by plugins which returns -	// the "ABI" version the plugin was built for, and we can compare that -	// to the ABI version of the executable. - -	// Load all plugins. -	// Scan for all plugins in this directory -	FilesystemNode dir(PLUGIN_DIRECTORY); -	FSList files; -	if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) { -		error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY); -	} - -	for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) { -		Common::String name(i->getName()); -		if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) { -			pl.push_back(new DCPlugin(i->getPath())); -		} -	} - - -	return pl; +Plugin* SDLPluginProvider::createPlugin(const Common::String &filename) const { +	return new DCPlugin(filename);  } diff --git a/backends/plugins/dc/dc-provider.h b/backends/plugins/dc/dc-provider.h index f13bdf0636..1b96f55d4d 100644 --- a/backends/plugins/dc/dc-provider.h +++ b/backends/plugins/dc/dc-provider.h @@ -30,9 +30,16 @@  #if defined(DYNAMIC_MODULES) && defined(__DC__) -class DCPluginProvider : public PluginProvider { -public: -	virtual PluginList getPlugins(); +class DCPluginProvider : public FilePluginProvider { +protected: +	Plugin* createPlugin(const Common::String &filename) const; + +	virtual const char* getPrefix() const { return ""; } +	virtual const char* getSuffix() const { return ".PLG"; } + +	virtual void addCustomDirectories(Common::StringList &dirs) const { +		dirs.push_back("/"); +	}  };  #endif // defined(DYNAMIC_MODULES) && defined(__DC__) diff --git a/backends/plugins/posix/posix-provider.cpp b/backends/plugins/posix/posix-provider.cpp index a268aa36e1..39847e53bf 100644 --- a/backends/plugins/posix/posix-provider.cpp +++ b/backends/plugins/posix/posix-provider.cpp @@ -27,10 +27,8 @@  #include "backends/plugins/posix/posix-provider.h"  #include "backends/plugins/dynamic-plugin.h" -#include "common/fs.h"  #include <dlfcn.h> -#define PLUGIN_DIRECTORY	"plugins/"  class POSIXPlugin : public DynamicPlugin { @@ -68,6 +66,7 @@ public:  		return DynamicPlugin::loadPlugin();  	} +  	void unloadPlugin() {  		DynamicPlugin::unloadPlugin();  		if (_dlHandle) { @@ -79,42 +78,8 @@ public:  }; -PluginList POSIXPluginProvider::getPlugins() { -	PluginList pl; - - -	// Load dynamic plugins -	// TODO... this is right now just a nasty hack. -	// This should search one or multiple directories for all plugins it can -	// find (to this end, we maybe should use a special prefix/suffix; e.g. -	// instead of libscumm.so, use scumm.engine or scumm.plugin etc.). -	// -	// The list of directories to search could be e.g.: -	// User specified (via config file), ".", "./plugins", "$(prefix)/lib". -	// -	// We also need to add code which ensures what we are looking at is -	// a) a ScummVM engine and b) matches the version of the executable. -	// Hence one more symbol should be exported by plugins which returns -	// the "ABI" version the plugin was built for, and we can compare that -	// to the ABI version of the executable. - -	// Load all plugins. -	// Scan for all plugins in this directory -	FilesystemNode dir(PLUGIN_DIRECTORY); -	FSList files; -	if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) { -		error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY); -	} - -	for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) { -		Common::String name(i->getName()); -		if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) { -			pl.push_back(new POSIXPlugin(i->getPath())); -		} -	} - - -	return pl; +Plugin* POSIXPluginProvider::createPlugin(const Common::String &filename) const { +	return new POSIXPlugin(filename);  } diff --git a/backends/plugins/posix/posix-provider.h b/backends/plugins/posix/posix-provider.h index 7a7b780fbe..40c16b3e11 100644 --- a/backends/plugins/posix/posix-provider.h +++ b/backends/plugins/posix/posix-provider.h @@ -30,9 +30,9 @@  #if defined(DYNAMIC_MODULES) && defined(UNIX) -class POSIXPluginProvider : public PluginProvider { -public: -	virtual PluginList getPlugins(); +class POSIXPluginProvider : public FilePluginProvider { +protected: +	Plugin* createPlugin(const Common::String &filename) const;  };  #endif // defined(DYNAMIC_MODULES) && defined(UNIX) diff --git a/backends/plugins/sdl/sdl-provider.cpp b/backends/plugins/sdl/sdl-provider.cpp index 5cdc7223a5..6df1dec680 100644 --- a/backends/plugins/sdl/sdl-provider.cpp +++ b/backends/plugins/sdl/sdl-provider.cpp @@ -27,11 +27,9 @@  #include "backends/plugins/sdl/sdl-provider.h"  #include "backends/plugins/dynamic-plugin.h" -#include "common/fs.h"  #include "SDL.h"  #include "SDL_loadso.h" -#define PLUGIN_DIRECTORY	"plugins/"  class SDLPlugin : public DynamicPlugin { @@ -69,6 +67,7 @@ public:  		return DynamicPlugin::loadPlugin();  	} +  	void unloadPlugin() {  		DynamicPlugin::unloadPlugin();  		if (_dlHandle) { @@ -79,43 +78,9 @@ public:  }; -PluginList SDLPluginProvider::getPlugins() { -	PluginList pl; - - -	// Load dynamic plugins -	// TODO... this is right now just a nasty hack. -	// This should search one or multiple directories for all plugins it can -	// find (to this end, we maybe should use a special prefix/suffix; e.g. -	// instead of libscumm.so, use scumm.engine or scumm.plugin etc.). -	// -	// The list of directories to search could be e.g.: -	// User specified (via config file), ".", "./plugins", "$(prefix)/lib". -	// -	// We also need to add code which ensures what we are looking at is -	// a) a ScummVM engine and b) matches the version of the executable. -	// Hence one more symbol should be exported by plugins which returns -	// the "ABI" version the plugin was built for, and we can compare that -	// to the ABI version of the executable. - -	// Load all plugins. -	// Scan for all plugins in this directory -	FilesystemNode dir(PLUGIN_DIRECTORY); -	FSList files; -	if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) { -		error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY); -	} - -	for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) { -		Common::String name(i->getName()); -		if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) { -			pl.push_back(new SDLPlugin(i->getPath())); -		} -	} - - -	return pl; +Plugin* SDLPluginProvider::createPlugin(const Common::String &filename) const { +	return new SDLPlugin(filename);  } -#endif // defined(DYNAMIC_MODULES) && defined(UNIX) +#endif // defined(DYNAMIC_MODULES) && defined(SDL_BACKEND) diff --git a/backends/plugins/sdl/sdl-provider.h b/backends/plugins/sdl/sdl-provider.h index 7e03a4ec57..a9ec657e33 100644 --- a/backends/plugins/sdl/sdl-provider.h +++ b/backends/plugins/sdl/sdl-provider.h @@ -30,9 +30,9 @@  #if defined(DYNAMIC_MODULES) && defined(SDL_BACKEND) -class SDLPluginProvider : public PluginProvider { -public: -	virtual PluginList getPlugins(); +class SDLPluginProvider : public FilePluginProvider { +protected: +	Plugin* createPlugin(const Common::String &filename) const;  };  #endif // defined(DYNAMIC_MODULES) && defined(UNIX) diff --git a/backends/plugins/win32/win32-provider.cpp b/backends/plugins/win32/win32-provider.cpp index 8cb9a762b2..0592638140 100644 --- a/backends/plugins/win32/win32-provider.cpp +++ b/backends/plugins/win32/win32-provider.cpp @@ -27,14 +27,9 @@  #include "backends/plugins/win32/win32-provider.h"  #include "backends/plugins/dynamic-plugin.h" -#include "common/fs.h"  #include <windows.h> -#define PLUGIN_DIRECTORY	"" -#define PLUGIN_PREFIX		"" -#define PLUGIN_SUFFIX		".dll" -  class Win32Plugin : public DynamicPlugin {  private: @@ -94,6 +89,7 @@ public:  		return DynamicPlugin::loadPlugin();  	} +  	void unloadPlugin() {  		DynamicPlugin::unloadPlugin();  		if (_dlHandle) { @@ -107,42 +103,8 @@ public:  }; -PluginList Win32PluginProvider::getPlugins() { -	PluginList pl; - - -	// Load dynamic plugins -	// TODO... this is right now just a nasty hack. -	// This should search one or multiple directories for all plugins it can -	// find (to this end, we maybe should use a special prefix/suffix; e.g. -	// instead of libscumm.so, use scumm.engine or scumm.plugin etc.). -	// -	// The list of directories to search could be e.g.: -	// User specified (via config file), ".", "./plugins", "$(prefix)/lib". -	// -	// We also need to add code which ensures what we are looking at is -	// a) a ScummVM engine and b) matches the version of the executable. -	// Hence one more symbol should be exported by plugins which returns -	// the "ABI" version the plugin was built for, and we can compare that -	// to the ABI version of the executable. - -	// Load all plugins. -	// Scan for all plugins in this directory -	FilesystemNode dir(PLUGIN_DIRECTORY); -	FSList files; -	if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) { -		error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY); -	} - -	for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) { -		Common::String name(i->getName()); -		if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) { -			pl.push_back(new Win32Plugin(i->getPath())); -		} -	} - - -	return pl; +Plugin* Win32PluginProvider::createPlugin(const Common::String &filename) const { +	return new Win32Plugin(filename);  } diff --git a/backends/plugins/win32/win32-provider.h b/backends/plugins/win32/win32-provider.h index e80e77521d..e4b0be7395 100644 --- a/backends/plugins/win32/win32-provider.h +++ b/backends/plugins/win32/win32-provider.h @@ -30,9 +30,14 @@  #if defined(DYNAMIC_MODULES) && defined(_WIN32) -class Win32PluginProvider : public PluginProvider { -public: -	virtual PluginList getPlugins(); +class Win32PluginProvider : public FilePluginProvider { +protected: +	Plugin* createPlugin(const Common::String &filename) const; + +	virtual const char* getPrefix() const { return ""; } +	virtual const char* getSuffix() const { return ".dll"; } + +	virtual void addCustomDirectories(Common::StringList &dirs) const {}  };  #endif // defined(DYNAMIC_MODULES) && defined(_WIN32)  | 
