diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-22 00:30:31 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-22 00:30:31 +0000 |
commit | 69cac65817d949cda2672ec4f0aa73d5e66a0ba1 (patch) | |
tree | 073fde0496ea90eb5bf5cffe66a8da43a9f55fbc /kopete/protocols/msn/msnswitchboardsocket.cpp | |
parent | 3467e6464beac3a162839bf7078e22e3a74d73e7 (diff) | |
download | tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.tar.gz tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.zip |
TQt4 port kdenetwork
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1237912 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/msn/msnswitchboardsocket.cpp')
-rw-r--r-- | kopete/protocols/msn/msnswitchboardsocket.cpp | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/kopete/protocols/msn/msnswitchboardsocket.cpp b/kopete/protocols/msn/msnswitchboardsocket.cpp index 7754c448..896de926 100644 --- a/kopete/protocols/msn/msnswitchboardsocket.cpp +++ b/kopete/protocols/msn/msnswitchboardsocket.cpp @@ -63,8 +63,8 @@ #include "dispatcher.h" using P2P::Dispatcher; -MSNSwitchBoardSocket::MSNSwitchBoardSocket( MSNAccount *account , TQObject *parent ) -: MSNSocket( parent ) +MSNSwitchBoardSocket::MSNSwitchBoardSocket( MSNAccount *account , TQObject *tqparent ) +: MSNSocket( tqparent ) { m_account = account; m_recvIcons=0; @@ -80,7 +80,7 @@ MSNSwitchBoardSocket::~MSNSwitchBoardSocket() { kdDebug(14140) << k_funcinfo << endl; - TQMap<TQString , QPair<TQString , KTempFile*> >::Iterator it; + TQMap<TQString , TQPair<TQString , KTempFile*> >::Iterator it; for ( it = m_emoticons.begin(); it != m_emoticons.end(); ++it ) { delete it.data().second; @@ -93,8 +93,8 @@ void MSNSwitchBoardSocket::connectToSwitchBoard(TQString ID, TQString address, T m_ID = ID; m_auth = auth; - TQString server = address.left( address.find( ":" ) ); - uint port = address.right( address.length() - address.findRev( ":" ) - 1 ).toUInt(); + TQString server = address.left( address.tqfind( ":" ) ); + uint port = address.right( address.length() - address.tqfindRev( ":" ) - 1 ).toUInt(); TQObject::connect( this, TQT_SIGNAL( blockRead( const TQByteArray & ) ), this, TQT_SLOT(slotReadMessage( const TQByteArray & ) ) ); @@ -128,7 +128,7 @@ void MSNSwitchBoardSocket::handleError( uint code, uint id ) } case 215: { - msg = i18n( "The user %1 is already in this chat." ).arg( m_msgHandle ); + msg = i18n( "The user %1 is already in this chat." ).tqarg( m_msgHandle ); type = MSNSocket::ErrorServerError; //userLeftChat(m_msgHandle , i18n("user was twice in this chat") ); //(the user shouln't join there @@ -136,7 +136,7 @@ void MSNSwitchBoardSocket::handleError( uint code, uint id ) } case 216: { - msg = i18n( "The user %1 is online but has blocked you:\nyou can not talk to this user." ).arg( m_msgHandle ); + msg = i18n( "The user %1 is online but has blocked you:\nyou can not talk to this user." ).tqarg( m_msgHandle ); type = MSNSocket::ErrorInformation; userLeftChat(m_msgHandle, i18n("user blocked you")); @@ -145,7 +145,7 @@ void MSNSwitchBoardSocket::handleError( uint code, uint id ) case 217: { // TODO: we need to know the nickname instead of the handle. - msg = i18n( "The user %1 is currently not signed in.\n" "Messages will not be delivered." ).arg( m_msgHandle ); + msg = i18n( "The user %1 is currently not signed in.\n" "Messages will not be delivered." ).tqarg( m_msgHandle ); type = MSNSocket::ErrorServerError; userLeftChat(m_msgHandle, i18n("user disconnected")); @@ -153,7 +153,7 @@ void MSNSwitchBoardSocket::handleError( uint code, uint id ) } case 713: { - TQString msg = i18n( "You are trying to invite too many contacts to this chat at the same time" ).arg( m_msgHandle ); + TQString msg = i18n( "You are trying to invite too many contacts to this chat at the same time" ).tqarg( m_msgHandle ); type = MSNSocket::ErrorInformation; userLeftChat(m_msgHandle, i18n("user blocked you")); @@ -191,7 +191,7 @@ void MSNSwitchBoardSocket::parseCommand( const TQString &cmd, uint id , // new user joins the chat, update user in chat list TQString handle = data.section( ' ', 0, 0 ); TQString screenname = unescape(data.section( ' ', 1, 1 )); - if( !m_chatMembers.contains( handle ) ) + if( !m_chatMembers.tqcontains( handle ) ) m_chatMembers.append( handle ); emit userJoined( handle, screenname, false ); } @@ -199,7 +199,7 @@ void MSNSwitchBoardSocket::parseCommand( const TQString &cmd, uint id , { // we have joined a multi chat session- this are the users in this chat TQString handle = data.section( ' ', 2, 2 ); - if( !m_chatMembers.contains( handle ) ) + if( !m_chatMembers.tqcontains( handle ) ) m_chatMembers.append( handle ); TQString screenname = unescape(data.section( ' ', 3, 3)); @@ -214,8 +214,8 @@ void MSNSwitchBoardSocket::parseCommand( const TQString &cmd, uint id , // some has disconnect from chat, update user in chat list cleanQueue(); //in case some message are waiting their emoticons, never mind, send them - TQString handle = data.section( ' ', 0, 0 ).replace( "\r\n" , "" ); - userLeftChat( handle, (data.section( ' ', 1, 1 ) == "1" ) ? i18n("timeout") : TQString::null ); + TQString handle = data.section( ' ', 0, 0 ).tqreplace( "\r\n" , "" ); + userLeftChat( handle, (data.section( ' ', 1, 1 ) == "1" ) ? i18n("timeout") : TQString() ); } else if( cmd == "MSG" ) { @@ -265,13 +265,13 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) else if( type== "text/x-msmsgscontrol" ) { TQString message; - message = msg.right( msg.length() - msg.findRev( " " ) - 1 ); - message = message.replace( "\r\n" ,"" ); + message = msg.right( msg.length() - msg.tqfindRev( " " ) - 1 ); + message = message.tqreplace( "\r\n" ,"" ); emit receivedTypingMsg( message.lower(), true ); } else if(type == "text/x-msnmsgr-datacast") { - if(msg.contains("ID:")) + if(msg.tqcontains("ID:")) { TQRegExp rx("ID: ([0-9]*)"); rx.search(msg); @@ -293,7 +293,7 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) TQColor fontColor; TQFont font; - if ( msg.contains( "X-MMS-IM-Format" ) ) + if ( msg.tqcontains( "X-MMS-IM-Format" ) ) { TQString fontName; TQString fontInfo; @@ -329,7 +329,7 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) } } - fontName = parseFontAttr(fontInfo, "FN").replace( "%20" , " " ); + fontName = parseFontAttr(fontInfo, "FN").tqreplace( "%20" , " " ); // Some clients like Trillian and Kopete itself send a font // name of 'MS Serif' since MS changed the server to @@ -343,10 +343,10 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) font = TQFont( fontName, parseFontAttr( fontInfo, "PF" ).toInt(), // font size - ef.contains( 'B' ) ? TQFont::Bold : TQFont::Normal, - ef.contains( 'I' ) ); - font.setUnderline(ef.contains( 'U' )); - font.setStrikeOut(ef.contains( 'S' )); + ef.tqcontains( 'B' ) ? TQFont::Bold : TQFont::Normal, + ef.tqcontains( 'I' ) ); + font.setUnderline(ef.tqcontains( 'U' )); + font.setStrikeOut(ef.tqcontains( 'S' )); } } @@ -359,17 +359,17 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) others.append( m_account->contacts()[ *it2 ] ); } - TQString message=msg.right( msg.length() - msg.find("\r\n\r\n") - 4 ); + TQString message=msg.right( msg.length() - msg.tqfind("\r\n\r\n") - 4 ); //Stupid MSN PLUS colors code. message with incorrect charactere are not showed correctly in the chatwindow. //TODO: parse theses one to show the color too in Kopete - message.replace("\3","").replace("\4","").replace("\2","").replace("\5","").replace("\6","").replace("\7",""); + message.tqreplace("\3","").tqreplace("\4","").tqreplace("\2","").tqreplace("\5","").tqreplace("\6","").tqreplace("\7",""); if(!m_account->contacts()[m_msgHandle]) { //this may happens if the contact has been deleted. kdDebug(14140) << k_funcinfo <<"WARNING: contact is null, adding it" <<endl; - if( !m_chatMembers.contains( m_msgHandle ) ) + if( !m_chatMembers.tqcontains( m_msgHandle ) ) m_chatMembers.append( m_msgHandle ); emit userJoined( m_msgHandle , m_msgHandle , false); } @@ -432,9 +432,9 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) TQString txt=rx.cap(1); kdDebug(14140) << k_funcinfo << "emoticon: " << txt << " msnobj: " << msnobj<< endl; - if( !m_emoticons.contains(msnobj) || !m_emoticons[msnobj].second ) + if( !m_emoticons.tqcontains(msnobj) || !m_emoticons[msnobj].second ) { - m_emoticons.insert(msnobj, qMakePair(txt,(KTempFile*)0L)); + m_emoticons.insert(msnobj, tqMakePair(txt,(KTempFile*)0L)); MSNContact *c=static_cast<MSNContact*>(m_account->contacts()[m_msgHandle]); if(!c) return; @@ -493,7 +493,7 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) } - else if(type == "image/gif" || msg.contains("Message-ID:")) + else if(type == "image/gif" || msg.tqcontains("Message-ID:")) { // Incoming inkformatgif. TQRegExp regex("Message-ID: \\{([0-9A-F\\-]*)\\}"); @@ -510,7 +510,7 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) { bool valid = true; // Retrieve the nmber of data chunks. - Q_UINT32 numberOfChunks = chunks.toUInt(&valid); + TQ_UINT32 numberOfChunks = chunks.toUInt(&valid); if(valid && (numberOfChunks > 1)) { regex = TQRegExp("base64:([0-9a-zA-Z+/=]+)"); @@ -536,7 +536,7 @@ void MSNSwitchBoardSocket::slotReadMessage( const TQByteArray &bytes ) if(!messageId.isNull()) { - if(m_inkMessageBuffer.contains(messageId)) + if(m_inkMessageBuffer.tqcontains(messageId)) { if(chunks.isNull()) { @@ -577,7 +577,7 @@ void MSNSwitchBoardSocket::sendTypingMsg( bool isTyping ) if( !isTyping ) return; - if ( onlineStatus() != Connected || m_chatMembers.empty()) + if ( onlinetqStatus() != Connected || m_chatMembers.empty()) { //we are not yet in a chat. //if we send that command now, we may get disconnected. @@ -653,14 +653,14 @@ int MSNSwitchBoardSocket::sendCustomEmoticon(const TQString &name, const TQStrin // this sends a short message to the server int MSNSwitchBoardSocket::sendMsg( const Kopete::Message &msg ) { - if ( onlineStatus() != Connected || m_chatMembers.empty()) + if ( onlinetqStatus() != Connected || m_chatMembers.empty()) { // m_messagesQueue.append(msg); return -1; } #if 0 //this is to test webcam - if(msg.plainBody().contains("/webcam")) + if(msg.plainBody().tqcontains("/webcam")) { PeerDispatcher()->startWebcam( m_myHandle , m_msgHandle); return -3; @@ -678,7 +678,7 @@ int MSNSwitchBoardSocket::sendMsg( const Kopete::Message &msg ) { for ( TQStringList::const_iterator itr2 = itr.data().constBegin(); itr2 != itr.data().constEnd(); ++itr2 ) { - if ( msg.plainBody().contains( *itr2 ) ) + if ( msg.plainBody().tqcontains( *itr2 ) ) sendCustomEmoticon( *itr2, itr.key() ); } } @@ -748,7 +748,7 @@ int MSNSwitchBoardSocket::sendMsg( const Kopete::Message &msg ) head += "; RL=1"; head += "\r\n"; - TQString message= msg.plainBody().replace( "\n" , "\r\n" ); + TQString message= msg.plainBody().tqreplace( "\n" , "\r\n" ); //-- Check if the message isn't too big, TODO: do that at the libkopete level. int len_H=head.utf8().length(); // != head.length() because i need the size in butes and @@ -767,8 +767,8 @@ int MSNSwitchBoardSocket::sendMsg( const Kopete::Message &msg ) int nb=(int)ceil((float)(len_M)/(float)(futurmessages_size)); - if(KMessageBox::warningContinueCancel(0L /* FIXME: we should try to find a parent somewere*/ , - i18n("The message you are trying to send is too long; it will be split into %1 messages.").arg(nb) , + if(KMessageBox::warningContinueCancel(0L /* FIXME: we should try to find a tqparent somewere*/ , + i18n("The message you are trying to send is too long; it will be split into %1 messages.").tqarg(nb) , i18n("Message too big - MSN Plugin" ), KStdGuiItem::cont() , "SendLongMessages" ) == KMessageBox::Continue ) { @@ -850,7 +850,7 @@ void MSNSwitchBoardSocket::slotSocketClosed( ) void MSNSwitchBoardSocket::slotCloseSession() { - sendCommand( "OUT", TQString::null, false ); + sendCommand( "OUT", TQString(), false ); disconnect(); } @@ -888,7 +888,7 @@ void MSNSwitchBoardSocket::userLeftChat(const TQString& handle , const TQString { emit userLeft( handle, reason ); - if( m_chatMembers.contains( handle ) ) + if( m_chatMembers.tqcontains( handle ) ) m_chatMembers.remove( handle ); if(m_chatMembers.isEmpty()) @@ -907,7 +907,7 @@ void MSNSwitchBoardSocket::slotEmoticonReceived( KTempFile *file, const TQStrin { kdDebug(14141) << k_funcinfo << msnObj << endl; - if(m_emoticons.contains(msnObj)) + if(m_emoticons.tqcontains(msnObj)) { //it's an emoticon m_emoticons[msnObj].second=file; @@ -920,7 +920,7 @@ void MSNSwitchBoardSocket::slotEmoticonReceived( KTempFile *file, const TQStrin } else if(msnObj == "inkformatgif") { - TQString msg=i18n("<img src=\"%1\" alt=\"Typewrited message\" />" ).arg( file->name() ); + TQString msg=i18n("<img src=\"%1\" alt=\"Typewrited message\" />" ).tqarg( file->name() ); kdDebug(14140) << k_funcinfo << file->name() <<endl; @@ -941,7 +941,7 @@ void MSNSwitchBoardSocket::slotEmoticonReceived( KTempFile *file, const TQStrin { //this may happens if the contact has been deleted. kdDebug(14140) << k_funcinfo <<"WARNING: contact is null, adding it" <<endl; - if( !m_chatMembers.contains( m_msgHandle ) ) + if( !m_chatMembers.tqcontains( m_msgHandle ) ) m_chatMembers.append( m_msgHandle ); emit userJoined( m_msgHandle , m_msgHandle , false); } @@ -961,7 +961,7 @@ void MSNSwitchBoardSocket::slotEmoticonReceived( KTempFile *file, const TQStrin } } -void MSNSwitchBoardSocket::slotIncomingFileTransfer(const TQString& from, const TQString& /*fileName*/, Q_INT64 /*fileSize*/) +void MSNSwitchBoardSocket::slotIncomingFileTransfer(const TQString& from, const TQString& /*fileName*/, TQ_INT64 /*fileSize*/) { TQPtrList<Kopete::Contact> others; others.append( m_account->myself() ); @@ -976,7 +976,7 @@ void MSNSwitchBoardSocket::slotIncomingFileTransfer(const TQString& from, const { //this may happens if the contact has been deleted. kdDebug(14140) << k_funcinfo <<"WARNING: contact is null, adding it" <<endl; - if( !m_chatMembers.contains( m_msgHandle ) ) + if( !m_chatMembers.tqcontains( m_msgHandle ) ) m_chatMembers.append( m_msgHandle ); emit userJoined( m_msgHandle , m_msgHandle , false); } @@ -1008,12 +1008,12 @@ void MSNSwitchBoardSocket::cleanQueue() Kopete::Message &MSNSwitchBoardSocket::parseCustomEmoticons(Kopete::Message &kmsg) { TQString message=kmsg.escapedBody(); - TQMap<TQString , QPair<TQString , KTempFile*> >::Iterator it; + TQMap<TQString , TQPair<TQString , KTempFile*> >::Iterator it; for ( it = m_emoticons.begin(); it != m_emoticons.end(); ++it ) { TQString es=TQStyleSheet::escape(it.data().first); KTempFile *f=it.data().second; - if(message.contains(es) && f) + if(message.tqcontains(es) && f) { TQString imgPath = f->name(); TQImage iconImage(imgPath); @@ -1021,19 +1021,19 @@ Kopete::Message &MSNSwitchBoardSocket::parseCustomEmoticons(Kopete::Message &kms * emoticons like that. So, in that case, we show like the MSN client */ #if 0 TQString em = TQRegExp::escape( es ); - message.replace( TQRegExp(TQString::fromLatin1( "(^|[\\W\\s]|%1)(%2)(?!\\w)" ).arg(em).arg(em)), - TQString::fromLatin1("\\1<img align=\"center\" width=\"") + + message.tqreplace( TQRegExp(TQString::tqfromLatin1( "(^|[\\W\\s]|%1)(%2)(?!\\w)" ).tqarg(em).tqarg(em)), + TQString::tqfromLatin1("\\1<img align=\"center\" width=\"") + #endif //match any occurence which is not in a html tag. - message.replace( TQRegExp(TQString::fromLatin1("%1(?![^><]*>)").arg(TQRegExp::escape(es))), - TQString::fromLatin1("<img align=\"center\" width=\"") + + message.tqreplace( TQRegExp(TQString::tqfromLatin1("%1(?![^><]*>)").tqarg(TQRegExp::escape(es))), + TQString::tqfromLatin1("<img align=\"center\" width=\"") + TQString::number(iconImage.width()) + - TQString::fromLatin1("\" height=\"") + + TQString::tqfromLatin1("\" height=\"") + TQString::number(iconImage.height()) + - TQString::fromLatin1("\" src=\"") + imgPath + - TQString::fromLatin1("\" title=\"") + es + - TQString::fromLatin1("\" alt=\"") + es + - TQString::fromLatin1( "\"/>" ) ); + TQString::tqfromLatin1("\" src=\"") + imgPath + + TQString::tqfromLatin1("\" title=\"") + es + + TQString::tqfromLatin1("\" alt=\"") + es + + TQString::tqfromLatin1( "\"/>" ) ); kmsg.setBody(message, Kopete::Message::RichText); } } @@ -1060,12 +1060,12 @@ TQString MSNSwitchBoardSocket::parseFontAttr(TQString str, TQString attr) TQString tmp; int pos1=0, pos2=0; - pos1 = str.find(attr + "="); + pos1 = str.tqfind(attr + "="); if (pos1 == -1) return ""; - pos2 = str.find(";", pos1+3); + pos2 = str.tqfind(";", pos1+3); if (pos2 == -1) tmp = str.mid(pos1+3, str.length() - pos1 - 3); @@ -1092,7 +1092,7 @@ Dispatcher* MSNSwitchBoardSocket::PeerDispatcher() // TQObject::connect(this, TQT_SIGNAL(blockRead(const TQByteArray&)), m_dispatcher, TQT_SLOT(slotReadMessage(const TQByteArray&))); // TQObject::connect(m_dispatcher, TQT_SIGNAL(sendCommand(const TQString&, const TQString&, bool, const TQByteArray&, bool)), this, TQT_SLOT(sendCommand(const TQString&, const TQString&, bool, const TQByteArray&, bool))); - TQObject::connect(m_dispatcher, TQT_SIGNAL(incomingTransfer(const TQString&, const TQString&, Q_INT64)), this, TQT_SLOT(slotIncomingFileTransfer(const TQString&, const TQString&, Q_INT64))); + TQObject::connect(m_dispatcher, TQT_SIGNAL(incomingTransfer(const TQString&, const TQString&, TQ_INT64)), this, TQT_SLOT(slotIncomingFileTransfer(const TQString&, const TQString&, TQ_INT64))); TQObject::connect(m_dispatcher, TQT_SIGNAL(displayIconReceived(KTempFile *, const TQString&)), this, TQT_SLOT(slotEmoticonReceived( KTempFile *, const TQString&))); TQObject::connect(this, TQT_SIGNAL(msgAcknowledgement(unsigned int, bool)), m_dispatcher, TQT_SLOT(messageAcknowledged(unsigned int, bool))); m_dispatcher->m_pictureUrl = m_account->pictureUrl(); @@ -1104,7 +1104,7 @@ void MSNSwitchBoardSocket::slotKeepAliveTimer( ) { /* This is a workaround against the bug 113425 - The problem: the P2P::Webcam class is parent of us, and when we get deleted, it get deleted. + The problem: the P2P::Webcam class is tqparent of us, and when we get deleted, it get deleted. the correct solution would be to change that. The second problem: after one minute of inactivity, the official client close the chat socket. the workaround: we simulate the activity by sending small packet each 50 seconds @@ -1112,7 +1112,7 @@ void MSNSwitchBoardSocket::slotKeepAliveTimer( ) the bad side effect: some switchboard connection may be maintained for really long time! */ - if ( onlineStatus() != Connected || m_chatMembers.empty()) + if ( onlinetqStatus() != Connected || m_chatMembers.empty()) { //we are not yet in a chat. //if we send that command now, we may get disconnected. |