diff --git a/src/pluginhost.cpp b/src/pluginhost.cpp index b3ff446..06e5260 100644 --- a/src/pluginhost.cpp +++ b/src/pluginhost.cpp @@ -17,6 +17,7 @@ #include "iqnamespacefilter.h" #include "eventfilter.h" #include "optionaccessor.h" +#include "applicationinfo.h" /** * \brief Constructs a host/wrapper for a plugin. @@ -32,12 +33,17 @@ */ PluginHost::PluginHost(PluginManager* manager, const QString& pluginFile) : manager_(manager) - , file_(pluginFile) , plugin_(0) + , file_(pluginFile) + , name_() + , shortName_() + , version_() , loader_(0) + , valid_(false) , connected_(false) , enabled_(false) - , valid_(false) + , iqNsFilters_() + , iqNsxFilters_() { load(); // reads plugin name, etc unload(); @@ -250,6 +256,12 @@ bool PluginHost::enable() qDebug("connecting option accessor"); o->setOptionAccessingHost(this); } + + PsiPlugin* p = qobject_cast<PsiPlugin*>(plugin_); + if (p) + { + p->setHomeDir(ApplicationInfo::homeDir()); + } connected_ = true; } @@ -396,7 +408,8 @@ bool PluginHost::processEvent(int account, const QDomElement& e) * \param subject Message subject * \return Continue processing the event; true if the stanza should be silently discarded. */ -bool PluginHost::processMessage(int account, const QString& jidFrom, const QString& body, const QString& subject) +bool PluginHost::processMessage(int account, const QString& jidFrom, + QString& body, QString& subject) { bool handled = false; EventFilter *ef = qobject_cast<EventFilter*>(plugin_); @@ -406,6 +419,28 @@ bool PluginHost::processMessage(int account, const QString& jidFrom, const QStri return handled; } +bool PluginHost::processMessage(int account, const QString& jidFrom, + QDomElement& htmlBody, QString& subject) +{ + bool handled = false; + EventFilter *ef = qobject_cast<EventFilter*>(plugin_); + if (ef && ef->processMessage(account, jidFrom, htmlBody, subject)) { + handled = true; + } + return handled; +} + +bool PluginHost::processOutgoingMessage(int account, const QString& jidTo, + QString& body, QString& subject) +{ + bool handled = false; + EventFilter *ef = qobject_cast<EventFilter*>(plugin_); + if (ef && ef->processOutgoingMessage(account, jidTo, body, subject)) { + handled = true; + } + return handled; +} + //-- StanzaSender --------------------------------------------------- @@ -564,6 +599,8 @@ void PluginHost::removeIqNamespaceFilter(const QRegExp &ns, IqNamespaceFilter *f */ void PluginHost::setPluginOption( const QString& option, const QVariant& value) { + Q_UNUSED(option) + Q_UNUSED(value) // TODO(mck) //PsiPlugin* plugin=NULL; @@ -587,6 +624,7 @@ void PluginHost::setPluginOption( const QString& option, const QVariant& value) */ QVariant PluginHost::getPluginOption(const QString& option) { + Q_UNUSED(option) return QVariant(); // TODO(mck) } @@ -617,6 +655,31 @@ QVariant PluginHost::getGlobalOption(const QString& option) } +void PluginHost::logout(int account) +{ + qobject_cast<PsiPlugin*>(plugin_)->logout(account); +} + +void PluginHost::contactOnline(int account, const QString& jid) +{ + qobject_cast<PsiPlugin*>(plugin_)->contactOnline(account, jid); +} + +void PluginHost::contactOffline(int account, const QString& jid) +{ + qobject_cast<PsiPlugin*>(plugin_)->contactOffline(account, jid); +} + + +QAction* PluginHost::getChatDlgMenuEntries(QWidget* parent, + int account, + const QString& otherJid) +{ + return qobject_cast<PsiPlugin*>(plugin_)->getChatDlgMenuEntries(parent, + account, + otherJid); +} + //-- helpers -------------------------------------------------------- static bool operator<(const QRegExp &a, const QRegExp &b)