[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#284334: kopete: [PATCH] Drop messages fro muser not in your contact list.



Package: kopete
Version: 4:3.5.5-5
Followup-For: Bug #284334

I would like to see the feature "Drop messages from users not at contact
list" at kopete. Gooling I found simple solution and write confuguration
for it. Patch  attached.

-- PATCH START --
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/icqaccount.cpp kdenetwork-3.5.5/kopete/protocols/oscar/icq/icqaccount.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/icqaccount.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/icqaccount.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -174,6 +174,7 @@
 		oscarSettings->setHideIP( configGroup()->readBoolEntry( "HideIP", true ) );
 		oscarSettings->setRequireAuth( configGroup()->readBoolEntry( "RequireAuth", false ) );
 		oscarSettings->setRespectRequireAuth( configGroup()->readBoolEntry( "RespectRequireAuth", true ) );
+		oscarSettings->setDropNotInList( configGroup()->readBoolEntry( "DropNotInList", false ) );
 		//FIXME: also needed for the other call to setStatus (in setPresenceTarget)
 		DWORD status = pres.toOscarStatus();
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui	2007-07-19 13:14:26.000000000 +0700
@@ -331,13 +331,27 @@
                             </widget>
                             <widget class="QCheckBox" row="1" column="0">
                                 <property name="name">
+                                    <cstring>chkDropNotInList</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Drop messages from users not in contact list</string>
+                                </property>
+                                <property name="toolTip" stdset="0">
+                                    <string>Enable spam protection, which will not show you messages from users not at your contact list.</string>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>Enable spam protection, which will not show you messages from users not at your contact list.  Check this box, and kopete will drop any messages from users not at your contact list.</string>
+                                </property>
+                            </widget>
+                            <widget class="QCheckBox" row="2" column="0">
+                                <property name="name">
                                     <cstring>chkRespectRequireAuth</cstring>
                                 </property>
                                 <property name="text">
                                     <string>Respect other contacts' &amp;wish to require authorization</string>
                                 </property>
                             </widget>
-                            <widget class="QCheckBox" row="2" column="0">
+                            <widget class="QCheckBox" row="3" column="0">
                                 <property name="name">
                                     <cstring>chkHideIP</cstring>
                                 </property>
@@ -351,7 +365,7 @@
                                     <string>Checking this box will not allow people to see what your IP address if they view your ICQ user details such as name, address, or age.</string>
                                 </property>
                             </widget>
-                            <widget class="QCheckBox" row="3" column="0">
+                            <widget class="QCheckBox" row="4" column="0">
                                 <property name="name">
                                     <cstring>chkWebAware</cstring>
                                 </property>
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -77,6 +77,9 @@
 
         bool configValue = mAccount->configGroup()->readBoolEntry( "RequireAuth", false );
 		mAccountSettings->chkRequireAuth->setChecked( configValue );
+        
+		configValue = mAccount->configGroup()->readBoolEntry( "DropNotInList", false );
+		mAccountSettings->chkDropNotInList->setChecked( configValue );
 
         configValue = mAccount->configGroup()->readBoolEntry( "RespectRequireAuth", true );
 		mAccountSettings->chkRespectRequireAuth->setChecked( configValue );
@@ -130,6 +133,9 @@
     bool configValue = mAccountSettings->chkRequireAuth->isChecked();
 	mAccount->configGroup()->writeEntry( "RequireAuth", configValue );
 
+	configValue = mAccountSettings->chkDropNotInList->isChecked();
+	mAccount->configGroup()->writeEntry( "DropNotInList", configValue );
+
     configValue = mAccountSettings->chkRespectRequireAuth->isChecked();
 	mAccount->configGroup()->writeEntry( "RespectRequireAuth", configValue );
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.cpp kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.cpp	2005-09-10 15:20:23.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -59,6 +59,16 @@
 	return m_respectRequireAuth;
 }
 
