Hello,
This is updated patch for lenny's 4:3.5.9-4 kopete
--- orig/kdenetwork-3.5.9/kopete/protocols/oscar/icq/icqaccount.cpp 2008-02-13 15:37:43.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/icq/icqaccount.cpp 2008-09-18 10:42:01.000000000 +0700 @@ -172,6 +172,7 @@ Oscar::Settings* oscarSettings = engine()->clientSettings(); oscarSettings->setWebAware( configGroup()->readBoolEntry( "WebAware", false ) ); oscarSettings->setHideIP( configGroup()->readBoolEntry( "HideIP", true ) ); + oscarSettings->setDropNotInList( configGroup()->readBoolEntry( "DropNotInList", false ) ); //FIXME: also needed for the other call to setStatus (in setPresenceTarget) DWORD status = pres.toOscarStatus(); --- orig/kdenetwork-3.5.9/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui 2008-02-13 15:37:43.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/icq/ui/icqeditaccountui.ui 2008-09-18 10:38:29.000000000 +0700 @@ -360,6 +360,20 @@ <string>Check this box to enable ICQ's Web Aware functionality, which allows people to see your online status from ICQ's web page, and send you a message without necessarily having ICQ themselves.</string> </property> </widget> + <widget class="QCheckBox" row="3" 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> </grid> </widget> <spacer row="3" column="0"> --- orig/kdenetwork-3.5.9/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp 2008-02-13 15:37:43.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/icq/ui/icqeditaccountwidget.cpp 2008-09-18 10:42:01.000000000 +0700 @@ -84,6 +84,9 @@ configValue = mAccount->configGroup()->readBoolEntry( "WebAware", false ); mAccountSettings->chkWebAware->setChecked( configValue ); + configValue = mAccount->configGroup()->readBoolEntry( "DropNotInList", false ); + mAccountSettings->chkDropNotInList->setChecked( configValue ); + int encodingValue = mAccount->configGroup()->readNumEntry( "DefaultEncoding", 4 ); mProtocol->setComboFromTable( mAccountSettings->encodingCombo, mProtocol->encodings(), @@ -133,6 +136,9 @@ configValue = mAccountSettings->chkWebAware->isChecked(); mAccount->configGroup()->writeEntry( "WebAware", configValue ); + configValue = mAccountSettings->chkDropNotInList->isChecked(); + mAccount->configGroup()->writeEntry( "DropNotInList", configValue ); + int encodingMib = mProtocol->getCodeForCombo( mAccountSettings->encodingCombo, mProtocol->encodings() ); mAccount->configGroup()->writeEntry( "DefaultEncoding", encodingMib ); --- orig/kdenetwork-3.5.9/kopete/protocols/oscar/liboscar/oscarsettings.cpp 2008-02-13 15:37:43.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/liboscar/oscarsettings.cpp 2008-09-18 10:42:01.000000000 +0700 @@ -59,7 +59,15 @@ return m_hideIP; } +void Settings::setDropNotInList( bool drop ) +{ + m_dropNotInList = drop; +} +bool Settings::dropNotInList() const +{ + return m_dropNotInList; +} --- orig/kdenetwork-3.5.9/kopete/protocols/oscar/liboscar/oscarsettings.h 2008-02-13 15:37:43.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/liboscar/oscarsettings.h 2008-09-18 10:42:01.000000000 +0700 @@ -47,11 +47,16 @@ void setHideIP( bool hide ); bool hideIP() const; + + /* Anti-spam settings */ + void setDropNotInList( bool drop ); + bool dropNotInList() const; private: bool m_webAware; bool m_requireAuth; bool m_hideIP; + bool m_dropNotInList; }; } --- orig/kdenetwork-3.5.9/kopete/protocols/oscar/oscaraccount.cpp 2007-01-15 17:23:51.000000000 +0600 +++ work/kdenetwork-3.5.9/kopete/protocols/oscar/oscaraccount.cpp 2008-09-18 10:42:01.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,32 @@ } /* 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() ) + { + kdWarning(OSCAR_RAW_DEBUG) << "Dropping message from '" << sender << "' because he is not in contact list (" << message.properties() << ")" << endl; + return; + } + } + + 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 ) {