[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] Fwd: texteffect plugin kopete (cambridge scrambler)
From:       "Stefan Kombrink" <katakombi () gmail ! com>
Date:       2006-05-05 14:41:46
Message-ID: 3f6a1ade0605050741l2a3b2bb0gc4ad2e6326fcf1b8 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


---------- Forwarded message ----------
From: Stefan Kombrink <katakombi@web.de>
Date: May 2, 2006 10:38 AM
Subject: texteffect plugin kopete (cambridge scrambler)
To: kde-devel@kde.org

hi there,

I extended the texteffect plugin of kopete to send text distorted by the
well-known cambridge scrambler (see
http://www.little-idiot.de/kybernetik/scramble.htm [German]).
It's just a simple patch, but maybe somebody feels like testing it.
I recommend using it on notoric bad spelling chat partners - you'd never be
able to produce that many mistakes at such high typing rates :-)


  Stefan K. >8^)



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e
<<

NB: If you reply please CC me for I am not subscribed!

[Attachment #5 (text/html)]

<br><br>---------- Forwarded message ----------<br><span class="gmail_quote">From: <b \
class="gmail_sendername">Stefan Kombrink</b> &lt;<a \
href="mailto:katakombi@web.de">katakombi@web.de</a>&gt;<br>Date: May 2, 2006 10:38 AM \
<br>Subject: texteffect plugin kopete (cambridge scrambler)<br>To: <a \
href="mailto:kde-devel@kde.org">kde-devel@kde.org</a><br><br></span>hi there,<br><br> \
I extended the texteffect plugin of kopete to send text distorted by the \
<br>well-known cambridge scrambler (see<br><a \
href="http://www.little-idiot.de/kybernetik/scramble.htm">http://www.little-idiot.de/kybernetik/scramble.htm</a> \
[German]).<br>It's just a simple patch, but maybe somebody feels like testing it. \
<br>I recommend using it on notoric bad spelling chat partners - you'd never \
be<br>able to produce that many mistakes at such high typing rates \
:-)<br><br><br>&nbsp;&nbsp;Stefan K. &gt;8^)<br><br><br><br>&gt;&gt; Visit <a \
href="http://mail.kde.org/mailman/listinfo/kde-devel#unsub"> \
http://mail.kde.org/mailman/listinfo/kde-devel#unsub</a> to unsubscribe \
&lt;&lt;<br><br>NB: If you reply please CC me for I am not subscribed!<br><br><br>


["CambridgeScrambler.diff" (text/x-diff)]

Gemeinsame Unterverzeichnisse: texteffect/.deps und texteffect-new/.deps.
Gemeinsame Unterverzeichnisse: texteffect/icons und texteffect-new/icons.
Gemeinsame Unterverzeichnisse: texteffect/.libs und texteffect-new/.libs.
Gemeinsame Unterverzeichnisse: texteffect/.svn und texteffect-new/.svn.
diff -Nau texteffect/texteffectconfig.cpp texteffect-new/texteffectconfig.cpp
--- texteffect/texteffectconfig.cpp	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectconfig.cpp	2006-05-02 09:54:29.000000000 +0200
@@ -44,6 +44,7 @@
 	mColorChar = config->readBoolEntry("Color change every char", false);
 
 	mLamer = config->readBoolEntry("L4m3r", false);
+	mScrambler = config->readBoolEntry("Scrambler", false);
 	mWaves = config->readBoolEntry("WaVeS", false);
 }
 
@@ -64,6 +65,7 @@
 	config->writeEntry("Color change every char", mColorChar);
 
 	config->writeEntry("L4m3r", mLamer);
+	config->writeEntry("Scrambler", mScrambler);
 	config->writeEntry("WaVeS", mWaves);
 
 	config->sync();
@@ -99,6 +101,11 @@
 	return mLamer;
 }
 
+bool TextEffectConfig::scrambler() const
+{
+	return mScrambler;
+}
+
 bool TextEffectConfig::waves() const
 {
 	return mWaves;
@@ -134,6 +141,11 @@
 	mLamer = newLamers;
 }
 
+void TextEffectConfig::setScrambler(bool newScrambler)
+{
+	mScrambler = newScrambler;
+}
+
 void TextEffectConfig::setWaves(bool newWaves)
 {
 	mWaves = newWaves;
diff -Nau texteffect/texteffectconfig.h texteffect-new/texteffectconfig.h
--- texteffect/texteffectconfig.h	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectconfig.h	2006-05-02 09:54:29.000000000 +0200
@@ -36,6 +36,7 @@
 	bool colorChar() const;
 	bool colorRandom() const;
 	bool lamer() const;
+	bool scrambler() const;
 	bool waves() const;
 
 	void setColors(const QStringList &newColors = QStringList());
@@ -44,6 +45,7 @@
 	void setColorWords(bool newWords);
 	void setColorRandom(bool newRandom);
 	void setLamer(bool newLamer);
+	void setScrambler(bool newScrambler);
 	void setWaves(bool newWaves);
     QStringList defaultColorList();
 
@@ -55,6 +57,7 @@
 	bool mColorChar;
 	bool mColorRandom;
 	bool mLamer;
+	bool mScrambler;
 	bool mWaves;
 
 };
diff -Nau texteffect/texteffectplugin.cpp texteffect-new/texteffectplugin.cpp
--- texteffect/texteffectplugin.cpp	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectplugin.cpp	2006-05-02 09:54:29.000000000 +0200
@@ -16,6 +16,7 @@
  ***************************************************************************/
 
 #include <stdlib.h>
+#include <time.h>
 
 #include <kdebug.h>
 #include <kgenericfactory.h>
@@ -43,6 +44,7 @@
 		SLOT( slotOutgoingMessage( Kopete::Message & ) ) );
 
 	 last_color=0;
