Hi!

Here some patches to add CTCP ACTION functionality for jabber. Also need to 
change chat window style. There is only pidgin style patches.

It my first trying to develop open source project. Don't be strict =).

Anton Ermolenko.

Best regards!
Index: chattexteditpart.cpp
===================================================================
--- chattexteditpart.cpp	(revision 1070654)
+++ chattexteditpart.cpp	(working copy)
@@ -417,8 +417,23 @@
 
 Kopete::Message ChatTextEditPart::contents()
 {
+	bool isCTCP = false;
+	QString currentText = text();
+	QString ctcpActionPattern = "(/me )+.*";
+	QString ctcpActionReplacePattern = "(/me )+";
+	QRegExp rx(ctcpActionPattern);
+	
+	if(rx.exactMatch(currentText))
+	{
+		rx.setPattern(ctcpActionReplacePattern);
+		currentText.replace(rx, " ");
+		editor->setTextOrHtml(currentText);
+		isCTCP = true;
+	}
+	
 	Kopete::Message currentMsg( m_session->myself(), m_session->members() );
 	currentMsg.setDirection( Kopete::Message::Outbound );
+	isCTCP ? currentMsg.setType(Kopete::Message::TypeAction) : currentMsg.setType(Kopete::Message::TypeNormal);
 
 	if (isRichTextEnabled())
 	{
Index: styles/Pidgin/Contents/Resources/Outgoing/Action.html
===================================================================
--- styles/Pidgin/Contents/Resources/Outgoing/Action.html	(revision 1070654)
+++ styles/Pidgin/Contents/Resources/Outgoing/Action.html	(working copy)
@@ -1,6 +1,8 @@
 <div class="KopeteMessage" style="direction: %messageDirection%;">
-    <span style="color:%senderColor%;"><span class="outActionTime">(%time%) </span>
-	 <span class="outActionMetacontact">%sender%:&nbsp;</span></span>
-	 <span class="outActionMessage" style="background-color: %textbackgroundcolor{#4386cf}%;">%message%</span>
+	<span style="color:%senderColor%;s">
+		<!--<span class="inActionTime">(%time%) </span>-->
+		<span class="outActionMetacontact"><b>***<i>%sender%</i>&nbsp;</b></span>
+	</span>
+	<span class="outActionMessage" style="background-color: %textbackgroundcolor{#4386cf}%;">%message%</span>
 </div>
 <div id="insert"></div>
Index: jabbercontact.cpp
===================================================================
--- jabbercontact.cpp	(revision 1070654)
+++ jabbercontact.cpp	(working copy)
@@ -405,6 +405,10 @@
 	}
 	else
 	{
+		bool isCTCP = false;
+		QString ctcpActionPattern = "(/me )+.*";
+		QRegExp rx(ctcpActionPattern);
+		
 		// store message id for outgoing notifications
 		mLastReceivedMessageId = message.id ();
 
@@ -420,6 +424,13 @@
 				body = QString ("-----BEGIN PGP MESSAGE-----\n\n") + message.xencrypted () + QString ("\n-----END PGP MESSAGE-----\n");
 			}
 		}
+		
+		if(rx.exactMatch(body))
+		{
+			rx.setPattern("(/me )+");
+			body.replace(rx, " ");
+			isCTCP = true;
+		}
 
 		if( message.containsHTML() )
 		{
@@ -440,6 +451,10 @@
 			newMessage->setSubject( message.subject() );
 			newMessage->setDirection( Kopete::Message::Inbound );
 			newMessage->setRequestedPlugin( viewPlugin );
+			if(isCTCP)
+			{
+				newMessage->setType(Kopete::Message::TypeAction);
+			}
 		}
 	}
 
Index: styles/Pidgin/Contents/Resources/Incoming/Action.html
===================================================================
--- styles/Pidgin/Contents/Resources/Incoming/Action.html	(revision 1070654)
+++ styles/Pidgin/Contents/Resources/Incoming/Action.html	(working copy)
@@ -1,6 +1,8 @@
 <div class="KopeteMessage" style="direction: %messageDirection%;">
-    <span style="color:%senderColor%;s"><span class="inActionTime">(%time%) </span>
-	 <span class="inActionMetacontact">%sender%:&nbsp;</span></span>
+    <span style="color:%senderColor%;s">
+		<!--<span class="inActionTime">(%time%) </span>-->
+		<span class="inActionMetacontact"><b>***<i>%sender%</i>&nbsp;</b></span>
+	 </span>
 	 <span class="inActionMessage" style="background-color: %textbackgroundcolor{#4386cf}%;">%message%</span>
 </div>
 <div id="insert"></div>
_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to