+void Settings::setDropNotInList( bool drop )
+{
+	m_dropNotInList = drop;
+}
+
+bool Settings::dropNotInList() const
+{
+	return m_dropNotInList;
+}
+
 void Settings::setHideIP( bool hide )
 {
 	m_hideIP = hide;
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.h kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.h
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.h	2005-09-10 15:20:23.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.h	2007-07-19 13:14:26.000000000 +0700
@@ -44,6 +44,10 @@
 	bool requireAuth() const;
 	void setRespectRequireAuth( bool require );
 	bool respectRequireAuth() const;
+
+	/* Anti-spam settings */
+	void setDropNotInList( bool drop );
+	bool dropNotInList() const;
 	
 	/* Hide IP Settings */
 	void setHideIP( bool hide );
@@ -54,6 +58,7 @@
 	bool m_webAware;
 	bool m_requireAuth;
 	bool m_respectRequireAuth;
+	bool m_dropNotInList;
 	bool m_hideIP;
 };
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/oscaraccount.cpp kdenetwork-3.5.5/kopete/protocols/oscar/oscaraccount.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/oscaraccount.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/oscaraccount.cpp	2007-07-19 13:23:04.000000000 +0700
@@ -55,6 +55,7 @@
 #include "oscarutils.h"
 #include "oscarclientstream.h"
 #include "oscarconnector.h"
+#include "oscarsettings.h"
 #include "ssimanager.h"
 #include "oscarlistnonservercontacts.h"
 #include "oscarversionupdater.h"
@@ -380,19 +381,36 @@
 	}
 
 	/* Logic behind this:
-	 * If we don't have the contact yet, create it as a temporary
-	 * Create the message manager
-	 * Get the sanitized message back
-	 * Append to the chat window
+	 * 1. Check if we should drop the message.
+	 * 2. If we don't have the contact yet, create it as a temporary
+	 *    Create the message manager
+	 *    Get the sanitized message back
+	 *    Append to the chat window
 	 */
 	QString sender = Oscar::normalize( message.sender() );
-	if ( !contacts()[sender] )
+	OscarContact* ocSender = static_cast<OscarContact *> ( contacts()[sender] ); 
+
+	if (!ocSender || ocSender->metaContact()->isTemporary()) 
+	{
+		// Try to drop the message 
+		if( engine()->clientSettings()->dropNotInList() )  
+		{
+			if ( ( message.properties() & Oscar::Message::Request ) == 0) 
+			{
+				kdWarning(OSCAR_RAW_DEBUG) << "Dropping message from '" << sender << "' because he is not in contact list (" << message.properties() << ")" << endl;
+				return;
+			}
+			kdWarning(OSCAR_RAW_DEBUG) << "Passing message from '" << sender << "' (" << message.properties() << ")" << endl;
+		}
+	}
+
+	if (!ocSender) 
 	{
 		kdDebug(OSCAR_RAW_DEBUG) << "Adding '" << sender << "' as temporary contact" << endl;
 		addContact( sender, QString::null, 0,  Kopete::Account::Temporary );
 	}
 
-	OscarContact* ocSender = static_cast<OscarContact *> ( contacts()[sender] ); //should exist now
+	ocSender = static_cast<OscarContact *> ( contacts()[sender] ); //should exist now
 
 	if ( !ocSender )
 	{
-- PATCH END--

diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/icqaccount.cpp kdenetwork-3.5.5/kopete/protocols/oscar/icq/icqaccount.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/icqaccount.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/icqaccount.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -174,6 +174,7 @@
 		oscarSettings->setHideIP( configGroup()->readBoolEntry( "HideIP", true ) );
 		oscarSettings->setRequireAuth( configGroup()->readBoolEntry( "RequireAuth", false ) );
 		oscarSettings->setRespectRequireAuth( configGroup()->readBoolEntry( "RespectRequireAuth", true ) );
+		oscarSettings->setDropNotInList( configGroup()->readBoolEntry( "DropNotInList", false ) );
 		//FIXME: also needed for the other call to setStatus (in setPresenceTarget)
 		DWORD status = pres.toOscarStatus();
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui	2007-07-19 13:14:26.000000000 +0700
@@ -331,13 +331,27 @@
                             </widget>
                             <widget class="QCheckBox" row="1" column="0">
                                 <property name="name">
+                                    <cstring>chkDropNotInList</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Drop messages from users not in contact list</string>
+                                </property>
+                                <property name="toolTip" stdset="0">
+                                    <string>Enable spam protection, which will not show you messages from users not at your contact list.</string>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>Enable spam protection, which will not show you messages from users not at your contact list.  Check this box, and kopete will drop any messages from users not at your contact list.</string>
+                                </property>
+                            </widget>
+                            <widget class="QCheckBox" row="2" column="0">
+                                <property name="name">
                                     <cstring>chkRespectRequireAuth</cstring>
                                 </property>
                                 <property name="text">
                                     <string>Respect other contacts' &amp;wish to require authorization</string>
                                 </property>
                             </widget>
-                            <widget class="QCheckBox" row="2" column="0">
+                            <widget class="QCheckBox" row="3" column="0">
                                 <property name="name">
                                     <cstring>chkHideIP</cstring>
                                 </property>
@@ -351,7 +365,7 @@
                                     <string>Checking this box will not allow people to see what your IP address if they view your ICQ user details such as name, address, or age.</string>
                                 </property>
                             </widget>
-                            <widget class="QCheckBox" row="3" column="0">
+                            <widget class="QCheckBox" row="4" column="0">
                                 <property name="name">
                                     <cstring>chkWebAware</cstring>
                                 </property>
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -77,6 +77,9 @@
 
         bool configValue = mAccount->configGroup()->readBoolEntry( "RequireAuth", false );
 		mAccountSettings->chkRequireAuth->setChecked( configValue );
+        
+		configValue = mAccount->configGroup()->readBoolEntry( "DropNotInList", false );
+		mAccountSettings->chkDropNotInList->setChecked( configValue );
 
         configValue = mAccount->configGroup()->readBoolEntry( "RespectRequireAuth", true );
 		mAccountSettings->chkRespectRequireAuth->setChecked( configValue );
@@ -130,6 +133,9 @@
     bool configValue = mAccountSettings->chkRequireAuth->isChecked();
 	mAccount->configGroup()->writeEntry( "RequireAuth", configValue );
 
+	configValue = mAccountSettings->chkDropNotInList->isChecked();
+	mAccount->configGroup()->writeEntry( "DropNotInList", configValue );
+
     configValue = mAccountSettings->chkRespectRequireAuth->isChecked();
 	mAccount->configGroup()->writeEntry( "RespectRequireAuth", configValue );
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.cpp kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.cpp	2005-09-10 15:20:23.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.cpp	2007-07-19 13:14:26.000000000 +0700
@@ -59,6 +59,16 @@
 	return m_respectRequireAuth;
 }
 
+void Settings::setDropNotInList( bool drop )
+{
+	m_dropNotInList = drop;
+}
+
+bool Settings::dropNotInList() const
+{
+	return m_dropNotInList;
+}
+
 void Settings::setHideIP( bool hide )
 {
 	m_hideIP = hide;
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.h kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.h
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/liboscar/oscarsettings.h	2005-09-10 15:20:23.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/liboscar/oscarsettings.h	2007-07-19 13:14:26.000000000 +0700
@@ -44,6 +44,10 @@
 	bool requireAuth() const;
 	void setRespectRequireAuth( bool require );
 	bool respectRequireAuth() const;
+
+	/* Anti-spam settings */
+	void setDropNotInList( bool drop );
+	bool dropNotInList() const;
 	
 	/* Hide IP Settings */
 	void setHideIP( bool hide );
@@ -54,6 +58,7 @@
 	bool m_webAware;
 	bool m_requireAuth;
 	bool m_respectRequireAuth;
+	bool m_dropNotInList;
 	bool m_hideIP;
 };
 
diff -Nur --exclude=Makefile.in kdenetwork-3.5.5.clean/kopete/protocols/oscar/oscaraccount.cpp kdenetwork-3.5.5/kopete/protocols/oscar/oscaraccount.cpp
--- kdenetwork-3.5.5.clean/kopete/protocols/oscar/oscaraccount.cpp	2006-10-02 00:26:54.000000000 +0700
+++ kdenetwork-3.5.5/kopete/protocols/oscar/oscaraccount.cpp	2007-07-19 13:23:04.000000000 +0700
@@ -55,6 +55,7 @@
 #include "oscarutils.h"
 #include "oscarclientstream.h"
 #include "oscarconnector.h"
+#include "oscarsettings.h"
 #include "ssimanager.h"
 #include "oscarlistnonservercontacts.h"
 #include "oscarversionupdater.h"
@@ -380,19 +381,36 @@
 	}
 
 	/* Logic behind this:
-	 * If we don't have the contact yet, create it as a temporary
-	 * Create the message manager
-	 * Get the sanitized message back
-	 * Append to the chat window
+	 * 1. Check if we should drop the message.
+	 * 2. If we don't have the contact yet, create it as a temporary
+	 *    Create the message manager
+	 *    Get the sanitized message back
+	 *    Append to the chat window
 	 */
 	QString sender = Oscar::normalize( message.sender() );