+	 srand( time( 0 ) );
 }
 
 TextEffectPlugin::~TextEffectPlugin()
@@ -66,7 +68,7 @@
 
 	QStringList colors=m_config->colors();
 
-	if(m_config->colorChar() || m_config->colorWords() || m_config->lamer() || \
m_config->waves() ) +	if(m_config->colorChar() || m_config->colorWords() || \
m_config->lamer() || m_config->scrambler() || m_config->waves() )  {
 		QString original=msg.plainBody();
 		QString resultat;
@@ -74,6 +76,11 @@
 		unsigned int c=0;
 		bool wavein=false;
 
+		if ( m_config->scrambler() )
+		{
+			original = scramble( original );
+		}
+
 		for(unsigned int f=0;f<original.length();f++)
 		{
 			QChar x=original[f];
@@ -168,6 +175,7 @@
 		}
 		if( m_config->colorChar() || m_config->colorWords() )
 			resultat+="</font>";
+
 		msg.setBody(resultat,Kopete::Message::RichText);
 	}
 
@@ -193,6 +201,35 @@
 	m_config->load();
 }
 
+QString TextEffectPlugin::scramble( const QString & s )
+{
+	QStringList words = QStringList::split( QString( " " ), s );
+
+	QString result, scrambledWord;
+
+	//for ( int i = 0; i < words.count(); i++ )
+	//	kdDebug() << words[i] << endl;
+	
+	for ( int i = 0; i < words.count(); i++ )
+	{
+		// initially copy the word
+		scrambledWord = words[i];
+
+		int len = words[i].length();
+		for ( int j = 1; j < len - 1; j++ )
+		{
+			// choose an arbitrary char and swap with the j-th char
+			int ix = 1 + rand() % ( len - 2 );
+			QChar tmp = scrambledWord[ix];
+			scrambledWord[ix] = scrambledWord[j];
+			scrambledWord[j] = tmp;
+		}
+		result.append( scrambledWord ).append( ' ' );
+	}
+	
+	return result;
+}
+
 
 #include "texteffectplugin.moc"
 
diff -Nau texteffect/texteffectplugin.h texteffect-new/texteffectplugin.h
--- texteffect/texteffectplugin.h	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectplugin.h	2006-05-02 09:54:29.000000000 +0200
@@ -52,6 +52,9 @@
 	void slotOutgoingMessage( Kopete::Message& msg );
 	void slotSettingsChanged();
 
+protected:
+	QString scramble( const QString& s ); 
+
 private:
 	static TextEffectPlugin* pluginStatic_;
 	unsigned int last_color;
diff -Nau texteffect/texteffectpreferences.cpp \
                texteffect-new/texteffectpreferences.cpp
--- texteffect/texteffectpreferences.cpp	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectpreferences.cpp	2006-05-02 09:54:29.000000000 +0200
@@ -67,6 +67,8 @@
 	// Connect up all the check boxes
 	connect( preferencesDialog->m_lamer, SIGNAL( clicked() ),
 			 this, SLOT( slotSettingChanged() ) );
+	connect( preferencesDialog->m_scrambler, SIGNAL( clicked() ),
+			this, SLOT( slotSettingChanged() ) );
 	connect( preferencesDialog->m_casewaves, SIGNAL( clicked() ),
 			 this, SLOT( slotSettingChanged() ) );
 
@@ -103,9 +105,9 @@
 	preferencesDialog->m_words->setChecked(config->colorWords());
 	preferencesDialog->m_char->setChecked(config->colorChar());
 	preferencesDialog->m_lamer->setChecked(config->lamer());
+	preferencesDialog->m_scrambler->setChecked(!config->lamer());
 	preferencesDialog->m_casewaves->setChecked(config->waves());
 
-
 	// Call parent's save method
 	KCModule::load();
 
@@ -127,6 +129,7 @@
 	config->setColorChar(preferencesDialog->m_char->isChecked());
 
 	config->setLamer(preferencesDialog->m_lamer->isChecked());
+	config->setScrambler(preferencesDialog->m_scrambler->isChecked());
 	config->setWaves(preferencesDialog->m_casewaves->isChecked());
 
 	config->save();
diff -Nau texteffect/texteffectprefs.ui texteffect-new/texteffectprefs.ui
--- texteffect/texteffectprefs.ui	2006-05-02 09:55:14.000000000 +0200
+++ texteffect-new/texteffectprefs.ui	2006-05-02 09:54:29.000000000 +0200
@@ -13,6 +13,9 @@
             <height>529</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>TextEffectPrefs</string>
+    </property>
     <grid>
         <property name="name">
             <cstring>unnamed</cstring>
@@ -168,20 +171,20 @@
                         <property name="name">
                             <cstring>m_lamer</cstring>
                         </property>
-                        <property name="sizePolicy">
-                            <sizepolicy>
-                                <hsizetype>7</hsizetype>
-                                <vsizetype>0</vsizetype>
-                                <horstretch>0</horstretch>
-                                <verstretch>0</verstretch>
-                            </sizepolicy>
-                        </property>
                         <property name="text">
                             <string>L4m3r t4lk</string>
                         </property>
                     </widget>
                     <widget class="QCheckBox">
                         <property name="name">
+                            <cstring>m_scrambler</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Cambridge scrambler</string>
+                        </property>
+                    </widget>
+                    <widget class="QCheckBox">
+                        <property name="name">
                             <cstring>m_casewaves</cstring>
                         </property>
                         <property name="sizePolicy">
@@ -209,7 +212,7 @@
                         <property name="sizeHint">
                             <size>
                                 <width>20</width>
-                                <height>279</height>
+                                <height>240</height>
                             </size>
                         </property>
                     </spacer>


[Attachment #7 (application/pgp-signature)]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic