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

List:       kde-commits
Subject:    branches/KDE/4.2/kdenetwork/kopete/plugins/pipes
From:       Roman Jarosz <kedgedev () centrum ! cz>
Date:       2009-01-16 13:59:00
Message-ID: 1232114340.480073.21475.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 912008 by rjarosz:

Backport fix for bug 173195: Pipes plugin doesn't support Unicode.
Patch by Sebastian Strand, thanks.

CCBUG: 173195



 M  +12 -12    pipesplugin.cpp  
 M  +3 -3      pipesplugin.h  


--- branches/KDE/4.2/kdenetwork/kopete/plugins/pipes/pipesplugin.cpp #912007:912008
@@ -108,32 +108,32 @@
 
 	// poop out appropriate data
 	if ( pipeOptions.pipeContents == HtmlBody )
-		pipe.write ( msg.escapedBody().toLocal8Bit() );
+		pipe.write ( msg.escapedBody().toUtf8() );
 	else if ( pipeOptions.pipeContents == PlainBody )
-		pipe.write ( msg.plainBody().toLocal8Bit() );
+		pipe.write ( msg.plainBody().toUtf8() );
 	else if ( pipeOptions.pipeContents == Xml )
-		pipe.write ( createXml ( msg ).toLocal8Bit() );
+		pipe.write ( createXml ( msg ) );
 
 	pipe.closeWriteChannel();
 	pipe.waitForFinished();
 
-	QString pipeReturn = pipe.readAllStandardOutput();
+	QByteArray pipeReturn = pipe.readAllStandardOutput();
 
 	// set data in message to output of pipe
 	if ( pipeOptions.pipeContents == HtmlBody )
-		msg.setHtmlBody ( pipeReturn );
+		msg.setHtmlBody ( QString::fromUtf8( pipeReturn ) );
 	else if ( pipeOptions.pipeContents == PlainBody )
-		msg.setPlainBody ( pipeReturn );
+		msg.setPlainBody ( QString::fromUtf8( pipeReturn ) );
 	else if ( pipeOptions.pipeContents == Xml )
 		readXml ( pipeOptions, msg, pipeReturn );
 }
 
-QString PipesPlugin::createXml ( const Kopete::Message & msg )
+QByteArray PipesPlugin::createXml ( const Kopete::Message & msg )
 {
 	/*
 	Here's an example of what a pipee will get:
 
-	<?xml version="1.0" encoding="ISO-8859-1"?>
+	<?xml version="1.0" encoding="UTF-8"?>
 	<message subject=""
 		route="outbound"
 		importance="1"
@@ -270,13 +270,13 @@
 	body.setAttribute ( "dir", msg.plainBody().isRightToLeft() ? "rtl" : "ltr" );
 	body.appendChild ( doc.createTextNode ( msg.escapedBody() ) );
 
-	QDomNode xsdInstruction = doc.createProcessingInstruction ( "xml", "version=\"1.0\" \
encoding=\"ISO-8859-1\"" ); +	QDomNode xsdInstruction = \
doc.createProcessingInstruction ( "xml", "version=\"1.0\" encoding=\"UTF-8\"" );  \
doc.insertBefore ( xsdInstruction, doc.firstChild() );  
-	return doc.toString();
+	return doc.toByteArray();
 }
 
-void PipesPlugin::readXml ( PipeOptions pipeOptions, Kopete::Message & msg, const \
QString & pipeReturn ) +void PipesPlugin::readXml ( PipeOptions pipeOptions, \
Kopete::Message & msg, const QByteArray & pipeReturn )  {
 	/* modification to the following attributes/elements in the XML will be reflected \
                back into the message:
 	- "timestamp" but *not* other time attributes
@@ -296,7 +296,7 @@
 	int errorLine, errorCol;
 
 	// if the pipe returns bad XML, tell user and do not process.
-	if ( ! doc.setContent ( pipeReturn.toLocal8Bit(), false/*namespaceProcessing*/, \
&readError, &errorLine, &errorCol ) ) +	if ( ! doc.setContent ( pipeReturn, \
false/*namespaceProcessing*/, &readError, &errorLine, &errorCol ) )  {
 		KMessageBox::error ( msg.manager()->view()->mainWidget() ?
 		                     msg.manager()->view()->mainWidget() : \
                Kopete::UI::Global::mainWidget(),
--- branches/KDE/4.2/kdenetwork/kopete/plugins/pipes/pipesplugin.h #912007:912008
@@ -94,13 +94,13 @@
 		 * Turn a Message into a QDomDocument, return that XML.
 		 * Info for the XML is pulled from all over Kopete.
 		 */
-		static QString createXml ( const Kopete::Message & );
+		static QByteArray createXml ( const Kopete::Message & );
 
 		/*
-		 * Take a QString containing XML, take pertinent info from
+		 * Take a QByteArray containing XML, take pertinent info from
 		 * that, and put it in the Message.
 		 */
-		static void readXml ( PipeOptions, Kopete::Message &, const QString & );
+		static void readXml ( PipeOptions, Kopete::Message &, const QByteArray & );
 
 	private:
 		static PipesPlugin* mPluginStatic;


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

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