diff --git a/honoka/src/honoka_imengine.cpp b/honoka/src/honoka_imengine.cpp index 6820b9d..69ba8ea 100644 --- a/honoka/src/honoka_imengine.cpp +++ b/honoka/src/honoka_imengine.cpp @@ -195,6 +195,9 @@ DIR *dir = opendir(HONOKA_PLUGINDIR); if (dir) { struct dirent *entry; + // + // �ץ饰�����ɤ߹�����ʬ�� + // while((entry = readdir(dir)) != NULL) { String d = entry->d_name; if ((d.substr(0,6) == "plugin") && (d.substr(d.length() - 3,3) == ".so")) { @@ -212,11 +215,22 @@ } if (getPluginVersion() == HONOKA_PLUGIN_VERSION) { HonokaPluginBase *p = getInstance(_scim_config); + HonokaPluginEntry pe; + pe.filename = d; + pe.createInstance = getInstance; + pe.deleteInstance = deleteInstance; + pe.getPluginVersion = getPluginVersion; + if (plugins.find(p->getName()) != plugins.end()) { + deleteInstance(p); + dlclose(plugin); + } else if (p->getPluginType() == "Convertor") { convertors.push_back(static_cast(p)); + plugins.insert(pair(p->getName(),pe)); } else if (p->getPluginType() == "PreEditor") { preeditors.push_back(static_cast(p)); + plugins.insert(pair(p->getName(),pe)); } else { deleteInstance(p); dlclose(plugin); diff --git a/honoka/src/honoka_imengine.h b/honoka/src/honoka_imengine.h index d110fa8..907db93 100644 --- a/honoka/src/honoka_imengine.h +++ b/honoka/src/honoka_imengine.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #define Uses_SCIM_ICONV @@ -72,6 +73,15 @@ bool comp(const KeyEvent &k); }; +class HonokaPluginEntry +{ +public: + String filename; + createInstanceFunc *createInstance; + deleteInstanceFunc *deleteInstance; + getPluginVersionFunc *getPluginVersion; +}; + class HonokaInstance : public IMEngineInstanceBase { @@ -108,6 +118,7 @@ bool auto_conversion; String defaultPreEditor; IConvert m_iconv; + map plugins; vector preeditors; vector convertors; String sType; diff --git a/honoka/src/honokapluginbase.cpp b/honoka/src/honokapluginbase.cpp index 0506355..50586ec 100644 --- a/honoka/src/honokapluginbase.cpp +++ b/honoka/src/honokapluginbase.cpp @@ -35,3 +35,8 @@ return type; } +String HonokaPluginBase::getName() +{ + return String("PluginBase"); +} + diff --git a/honoka/src/honokapluginbase.h b/honoka/src/honokapluginbase.h index 169f0ad..509a61a 100644 --- a/honoka/src/honokapluginbase.h +++ b/honoka/src/honokapluginbase.h @@ -51,6 +51,7 @@ public: String getPluginType(); + virtual String getName(); private: String type;