[prev in list] [next in list] [prev in thread] [next in thread]
List: licq-cvs
Subject: [Licq-cvs] r4446 - in branches/newapi/licq: include src
From: emostar () users ! sourceforge ! net
Date: 2006-06-10 3:20:42
Message-ID: 20060610032042.19067.qmail () mail ! thejon ! org
[Download RAW message or body]
Author: emostar
Date: 2006-06-10 12:20:41 +0900 (Sat, 10 Jun 2006)
New Revision: 4446
Modified:
branches/newapi/licq/include/licq_icqd.h
branches/newapi/licq/src/icqd.cpp
branches/newapi/licq/src/licq.cpp
branches/newapi/licq/src/licq.h
branches/newapi/licq/src/pluginmanager.cpp
Log:
Do some cleanup (remove unneeded code)
Get things compiling again.
Modified: branches/newapi/licq/include/licq_icqd.h
===================================================================
--- branches/newapi/licq/include/licq_icqd.h 2006-06-10 03:20:17 UTC (rev 4445)
+++ branches/newapi/licq/include/licq_icqd.h 2006-06-10 03:20:41 UTC (rev 4446)
@@ -73,6 +73,7 @@
class ProxyServer;
class CReverseConnectToUserData;
class CMSN;
+class CPluginManager;
#define FOR_EACH_PROTO_PLUGIN_START(d) \
{ \
@@ -193,6 +194,9 @@
pthread_t *Shutdown();
void SaveConf();
+ /// Get the plugin manager instance.
+ CPluginManager *getPluginManager() const { return m_pPluginManager; }
+
int registerCallback(const std::string &, const TCallback &, unsigned char);
bool unregisterCallback(const std::string &, int);
@@ -684,6 +688,7 @@
protected:
CLicq *licq;
COnEventManager m_xOnEventManager;
+ CPluginManager *m_pPluginManager;
int pipe_newsocket[2], fifo_fd;
FILE *fifo_fs;
EDaemonStatus m_eStatus;
Modified: branches/newapi/licq/src/icqd.cpp
===================================================================
--- branches/newapi/licq/src/icqd.cpp 2006-06-10 03:20:17 UTC (rev 4445)
+++ branches/newapi/licq/src/icqd.cpp 2006-06-10 03:20:41 UTC (rev 4446)
@@ -37,10 +37,10 @@
#include "licq_log.h"
#include "licq_translate.h"
#include "licq_packets.h"
-#include "licq_plugind.h"
#include "licq_gpg.h" // ##
#include "licq.h"
#include "support.h"
+#include "licq_pluginmanager.h"
//#include "licq_callback.h"
#include "licq_icqd.h"
@@ -135,6 +135,7 @@
licq = _licq;
gLicqDaemon = this;
+ m_pPluginManager = new CPluginManager(*this, "./", "./");
// Initialise the data values
m_nIgnoreTypes = 0;
Modified: branches/newapi/licq/src/licq.cpp
===================================================================
--- branches/newapi/licq/src/licq.cpp 2006-06-10 03:20:17 UTC (rev 4445)
+++ branches/newapi/licq/src/licq.cpp 2006-06-10 03:20:41 UTC (rev 4446)
@@ -49,6 +49,7 @@
#include "licq_user.h"
#include "licq_icqd.h"
#include "licq_socket.h"
+#include "licq_pluginmanager.h"
#include "licq.conf.h"
@@ -257,6 +258,9 @@
// Fork into the background
if (bFork && fork()) exit(0);
+ // Create the daemon
+ licqDaemon = new CLicqDaemon(this);
+
// See if redirection works, set bUseColor to false if we redirect
// to a file.
if (szRedirect)
@@ -346,23 +350,17 @@
return false;
// Load up the plugins
- m_nNextId = 1;
+ CPluginManager *pluginMgr = licqDaemon->getPluginManager();
vector <char *>::iterator iter;
for (iter = vszPlugins.begin(); iter != vszPlugins.end(); ++iter)
{
-#if 0
- //TODO
- GeneralPluginPtr plug = LoadPlugin(*iter, argc, argv);
- if (plug.get() == 0) return false;
- if (bHelp)
+ TPluginId id = pluginMgr->loadPlugin(*iter);
+ if (id)
{
- fprintf(stderr, "Licq Plugin: %s %s\n%s\n----------\n",
- list_plugins.back()->Name(),
- list_plugins.back()->Version(),
- (*(list_plugins.back())->fUsage)() );
- list_plugins.pop_back();
+ // Plugin has successfully been loaded
+ // FIXME NEWAPI We need a way to get a handle to this plugin
}
-#endif
+
free(*iter);
}
if (bHelp) return false;
@@ -401,7 +399,7 @@
{
sprintf(szKey, "ProtoPlugin%d", i+1);
if (!licqConf.ReadStr(szKey, szData)) continue;
- //TODO if (LoadProtocolPlugin(szData) == false) return false;
+ if (pluginMgr->loadPlugin(szData) == 0) return false;
}
}
}
@@ -418,25 +416,15 @@
{
sprintf(szKey, "Plugin%d", i + 1);
if (!licqConf.ReadStr(szKey, szData)) continue;
- //TODO if (LoadPlugin(szData, argc, argv) == NULL) return false;
+ if (pluginMgr->loadPlugin(szData) == 0) return false;
}
}
else // If no plugins, try some defaults one by one
{
-#if 0
- //TODO
- GeneralPluginPtr plug = LoadPlugin("qt-gui", argc, argv);
- if (plug.get() == 0)
- {
- plug = LoadPlugin("kde-gui", argc, argv);
- if (plug.get() == 0)
- {
- plug = LoadPlugin("console", argc, argv);
- if (plug.get() == 0)
- return false;
- }
- }
-#endif
+ if (pluginMgr->loadPlugin("qt-gui") == 0)
+ if (pluginMgr->loadPlugin("kde-gui") == 0)
+ if (pluginMgr->loadPlugin("console") == 0)
+ return false;
}
}
@@ -471,9 +459,6 @@
sprintf(szFilename, "%s%s", SHARE_DIR, UTILITY_DIR);
gUtilityManager.LoadUtilities(szFilename);
- // Create the daemon
- licqDaemon = new CLicqDaemon(this);
-
return true;
}
@@ -588,158 +573,6 @@
return true;
}
-#if 0
- //TODO Delete this
-/*-----------------------------------------------------------------------------
- * LoadPlugin
- *
- * Loads the given plugin using the given command line arguments.
- *---------------------------------------------------------------------------*/
-GeneralPluginPtr CLicq::LoadPlugin(const char *_szName, int argc, char **argv)
-{
- void *handle;
- const char *error;
- char szPlugin[MAX_FILENAME_LEN];
-
- // First check if the plugin is in the shared location
- if ( _szName[0] != '/' && _szName[0] != '.')
- {
- snprintf(szPlugin, MAX_FILENAME_LEN, "%slicq_%s.so", LIB_DIR, _szName);
- }
- else
- {
- strncpy(szPlugin, _szName, MAX_FILENAME_LEN);
- }
- szPlugin[MAX_FILENAME_LEN - 1] = '\0';
-
- handle = dlopen (szPlugin, RTLD_LAZY);//DLOPEN_POLICY);
- if (handle == NULL)
- {
- const char *error = dlerror();
- gLog.Error("%sUnable to load plugin (%s): %s.\n", L_ERRORxSTR, _szName,
- error);
-
- if (!strstr(error, "No such file"))
- {
- gLog.Warn("%sThis usually happens when your plugin\n"
- "%sis not kept in sync with the daemon.\n"
- "%sPlease try recompiling the plugin.\n"
- "%sIf you are still having problems, see\n"
- "%sthe FAQ at www.licq.org\n",
- L_WARNxSTR, L_BLANKxSTR, L_BLANKxSTR, L_BLANKxSTR,
- L_BLANKxSTR);
- }
-
- return GeneralPluginPtr();
- }
-
- create_f *createPlugin = (create_f *)dlsym(handle, "createPlugin");
- if ((error = dlerror()) != 0)
- {
- gLog.Error("%sFailed to find createPlugin() function in plugin (%s): %s\n",
- L_ERRORxSTR, _szName, error);
- return GeneralPluginPtr();
- }
-
- GeneralPluginPtr p(createPlugin());
- p->setHandle(handle);
- p->setId(m_nNextId++);
-
- if (!p->initPlugin())
- {
- gLog.Error("%sFailed to initialize plugin (%s).\n", L_ERRORxSTR,
- p->getPluginName().c_str());
- return GeneralPluginPtr();
- }
-
- pthread_mutex_lock(&mutex_plugins);
- list_plugins.push_back(p);
- pthread_mutex_unlock(&mutex_plugins);
- return p;
-}
-
-
-void CLicq::StartPlugin(GeneralPluginPtr p)
-{
- gLog.Info(tr("%sStarting plugin %s (version %s).\n"), L_INITxSTR,
- p->getPluginName().c_str(), p->getPluginVersion().c_str());
- SThreadParam *pParam = new SThreadParam;
- pParam->pDaemon = licqDaemon;
- pParam->pPlugin = p;
- pthread_create(p->getThreadHandle(), NULL, StartGeneralThread_tep, pParam);
-}
-
-ProtocolPluginPtr CLicq::LoadProtocolPlugin(const char *_szName)
-{
- void *handle;
- const char *error = NULL;
- char szFileName[MAX_FILENAME_LEN];
-
- if (_szName[0] != '/' && _szName[0] != '.')
- snprintf(szFileName, MAX_FILENAME_LEN, "%sprotocol_%s.so", LIB_DIR, _szName);
- else
- snprintf(szFileName, MAX_FILENAME_LEN, "%s", _szName);
- szFileName[MAX_FILENAME_LEN - 1] = '\0';
-
- handle = dlopen(szFileName, DLOPEN_POLICY);
-
- if (handle == NULL)
- {
- error = dlerror();
- gLog.Error("%sUnable to load plugin (%s): %s\n", L_ERRORxSTR, _szName,
- error);
- return ProtocolPluginPtr();
- }
-
- create_pp *createPlugin = (create_pp *)dlsym(handle, "createPlugin");
- if ((error = dlerror()) != 0)
- {
- gLog.Error("%sFailed to find createPlugin() function in plugin (%s): %s\n",
- L_ERRORxSTR, _szName, error);
- return ProtocolPluginPtr();
- }
-
- ProtocolPluginPtr p(createPlugin());
- p->setHandle(handle);
- p->setId(m_nNextId++);
-
-#if 0
- // What should we do about the PPID?
- // PPID
- p->m_nPPID = p->fPPID()[0] << 24 | p->fPPID()[1] << 16 | p->fPPID()[2] << 8 | p->fPPID()[3];
-
- // Other info
- p->m_nSendFunctions = fSendFuncs();
-
- // Finish it up
- *p->nId = m_nNextId++;
- p->m_pHandle = handle;
-#endif
- pthread_mutex_lock(&mutex_protoplugins);
- list_protoplugins.push_back(p);
- pthread_mutex_unlock(&mutex_protoplugins);
-
- // Let the gui plugins know about the new protocol plugin
-#if 0
- //XXX Change this to the new signal pipeline
- if (licqDaemon)
- licqDaemon->PushPluginSignal(new CICQSignal(SIGNAL_NEWxPROTO_PLUGIN,p->PPID(),
- 0));
-#endif
- return p;
-}
-
-void CLicq::StartProtocolPlugin(ProtocolPluginPtr p)
-{
- gLog.Info(tr("%sStarting protocol plugin %s (version %s).\n"), L_INITxSTR,
- p->getPluginName().c_str(), p->getPluginVersion().c_str());
- SThreadParam_PP *pParam = new SThreadParam_PP;
- pParam->pDaemon = licqDaemon;
- pParam->pPlugin = p;
- pthread_create(p->getThreadHandle(), NULL, StartProtocolThread_tep, pParam);
-}
-#endif
-
int CLicq::Main()
{
int nResult = 0;
Modified: branches/newapi/licq/src/licq.h
===================================================================
--- branches/newapi/licq/src/licq.h 2006-06-10 03:20:17 UTC (rev 4445)
+++ branches/newapi/licq/src/licq.h 2006-06-10 03:20:41 UTC (rev 4446)
@@ -28,10 +28,6 @@
bool Init(int argc, char **argv);
int Main();
const char *Version();
-// GeneralPluginPtr LoadPlugin(const char *, int, char **);
-// void StartPlugin(GeneralPluginPtr);
-// ProtocolPluginPtr LoadProtocolPlugin(const char *);
-// void StartProtocolPlugin(ProtocolPluginPtr);
void ShutdownPlugins();
@@ -43,7 +39,6 @@
bool UpgradeLicq(CIniFile &);
CLicqDaemon *licqDaemon;
- unsigned short m_nNextId;
PluginsList list_plugins;
pthread_mutex_t mutex_plugins;
ProtocolPluginsList list_protoplugins;
Modified: branches/newapi/licq/src/pluginmanager.cpp
===================================================================
--- branches/newapi/licq/src/pluginmanager.cpp 2006-06-10 03:20:17 UTC (rev 4445)
+++ branches/newapi/licq/src/pluginmanager.cpp 2006-06-10 03:20:41 UTC (rev 4446)
@@ -40,6 +40,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/exception.hpp>
//BEGIN SPluginInstance
@@ -158,62 +159,70 @@
return false;
namespace bfs = boost::filesystem;
- bfs::path dir(pimpl->m_datadir, bfs::native); // FIXME may throw...
- bfs::directory_iterator file(dir);
- bfs::directory_iterator fileEnd;
+ try
+ {
+ bfs::path dir(pimpl->m_datadir, bfs::native);
+ bfs::directory_iterator file(dir);
+ bfs::directory_iterator fileEnd;
- char buffer[MAX_LINE_LEN];
+ char buffer[MAX_LINE_LEN];
- for (; file != fileEnd; file++)
- {
- const bool isPlugin = boost::ends_with(file->string(), ".plugin");
- const bool isProtocol = boost::ends_with(file->string(), ".protocol");
+ for (; file != fileEnd; file++)
+ {
+ const bool isPlugin = boost::ends_with(file->string(), ".plugin");
+ const bool isProtocol = boost::ends_with(file->string(), ".protocol");
- if (! (isPlugin || isProtocol))
- continue;
+ if (! (isPlugin || isProtocol))
+ continue;
- boost::shared_ptr<SPluginData> data = SPluginData::create();
+ boost::shared_ptr<SPluginData> data = SPluginData::create();
- if (isPlugin)
- data->type = PLUGIN_GENERAL;
- else if (isProtocol)
- data->type = PLUGIN_PROTOCOL;
+ if (isPlugin)
+ data->type = PLUGIN_GENERAL;
+ else if (isProtocol)
+ data->type = PLUGIN_PROTOCOL;
- CIniFile dataFile;
- if (! dataFile.LoadFile(file->string().c_str()))
- continue;
+ CIniFile dataFile;
+ if (! dataFile.LoadFile(file->string().c_str()))
+ continue;
- if (isPlugin && !dataFile.SetSection("Licq General Plugin"))
- continue;
- else if (isProtocol && !dataFile.SetSection("Licq Protocol Plugin"))
- continue;
+ if (isPlugin && !dataFile.SetSection("Licq General Plugin"))
+ continue;
+ else if (isProtocol && !dataFile.SetSection("Licq Protocol Plugin"))
+ continue;
- if (dataFile.ReadStr("Name", buffer))
- data->name = buffer;
+ if (dataFile.ReadStr("Name", buffer))
+ data->name = buffer;
- if (dataFile.ReadStr("Version", buffer))
- data->version = buffer;
+ if (dataFile.ReadStr("Version", buffer))
+ data->version = buffer;
- if (dataFile.ReadStr("Library", buffer))
- data->library = buffer;
+ if (dataFile.ReadStr("Library", buffer))
+ data->library = buffer;
- if (dataFile.ReadStr("Description", buffer))
- data->description = buffer;
+ if (dataFile.ReadStr("Description", buffer))
+ data->description = buffer;
- if (dataFile.ReadStr("Long Description", buffer))
- data->longDescription = buffer;
+ if (dataFile.ReadStr("Long Description", buffer))
+ data->longDescription = buffer;
- if (dataFile.ReadStr("Authors", buffer))
- {
- using boost::is_any_of;
- std::string authors(buffer);
- boost::trim_if(authors, is_any_of(";"));
- boost::split(data->authors, authors, is_any_of(";"));
+ if (dataFile.ReadStr("Authors", buffer))
+ {
+ using boost::is_any_of;
+ std::string authors(buffer);
+ boost::trim_if(authors, is_any_of(";"));
+ boost::split(data->authors, authors, is_any_of(";"));
+ }
+
+ if (data->name.size() > 0 && data->library.size() > 0)
+ pimpl->m_pluginData[data->name] = data; // This will make data into a const pointer
}
-
- if (data->name.size() > 0 && data->library.size() > 0)
- pimpl->m_pluginData[data->name] = data; // This will make data into a const pointer
}
+ catch (const bfs::filesystem_error &e)
+ {
+ gLog.Error("%sUnable to load plugin data file: %s\n", L_ERRORxSTR, e.what());
+ isDone = false;
+ }
return (isDone = true);
}
_______________________________________________
Licq-cvs mailing list
Licq-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/licq-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic