Hello,

I've written a new plugin which allows flexible filtering of messages by the 
sender or the content of the messages.

It can
- Drop messages from contacts not on the contactlist
- Drop messages from contacts on the blacklist
- Drop messages from contacts not on the whitelist
- Drop messages that contain one or more words of a list
- Drop messages that contain all words of a list

It's not finished yet but most parts already work. I'd like to know what you 
think of it and wheter i should import it to svn.

Also, I'm not sure if the name "Privacy" is the best choice :|

Regards,
André
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(Revision 576968)
+++ CMakeLists.txt	(Arbeitskopie)
@@ -14,6 +14,7 @@
 add_subdirectory( alias ) 
 add_subdirectory( addbookmarks ) 
 #add_subdirectory( statistics ) 
+add_subdirectory( privacy )
 
 if( LIBXML2_FOUND AND LIBXSLT_FOUND )
   add_subdirectory( webpresence )
Index: privacy/privacyconfig.kcfgc
===================================================================
--- privacy/privacyconfig.kcfgc	(Revision 0)
+++ privacy/privacyconfig.kcfgc	(Revision 0)
@@ -0,0 +1,7 @@
+# Code generation options for kconfig_compiler
+File=privacyconfig.kcfg
+ClassName=PrivacyConfig
+Singleton=true
+Mutators=true
+MemberVariables=private
+GlobalEnums=true

Eigenschaftsänderungen: privacy/privacyconfig.kcfgc
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacypreferences.cpp
===================================================================
--- privacy/privacypreferences.cpp	(Revision 0)
+++ privacy/privacypreferences.cpp	(Revision 0)
@@ -0,0 +1,190 @@
+/*
+    privacypreferences.cpp
+
+    Copyright (c) 2006 by Andre Duffeck             <[EMAIL PROTECTED]>
+    Kopete    (c) 2003-2006 by the Kopete developers  <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This program is free software; you can redistribute it and/or modify  *
+    * it under the terms of the GNU General Public License as published by  *
+    * the Free Software Foundation; either version 2 of the License, or     *
+    * (at your option) any later version.                                   *
+    *                                                                       *
+    *************************************************************************
+*/
+
+#include "privacypreferences.h"
+#include "privacyconfig.h"
+#include "ui_privacydialog.h"
+
+#include <kgenericfactory.h>
+#include <kinputdialog.h>
+
+#include <QLayout>
+#include <QVBoxLayout>
+
+typedef KGenericFactory<PrivacyPreferences> PrivacyPreferencesFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kopete_privacy, PrivacyPreferencesFactory( "kcm_kopete_privacy" ) )
+
+PrivacyPreferences::PrivacyPreferences(QWidget *parent, const QStringList &args)
+	: KCModule(PrivacyPreferencesFactory::instance(), parent, args)
+{
+	kDebug() << k_funcinfo << "called." << endl;
+	
+	QVBoxLayout* l = new QVBoxLayout( this );
+	QWidget* w = new QWidget;
+	p = new Ui::PrivacyPrefsUI;
+	p->setupUi( w );
+	l->addWidget( w );
+
+	connect(p->chkAllowAll, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+	connect(p->chkOnlyWhiteList, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+	connect(p->chkAllButBlackList, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+	connect(p->chkDropAtLeastOne, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+	connect(p->chkDropAtLeastOne, SIGNAL(toggled(bool)), this, SLOT(slotChkDropAtLeastOneToggled()));
+	connect(p->chkDropAll, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+	connect(p->chkDropAll, SIGNAL(toggled(bool)), this, SLOT(slotChkDropAllToggled()));
+	connect(p->editDropAll, SIGNAL(textChanged()), this, SLOT(slotModified()));
+	connect(p->editDropAtLeastOne, SIGNAL(textChanged()), this, SLOT(slotModified()));
+	connect(p->listWhiteList, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(slotModified()));
+	connect(p->listBlackList, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(slotModified()));
+
+	connect(p->btnAddToWhiteList, SIGNAL(clicked()), this, SLOT(slotBtnAddToWhiteListClicked()));
+	connect(p->btnAddToBlackList, SIGNAL(clicked()), this, SLOT(slotBtnAddToBlackListClicked()));
+	connect(p->btnClearWhiteList, SIGNAL(clicked()), this, SLOT(slotBtnClearWhiteListClicked()));
+	connect(p->btnClearBlackList, SIGNAL(clicked()), this, SLOT(slotBtnClearBlackListClicked()));
+	connect(p->btnRemoveFromWhiteList, SIGNAL(clicked()), this, SLOT(slotBtnRemoveFromWhiteListClicked()));
+	connect(p->btnRemoveFromBlackList, SIGNAL(clicked()), this, SLOT(slotBtnRemoveFromBlackListClicked()));
+	load();
+}
+
+PrivacyPreferences::~PrivacyPreferences()
+{
+	kDebug() << k_funcinfo << "called." << endl;
+	delete p;
+}
+
+void PrivacyPreferences::load()
+{
+	kDebug() << k_funcinfo << "called." << endl;
+
+	PrivacyConfig::self()->readConfig();
+
+	p->chkAllowAll->setChecked( PrivacyConfig::sender_AllowAll() );
+	p->chkOnlyWhiteList->setChecked( PrivacyConfig::sender_AllowNoneButWhiteList() );
+	p->listWhiteList->addItems( PrivacyConfig::whiteList() );
+	p->chkAllButBlackList->setChecked( PrivacyConfig::sender_AllowAllButBlackList() );
+	p->listBlackList->addItems( PrivacyConfig::blackList() );
+	p->chkOnlyContactList->setChecked( PrivacyConfig::sender_AllowNoneButContactList() );
+
+	p->chkDropAtLeastOne->setChecked( PrivacyConfig::content_DropIfAny() );
+	p->editDropAtLeastOne->setText( PrivacyConfig::dropIfAny() );
+	p->chkDropAll->setChecked( PrivacyConfig::content_DropIfAll() );
+	p->editDropAll->setText( PrivacyConfig::dropIfAll() );
+
+	emit KCModule::changed(false);
+}
+
+void PrivacyPreferences::save()
+{
+	kDebug(14310) << k_funcinfo << "called." << endl;
+	PrivacyConfig::setSender_AllowAll(p->chkAllowAll->isChecked());
+	PrivacyConfig::setSender_AllowNoneButWhiteList(p->chkOnlyWhiteList->isChecked());
+	QStringList whiteList;
+	for( int i = 0; i < p->listWhiteList->count(); ++i )
+	{
+		whiteList.append( p->listWhiteList->item(i)->text() );
+	}	
+	PrivacyConfig::setWhiteList(whiteList);
+	PrivacyConfig::setSender_AllowAllButBlackList(p->chkAllButBlackList->isChecked());
+	QStringList blackList;
+	for( int i = 0; i < p->listBlackList->count(); ++i )
+	{
+		blackList.append( p->listWhiteList->item(i)->text() );
+	}	
+	PrivacyConfig::setBlackList(blackList);
+	PrivacyConfig::setSender_AllowNoneButContactList(p->chkOnlyContactList->isChecked());
+
+	PrivacyConfig::setContent_DropIfAny(p->chkDropAtLeastOne->isChecked());
+	PrivacyConfig::setDropIfAny(p->editDropAtLeastOne->text());
+	PrivacyConfig::setContent_DropIfAll(p->chkDropAll->isChecked());
+	PrivacyConfig::setDropIfAll(p->editDropAll->text());
+
+	PrivacyConfig::self()->writeConfig();
+	emit KCModule::changed(false);
+}
+
+void PrivacyPreferences::slotModified()
+{
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotChkDropAtLeastOneToggled()
+{
+	p->editDropAtLeastOne->setReadOnly( p->chkDropAtLeastOne->isChecked() );
+}
+
+void PrivacyPreferences::slotChkDropAllToggled()
+{
+	p->editDropAll->setReadOnly( p->chkDropAll->isChecked() );
+}
+
+void PrivacyPreferences::slotBtnAddToWhiteListClicked()
+{
+	bool ok;
+	QString contact = KInputDialog::getText(
+		i18n( "Add contact to Whitelist" ), i18n( "Please enter the userId of the contact that should be whitelisted" ), QString::null, &ok );
+	
+	if( !ok )
+		return;
+
+	p->listWhiteList->addItem( contact );
+
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotBtnAddToBlackListClicked()
+{
+	bool ok;
+	QString contact = KInputDialog::getText(
+		i18n( "Add contact to Blacklist" ), i18n( "Please enter the userId of the contact that should be blacklisted" ), QString::null, &ok );
+	
+	if( !ok )
+		return;
+
+	p->listBlackList->addItem( contact );
+
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotBtnClearWhiteListClicked()
+{
+	p->listWhiteList->clear();
+
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotBtnClearBlackListClicked()
+{
+	p->listBlackList->clear();
+
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotBtnRemoveFromWhiteListClicked()
+{
+// 	QList<QListWidgetItem *> list = p->listWhiteList->selectedItems();
+	p->listWhiteList->takeItem( p->listWhiteList->currentRow() );
+	
+	emit KCModule::changed(true);
+}
+
+void PrivacyPreferences::slotBtnRemoveFromBlackListClicked()
+{
+// 	QList<QListWidgetItem *> list = p->listBlackList->selectedItems();
+	p->listBlackList->takeItem( p->listBlackList->currentRow() );
+	emit KCModule::changed(true);
+}
+
+#include "privacypreferences.moc"

Eigenschaftsänderungen: privacy/privacypreferences.cpp
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacymessagehandler.cpp
===================================================================
--- privacy/privacymessagehandler.cpp	(Revision 0)
+++ privacy/privacymessagehandler.cpp	(Revision 0)
@@ -0,0 +1,92 @@
+/*
+    privacymessagehandler.cpp - Kopete Message Filtering
+
+    Copyright (c) 2006 by Andre Duffeck <[EMAIL PROTECTED]>
+    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This library is free software; you can redistribute it and/or         *
+    * modify it under the terms of the GNU Lesser General Public            *
+    * License as published by the Free Software Foundation; either          *
+    * version 2 of the License, or (at your option) any later version.      *
+    *                                                                       *
+    *************************************************************************
+*/
+
+#include "privacymessagehandler.h"
+#include "kopetemessageevent.h"
+
+#include <kstaticdeleter.h>
+#include <kdebug.h>
+#include <qpointer.h>
+
+class PrivacyMessageHandlerFactory::Private
+{
+public:
+	Message::MessageDirection direction;
+	int position;
+	QPointer<QObject> target;
+	const char *slot;
+};
+
+PrivacyMessageHandlerFactory::PrivacyMessageHandlerFactory( Message::MessageDirection direction,
+	int position, QObject *target, const char *slot )
+ : d( new Private )
+{
+	kDebug() << k_funcinfo << endl;
+	d->direction = direction;
+	d->position = position;
+	d->target = target;
+	d->slot = slot;
+}
+
+PrivacyMessageHandlerFactory::~PrivacyMessageHandlerFactory()
+{
+	kDebug() << k_funcinfo << endl;
+	delete d;
+}
+
+MessageHandler *PrivacyMessageHandlerFactory::create( ChatSession */*manager*/, Message::MessageDirection direction )
+{
+	if ( direction != d->direction )
+		return 0;
+	MessageHandler *handler = new PrivacyMessageHandler;
+	QObject::connect( handler, SIGNAL( handle( Kopete::MessageEvent * ) ), d->target, d->slot );
+	return handler;
+}
+
+int PrivacyMessageHandlerFactory::filterPosition( ChatSession */*manager*/, Message::MessageDirection direction )
+{
+	if ( direction != d->direction )
+		return StageDoNotCreate;
+	return d->position;
+}
+
+PrivacyMessageHandler::PrivacyMessageHandler()
+{
+	kDebug() << k_funcinfo << endl;
+}
+
+PrivacyMessageHandler::~PrivacyMessageHandler()
+{
+	kDebug() << k_funcinfo << endl;
+}
+
+void PrivacyMessageHandler::handleMessage( MessageEvent *e )
+{
+	kDebug() << k_funcinfo << endl;
+	QPointer< MessageEvent > event = e;
+	emit handle( e );
+	if( event )
+	{
+		kDebug() << k_funcinfo << "MessageEvent still there!" << endl;
+		MessageHandler::handleMessage( event );
+	}
+	else
+		kDebug() << k_funcinfo << "MessageEvent destroyed!" << endl;
+}
+
+#include "privacymessagehandler.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:

Eigenschaftsänderungen: privacy/privacymessagehandler.cpp
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/kopete_privacy_config.desktop
===================================================================
--- privacy/kopete_privacy_config.desktop	(Revision 0)
+++ privacy/kopete_privacy_config.desktop	(Revision 0)
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+ServiceTypes=KCModule
+
+X-KDE-Library=kopete_privacy
+X-KDE-FactoryName=kcm_kopete_privacy
+X-KDE-ParentApp=kopete_privacy
+X-KDE-ParentComponents=kopete_privacy
+
+Name=Privacy
+Name[x-test]=xxPrivacyxx
+Comment=Privacy Plugin
+Comment[x-test]=xxPrivacy Pluginxx

Eigenschaftsänderungen: privacy/kopete_privacy_config.desktop
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacyplugin.h
===================================================================
--- privacy/privacyplugin.h	(Revision 0)
+++ privacy/privacyplugin.h	(Revision 0)
@@ -0,0 +1,50 @@
+/*
+    Privacy Plugin - Filter messages 
+
+    Copyright (c) 2006 by Andre Duffeck <[EMAIL PROTECTED]>
+    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This program is free software; you can redistribute it and/or modify  *
+    * it under the terms of the GNU General Public License as published by  *
+    * the Free Software Foundation; either version 2 of the License, or     *
+    * (at your option) any later version.                                   *
+    *                                                                       *
+    *************************************************************************
+*/
+
+#ifndef PRIVACY_PLUGIN_H
+#define PRIVACY_PLUGIN_H
+
+#include <qobject.h>
+
+#include "kopeteplugin.h"
+
+namespace Kopete { 
+	class Message;
+	class MetaContact;
+	class ChatSession;
+}
+class PrivacyMessageHandlerFactory;
+
+class PrivacyPlugin : public Kopete::Plugin
+{
+	Q_OBJECT
+
+public:
+	static PrivacyPlugin *plugin();
+
+	PrivacyPlugin( QObject *parent, const QStringList &args );
+	~PrivacyPlugin();
+
+private slots:
+	void slotSettingsChanged();
+	void slotIncomingMessage( Kopete::MessageEvent *event );
+
+private:
+	static PrivacyPlugin *pluginStatic_;
+	PrivacyMessageHandlerFactory *m_inboundHandler;
+};
+
+#endif

Eigenschaftsänderungen: privacy/privacyplugin.h
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacypreferences.h
===================================================================
--- privacy/privacypreferences.h	(Revision 0)
+++ privacy/privacypreferences.h	(Revision 0)
@@ -0,0 +1,57 @@
+/*
+    privacypreferences.h
+
+    Copyright (c) 2006 by Andre Duffeck             <[EMAIL PROTECTED]>
+    Kopete    (c) 2003-2006 by the Kopete developers  <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This program is free software; you can redistribute it and/or modify  *
+    * it under the terms of the GNU General Public License as published by  *
+    * the Free Software Foundation; either version 2 of the License, or     *
+    * (at your option) any later version.                                   *
+    *                                                                       *
+    *************************************************************************
+*/
+
+#ifndef PRIVACY_PREFERENCES_H
+#define PRIVACY_PREFERENCES_H
+
+#include "kcmodule.h"
+
+#include <QStringList>
+
+namespace Ui { class PrivacyPrefsUI; }
+class PrivacyConfig;
+
+class PrivacyPreferences : public KCModule
+{
+Q_OBJECT
+public:
+	enum SenderMode { AllowAllMessages, AllowNoMessagesExceptWhiteList, AllowAllMessagesExceptBlackList };
+
+	PrivacyPreferences(QWidget *parent=0, const QStringList &args = QStringList());
+	~PrivacyPreferences();
+
+	virtual void save();
+	virtual void load();	
+
+private slots:
+	void slotModified();
+	void slotChkDropAtLeastOneToggled();
+	void slotChkDropAllToggled();
+
+	void slotBtnAddToWhiteListClicked();
+	void slotBtnAddToBlackListClicked();	
+	void slotBtnClearWhiteListClicked();
+	void slotBtnClearBlackListClicked();
+	void slotBtnRemoveFromWhiteListClicked();
+	void slotBtnRemoveFromBlackListClicked();
+private:
+	Ui::PrivacyPrefsUI *p;
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
+

Eigenschaftsänderungen: privacy/privacypreferences.h
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacymessagehandler.h
===================================================================
--- privacy/privacymessagehandler.h	(Revision 0)
+++ privacy/privacymessagehandler.h	(Revision 0)
@@ -0,0 +1,57 @@
+/*
+    privacymessagehandler.h - Kopete Message Filtering
+
+    Copyright (c) 2006 by Andre Duffeck <[EMAIL PROTECTED]>
+    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This library is free software; you can redistribute it and/or         *
+    * modify it under the terms of the GNU Lesser General Public            *
+    * License as published by the Free Software Foundation; either          *
+    * version 2 of the License, or (at your option) any later version.      *
+    *                                                                       *
+    *************************************************************************
+*/
+
+#ifndef PRIVACY_MESSAGEHANDLER_H
+#define PRIVACY_MESSAGEHANDLER_H
+
+#include "kopetemessagehandler.h"
+
+using namespace Kopete;
+
+class PrivacyMessageHandlerFactory : public MessageHandlerFactory
+{
+public:
+
+	PrivacyMessageHandlerFactory( Message::MessageDirection direction, int position,
+	                             QObject *target, const char *slot );
+	~PrivacyMessageHandlerFactory();
+	
+	MessageHandler *create( ChatSession *manager, Message::MessageDirection direction );
+	int filterPosition( ChatSession *manager, Message::MessageDirection direction );
+	
+private:
+	class Private;
+	Private *d;
+};
+
+class PrivacyMessageHandler : public MessageHandler
+{
+	Q_OBJECT
+public:
+	PrivacyMessageHandler();
+	~PrivacyMessageHandler();
+	
+	void handleMessage( MessageEvent *event );
+	
+signals:
+	void handle( Kopete::MessageEvent *event );
+
+private:
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:

Eigenschaftsänderungen: privacy/privacymessagehandler.h
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacydialog.ui
===================================================================
--- privacy/privacydialog.ui	(Revision 0)
+++ privacy/privacydialog.ui	(Revision 0)
@@ -0,0 +1,208 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>PrivacyPrefsUI</class>
+ <widget class="QWidget" name="PrivacyPrefsUI" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>653</width>
+    <height>481</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Filter by sender</string>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="1" column="0" colspan="2" >
+       <widget class="QCheckBox" name="chkOnlyContactList" >
+        <property name="text" >
+         <string>Allow messages only from contacts on my contactlist</string>
+        </property>
+        <property name="autoExclusive" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0" colspan="2" >
+       <widget class="QCheckBox" name="chkOnlyWhiteList" >
+        <property name="text" >
+         <string>Allow messages only from contacts on the whitelist</string>
+        </property>
+        <property name="autoExclusive" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" colspan="2" >
+       <widget class="QCheckBox" name="chkAllButBlackList" >
+        <property name="text" >
+         <string>Allow all messages but messages from contacts on the blacklist</string>
+        </property>
+        <property name="autoExclusive" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" colspan="2" >
+       <widget class="QCheckBox" name="chkAllowAll" >
+        <property name="text" >
+         <string>Allow all messages</string>
+        </property>
+        <property name="checked" >
+         <bool>true</bool>
+        </property>
+        <property name="autoExclusive" >
+         <bool>true</bool>
+        </property>
+        <property name="tristate" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1" >
+       <layout class="QGridLayout" >
+        <property name="margin" >
+         <number>0</number>
+        </property>
+        <property name="spacing" >
+         <number>6</number>
+        </property>
+        <item row="2" column="1" >
+         <widget class="QPushButton" name="btnRemoveFromBlackList" >
+          <property name="text" >
+           <string>Remove</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="2" >
+         <widget class="QPushButton" name="btnClearBlackList" >
+          <property name="text" >
+           <string>Clear</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0" >
+         <widget class="QPushButton" name="btnAddToBlackList" >
+          <property name="text" >
+           <string>Add</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="0" colspan="3" >
+         <widget class="QLabel" name="label_2" >
+          <property name="text" >
+           <string>Blacklist:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0" colspan="3" >
+         <widget class="QListWidget" name="listBlackList" />
+        </item>
+       </layout>
+      </item>
+      <item row="4" column="0" >
+       <layout class="QGridLayout" >
+        <property name="margin" >
+         <number>0</number>
+        </property>
+        <property name="spacing" >
+         <number>6</number>
+        </property>
+        <item row="1" column="0" colspan="3" >
+         <widget class="QListWidget" name="listWhiteList" />
+        </item>
+        <item row="0" column="0" colspan="2" >
+         <widget class="QLabel" name="label" >
+          <property name="text" >
+           <string>Whitelist:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1" >
+         <widget class="QPushButton" name="btnRemoveFromWhiteList" >
+          <property name="text" >
+           <string>Remove</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0" >
+         <widget class="QPushButton" name="btnAddToWhiteList" >
+          <property name="text" >
+           <string>Add</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="2" >
+         <widget class="QPushButton" name="btnClearWhiteList" >
+          <property name="text" >
+           <string>Clear</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QGroupBox" name="groupBox_2" >
+     <property name="title" >
+      <string>Filter by content (seperate word lists by commas)</string>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="3" column="0" >
+       <widget class="QLineEdit" name="editDropAll" />
+      </item>
+      <item row="1" column="0" >
+       <widget class="QLineEdit" name="editDropAtLeastOne" />
+      </item>
+      <item row="2" column="0" >
+       <widget class="QCheckBox" name="chkDropAll" >
+        <property name="text" >
+         <string>Drop messages that contain all of the following words:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" >
+       <widget class="QCheckBox" name="chkDropAtLeastOne" >
+        <property name="text" >
+         <string>Drop messages that contain at least one of the following words:</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>

Eigenschaftsänderungen: privacy/privacydialog.ui
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/kopete_privacy.desktop
===================================================================
--- privacy/kopete_privacy.desktop	(Revision 0)
+++ privacy/kopete_privacy.desktop	(Revision 0)
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+X-Kopete-Version=1000900
+ServiceTypes=Kopete/Plugin
+X-KDE-Library=kopete_privacy
+X-KDE-PluginInfo-Author=Andre Duffeck
[EMAIL PROTECTED]
+X-KDE-PluginInfo-Name=kopete_privacy
+X-KDE-PluginInfo-Version=0.1.0
+X-KDE-PluginInfo-Website=http://kopete.kde.org
+X-KDE-PluginInfo-Category=Plugins
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+Name=Privacy
+Name[x-test]=xxConnection Statusxx
+Comment=Filters incoming messages
+Comment[x-test]=xxFilters incoming messagesxx

Eigenschaftsänderungen: privacy/kopete_privacy.desktop
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacyconfig.kcfg
===================================================================
--- privacy/privacyconfig.kcfg	(Revision 0)
+++ privacy/privacyconfig.kcfg	(Revision 0)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Author: Andre Duffeck -->
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0";
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd"; >
+	<kcfgfile name="kopeterc"/>
+
+	<group name="Privacy Plugin">
+		<entry name="Sender_AllowAll" type="Bool">
+			<label>Allow everyone to send you messages.</label>
+			<default>true</default>
+		</entry>
+		<entry name="Sender_AllowNoneButWhiteList" type="Bool">
+			<label>Allow nobody to send you messages, except the contacts on the whitelist.</label>
+			<default>false</default>
+		</entry>
+		<entry name="Sender_AllowAllButBlackList" type="Bool">
+			<label>Allow everyone to send you messages, except the contacts on the blacklist.</label>
+			<default>false</default>
+		</entry>
+		<entry name="Sender_AllowNoneButContactList" type="Bool">
+			<label>Allow everyone to send you messages, except the contacts on the blacklist.</label>
+			<default>false</default>
+		</entry>
+		<entry name="WhiteList" type="StringList">
+			<label>Contacts on the whitelist.</label>
+			<default></default>
+		</entry>
+		<entry name="BlackList" type="StringList">
+			<label>Contacts on the blacklist.</label>
+			<default></default>
+		</entry>
+		<entry name="Content_DropIfAny" type="Bool">
+			<label>Drop messages that contain at least one of the following words.</label>
+			<default>false</default>
+		</entry>
+		<entry name="DropIfAny" type="String">
+			<label>Words to look for.</label>
+			<default></default>
+		</entry>
+		<entry name="Content_DropIfAll" type="Bool">
+			<label>Drop messages that contain all of the following words.</label>
+			<default>false</default>
+		</entry>
+		<entry name="DropIfAll" type="String">
+			<label>Words to look for.</label>
+			<default></default>
+		</entry>
+	</group>
+</kcfg>

Eigenschaftsänderungen: privacy/privacyconfig.kcfg
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/privacyplugin.cpp
===================================================================
--- privacy/privacyplugin.cpp	(Revision 0)
+++ privacy/privacyplugin.cpp	(Revision 0)
@@ -0,0 +1,136 @@
+/*
+    Privacy Plugin - Filter messages 
+
+    Copyright (c) 2006 by Andre Duffeck <[EMAIL PROTECTED]>
+    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+    *************************************************************************
+    *                                                                       *
+    * This program is free software; you can redistribute it and/or modify  *
+    * it under the terms of the GNU General Public License as published by  *
+    * the Free Software Foundation; either version 2 of the License, or     *
+    * (at your option) any later version.                                   *
+    *                                                                       *
+    *************************************************************************
+*/
+#include "kopetecontact.h"
+#include "kopetemetacontact.h"
+#include "kopetemessage.h"
+#include "kopetemessageevent.h"
+#include "kopetechatsessionmanager.h"
+#include "privacymessagehandler.h"
+#include "privacyconfig.h"
+
+#include <kgenericfactory.h>
+
+#include "privacyplugin.h"
+
+typedef KGenericFactory<PrivacyPlugin> PrivacyPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( kopete_privacy, PrivacyPluginFactory( "kopete_privacy" )  )
+PrivacyPlugin * PrivacyPlugin::pluginStatic_ = 0L;
+
+PrivacyPlugin::PrivacyPlugin( QObject *parent, const QStringList & )
+: Kopete::Plugin( PrivacyPluginFactory::instance(), parent )
+{
+	kDebug() << k_funcinfo << endl;
+	if( !pluginStatic_ )
+		pluginStatic_ = this;
+
+	m_inboundHandler = new PrivacyMessageHandlerFactory( Kopete::Message::Inbound,
+		Kopete::MessageHandlerFactory::InStageStart, this, SLOT( slotIncomingMessage( Kopete::MessageEvent * ) ) );
+
+	connect( this, SIGNAL( settingsChanged() ), this, SLOT( slotSettingsChanged() ) );
+}
+
+
+PrivacyPlugin::~PrivacyPlugin()
+{
+	kDebug() << k_funcinfo << endl;
+	pluginStatic_ = 0L;
+	delete m_inboundHandler;
+}
+
+PrivacyPlugin *PrivacyPlugin::plugin()
+{
+	return pluginStatic_ ;
+}
+
+void PrivacyPlugin::slotSettingsChanged()
+{
+	PrivacyConfig::self()->readConfig();
+}
+
+void PrivacyPlugin::slotIncomingMessage( Kopete::MessageEvent *event )
+{
+	kDebug() << k_funcinfo << endl;
+
+	Kopete::Message msg = event->message();
+
+	if( msg.direction() == Kopete::Message::Outbound ||
+		msg.direction() == Kopete::Message::Internal )
+		return;
+
+	// Verify sender
+	if( PrivacyConfig::sender_AllowNoneButWhiteList() )
+	{
+		if( !PrivacyConfig::whiteList().contains( msg.from()->contactId() ) )
+		{
+			kDebug() << k_funcinfo << "Message from " << msg.from()->contactId() << " dropped (not whitelisted)" << endl;
+			event->discard();
+			return;
+		}
+	}
+	else if( PrivacyConfig::sender_AllowAllButBlackList() )
+	{
+		if( PrivacyConfig::blackList().contains( msg.from()->contactId() ) )
+		{
+			kDebug() << k_funcinfo << "Message from " << msg.from()->contactId() << " dropped (blacklisted)" << endl;
+			event->discard();
+			return;
+		}
+	}
+	else if( PrivacyConfig::sender_AllowNoneButContactList() )
+	{
+		if( msg.from()->metaContact()->isTemporary() )
+		{
+			kDebug() << k_funcinfo << "Message from " << msg.from()->contactId() << " dropped (not on the contactlist)" << endl;
+			event->discard();
+			return;
+		}
+	}
+
+	// Verify content
+	if( PrivacyConfig::content_DropIfAny() )
+	{
+		foreach(QString word, PrivacyConfig::dropIfAny().split(',') )
+		{
+			if( msg.plainBody().contains( word ) )
+			{
+				kDebug() << k_funcinfo << "Message dropped because it contained: " << word << endl;
+				event->discard();
+				return;
+			}
+		}
+	}
+
+	if( PrivacyConfig::content_DropIfAll() )
+	{
+		bool drop = true;
+		foreach(QString word, PrivacyConfig::dropIfAll().split(',') )
+		{
+			if( !msg.plainBody().contains( word ) )
+			{
+				drop = false;
+				break;
+			}
+		}
+		if( drop )
+		{
+			kDebug() << k_funcinfo << "Message dropped because it contained blacklisted words." << endl;
+			event->discard();
+			return;
+		}
+	}
+}
+
+#include "privacyplugin.moc"

Eigenschaftsänderungen: privacy/privacyplugin.cpp
___________________________________________________________________
Name: svn:executable
   + *

Index: privacy/CMakeLists.txt
===================================================================
--- privacy/CMakeLists.txt	(Revision 0)
+++ privacy/CMakeLists.txt	(Revision 0)
@@ -0,0 +1,48 @@
+
+#add_subdirectory( icons ) 
+
+include_directories( 
+${KOPETE_INCLUDES} 
+)
+
+
+########### next target ###############
+
+set(kopete_privacy_PART_SRCS privacyplugin.cpp privacymessagehandler.cpp privacypreferences.cpp)
+
+kde4_add_kcfg_files(kopete_privacy_PART_SRCS privacyconfig.kcfgc )
+
+kde4_automoc(${kopete_privacy_PART_SRCS})
+
+kde4_add_plugin(kopete_privacy ${kopete_privacy_PART_SRCS})
+
+kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kopete_privacy )
+
+target_link_libraries(kopete_privacy  ${KDE4_KDECORE_LIBS} kopete )
+
+install(TARGETS kopete_privacy  DESTINATION ${PLUGIN_INSTALL_DIR})
+
+
+########### next target ###############
+
+set(kcm_kopete_privacy_PART_SRCS privacypreferences.cpp )
+
+kde4_add_ui_files(kcm_kopete_privacy_PART_SRCS privacydialog.ui )
+
+kde4_add_kcfg_files(kcm_kopete_privacy_PART_SRCS privacyconfig.kcfgc )
+
+kde4_automoc(${kcm_kopete_privacy_PART_SRCS})
+
+kde4_add_plugin(kcm_kopete_privacy ${kcm_kopete_privacy_PART_SRCS})
+
+kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kcm_kopete_privacy )
+
+target_link_libraries(kcm_kopete_privacy  ${KDE4_KUTILS_LIBS} kopete )
+
+install(TARGETS kcm_kopete_privacy  DESTINATION ${PLUGIN_INSTALL_DIR})
+
+
+########### install files ###############
+
+install( FILES kopete_privacy.desktop  DESTINATION ${SERVICES_INSTALL_DIR})
+install( FILES kopete_privacy_config.desktop  DESTINATION ${SERVICES_INSTALL_DIR}/kconfiguredialog)
\ Kein Zeilenvorschub am Ende der Datei

Eigenschaftsänderungen: privacy/CMakeLists.txt
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to