added: sessions data for plugins (plugindata.h plugindata.cpp)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@598 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -29,6 +29,7 @@ size_t i;
|
||||
|
||||
Plugin::Plugin()
|
||||
{
|
||||
current_plugin = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +44,7 @@ void Plugin::LoadPlugins(const std::vector<std::string> & plugins)
|
||||
size_t i;
|
||||
|
||||
for(i=0 ; i<plugins.size() ; ++i)
|
||||
{
|
||||
LoadPlugin(plugins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,10 +81,15 @@ void Plugin::LoadPlugin(const char * filename)
|
||||
}
|
||||
|
||||
arg.Clear();
|
||||
|
||||
|
||||
int old_current_plugin = current_plugin;
|
||||
|
||||
current_plugin = (int)plugins.size();
|
||||
arg.plugin_id = current_plugin;
|
||||
|
||||
if( fun(&arg) )
|
||||
{
|
||||
log << log1 << "Pl: plugin loaded: " << filename << logend;
|
||||
log << log1 << "Pl: plugin loaded: " << filename << ", index: " << plugins.size() << logend;
|
||||
plugins.push_back(p);
|
||||
}
|
||||
else
|
||||
@@ -93,6 +97,8 @@ void Plugin::LoadPlugin(const char * filename)
|
||||
log << log1 << "Pl: plugin Init() returned false (" << filename << ") " << logend;
|
||||
dlclose(p);
|
||||
}
|
||||
|
||||
current_plugin = old_current_plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,26 +108,49 @@ Arg * Plugin::Call(int message, void * a, void * a2, void * a3)
|
||||
{
|
||||
Slots::iterator i = slots.lower_bound(message);
|
||||
arg.Clear();
|
||||
arg.app = a;
|
||||
arg.app2 = a2;
|
||||
arg.app3 = a3;
|
||||
|
||||
int old_current_plugin = current_plugin;
|
||||
|
||||
for( ; i!=slots.end() && i->first==message ; ++i )
|
||||
{
|
||||
if( i->second(&arg) )
|
||||
arg.app = a;
|
||||
arg.app2 = a2;
|
||||
arg.app3 = a3;
|
||||
current_plugin = i->second.index;
|
||||
arg.plugin_id = current_plugin;
|
||||
|
||||
if( request.session && current_plugin != -1 )
|
||||
arg.plugin_data_base = request.session->plugin_data.Get(current_plugin);
|
||||
else
|
||||
arg.plugin_data_base = 0;
|
||||
|
||||
if( i->second.fun(&arg) )
|
||||
arg.ret_true++;
|
||||
else
|
||||
arg.ret_false++;
|
||||
}
|
||||
|
||||
current_plugin = old_current_plugin;
|
||||
|
||||
return &arg;
|
||||
}
|
||||
|
||||
|
||||
size_t Plugin::Size()
|
||||
{
|
||||
return plugins.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Plugin::Assign(int message, Fun fun)
|
||||
{
|
||||
slots.insert( std::make_pair(message, fun) );
|
||||
Slot s;
|
||||
|
||||
s.fun = fun;
|
||||
s.index = current_plugin;
|
||||
|
||||
slots.insert( std::make_pair(message, s) );
|
||||
|
||||
log << log3 << "Plugin: added function for message: " << message << ", plugin index: " << s.index << logend;
|
||||
}
|
||||
|
Reference in New Issue
Block a user