Originally committed to SVN as r1945.

This commit is contained in:
Rodrigo Braz Monteiro 2008-03-07 00:47:57 +00:00
parent e65fdf1fcf
commit 6bdee2a765
11 changed files with 147 additions and 31 deletions

View file

@ -231,6 +231,7 @@ aegisub_SOURCES = \
mkv_wrap.cpp \ mkv_wrap.cpp \
mythes.cxx \ mythes.cxx \
options.cpp \ options.cpp \
plugin_manager.cpp \
scintilla_text_ctrl.cpp \ scintilla_text_ctrl.cpp \
spellchecker.cpp \ spellchecker.cpp \
spline.cpp \ spline.cpp \

View file

@ -127,12 +127,6 @@ void AudioPlayer::OnStopAudio(wxCommandEvent &event) {
////////////// //////////////
// Get player // Get player
AudioPlayer* AudioPlayerFactory::GetAudioPlayer() { AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
// Register factories
// HACK: fix me
static bool init = false;
if (!init) RegisterFactories();
init = true;
// List of providers // List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Audio player"))); wxArrayString list = GetFactoryList(Options.AsText(_T("Audio player")));
@ -158,7 +152,7 @@ AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
////////////////////////// //////////////////////////
// Register all factories // Register all factories
void AudioPlayerFactory::RegisterFactories() { void AudioPlayerFactory::RegisterProviders() {
#ifdef WITH_ALSA #ifdef WITH_ALSA
new AlsaPlayerFactory(); new AlsaPlayerFactory();
#endif #endif

View file

@ -104,7 +104,7 @@ protected:
public: public:
virtual ~AudioPlayerFactory() {} virtual ~AudioPlayerFactory() {}
static AudioPlayer *GetAudioPlayer(); static AudioPlayer *GetAudioPlayer();
static void RegisterFactories(); static void RegisterProviders();
}; };

View file

@ -192,12 +192,6 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
//////////////// ////////////////
// Get provider // Get provider
AudioProvider *AudioProviderFactory::GetAudioProvider(wxString filename, int cache) { AudioProvider *AudioProviderFactory::GetAudioProvider(wxString filename, int cache) {
// Initialize providers
// HACK: fixme
static bool init = false;
if (!init) RegisterProviders();
init = true;
// Prepare provider // Prepare provider
AudioProvider *provider = NULL; AudioProvider *provider = NULL;

View file

@ -65,6 +65,7 @@
#include "auto4_base.h" #include "auto4_base.h"
#endif #endif
#include "version.h" #include "version.h"
#include "plugin_manager.h"
/////////////////// ///////////////////
@ -156,11 +157,9 @@ bool AegisubApp::OnInit() {
locale.Init(wxLANGUAGE_DEFAULT); locale.Init(wxLANGUAGE_DEFAULT);
#endif #endif
// Set association // Load plugins
#ifndef _DEBUG plugins = new PluginManager();
StartupLog(_T("Install file type associations")); plugins->RegisterBuiltInPlugins();
RegistryAssociate();
#endif
// Load Automation scripts // Load Automation scripts
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
@ -172,6 +171,12 @@ bool AegisubApp::OnInit() {
StartupLog(_T("Prepare export filters")); StartupLog(_T("Prepare export filters"));
AssExportFilterChain::PrepareFilters(); AssExportFilterChain::PrepareFilters();
// Set association
#ifndef _DEBUG
StartupLog(_T("Install file type associations"));
RegistryAssociate();
#endif
// Get parameter subs // Get parameter subs
StartupLog(_T("Parse command line")); StartupLog(_T("Parse command line"));
wxArrayString subs; wxArrayString subs;
@ -205,6 +210,7 @@ bool AegisubApp::OnInit() {
int AegisubApp::OnExit() { int AegisubApp::OnExit() {
SubtitleFormat::DestroyFormats(); SubtitleFormat::DestroyFormats();
VideoContext::Clear(); VideoContext::Clear();
delete plugins;
Options.Clear(); Options.Clear();
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
delete global_scripts; delete global_scripts;

View file

@ -51,6 +51,7 @@
////////////// //////////////
// Prototypes // Prototypes
class FrameMain; class FrameMain;
class PluginManager;
namespace Automation4 { class AutoloadScriptManager; } namespace Automation4 { class AutoloadScriptManager; }
@ -58,6 +59,8 @@ namespace Automation4 { class AutoloadScriptManager; }
// Application class definition // Application class definition
class AegisubApp: public wxApp { class AegisubApp: public wxApp {
private: private:
PluginManager *plugins;
void OnMouseWheel(wxMouseEvent &event); void OnMouseWheel(wxMouseEvent &event);
void OnKey(wxKeyEvent &key); void OnKey(wxKeyEvent &key);

View file

@ -0,0 +1,71 @@
// Copyright (c) 2008, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
///////////
// Headers
#include "plugin_manager.h"
#include "video_provider.h"
#include "audio_provider.h"
#include "audio_player.h"
#include "subtitles_provider.h"
///////////////
// Constructor
PluginManager::PluginManager() {
init = false;
}
//////////////
// Destructor
PluginManager::~PluginManager() {
}
//////////////////////////////////
// Registers all built-in plugins
void PluginManager::RegisterBuiltInPlugins() {
if (!init) {
VideoProviderFactory::RegisterProviders();
AudioProviderFactory::RegisterProviders();
AudioPlayerFactory::RegisterProviders();
SubtitlesProviderFactory::RegisterProviders();
}
// Done
init = true;
}

51
aegisub/plugin_manager.h Normal file
View file

@ -0,0 +1,51 @@
// Copyright (c) 2008, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
////////////////////////
// Plugin manager class
class PluginManager {
private:
bool init;
public:
PluginManager();
~PluginManager();
void RegisterBuiltInPlugins();
};

View file

@ -66,12 +66,6 @@ bool SubtitlesProviderFactory::ProviderAvailable() {
//////////////// ////////////////
// Get provider // Get provider
SubtitlesProvider* SubtitlesProviderFactory::GetProvider() { SubtitlesProvider* SubtitlesProviderFactory::GetProvider() {
// Register them
// HACK: fix me
static bool init = false;
if (!init) RegisterProviders();
init = true;
// List of providers // List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Subtitles provider"))); wxArrayString list = GetFactoryList(Options.AsText(_T("Subtitles provider")));

View file

@ -61,12 +61,6 @@ VideoProvider *VideoProviderFactory::GetProvider(wxString video,double fps) {
return new DummyVideoProvider(video, fps); return new DummyVideoProvider(video, fps);
} }
// Register the first time
// HACK: move this into program initialization later
static bool init = false;
if (!init) RegisterProviders();
init = true;
// List of providers // List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Video provider"))); wxArrayString list = GetFactoryList(Options.AsText(_T("Video provider")));

View file

@ -1444,6 +1444,14 @@
RelativePath="..\..\aegisub\options.h" RelativePath="..\..\aegisub\options.h"
> >
</File> </File>
<File
RelativePath="..\..\aegisub\plugin_manager.cpp"
>
</File>
<File
RelativePath="..\..\aegisub\plugin_manager.h"
>
</File>
<File <File
RelativePath="..\..\aegisub\setup.cpp" RelativePath="..\..\aegisub\setup.cpp"
> >