Author: erijo
Date: Mon Oct 25 04:52:02 2010
New Revision: 7946
Log:
Setup a plugin's log instance before calling the init function
Modified:
trunk/licq/src/daemon.cpp
trunk/licq/src/daemon.h
trunk/licq/src/licq.cpp
trunk/licq/src/plugins/pluginmanager.cpp
Modified: trunk/licq/src/daemon.cpp
==============================================================================
--- trunk/licq/src/daemon.cpp (original)
+++ trunk/licq/src/daemon.cpp Mon Oct 25 04:52:02 2010
@@ -71,7 +71,8 @@
const char* const Daemon::TranslationDir = "translations";
const char* const Daemon::UtilityDir = "utilities";
-Daemon::Daemon()
+Daemon::Daemon() :
+ licq(NULL)
{
// Set static variables based on compile time constants
myLibDir = INSTALL_LIBDIR;
@@ -93,11 +94,11 @@
myBaseDir += '/';
}
-void Daemon::initialize(CLicq* _licq)
-{
+void Daemon::initialize()
+{
+ assert(licq != NULL);
+
string temp;
-
- licq = _licq;
myShuttingDown = false;
Modified: trunk/licq/src/daemon.h
==============================================================================
--- trunk/licq/src/daemon.h (original)
+++ trunk/licq/src/daemon.h Mon Oct 25 04:52:02 2010
@@ -38,10 +38,12 @@
Daemon();
~Daemon();
+ void preInitialize(CLicq* _licq) { licq = _licq; }
+
/**
* Initialize the daemon
*/
- void initialize(CLicq* licq);
+ void initialize();
/**
* Get next available id to use for an event
Modified: trunk/licq/src/licq.cpp
==============================================================================
--- trunk/licq/src/licq.cpp (original)
+++ trunk/licq/src/licq.cpp Mon Oct 25 04:52:02 2010
@@ -250,6 +250,8 @@
myConsoleLog->setLogLevel(Licq::Log::Error, true);
myConsoleLog->setLogLevel(Licq::Log::Warning, true);
myLogService.registerDefaultLogSink(myConsoleLog);
+
+ gDaemon.preInitialize(this);
char *szRedirect = NULL;
vector <char *> vszPlugins;
@@ -620,7 +622,7 @@
// Start things going
if (!LicqDaemon::gUserManager.Load())
return false;
- gDaemon.initialize(this);
+ gDaemon.initialize();
gOnEventManager.initialize();
gSarManager.initialize();
gStatistics.initialize();
Modified: trunk/licq/src/plugins/pluginmanager.cpp
==============================================================================
--- trunk/licq/src/plugins/pluginmanager.cpp (original)
+++ trunk/licq/src/plugins/pluginmanager.cpp Mon Oct 25 04:52:02 2010
@@ -63,6 +63,14 @@
// Empty
}
+// Called in the plugin's thread just before the init function
+static void initPluginCallback(const Plugin& plugin)
+{
+ std::string name = plugin.getName();
+ std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+ gDaemon.getLogService().createThreadLog(name);
+}
+
GeneralPlugin::Ptr PluginManager::loadGeneralPlugin(
const std::string& name, int argc, char** argv, bool keep)
{
@@ -77,7 +85,7 @@
GeneralPlugin::Ptr plugin(new GeneralPlugin(lib, pluginThread));
// Let the plugin initialize itself
- if (!plugin->init(argc, argv))
+ if (!plugin->init(argc, argv, &initPluginCallback))
{
gLog.error(tr("Failed to initialize plugin (%s)"),
plugin->getName());
@@ -127,7 +135,7 @@
ProtocolPlugin::Ptr plugin(new ProtocolPlugin(lib, pluginThread, icq));
// Let the plugin initialize itself
- if (!plugin->init())
+ if (!plugin->init(&initPluginCallback))
{
gLog.error(tr("Failed to initialize plugin (%s)"),
plugin->getName());
@@ -520,14 +528,6 @@
return DynamicLibrary::Ptr();
}
-// Called in the plugin's thread just before the main entry point
-static void startPluginCallback(const Plugin& plugin)
-{
- std::string name = plugin.getName();
- std::transform(name.begin(), name.end(), name.begin(), ::tolower);
- gDaemon.getLogService().createThreadLog(name);
-}
-
static void exitPluginCallback(const Plugin& plugin)
{
gPluginManager.pluginHasExited(plugin.getId());
@@ -546,5 +546,5 @@
plugin->getName(), plugin->getVersion());
}
- plugin->startThread(startPluginCallback, exitPluginCallback);
-}
+ plugin->startThread(NULL, exitPluginCallback);
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.