-	if ( !contacts()[sender] )
+	OscarContact* ocSender = static_cast<OscarContact *> ( contacts()[sender] ); 
+
+	if (!ocSender || ocSender->metaContact()->isTemporary()) 
+	{
+		// Try to drop the message 
+		if( engine()->clientSettings()->dropNotInList() )  
+		{
+			if ( ( message.properties() & Oscar::Message::Request ) == 0) 
+			{
+				kdWarning(OSCAR_RAW_DEBUG) << "Dropping message from '" << sender << "' because he is not in contact list (" << message.properties() << ")" << endl;
+				return;
+			}
+			kdWarning(OSCAR_RAW_DEBUG) << "Passing message from '" << sender << "' (" << message.properties() << ")" << endl;
+		}
+	}
+
+	if (!ocSender) 
 	{
 		kdDebug(OSCAR_RAW_DEBUG) << "Adding '" << sender << "' as temporary contact" << endl;
 		addContact( sender, QString::null, 0,  Kopete::Account::Temporary );
 	}
 
-	OscarContact* ocSender = static_cast<OscarContact *> ( contacts()[sender] ); //should exist now
+	ocSender = static_cast<OscarContact *> ( contacts()[sender] ); //should exist now
 
 	if ( !ocSender )
 	{
-- PATCH END --

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages kopete depends on:
ii  kdelibs4c2a            4:3.5.5a.dfsg.1-8 core libraries and binaries for al
ii  libacl1                2.2.41-1          Access control list shared library
ii  libart-2.0-2           2.3.17-1          Library of functions for 2D graphi
ii  libattr1               2.4.32-1          Extended attribute shared library
ii  libaudio2              1.8-4             The Network Audio System (NAS). (s
ii  libc6                  2.3.6.ds1-13      GNU C Library: Shared libraries
ii  libfam0                2.7.0-12          Client library to control the FAM 
ii  libfontconfig1         2.4.2-1.2         generic font configuration library
ii  libfreetype6           2.2.1-5+etch1     FreeType 2 font engine, shared lib
ii  libgadu3               1:1.7~rc2-1etch1  Gadu-Gadu protocol library - runti
ii  libgcc1                1:4.1.1-21        GCC support library
ii  libglib2.0-0           2.12.4-2          The GLib library of C routines
ii  libgsmme1c2a           1.10-10           GSM mobile phone access library
ii  libice6                1:1.0.1-2         X11 Inter-Client Exchange library
ii  libidn11               0.6.5-1           GNU libidn library, implementation
ii  libjpeg62              6b-13             The Independent JPEG Group's JPEG 
ii  libmeanwhile1          1.0.2-2           open implementation of the Lotus S
ii  libpcre3               6.7-1             Perl 5 Compatible Regular Expressi
ii  libpng12-0             1.2.15~beta5-1    PNG library - runtime
ii  libqt3-mt              3:3.3.7-4         Qt GUI Library (Threaded runtime v
ii  libsm6                 1:1.0.1-3         X11 Session Management library
ii  libstdc++6             4.1.1-21          The GNU Standard C++ Library v3
ii  libx11-6               2:1.0.3-7         X11 client-side library
ii  libxcursor1            1.1.7-4           X cursor management library
ii  libxext6               1:1.0.1-2         X11 miscellaneous extension librar
ii  libxft2                2.1.8.2-8         FreeType-based font drawing librar
ii  libxi6                 1:1.0.1-4         X11 Input extension library
ii  libxinerama1           1:1.0.1-4.1       X11 Xinerama extension library
ii  libxml2                2.6.27.dfsg-1     GNOME XML library
ii  libxrandr2             2:1.1.0.2-5       X11 RandR extension library
ii  libxrender1            1:0.9.1-3         X Rendering Extension client libra
ii  libxslt1.1             1.1.19-1          XSLT processing library - runtime 
ii  libxt6                 1:1.0.2-2         X11 toolkit intrinsics library
ii  zlib1g                 1:1.2.3-13        compression library - runtime

Versions of packages kopete recommends:
ii  qca-tls                       1.0-3      TLS plugin for the Qt Cryptographi

-- no debconf information



Reply to: