From 47c8a359c5276062c4bc17f0e82410f29081b502 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:48:06 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/protocols/irc/libkirc/kircmessage.cpp | 118 +++++++++++++-------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'kopete/protocols/irc/libkirc/kircmessage.cpp') diff --git a/kopete/protocols/irc/libkirc/kircmessage.cpp b/kopete/protocols/irc/libkirc/kircmessage.cpp index f1a5b61f..73a1e53f 100644 --- a/kopete/protocols/irc/libkirc/kircmessage.cpp +++ b/kopete/protocols/irc/libkirc/kircmessage.cpp @@ -30,20 +30,20 @@ using namespace KIRC; #ifndef _IRC_STRICTNESS_ -QRegExp Message::m_IRCNumericCommand("^\\d{1,3}$"); +TQRegExp Message::m_IRCNumericCommand("^\\d{1,3}$"); // TODO: This regexp parsing is no good. It's slower than it needs to be, and -// is not codec-safe since QString requires a codec. NEed to parse this with +// is not codec-safe since TQString requires a codec. NEed to parse this with // our own parsing class that operates on the raw QCStrings -QRegExp Message::m_IRCCommandType1( +TQRegExp Message::m_IRCCommandType1( "^(?::([^ ]+) )?([A-Za-z]+|\\d{1,3})((?: [^ :][^ ]*)*) ?(?: :(.*))?$"); // Extra end arg space check -------------------------^ #else // _IRC_STRICTNESS_ -QRegExp Message::m_IRCNumericCommand("^\\d{3,3}$"); +TQRegExp Message::m_IRCNumericCommand("^\\d{3,3}$"); -QRegExp Message::m_IRCCommandType1( +TQRegExp Message::m_IRCCommandType1( "^(?::([^ ]+) )?([A-Za-z]+|\\d{3,3})((?: [^ :][^ ]*){0,13})(?: :(.*))?$"); -QRegExp Message::m_IRCCommandType2( +TQRegExp Message::m_IRCCommandType2( "^(?::[[^ ]+) )?([A-Za-z]+|\\d{3,3})((?: [^ :][^ ]*){14,14})(?: (.*))?$"); #endif // _IRC_STRICTNESS_ @@ -90,7 +90,7 @@ Message::~Message() delete m_ctcpMessage; } -void Message::writeRawMessage(Engine *engine, const QTextCodec *codec, const QString &str) +void Message::writeRawMessage(Engine *engine, const TQTextCodec *codec, const TQString &str) { // FIXME: Really handle this if (!engine->socket()) @@ -99,65 +99,65 @@ void Message::writeRawMessage(Engine *engine, const QTextCodec *codec, const QSt return; } - QString txt = str + QString::fromLatin1("\r\n"); + TQString txt = str + TQString::fromLatin1("\r\n"); - QCString s(codec->fromUnicode(txt)); + TQCString s(codec->fromUnicode(txt)); kdDebug(14120) << "Message is " << s.length() << " chars" << endl; // FIXME: Should check the amount of data really writen. int wrote = engine->socket()->writeBlock(s.data(), s.length()); - kdDebug(14121) << QString::fromLatin1("(%1 bytes) >> %2").arg(wrote).arg(str) << endl; + kdDebug(14121) << TQString::fromLatin1("(%1 bytes) >> %2").arg(wrote).arg(str) << endl; } -void Message::writeMessage(Engine *engine, const QTextCodec *codec, const QString &message) +void Message::writeMessage(Engine *engine, const TQTextCodec *codec, const TQString &message) { writeRawMessage(engine, codec, quote(message)); } -void Message::writeMessage(Engine *engine, const QTextCodec *codec, - const QString &command, const QStringList &args, const QString &suffix) +void Message::writeMessage(Engine *engine, const TQTextCodec *codec, + const TQString &command, const TQStringList &args, const TQString &suffix) { - QString msg = command; + TQString msg = command; if (!args.isEmpty()) - msg += QChar(' ') + args.join(QChar(' ')).stripWhiteSpace(); // some extra check should be done here + msg += TQChar(' ') + args.join(TQChar(' ')).stripWhiteSpace(); // some extra check should be done here if (!suffix.isNull()) - msg = msg.stripWhiteSpace() + QString::fromLatin1(" :") + suffix; + msg = msg.stripWhiteSpace() + TQString::fromLatin1(" :") + suffix; writeMessage(engine, codec, msg); } -void Message::writeCtcpMessage(Engine *engine, const QTextCodec *codec, - const QString &command, const QString&to, - const QString &ctcpMessage) +void Message::writeCtcpMessage(Engine *engine, const TQTextCodec *codec, + const TQString &command, const TQString&to, + const TQString &ctcpMessage) { - writeMessage(engine, codec, command, to, QChar(0x01) + ctcpQuote(ctcpMessage) + QChar(0x01)); + writeMessage(engine, codec, command, to, TQChar(0x01) + ctcpQuote(ctcpMessage) + TQChar(0x01)); } -void Message::writeCtcpMessage(Engine *engine, const QTextCodec *codec, - const QString &command, const QString &to, const QString &suffix, - const QString &ctcpCommand, const QStringList &ctcpArgs, const QString &ctcpSuffix ) +void Message::writeCtcpMessage(Engine *engine, const TQTextCodec *codec, + const TQString &command, const TQString &to, const TQString &suffix, + const TQString &ctcpCommand, const TQStringList &ctcpArgs, const TQString &ctcpSuffix ) { - QString ctcpMsg = ctcpCommand; + TQString ctcpMsg = ctcpCommand; if (!ctcpArgs.isEmpty()) - ctcpMsg += QChar(' ') + ctcpArgs.join(QChar(' ')).stripWhiteSpace(); // some extra check should be done here + ctcpMsg += TQChar(' ') + ctcpArgs.join(TQChar(' ')).stripWhiteSpace(); // some extra check should be done here if (!ctcpSuffix.isNull()) - ctcpMsg += QString::fromLatin1(" :") + ctcpSuffix; + ctcpMsg += TQString::fromLatin1(" :") + ctcpSuffix; - writeMessage(engine, codec, command, to, suffix + QChar(0x01) + ctcpQuote(ctcpMsg) + QChar(0x01)); + writeMessage(engine, codec, command, to, suffix + TQChar(0x01) + ctcpQuote(ctcpMsg) + TQChar(0x01)); } -Message Message::parse(Engine *engine, const QTextCodec *codec, bool *parseSuccess) +Message Message::parse(Engine *engine, const TQTextCodec *codec, bool *parseSuccess) { if (parseSuccess) *parseSuccess=false; if (engine->socket()->canReadLine()) { - QCString raw(engine->socket()->bytesAvailable()+1); + TQCString raw(engine->socket()->bytesAvailable()+1); Q_LONG length = engine->socket()->readLine(raw.data(), raw.count()); if( length > -1 ) @@ -197,21 +197,21 @@ Message Message::parse(Engine *engine, const QTextCodec *codec, bool *parseSucce return Message(); } -QString Message::quote(const QString &str) +TQString Message::quote(const TQString &str) { - QString tmp = str; - QChar q('\020'); - tmp.replace(q, q+QString(q)); - tmp.replace(QChar('\r'), q+QString::fromLatin1("r")); - tmp.replace(QChar('\n'), q+QString::fromLatin1("n")); - tmp.replace(QChar('\0'), q+QString::fromLatin1("0")); + TQString tmp = str; + TQChar q('\020'); + tmp.replace(q, q+TQString(q)); + tmp.replace(TQChar('\r'), q+TQString::fromLatin1("r")); + tmp.replace(TQChar('\n'), q+TQString::fromLatin1("n")); + tmp.replace(TQChar('\0'), q+TQString::fromLatin1("0")); return tmp; } // FIXME: The unquote system is buggy. -QString Message::unquote(const QString &str) +TQString Message::unquote(const TQString &str) { - QString tmp = str; + TQString tmp = str; char b[3] = { 020, 020, '\0' }; const char b2[2] = { 020, '\0' }; @@ -227,23 +227,23 @@ QString Message::unquote(const QString &str) return tmp; } -QString Message::ctcpQuote(const QString &str) +TQString Message::ctcpQuote(const TQString &str) { - QString tmp = str; - tmp.replace( QChar('\\'), QString::fromLatin1("\\\\")); - tmp.replace( (char)1, QString::fromLatin1("\\1")); + TQString tmp = str; + tmp.replace( TQChar('\\'), TQString::fromLatin1("\\\\")); + tmp.replace( (char)1, TQString::fromLatin1("\\1")); return tmp; } -QString Message::ctcpUnquote(const QString &str) +TQString Message::ctcpUnquote(const TQString &str) { - QString tmp = str; + TQString tmp = str; tmp.replace("\\\\", "\\"); tmp.replace("\\1", "\1" ); return tmp; } -bool Message::matchForIRCRegExp(const QCString &line, const QTextCodec *codec, Message &message) +bool Message::matchForIRCRegExp(const TQCString &line, const TQTextCodec *codec, Message &message) { if(matchForIRCRegExp(m_IRCCommandType1, codec, line, message)) return true; @@ -256,19 +256,19 @@ bool Message::matchForIRCRegExp(const QCString &line, const QTextCodec *codec, M // FIXME: remove the decodeStrings calls or update them. // FIXME: avoid the recursive call, it make the ctcp command unquoted twice (wich is wrong, but valid in most of the cases) -bool Message::matchForIRCRegExp(QRegExp ®exp, const QTextCodec *codec, const QCString &line, Message &msg ) +bool Message::matchForIRCRegExp(TQRegExp ®exp, const TQTextCodec *codec, const TQCString &line, Message &msg ) { if( regexp.exactMatch( codec->toUnicode(line) ) ) { msg.m_raw = line; msg.m_prefix = unquote(regexp.cap(1)); msg.m_command = unquote(regexp.cap(2)); - msg.m_args = QStringList::split(' ', regexp.cap(3)); + msg.m_args = TQStringList::split(' ', regexp.cap(3)); - QCString suffix = codec->fromUnicode(unquote(regexp.cap(4))); + TQCString suffix = codec->fromUnicode(unquote(regexp.cap(4))); if (!suffix.isNull() && suffix.length() > 0) { - QCString ctcpRaw; + TQCString ctcpRaw; if (extractCtcpCommand(suffix, ctcpRaw)) { msg.m_ctcpRaw = codec->toUnicode(ctcpRaw); @@ -279,7 +279,7 @@ bool Message::matchForIRCRegExp(QRegExp ®exp, const QTextCodec *codec, const int space = ctcpRaw.find(' '); if (!matchForIRCRegExp(msg.m_ctcpMessage->m_raw, codec, *msg.m_ctcpMessage)) { - QCString command; + TQCString command; if (space > 0) command = ctcpRaw.mid(0, space).upper(); else @@ -296,28 +296,28 @@ bool Message::matchForIRCRegExp(QRegExp ®exp, const QTextCodec *codec, const msg.m_suffix = Kopete::Message::decodeString( KSParser::parse(suffix), codec ); } else - msg.m_suffix = QString::null; + msg.m_suffix = TQString::null; return true; } return false; } -void Message::decodeAgain( const QTextCodec *codec ) +void Message::decodeAgain( const TQTextCodec *codec ) { matchForIRCRegExp(m_raw, codec, *this); } // FIXME: there are missing parts -QString Message::toString() const +TQString Message::toString() const { if( !isValid() ) - return QString::null; + return TQString::null; - QString msg = m_command; - for (QStringList::ConstIterator it = m_args.begin(); it != m_args.end(); ++it) - msg += QChar(' ') + *it; + TQString msg = m_command; + for (TQStringList::ConstIterator it = m_args.begin(); it != m_args.end(); ++it) + msg += TQChar(' ') + *it; if (!m_suffix.isNull()) - msg += QString::fromLatin1(" :") + m_suffix; + msg += TQString::fromLatin1(" :") + m_suffix; return msg; } @@ -339,7 +339,7 @@ bool Message::isValid() const * string is splited to get the first part of the message and fill the ctcp command. * FIXME: The code currently only match for a textual message or a ctcp message not both mixed as it can be (even if very rare). */ -bool Message::extractCtcpCommand(QCString &message, QCString &ctcpline) +bool Message::extractCtcpCommand(TQCString &message, TQCString &ctcpline) { uint len = message.length(); -- cgit v1.2.1