Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2
psi
psi-0.14-enable_otr.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File psi-0.14-enable_otr.patch of Package psi
Index: psi-0.14/configure =================================================================== --- psi-0.14.orig/configure +++ psi-0.14/configure @@ -48,6 +48,9 @@ Dependency options: --with-aspell-inc=[path] Path to Aspell include files --with-aspell-lib=[path] Path to Aspell library files --disable-enchant Disable use of enchant + --disable-plugins Disable use of Plugins + --enable-plugins Enable Psi Plugin support + EOT } @@ -274,6 +277,16 @@ while [ $# -gt 0 ]; do shift ;; + --disable-plugins) + QC_DISABLE_plugins="Y" + shift + ;; + + --enable-plugins) + QC_ENABLE_PLUGINS="Y" + shift + ;; + --verbose) QC_VERBOSE="Y" shift @@ -318,6 +331,8 @@ echo QC_DISABLE_aspell=$QC_DISABLE_aspel echo QC_WITH_ASPELL_INC=$QC_WITH_ASPELL_INC echo QC_WITH_ASPELL_LIB=$QC_WITH_ASPELL_LIB echo QC_DISABLE_enchant=$QC_DISABLE_enchant +echo QC_DISABLE_plugins=$QC_DISABLE_plugins +echo QC_ENABLE_PLUGINS=$QC_ENABLE_PLUGINS echo fi @@ -1614,6 +1629,48 @@ public: #endif } }; +#line 1 "plugins.qcm" +/* +-----BEGIN QCMOD----- +name: Plugins +arg: enable-plugins,Enable Psi Plugin support + +-----END QCMOD----- +*/ + +//---------------------------------------------------------------------------- +// qc_plugins +//---------------------------------------------------------------------------- +class qc_plugins : public ConfObj +{ +public: + qc_plugins(Conf *c) : ConfObj(c) {} + QString name() const { return "Plugins"; } + QString shortname() const { return "Plugins"; } + bool exec() + { + QString s; + + // Check if Jingle was enabled explicitly + s = conf->getenv("QC_ENABLE_PLUGINS"); + if(s.isEmpty()) + return false; + + conf->addDefine("PSI_PLUGINS"); + + // Finish + conf->addExtra("CONFIG += psi_plugins"); + + qWarning(""); + qWarning(""); + qWarning(" !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!"); + qWarning(" PLUGIN SUPPORT IS STILL UNFINISHED !!!"); + qWarning(" THE PLUGIN INTERFACE /WILL/ CHANGE !!!"); + qWarning(" USE AT YOUR OWN RISK !!!"); + + return true; + } +}; EOT cat >$1/modules_new.cpp <<EOT @@ -1665,6 +1722,10 @@ cat >$1/modules_new.cpp <<EOT o = new qc_conf(conf); o->required = true; o->disabled = false; + o = new qc_plugins(conf); + o->required = false; + o->disabled = false; + EOT cat >$1/conf4.h <<EOT @@ -2710,6 +2771,9 @@ export QC_WITH_ASPELL_INC export QC_WITH_ASPELL_LIB export QC_DISABLE_enchant export QC_VERBOSE +export QC_DISABLE_plugins +export QC_ENABLE_PLUGINS + rm -rf .qconftemp ( mkdir .qconftemp Index: psi-0.14/src/applicationinfo.cpp =================================================================== --- psi-0.14.orig/src/applicationinfo.cpp +++ psi-0.14/src/applicationinfo.cpp @@ -27,7 +27,7 @@ #define PROG_NAME "Psi" //#define PROG_VERSION "0.14-dev" " (" __DATE__ ")"; //CVS Builds are dated -#define PROG_VERSION "0.14"; +#define PROG_VERSION "0.14-patched"; #define PROG_CAPS_NODE "http://psi-im.org/caps"; #define PROG_CAPS_VERSION "caps-b75d8d2b25"; #define PROG_IPC_NAME "org.psi-im.Psi" // must not contain '\\' character on Windows Index: psi-0.14/src/pluginhost.cpp =================================================================== --- psi-0.14.orig/src/pluginhost.cpp +++ psi-0.14/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 accoun * \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 acco 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 */ 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 */ QVariant PluginHost::getPluginOption(const QString& option) { + Q_UNUSED(option) return QVariant(); // TODO(mck) } @@ -617,6 +655,31 @@ QVariant PluginHost::getGlobalOption(con } +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) Index: psi-0.14/src/pluginhost.h =================================================================== --- psi-0.14.orig/src/pluginhost.h +++ psi-0.14/src/pluginhost.h @@ -17,6 +17,7 @@ class QWidget; class QPluginLoader; +class QAction; class PluginManager; class IqNamespaceFilter; @@ -54,7 +55,13 @@ public: // for EventFilter bool processEvent(int account, const QDomElement& e); - bool processMessage(int account, const QString& jidFrom, const QString& body, const QString& subject); + bool processMessage(int account, const QString& jidFrom, + QString& body, QString& subject); + bool processMessage(int account, const QString& jidFrom, + QDomElement& body, QString& subject); + + bool processOutgoingMessage(int account, const QString& jidTo, + QString& body, QString& subject); // StanzaSendingHost void sendStanza(int account, const QDomElement& xml); @@ -74,6 +81,14 @@ public: void setGlobalOption(const QString& option, const QVariant& value); QVariant getGlobalOption(const QString& option); + + void logout(int account); + void contactOnline(int account, const QString& jid); + void contactOffline(int account, const QString& jid); + + QAction* getChatDlgMenuEntries(QWidget* parent, int account, + const QString& otherJid); + private: PluginManager* manager_; QObject* plugin_; Index: psi-0.14/src/pluginmanager.cpp =================================================================== --- psi-0.14.orig/src/pluginmanager.cpp +++ psi-0.14/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::availablePlug 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(co * \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 P { 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 acco { 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 Q 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"; Index: psi-0.14/src/pluginmanager.h =================================================================== --- psi-0.14.orig/src/pluginmanager.h +++ psi-0.14/src/pluginmanager.h @@ -13,6 +13,7 @@ #include <QDomElement> class QPluginLoader; +class QAction; class PsiAccount; class PsiPlugin; @@ -46,11 +47,26 @@ public: QWidget* optionsWidget(const QString& plugin); bool processEvent(const PsiAccount* account, QDomElement& eventXml); - bool processMessage(const PsiAccount* account, const QString& jidFrom, const QString& body, const QString& subject); + bool processMessage(const PsiAccount* account, const QString& jidFrom, + QString& body, QString& subject); + bool processMessage(const PsiAccount* account, const QString& jidFrom, + QDomElement& htmlBody, QString& subject); + bool processOutgoingMessage(const PsiAccount* account, const QString& jidTo, + QString& body, QString& subject); + + void logout(const PsiAccount* account); + void contactOnline(const PsiAccount* account, const QString& jid); + void contactOffline(const PsiAccount* account, const QString& jid); + static const QString loadOptionPrefix; static const QString pluginOptionPrefix; - + + QList<QAction*> getChatDlgMenuEntries(QWidget* parent, + const PsiAccount* account, + const QString& otherjid); + + private: PluginManager(); void loadAllPlugins(); Index: psi-0.14/src/plugins/include/eventfilter.h =================================================================== --- psi-0.14.orig/src/plugins/include/eventfilter.h +++ psi-0.14/src/plugins/include/eventfilter.h @@ -11,7 +11,15 @@ public: // true = handled, don't pass to next handler virtual bool processEvent(int account, const QDomElement& e) = 0; - virtual bool processMessage(int account, const QString& fromJid, const QString& body, const QString& subject) = 0; + + virtual bool processMessage(int account, const QString& fromJid, + QString& body, QString& subject) = 0; + + virtual bool processMessage(int account, const QString& fromJid, + QDomElement& body, QString& subject) = 0; + + virtual bool processOutgoingMessage(int account, const QString& toJid, + QString& body, QString& subject) = 0; }; Q_DECLARE_INTERFACE(EventFilter, "org.psi-im.EventFilter/0.1"); Index: psi-0.14/src/plugins/include/iqfilter.h =================================================================== --- psi-0.14.orig/src/plugins/include/iqfilter.h +++ psi-0.14/src/plugins/include/iqfilter.h @@ -13,4 +13,5 @@ public: Q_DECLARE_INTERFACE(IqFilter, "org.psi-im.IqFilter/0.1"); -#endif \ No newline at end of file +#endif + Index: psi-0.14/src/plugins/include/psiplugin.h =================================================================== --- psi-0.14.orig/src/plugins/include/psiplugin.h +++ psi-0.14/src/plugins/include/psiplugin.h @@ -87,6 +87,15 @@ public: */ virtual bool disable() = 0; + virtual void logout(int account) = 0; + virtual void contactOnline(int account, const QString& jid) = 0; + virtual void contactOffline(int account, const QString& jid) = 0; + + virtual QAction* getChatDlgMenuEntries(QWidget* parent, + int account, + const QString& otherJid) = 0; + + virtual void setHomeDir(const QString& dir) = 0; }; Q_DECLARE_INTERFACE(PsiPlugin, "org.psi-im.PsiPlugin/0.3"); Index: psi-0.14/src/plugins/include/stanzasender.h =================================================================== --- psi-0.14.orig/src/plugins/include/stanzasender.h +++ psi-0.14/src/plugins/include/stanzasender.h @@ -13,4 +13,5 @@ public: Q_DECLARE_INTERFACE(StanzaSender, "org.psi-im.StanzaSender/0.1"); -#endif \ No newline at end of file +#endif + Index: psi-0.14/src/psiaccount.cpp =================================================================== --- psi-0.14.orig/src/psiaccount.cpp +++ psi-0.14/src/psiaccount.cpp @@ -1286,6 +1286,10 @@ void PsiAccount::login() // disconnect or stop reconnecting void PsiAccount::logout(bool fast, const Status &s) { +#ifdef PSI_PLUGINS + PluginManager::instance()->logout(this); +#endif + if(!isActive()) return; @@ -1887,6 +1891,10 @@ void PsiAccount::client_resourceAvailabl UserResourceList::Iterator rit = u->userResourceList().find(j.resource()); bool found = (rit == u->userResourceList().end()) ? false: true; if(!found) { +#ifdef PSI_PLUGINS + PluginManager::instance()->contactOnline(this, j.node() + "@" + j.domain()); +#endif + popupType = PopupOnline; UserResource ur(r); @@ -2043,6 +2051,10 @@ void PsiAccount::client_resourceUnavaila PsiGrowlNotifier::instance()->popup(this, PsiPopup::AlertOffline, j, r, u); #endif } +#ifdef PSI_PLUGINS + PluginManager::instance()->contactOffline(this, j.node() + "@" + j.domain()); +#endif + } void PsiAccount::client_presenceError(const Jid &j, int, const QString &str) @@ -3001,7 +3013,6 @@ ChatDlg *PsiAccount::ensureChatDlg(const if(!pp.isNull()) p = pp; #ifdef __GNUC__ -#warning "Removed reparenting call from qwextend" #endif //reparent_good(window, 0, false); if(!p.isNull()) @@ -3638,6 +3649,25 @@ void PsiAccount::dj_sendMessage(const Me } } +#ifdef PSI_PLUGINS + if (nm.type() != "groupchat" && !nm.body().isEmpty()) + { + QString body = nm.body(); + QString subject = nm.subject(); + + PluginManager::instance()->processOutgoingMessage(this, nm.to().full(), + body, subject); + if (body != nm.body()) + { + nm.setBody(body); + } + if (subject != nm.subject()) + { + nm.setSubject(subject); + } + } +#endif + d->client->sendMessage(nm); // only toggle if not an invite or body is not empty @@ -3913,6 +3943,53 @@ void PsiAccount::handleEvent(PsiEvent* e } //FIXME(KIS): must now cause the event to be recreated from this xml or such. Horrid. #endif + +#ifdef PSI_PLUGINS + if(e->type() == PsiEvent::Message) + { + MessageEvent* messageEvent = (MessageEvent*) e; + Message message = messageEvent->message(); + + if (message.type() != "groupchat") + { + + bool discard = false; + if (message.containsHTML() && !message.html().text().isEmpty()) + { + HTMLElement htmlElement = message.html(); + QDomElement htmlBody = htmlElement.body(); + QString subject = message.subject(); + + discard = PluginManager::instance()->processMessage(this, e->from().full(), + htmlBody, subject); + htmlElement.setBody(htmlBody); + message.setHTML(htmlElement, message.lang()); + message.setBody(htmlElement.text()); + message.setSubject(subject); + } + else if (!message.body().isEmpty()) + { + QString body = message.body(); + QString subject = message.subject(); + + discard = PluginManager::instance()->processMessage(this, e->from().full(), + body, subject); + message.setBody(body); + message.setSubject(subject); + } + + if (discard) + { + delete e; + return; + } + + messageEvent->setMessage(message); + } + } +#endif + + if(d->acc.opt_log && activationType != FromXml) { if(e->type() == PsiEvent::Message || e->type() == PsiEvent::Auth) { @@ -3926,20 +4003,6 @@ void PsiAccount::handleEvent(PsiEvent* e MessageEvent *me = (MessageEvent *)e; const Message &m = me->message(); -#ifdef PSI_PLUGINS - //TODO(mck): clean up - //UserListItem *ulItem=NULL; - //if ( !ul.isEmpty() ) - // ulItem=ul.first(); - if (PluginManager::instance()->processMessage(this, e->from().full(), m.body(), m.subject())) { - delete e; - return; - } - //PluginManager::instance()->message(this,e->from(),ulItem,((MessageEvent*)e)->message().body()); -#endif - - - // Pass message events to chat window if ((m.containsEvents() || m.chatState() != StateNone) && m.body().isEmpty()) { if (PsiOptions::instance()->getOption("options.messages.send-composing-events").toBool()) { Index: psi-0.14/src/psichatdlg.cpp =================================================================== --- psi-0.14.orig/src/psichatdlg.cpp +++ psi-0.14/src/psichatdlg.cpp @@ -40,6 +40,7 @@ #include "jidutil.h" #include "textutil.h" #include "xmpp_tasks.h" +#include "pluginmanager.h" #include "lastactivitytask.h" @@ -325,6 +326,12 @@ void PsiChatDlg::initToolButtons() act_compact_ = new IconAction(tr("Toggle Compact/Full Size"), "psi/compact", tr("Toggle Compact/Full Size"), 0, this); connect(act_compact_, SIGNAL(triggered()), SLOT(toggleSmallChat())); + +#ifdef PSI_PLUGINS + act_plugins_ = PluginManager::instance()->getChatDlgMenuEntries(this, + account(), + jid().full()); +#endif } void PsiChatDlg::initToolBar() @@ -343,6 +350,13 @@ void PsiChatDlg::initToolBar() if (account()->voiceCaller()) { ui_.toolbar->addAction(act_voice_); } +#ifdef PSI_PLUGINS + foreach (QAction* i, act_plugins_ ) + { + ui_.toolbar->addAction(i); + } +#endif + } void PsiChatDlg::contextMenuEvent(QContextMenuEvent *) @@ -500,6 +514,13 @@ void PsiChatDlg::buildMenu() pm_settings_->addAction(act_info_); pm_settings_->addAction(act_history_); +#ifdef PSI_PLUGINS + foreach (QAction* a, act_plugins_) + { + pm_settings_->insertSeparator(); + pm_settings_->addAction(a); + } +#endif } void PsiChatDlg::updateCounter() Index: psi-0.14/src/psichatdlg.h =================================================================== --- psi-0.14.orig/src/psichatdlg.h +++ psi-0.14/src/psichatdlg.h @@ -77,6 +77,10 @@ private: IconAction* act_file_; IconAction* act_compact_; IconAction* act_voice_; +#ifdef PSI_PLUGINS + QList<QAction*> act_plugins_; +#endif + QAction *act_mini_cmd_; Index: psi-0.14/src/src.pro =================================================================== --- psi-0.14.orig/src/src.pro +++ psi-0.14/src/src.pro @@ -10,7 +10,7 @@ CONFIG += qt thread x11 #CONFIG += use_crash CONFIG += pep #CONFIG += whiteboarding -#CONFIG += psi_plugins +CONFIG += psi_plugins DEFINES += QT_STATICPLUGIN DEFINES += QT3_SUPPORT_WARNINGS
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor