the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -30,6 +30,15 @@ size_t i;
|
||||
Plugin::Plugin()
|
||||
{
|
||||
current_plugin = -1;
|
||||
request = 0;
|
||||
|
||||
db = 0;
|
||||
config = 0;
|
||||
request = 0;
|
||||
system = 0;
|
||||
functions = 0;
|
||||
templates = 0;
|
||||
session_manager = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +48,67 @@ Plugin::~Plugin()
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
void Plugin::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetRequest(Request * prequest)
|
||||
{
|
||||
request = prequest;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetFunctions(Functions * pfunctions)
|
||||
{
|
||||
functions = pfunctions;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetTemplates(Templates * ptemplates)
|
||||
{
|
||||
templates = ptemplates;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::SetSessionManager(SessionManager * psession_manager)
|
||||
{
|
||||
session_manager = psession_manager;
|
||||
}
|
||||
|
||||
|
||||
bool Plugin::SetPointers(PluginInfo & info)
|
||||
{
|
||||
// for safety we call a plugin function only when all our pointers are not null
|
||||
bool res = (db && config && request && system && functions && templates && session_manager);
|
||||
|
||||
if( !res )
|
||||
log << log1 << "Plugin: cannot call a function - some of the winix pointers are null" << logend;
|
||||
|
||||
info.db = db;
|
||||
info.config = config;
|
||||
info.request = request;
|
||||
info.system = system;
|
||||
info.functions = functions;
|
||||
info.templates = templates;
|
||||
info.session_manager = session_manager;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void Plugin::LoadPlugins(const std::vector<std::string> & plugins)
|
||||
{
|
||||
size_t i;
|
||||
@@ -60,7 +130,8 @@ void * Plugin::LoadInitFun(const char * filename, Fun1 & fun_init)
|
||||
|
||||
if( !p )
|
||||
{
|
||||
log << log1 << "Plugin: cannot load a plugin: " << filename << logend;
|
||||
log << log1 << "Plugin: cannot load a plugin: \"" << filename << "\"" << logend;
|
||||
log << log1 << "Plugin: dlerror: " << dlerror() << logend;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,6 +161,9 @@ Fun1 fun_init;
|
||||
void * plugin_handle;
|
||||
int old_current_plugin;
|
||||
|
||||
if( !SetPointers(info) )
|
||||
return;
|
||||
|
||||
if( !(plugin_handle = LoadInitFun(filename, fun_init)) )
|
||||
return;
|
||||
|
||||
@@ -102,7 +176,7 @@ int old_current_plugin;
|
||||
|
||||
PluginsItem item;
|
||||
item.handle = plugin_handle;
|
||||
item.plugin_name = (const char *)info.p1;
|
||||
item.plugin_name = reinterpret_cast<const char *>(info.p1);
|
||||
|
||||
plugins.push_back(item);
|
||||
|
||||
@@ -113,11 +187,14 @@ int old_current_plugin;
|
||||
|
||||
void Plugin::Call(int message, Slots::iterator & slot)
|
||||
{
|
||||
if( !SetPointers(info) )
|
||||
return;
|
||||
|
||||
current_plugin = slot->second.index;
|
||||
info.plugin_id = current_plugin;
|
||||
|
||||
if( request.session && current_plugin != -1 )
|
||||
info.plugin_data_base = request.session->plugin_data.Get(current_plugin);
|
||||
if( request && request->session && current_plugin != -1 )
|
||||
info.plugin_data_base = request->session->plugin_data.Get(current_plugin);
|
||||
else
|
||||
info.plugin_data_base = 0;
|
||||
|
||||
@@ -168,36 +245,43 @@ void Plugin::Call(int message)
|
||||
Call(message, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, void * p1_)
|
||||
{
|
||||
Call(message, p1_, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, void * p1_, void * p2_)
|
||||
{
|
||||
Call(message, p1_, p2_, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, long l1_)
|
||||
{
|
||||
Call(message, 0, 0, l1_, 0);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, long l1_, long l2_)
|
||||
{
|
||||
Call(message, 0, 0, l1_, l2_);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, void * p1_, long l1_)
|
||||
{
|
||||
Call(message, p1_, 0, l1_, 0);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, void * p1_, long l1_, long l2_)
|
||||
{
|
||||
Call(message, p1_, 0, l1_, l2_);
|
||||
}
|
||||
|
||||
|
||||
void Plugin::Call(int message, void * p1_, void * p2_, long l1_)
|
||||
{
|
||||
Call(message, p1_, p2_, l1_, 0);
|
||||
|
Reference in New Issue
Block a user