File psi-0.15-enable_otr.patch of Package psi

diff -ruN ./configure ../psi-0.15.otr/configure
--- ./configure	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/configure	2012-10-10 14:01:28.460794002 +0900
@@ -41,6 +41,8 @@
   --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
 }
@@ -251,6 +253,16 @@
 			QC_DISABLE_enchant="Y"
 			shift
 			;;
+		--disable-plugins)
+			QC_DISABLE_plugins="Y"
+			shift
+			;;
+
+		--enable-plugins)
+			QC_ENABLE_PLUGINS="Y"
+			shift
+			;;
+
 
 		--verbose)
 			QC_VERBOSE="Y"
@@ -293,6 +305,8 @@
 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
 
@@ -1547,6 +1561,49 @@
 	}
 };
 
+#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
     o = new qc_qt4(conf);
@@ -1594,6 +1651,9 @@
     o = new qc_recursiveprl(conf);
     o->required = true;
     o->disabled = false;
+    o = new qc_plugins(conf);
+    o->required = false;
+    o->disabled = false;
 
 EOT
 cat >$1/conf4.h <<EOT
@@ -2636,6 +2696,9 @@
 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
diff -ruN ./src/applicationinfo.cpp ../psi-0.15.otr/src/applicationinfo.cpp
--- ./src/applicationinfo.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/applicationinfo.cpp	2012-10-10 14:04:21.860794003 +0900
@@ -36,9 +36,9 @@
 // Should also be overridable through an optional file.
 
 #define PROG_NAME "Psi"
-#define PROG_VERSION PSI_VERSION
+//#define PROG_VERSION PSI_VERSION
 //#define PROG_VERSION "0.15-dev" " (" __DATE__ ")" //CVS Builds are dated
-//#define PROG_VERSION "0.15";
+#define PROG_VERSION "0.15-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
diff -ruN ./src/options/opt_plugins.cpp ../psi-0.15.otr/src/options/opt_plugins.cpp
--- ./src/options/opt_plugins.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/options/opt_plugins.cpp	2012-10-10 14:47:19.641640000 +0900
@@ -135,7 +135,7 @@
 			value=Qt::Unchecked;
 		d->cb_loadPlugin->setChecked(value);
 	
-		d->vboxLayout1->remove(d->pluginOptions);
+		d->vboxLayout1->removeWidget(d->pluginOptions);
 		delete d->pluginOptions;
 		d->pluginOptions=NULL;
 		if (pluginOptions)
diff -ruN ./src/pluginhost.cpp ../psi-0.15.otr/src/pluginhost.cpp
--- ./src/pluginhost.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/pluginhost.cpp	2012-10-10 14:39:36.186393993 +0900
@@ -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)
 	, loader_(0)
+	, file_(pluginFile)
+	, name_()
+	, shortName_()
+	, version_()
+	, valid_(false)
 	, connected_(false)
 	, enabled_(false)
-	, valid_(false)
+	, iqNsFilters_()
+	, iqNsxFilters_()
 {
 	load();	// reads plugin name, etc
 	unload();
@@ -250,6 +256,12 @@
 				qDebug("connecting option accessor");
 				o->setOptionAccessingHost(this);
 			}
+
+			PsiPlugin* p = qobject_cast<PsiPlugin*>(plugin_);
+			if (p)
+			{
+			    p->setHomeDir(ApplicationInfo::homeDir(ApplicationInfo::CacheLocation));
+			}
 			
 			connected_ = true;
 		}
@@ -396,7 +408,7 @@
  * \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 +418,28 @@
 	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 +598,8 @@
  */
 void PluginHost::setPluginOption( const QString& option, const QVariant& value)
 {
+	Q_UNUSED(option)
+	Q_UNUSED(value)
 	// TODO(mck)
 
 	//PsiPlugin* plugin=NULL;
@@ -587,6 +623,7 @@
  */
 QVariant PluginHost::getPluginOption(const QString& option)
 {
+	Q_UNUSED(option)
 	return QVariant();	// TODO(mck)
 }
 
@@ -616,6 +653,30 @@
 	return PsiOptions::instance()->getOption(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 --------------------------------------------------------
 
diff -ruN ./src/pluginhost.h ../psi-0.15.otr/src/pluginhost.h
--- ./src/pluginhost.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/pluginhost.h	2012-10-10 14:10:23.728794002 +0900
@@ -17,6 +17,7 @@
 
 class QWidget;
 class QPluginLoader;
+class QAction;
 
 class PluginManager;
 class IqNamespaceFilter;
@@ -54,7 +55,13 @@
 
 	// 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);
@@ -73,6 +80,11 @@
 	QVariant getPluginOption(const QString& option);
 	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_;
diff -ruN ./src/pluginmanager.cpp ../psi-0.15.otr/src/pluginmanager.cpp
--- ./src/pluginmanager.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/pluginmanager.cpp	2012-10-10 14:15:53.995541999 +0900
@@ -150,6 +150,7 @@
  */
 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
@@ -239,7 +240,7 @@
 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));
@@ -257,14 +258,54 @@
  * \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;
 }
@@ -283,10 +324,13 @@
 {
 	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;
 }
