Summary: | XML document could not be parsed! | ||
---|---|---|---|
Product: | [Applications] kopete | Reporter: | Jacob Mather <jacobmather> |
Component: | general | Assignee: | Kopete Developers <kopete-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 0.8.0 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Jacob Mather
2004-02-19 21:18:28 UTC
FYI: the <![CDATA[ is Kopete. The (box)[1m is a Yahoo! colour code. Kopete doesn't strip them out properly. *** This bug has been marked as a duplicate of 75497 *** Not really a dup since they have different causes... and I can fix this one :) Mine! CVS commit by lilachaze: Strip out Yahoo! colour codes from message body. As a side bonus, improve colour code detection. [BACKPORT] CCMAIL: 75646-done@bugs.kde.org M +19 -15 yahooaccount.cpp 1.63.2.1 M +4 -0 yahooaccount.h 1.28.4.1 --- kdenetwork/kopete/protocols/yahoo/yahooaccount.cpp #1.63:1.63.2.1 @@ -23,4 +23,5 @@ #include <qdatetime.h> #include <qcolor.h> +#include <qregexp.h> // KDE @@ -123,4 +124,9 @@ void YahooAccount::setImportContacts(boo } +QString YahooAccount::stripMsgColorCodes(const QString& msg) +{ + return QString(msg).remove(QRegExp("\033\\[(..m|#......)")); +} + QColor YahooAccount::getMsgColor(const QString& msg) { @@ -128,29 +134,27 @@ QColor YahooAccount::getMsgColor(const Q * so we have to use this really hacky method to get colors */ - kdDebug(14180) << k_funcinfo << "msg is " << msg << endl; - //If we get here, the message uses a standard Yahoo color - //(selectable from the drop down box) + //kdDebug(14180) << k_funcinfo << "msg is " << msg << endl; //Please note that some of the colors are hard-coded to //match the yahoo colors - if ( msg.find("[38m") != -1 ) + if ( msg.find("\033[38m") != -1 ) return Qt::red; - if ( msg.find("[34m") != -1 ) + if ( msg.find("\033[34m") != -1 ) return Qt::green; - if ( msg.find("[31m") != -1 ) + if ( msg.find("\033[31m") != -1 ) return Qt::blue; - if ( msg.find("[39m") != -1 ) + if ( msg.find("\033[39m") != -1 ) return Qt::yellow; - if ( msg.find("[36m") != -1 ) + if ( msg.find("\033[36m") != -1 ) return Qt::darkMagenta; - if ( msg.find("[32m") != -1 ) + if ( msg.find("\033[32m") != -1 ) return Qt::cyan; - if ( msg.find("[37m") != -1 ) + if ( msg.find("\033[37m") != -1 ) return QColor("#FFAA39"); - if ( msg.find("[35m") != -1 ) + if ( msg.find("\033[35m") != -1 ) return QColor("#FFD8D8"); - if ( msg.find("[#") != -1 ) + if ( msg.find("\033[#") != -1 ) { - kdDebug(14180) << "Custom color is " << msg.mid(msg.find("[#")+1,7) << endl; - return QColor(msg.mid(msg.find("[#")+1,7)); + kdDebug(14180) << "Custom color is " << msg.mid(msg.find("\033[#")+2,7) << endl; + return QColor(msg.mid(msg.find("\033[#")+2,7)); } @@ -482,5 +486,5 @@ void YahooAccount::slotGotIm( const QStr KopeteMessage::Inbound , KopeteMessage::PlainText); - QString newMsg = kmsg.plainBody(); + QString newMsg = stripMsgColorCodes(kmsg.plainBody()); kmsg.setFg(getMsgColor(msg)); --- kdenetwork/kopete/protocols/yahoo/yahooaccount.h #1.28:1.28.4.1 @@ -123,4 +123,8 @@ protected: */ QColor getMsgColor(const QString& msg); + /** + * Remove color codes from a message + */ + QString stripMsgColorCodes(const QString& msg); protected slots: |