diff --git a/src/pluginmanager.cpp b/src/pluginmanager.cpp index c08aab4..babedd3 100644 --- a/src/pluginmanager.cpp +++ b/src/pluginmanager.cpp @@ -147,6 +147,7 @@ void PluginManager::loadEnabledPlugins() */ void PluginManager::optionChanged(const QString& option) { + Q_UNUSED(option) //QString("%1.%2").arg(loadOptionPrefix).arg(shortNames_[plugin]); //TODO(mck): implement this... for now, enabling/disabling requires psi restart @@ -236,7 +237,7 @@ QStringList PluginManager::availablePlugins() QWidget* PluginManager::optionsWidget(const QString& plugin) { QWidget* widget = 0; - if (hosts_.contains(plugin)) { + if (hosts_.contains(plugin) && hosts_[plugin]->isEnabled()) { widget = hosts_[plugin]->optionsWidget(); } else { qWarning("Attempting to get options for %s which doesn't exist", qPrintable(plugin)); @@ -254,19 +255,60 @@ QWidget* PluginManager::optionsWidget(const QString& plugin) * \param event Incoming event * \return Continue processing the event; true if the event should be silently discarded. */ -bool PluginManager::processMessage(const PsiAccount* account, const QString& jidFrom, const QString& body, const QString& subject) +bool PluginManager::processMessage(const PsiAccount* account, const QString& jidFrom, + QString& body, QString& subject) { bool handled = false; foreach (PluginHost* host, hosts_.values()) { - if (host->processMessage(accountIds_[account], jidFrom, body, subject)) { - handled = true; - break; - } + if (host->isEnabled()) + { + if (host->processMessage(accountIds_[account], jidFrom, body, subject)) { + handled = true; + break; + } + } + } + return handled; +} + +bool PluginManager::processMessage(const PsiAccount* account, const QString& jidFrom, + QDomElement& htmlBody, QString& subject) +{ + bool handled = false; + foreach (PluginHost* host, hosts_.values()) { + if (host->isEnabled()) + { + if (host->processMessage(accountIds_[account], jidFrom, htmlBody, subject)) { + handled = true; + break; + } + } } return handled; } /** + * process an outgoing message + */ +bool PluginManager::processOutgoingMessage(const PsiAccount* account, const QString& jidTo, + QString& body, QString& subject) +{ + bool handled = false; + foreach (PluginHost* host, hosts_.values()) { + if (host->isEnabled()) + { + if (host->processOutgoingMessage(accountIds_[account], jidTo, + body, subject)) { + handled = true; + break; + } + } + } + return handled; +} + + +/** * \brief Give each plugin the opportunity to process the incoming event * * Each plugin is passed the event in turn. Any plugin may then modify the event @@ -280,10 +322,13 @@ bool PluginManager::processEvent(const PsiAccount* account, QDomElement& event) { bool handled = false; foreach (PluginHost* host, hosts_.values()) { - if (host->processEvent(accountIds_[account], event)) { - handled = true; - break; - } + if (host->isEnabled()) + { + if (host->processEvent(accountIds_[account], event)) { + handled = true; + break; + } + } } return handled; } @@ -304,10 +349,13 @@ bool PluginManager::incomingXml(int account, const QDomElement &xml) { bool handled = false; foreach (PluginHost* host, hosts_.values()) { - if (host->incomingXml(account, xml)) { - handled = true; - break; - } + if (host->isEnabled()) + { + if (host->incomingXml(account, xml)) { + handled = true; + break; + } + } } return handled; } @@ -369,6 +417,62 @@ bool PluginManager::verifyStanza(const QString& stanza) return true; } +void PluginManager::logout(const PsiAccount* account) +{ + foreach (PluginHost* host, hosts_.values()) + { + if (host->isEnabled()) + { + host->logout(accountIds_[account]); + } + } +} + + +void PluginManager::contactOnline(const PsiAccount* account, const QString& jid) +{ + foreach (PluginHost* host, hosts_.values()) + { + if (host->isEnabled()) + { + host->contactOnline(accountIds_[account], jid); + } + } +} + +void PluginManager::contactOffline(const PsiAccount* account, const QString& jid) +{ + foreach (PluginHost* host, hosts_.values()) + { + if (host->isEnabled()) + { + host->contactOffline(accountIds_[account], jid); + } + } +} + +QList<QAction*> PluginManager::getChatDlgMenuEntries(QWidget* parent, + const PsiAccount* account, + const QString& otherJid) +{ + QList<QAction*> res; + foreach(PluginHost* host, hosts_.values()) + { + if (host->isEnabled()) + { + QAction* m = host->getChatDlgMenuEntries(parent, + accountIds_[account], + otherJid); + if (m) + { + res.append(m); + } + } + } + return res; +} + + PluginManager* PluginManager::instance_ = NULL; const QString PluginManager::loadOptionPrefix = "plugins.auto-load"; const QString PluginManager::pluginOptionPrefix = "plugins.options";