@@ -307,9 +351,12 @@
 {
 	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;
@@ -372,6 +419,61 @@
 	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";
diff -ruN ./src/pluginmanager.h ../psi-0.15.otr/src/pluginmanager.h
--- ./src/pluginmanager.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/pluginmanager.h	2012-10-10 14:16:42.979542001 +0900
@@ -13,6 +13,7 @@
 #include <QDomElement>
 
 class QPluginLoader;
+class QAction;
 
 class PsiAccount;
 class PsiPlugin;
@@ -46,11 +47,25 @@
 	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();
diff -ruN ./src/plugins/include/eventfilter.h ../psi-0.15.otr/src/plugins/include/eventfilter.h
--- ./src/plugins/include/eventfilter.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/plugins/include/eventfilter.h	2012-10-10 14:17:45.843542004 +0900
@@ -11,7 +11,15 @@
 	// 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");
diff -ruN ./src/plugins/include/iqfilter.h ../psi-0.15.otr/src/plugins/include/iqfilter.h
--- ./src/plugins/include/iqfilter.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/plugins/include/iqfilter.h	2012-10-10 14:18:11.543542001 +0900
@@ -13,4 +13,4 @@
 
 Q_DECLARE_INTERFACE(IqFilter, "org.psi-im.IqFilter/0.1");
 
-#endif
\ В конце файла нет новой строки
+#endif
diff -ruN ./src/plugins/include/psiplugin.h ../psi-0.15.otr/src/plugins/include/psiplugin.h
--- ./src/plugins/include/psiplugin.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/plugins/include/psiplugin.h	2012-10-10 14:18:42.771542003 +0900
@@ -86,6 +86,15 @@
 	 * \return true if plugin was successfully disabled
 	 */
 	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;
 
 };
 
diff -ruN ./src/plugins/include/stanzasender.h ../psi-0.15.otr/src/plugins/include/stanzasender.h
--- ./src/plugins/include/stanzasender.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/plugins/include/stanzasender.h	2012-10-10 14:18:54.559542001 +0900
@@ -13,4 +13,4 @@
 
 Q_DECLARE_INTERFACE(StanzaSender, "org.psi-im.StanzaSender/0.1");
 
-#endif
\ В конце файла нет новой строки
+#endif
diff -ruN ./src/psiaccount.cpp ../psi-0.15.otr/src/psiaccount.cpp
--- ./src/psiaccount.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/psiaccount.cpp	2012-10-10 14:22:41.463542001 +0900
@@ -1624,6 +1624,9 @@
 // disconnect or stop reconnecting
 void PsiAccount::logout(bool fast, const Status &s)
 {
+#ifdef PSI_PLUGINS
+    PluginManager::instance()->logout(this);
+#endif
 	if(!isActive())
 		return;
 
@@ -2326,6 +2329,9 @@
 		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);
@@ -2493,6 +2499,9 @@
 		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)
@@ -3574,7 +3583,6 @@
 			if(!pp.isNull())
 				p = pp;
 #ifdef __GNUC__
-#warning "Removed reparenting call from qwextend"
 #endif
 			//reparent_good(window, 0, false);
 			if(!p.isNull())
@@ -4257,6 +4265,25 @@
 		}
 	}
 
+#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
@@ -4593,6 +4620,52 @@
 	//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->psi->filterEvent(this, e)) {
 		delete e;
 		return;
@@ -4620,18 +4693,6 @@
 		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
-
 		QList<PsiEvent*> chatList;
 		d->eventQueue->extractChats(&chatList, me->from(), false, false);
 		if (messageListContainsEvent(chatList, me)) {
diff -ruN ./src/psichatdlg.cpp ../psi-0.15.otr/src/psichatdlg.cpp
--- ./src/psichatdlg.cpp	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/psichatdlg.cpp	2012-10-10 14:53:57.497640002 +0900
@@ -41,6 +41,7 @@
 #include "jidutil.h"
 #include "textutil.h"
 #include "xmpp_tasks.h"
+#include "pluginmanager.h"
 #include "lastactivitytask.h"
 
 
@@ -327,6 +328,11 @@
 
 	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()
@@ -345,6 +351,13 @@
 	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 *)
@@ -519,6 +532,13 @@
 
 	pm_settings_->addAction(act_info_);
 	pm_settings_->addAction(act_history_);
+#ifdef PSI_PLUGINS
+	foreach (QAction* a, act_plugins_)
+	{
+	    pm_settings_->addSeparator();
+	    pm_settings_->addAction(a);
+	}
+#endif
 }
 
 void PsiChatDlg::updateCounter()
diff -ruN ./src/psichatdlg.h ../psi-0.15.otr/src/psichatdlg.h
--- ./src/psichatdlg.h	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/psichatdlg.h	2012-10-10 14:25:00.495541994 +0900
@@ -77,6 +77,10 @@
 	IconAction* act_file_;
 	IconAction* act_compact_;
 	IconAction* act_voice_;
+#ifdef PSI_PLUGINS
+    QList<QAction*> act_plugins_;
+#endif
+
 
 	QAction *act_mini_cmd_;
 
diff -ruN ./src/src.pro ../psi-0.15.otr/src/src.pro
--- ./src/src.pro	2012-10-04 09:53:03.000000000 +0900
+++ ../psi-0.15.otr/src/src.pro	2012-10-10 14:25:25.119542002 +0900
@@ -10,7 +10,7 @@
 
 #CONFIG += use_crash
 CONFIG += pep
-#CONFIG += psi_plugins
+CONFIG += psi_plugins
 DEFINES += QT_STATICPLUGIN
 
 # Import several very useful Makefile targets