diff options
Diffstat (limited to 'src/otrlchatinterface.cpp')
-rw-r--r-- | src/otrlchatinterface.cpp | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/otrlchatinterface.cpp b/src/otrlchatinterface.cpp index 85f1e7f..65d0df6 100644 --- a/src/otrlchatinterface.cpp +++ b/src/otrlchatinterface.cpp @@ -44,14 +44,14 @@ #include <kanimwidget.h> #include <kpushbutton.h> -#include <qvbox.h> -#include <qlabel.h> -#include <qnamespace.h> -#include <qeventloop.h> -#include <qapplication.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qptrlist.h> +#include <tqvbox.h> +#include <tqlabel.h> +#include <tqnamespace.h> +#include <tqeventloop.h> +#include <tqapplication.h> +#include <tqfile.h> +#include <tqfileinfo.h> +#include <tqptrlist.h> #include "otrlchatinterface.h" #include "otrguiclient.h" @@ -74,7 +74,7 @@ static OtrlPolicy policy(void *opdata, ConnContext *context){ kdDebug() << "Disabling OTR for: " << session->protocol()->pluginId() << endl; return OTRL_POLICY_NEVER; } - QString policy = session->members().getFirst()->metaContact()->pluginData( OTRPlugin::plugin(), "otr_policy" ); + TQString policy = session->members().getFirst()->metaContact()->pluginData( OTRPlugin::plugin(), "otr_policy" ); switch( policy.toInt( &noerr, 10 ) ){ case 1: return OTRL_POLICY_ALWAYS; @@ -93,7 +93,7 @@ static void create_privkey(void *opdata, const char *accountname, const char *pr Kopete::ChatSession *session= ((Kopete::ChatSession*)opdata); - PrivKeyPopup *popup = new PrivKeyPopup( session->view()->mainWidget(), i18n("Generating private key"), Qt::WStyle_Dialog | Qt::WStyle_StaysOnTop ); + PrivKeyPopup *popup = new PrivKeyPopup( session->view()->mainWidget(), i18n("Generating private key"), TQt::WStyle_Dialog | TQt::WStyle_StaysOnTop ); KAnimWidget *anim = new KAnimWidget( "kde", 72, popup->animFrame, "kopete" ); anim->start(); anim->show(); @@ -103,7 +103,7 @@ static void create_privkey(void *opdata, const char *accountname, const char *pr KeyGenThread *keyGenThread = new KeyGenThread( accountname, protocol ); keyGenThread->start(); while( !keyGenThread->wait(100) ){ - qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput | QEventLoop::ExcludeSocketNotifiers, 100); + tqApp->eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers, 100); } popup->setCloseLock( false ); popup->close(); @@ -112,7 +112,7 @@ static void create_privkey(void *opdata, const char *accountname, const char *pr static int is_logged_in(void *opdata, const char *accountname, const char *protocol, const char *recipient){ Kopete::ChatSession *session= ((Kopete::ChatSession*)opdata); Kopete::ContactPtrList list = session->members(); - for ( QPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ + for ( TQPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ if( contact->contactId().compare( recipient ) == 0 ){ Kopete::OnlineStatus status = session->contactOnlineStatus( contact ); if( status == Kopete::OnlineStatus::Unknown){ @@ -128,12 +128,12 @@ static int is_logged_in(void *opdata, const char *accountname, const char *proto } static void inject_message( void *opdata, const char *accountname, const char *protocol, const char *recipient, const char *message ){ - //KMessageBox::information( NULL, QString(accountname) + ":" + QString(protocol) + ":" + QString(recipient) + ":" + QString(message) ); + //KMessageBox::information( NULL, TQString(accountname) + ":" + TQString(protocol) + ":" + TQString(recipient) + ":" + TQString(message) ); Kopete::ChatSession *session= ((Kopete::ChatSession*)opdata); Kopete::ContactPtrList list = session->members(); - for ( QPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ + for ( TQPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ if( contact->contactId().compare( recipient ) == 0 ){ - Kopete::Message msg( session->account()->myself(), contact, QString( message ), Kopete::Message::Outbound ); + Kopete::Message msg( session->account()->myself(), contact, TQString( message ), Kopete::Message::Outbound ); session->sendMessage( msg ); return; } @@ -141,16 +141,16 @@ static void inject_message( void *opdata, const char *accountname, const char *p } static void notify(void *opdata, OtrlNotifyLevel level, const char *accountname, const char *protocol, const char *username, const char *title, const char *primary, const char *secondary){ - KMessageBox::information(NULL, QString( primary ) + QString( secondary ), QString( title ) ); + KMessageBox::information(NULL, TQString( primary ) + TQString( secondary ), TQString( title ) ); } static int display_otr_message( void *opdata, const char *accountname, const char *protocol, const char *username, const char *message ){ Kopete::ChatSession *session= ((Kopete::ChatSession*)opdata); Kopete::ContactPtrList list = session->members(); - for ( QPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ + for ( TQPtrListIterator<Kopete::Contact> it( list ); Kopete::Contact *contact = it.current(); ++it ){ if( contact->contactId().compare( username ) == 0 ){ - Kopete::Message msg( session->members().getFirst(), session->account()->myself(), QString( message ), Kopete::Message::Internal ); - msg.setBody( QString( message ), Kopete::Message::RichText ); + Kopete::Message msg( session->members().getFirst(), session->account()->myself(), TQString( message ), Kopete::Message::Internal ); + msg.setBody( TQString( message ), Kopete::Message::RichText ); session->appendMessage( msg ); return 0; } @@ -175,13 +175,13 @@ static void protocol_name_free(void *opdata, const char *protocol_name){ static void new_fingerprint(void *opdata, OtrlUserState us, const char *accountname, const char *protocol, const char *username, unsigned char fingerprint[20]){ kdDebug() << "Received a new Fingerprint" << endl; Kopete::ChatSession *session= ((Kopete::ChatSession*)opdata); - Kopete::Message msg( session->members().getFirst(), session->account()->myself(), i18n("<b>Received a new fingerprint from <a>%1</a>. You should authenticate this contact.</b>").arg( session->members().getFirst()->contactId() ), Kopete::Message::Internal, Kopete::Message::RichText ); + Kopete::Message msg( session->members().getFirst(), session->account()->myself(), i18n("<b>Received a new fingerprint from <a>%1</a>. You should authenticate this contact.</b>").tqarg( session->members().getFirst()->contactId() ), Kopete::Message::Internal, Kopete::Message::RichText ); session->appendMessage( msg ); } static void write_fingerprints(void *opdata){ kdDebug() << "Writing fingerprints" << endl; - otrl_privkey_write_fingerprints( userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); + otrl_privkey_write_fingerprints( userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); } static void gone_secure(void *opdata, ConnContext *context){ @@ -257,11 +257,11 @@ OtrlChatInterface::OtrlChatInterface(){ userstate = otrl_userstate_create(); - otrl_privkey_read( userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); + otrl_privkey_read( userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); - otrl_privkey_read_fingerprints(userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); + otrl_privkey_read_fingerprints(userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); } @@ -284,8 +284,8 @@ OtrlUserState OtrlChatInterface::getUserstate(){ } -int OtrlChatInterface::decryptMessage( QString *msg, QString accountId, - QString protocol, QString contactId , Kopete::ChatSession *chatSession){ +int OtrlChatInterface::decryptMessage( TQString *msg, TQString accountId, + TQString protocol, TQString contactId , Kopete::ChatSession *chatSession){ int ignoremessage; char *newMessage = NULL; @@ -300,7 +300,7 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId, tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if( tlv ){ - Kopete::Message msg( chatSession->members().getFirst(), chatSession->account()->myself(), i18n("<b>%1</b> has ended the OTR session. You should do the same.").arg(chatSession->members().getFirst()->contactId()) , Kopete::Message::Internal, Kopete::Message::RichText ); + Kopete::Message msg( chatSession->members().getFirst(), chatSession->account()->myself(), i18n("<b>%1</b> has ended the OTR session. You should do the same.").tqarg(chatSession->members().getFirst()->contactId()) , Kopete::Message::Internal, Kopete::Message::RichText ); chatSession->appendMessage( msg ); OTRPlugin::plugin()->emitGoneSecure( chatSession, 3 ); @@ -315,7 +315,7 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId, if (nextMsg != OTRL_SMP_EXPECT1){ abortSMP( context, chatSession ); } else { - SMPPopup *popup = new SMPPopup( chatSession->view()->mainWidget(), i18n("Enter authentication secret"), Qt::WStyle_Dialog | Qt::WStyle_StaysOnTop, context, chatSession, false ); + SMPPopup *popup = new SMPPopup( chatSession->view()->mainWidget(), i18n("Enter authentication secret"), TQt::WStyle_Dialog | TQt::WStyle_StaysOnTop, context, chatSession, false ); popup->show(); } } @@ -378,42 +378,42 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId, if( !ignoremessage ){ // message is decrypted if( newMessage != NULL ){ - *msg = QString::fromUtf8(newMessage); + *msg = TQString::fromUtf8(newMessage); otrl_message_free( newMessage ); - msg->replace( '\n', "<br>", false ); + msg->tqreplace( TQString('\n'), TQString("<br>"), false ); } } return ignoremessage; } -QString OtrlChatInterface::encryptMessage( QString msg, QString accountId, - QString protocol, QString contactId , Kopete::ChatSession *chatSession ){ +TQString OtrlChatInterface::encryptMessage( TQString msg, TQString accountId, + TQString protocol, TQString contactId , Kopete::ChatSession *chatSession ){ int err; char * newMessage; if( otrl_proto_message_type( msg ) == OTRL_MSGTYPE_NOTOTR ){ - msg.replace( '<', "<", false ); + msg.tqreplace( TQString('<'), TQString("<"), false ); err = otrl_message_sending( userstate, &ui_ops, chatSession, accountId.latin1(), protocol.latin1(), contactId.latin1(), msg.utf8(), NULL, &newMessage, NULL, NULL ); if( err != 0 ){ msg = i18n("Encryption error"); } else { if( newMessage != NULL ){ - msg = QString::fromUtf8( newMessage ); + msg = TQString::fromUtf8( newMessage ); otrl_message_free( newMessage ); } } } OtrlMessageType type = otrl_proto_message_type( msg ); if( type == OTRL_MSGTYPE_NOTOTR | type == OTRL_MSGTYPE_TAGGEDPLAINTEXT ){ - msg.replace( "<", "<", false ); + msg.tqreplace( "<", "<", false ); } return msg; } -QString OtrlChatInterface::getDefaultQuery( QString accountId ){ +TQString OtrlChatInterface::getDefaultQuery( TQString accountId ){ char *message; message = otrl_proto_default_query_msg( accountId.latin1(), OTRL_POLICY_ALLOW_V2 ); - QString msg( message ); + TQString msg( message ); otrl_message_free( message ); return msg; } @@ -423,12 +423,12 @@ void OtrlChatInterface::disconnectSession( Kopete::ChatSession *chatSession ){ OTRPlugin::plugin()->emitGoneSecure( chatSession, false ); Kopete::Message msg( chatSession->account()->myself(), chatSession->members().getFirst(), i18n("Terminating OTR session."), Kopete::Message::Internal ); -// msg.setBody( QString( message ), Kopete::Message::RichText ); +// msg.setBody( TQString( message ), Kopete::Message::RichText ); chatSession->appendMessage( msg ); } -bool OtrlChatInterface::shouldDiscard( QString message ){ +bool OtrlChatInterface::shouldDiscard( TQString message ){ if( !message.isEmpty() && !message.isNull() ){ switch( otrl_proto_message_type( message.latin1() ) ){ case OTRL_MSGTYPE_TAGGEDPLAINTEXT: @@ -470,11 +470,11 @@ int OtrlChatInterface::privState( Kopete::ChatSession *session ){ return 0; } -QString OtrlChatInterface::formatContact(QString contactId){ +TQString OtrlChatInterface::formatContact(TQString contactId){ Kopete::MetaContact *metaContact = Kopete::ContactList::self()->findMetaContactByContactId(contactId); if( metaContact ){ - QString displayName = metaContact->displayName(); + TQString displayName = metaContact->displayName(); if((displayName != contactId) && !displayName.isNull()){ return displayName + " (" + contactId+")"; } @@ -487,7 +487,7 @@ void OtrlChatInterface::verifyFingerprint( Kopete::ChatSession *session ){ context = otrl_context_find( userstate, session->members().getFirst()->contactId().latin1(), session->account()->accountId().latin1(), session->protocol()->displayName().latin1(), 0, NULL, NULL, NULL); - SMPPopup *popup = new SMPPopup( session->view()->mainWidget(), i18n("Enter authentication secret"), Qt::WStyle_Dialog | Qt::WStyle_StaysOnTop, context, session, true ); + SMPPopup *popup = new SMPPopup( session->view()->mainWidget(), i18n("Enter authentication secret"), TQt::WStyle_Dialog | TQt::WStyle_StaysOnTop, context, session, true ); popup->show(); @@ -504,14 +504,14 @@ void OtrlChatInterface::setTrust( Kopete::ChatSession *session, bool trust ){ otrl_context_set_trust( fingerprint, NULL ); } kdDebug() << "Writing fingerprints" << endl; - otrl_privkey_write_fingerprints( userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); + otrl_privkey_write_fingerprints( userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); OTRPlugin::plugin()->emitGoneSecure( session, privState( session ) ); } else { kdDebug() << "could not find fingerprint" << endl; } } -Fingerprint *OtrlChatInterface::findFingerprint( QString account ){ +Fingerprint *OtrlChatInterface::findFingerprint( TQString account ){ ConnContext *context; for( context = userstate->context_root; context != NULL; context = context->next ){ @@ -524,7 +524,7 @@ Fingerprint *OtrlChatInterface::findFingerprint( QString account ){ return NULL; } -QString OtrlChatInterface::findActiveFingerprint( Kopete::ChatSession *session ){ +TQString OtrlChatInterface::findActiveFingerprint( Kopete::ChatSession *session ){ ConnContext *context; char hash[45]; @@ -555,16 +555,16 @@ bool OtrlChatInterface::isVerified( Kopete::ChatSession *session ){ void OtrlChatInterface::updateKeyfile( Kopete::Account *account ){ // Updating private keys from <=0.3 kdDebug() << "updating keys" << endl; - QFile keyfile( QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); - QString line; - QString file; + TQFile keyfile( TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); + TQString line; + TQString file; if( keyfile.open( IO_ReadWrite ) ){ kdDebug() << "file open" << endl; while( keyfile.readLine( line, 200 ) != -1){ - if( line.find( "protocol" ) != -1 ){ - if( line.find( account->accountLabel() ) != -1 ){ - line.replace( account->accountLabel(), account->protocol()->displayName() ); + if( line.tqfind( "protocol" ) != -1 ){ + if( line.tqfind( account->accountLabel() ) != -1 ){ + line.tqreplace( account->accountLabel(), account->protocol()->displayName() ); kdDebug() << "Successfully updated keyfile for account " << account->accountId() << endl; } } @@ -576,20 +576,20 @@ void OtrlChatInterface::updateKeyfile( Kopete::Account *account ){ keyfile.writeBlock( file.latin1(), file.length() ); keyfile.close(); otrl_privkey_forget_all( userstate ); - otrl_privkey_read( userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); + otrl_privkey_read( userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); file = ""; line = ""; // Updating fingerprints from <=0.3 kdDebug() << "updating fingerprints" << endl; - QFile fingerprintfile( QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); + TQFile fingerprintfile( TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); if( fingerprintfile.open( IO_ReadWrite ) ){ kdDebug() << "file open" << endl; while( fingerprintfile.readLine( line, 200 ) != -1){ - int pos = line.findRev( account->accountLabel() ); + int pos = line.tqfindRev( account->accountLabel() ); if( pos != -1 ){ - line.replace( pos, account->accountLabel().length(), account->protocol()->displayName() ); + line.tqreplace( pos, account->accountLabel().length(), account->protocol()->displayName() ); kdDebug() << "Successfully updated fingerprint for account " << account->accountId() << endl; } file.append( line ); @@ -600,21 +600,21 @@ void OtrlChatInterface::updateKeyfile( Kopete::Account *account ){ fingerprintfile.writeBlock( file.latin1(), file.length() ); fingerprintfile.close(); otrl_context_forget_all( userstate ); - otrl_privkey_read_fingerprints(userstate, QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); + otrl_privkey_read_fingerprints(userstate, TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); } -void OtrlChatInterface::checkFilePermissions( QString file ){ - if( QFile::exists( file ) ){ - QFile privkeys( file ); - QFileInfo privkeysInfo( privkeys ); - if( !privkeysInfo.permission( QFileInfo::ReadOwner | QFileInfo::WriteOwner ) | - privkeysInfo.permission( QFileInfo::ReadGroup ) | - privkeysInfo.permission( QFileInfo::WriteGroup ) | - privkeysInfo.permission( QFileInfo::ExeGroup ) | - privkeysInfo.permission( QFileInfo::ReadOther ) | - privkeysInfo.permission( QFileInfo::WriteOther ) | - privkeysInfo.permission( QFileInfo::ExeOther ) ){ +void OtrlChatInterface::checkFilePermissions( TQString file ){ + if( TQFile::exists( file ) ){ + TQFile privkeys( file ); + TQFileInfo privkeysInfo( privkeys ); + if( !privkeysInfo.permission( TQFileInfo::ReadOwner | TQFileInfo::WriteOwner ) | + privkeysInfo.permission( TQFileInfo::ReadGroup ) | + privkeysInfo.permission( TQFileInfo::WriteGroup ) | + privkeysInfo.permission( TQFileInfo::ExeGroup ) | + privkeysInfo.permission( TQFileInfo::ReadOther ) | + privkeysInfo.permission( TQFileInfo::WriteOther ) | + privkeysInfo.permission( TQFileInfo::ExeOther ) ){ kdDebug() << "Permissions of OTR storage file are wrong! Correcting..." << endl; chmod( file, 0600); } @@ -622,13 +622,13 @@ void OtrlChatInterface::checkFilePermissions( QString file ){ } -/*bool OtrlChatInterface::verifyQuestion( Kopete::ChatSession *session, QString fingerprint ){ +/*bool OtrlChatInterface::verifyQuestion( Kopete::ChatSession *session, TQString fingerprint ){ kdDebug() << "searching for Fingerprint" << endl; if( fingerprint != NULL ){ int doVerify = KMessageBox::questionYesNo( NULL, - i18n("Please contact %1 via another secure way and verify that the following Fingerprint is correct:").arg( formatContact(session->members().getFirst()->contactId())) + "\n\n" + fingerprint + "\n\n" + i18n("Are you sure you want to trust this fingerprint?"), + i18n("Please contact %1 via another secure way and verify that the following Fingerprint is correct:").tqarg( formatContact(session->members().getFirst()->contactId())) + "\n\n" + fingerprint + "\n\n" + i18n("Are you sure you want to trust this fingerprint?"), i18n("Verify fingerprint") ); if( doVerify == KMessageBox::Yes ){ return true; @@ -654,7 +654,7 @@ void OtrlChatInterface::abortSMP( ConnContext *context, Kopete::ChatSession *ses } } -void OtrlChatInterface::respondSMP( ConnContext *context, Kopete::ChatSession *session, QString secret, bool initiate ){ +void OtrlChatInterface::respondSMP( ConnContext *context, Kopete::ChatSession *session, TQString secret, bool initiate ){ if( initiate ){ context = otrl_context_find( userstate, session->members().getFirst()->contactId().latin1(), session->account()->accountId().latin1(), session->protocol()->displayName().latin1(), 0, NULL, NULL, NULL); otrl_message_initiate_smp( userstate, &ui_ops, session, context, (unsigned char*)secret.latin1(), secret.length() ); @@ -670,7 +670,7 @@ void OtrlChatInterface::respondSMP( ConnContext *context, Kopete::ChatSession *s /****************** KeyGenThread *******************/ -KeyGenThread::KeyGenThread( QString accountname, QString protocol ){ +KeyGenThread::KeyGenThread( TQString accountname, TQString protocol ){ this->accountname = accountname; this->protocol = protocol; } @@ -678,8 +678,8 @@ KeyGenThread::KeyGenThread( QString accountname, QString protocol ){ void KeyGenThread::run() { - kdDebug() << "Creating private key... Storing to: " + QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true)) + "privkeys" << endl; - otrl_privkey_generate(OtrlChatInterface::self()->getUserstate(), QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys", accountname, protocol); - OtrlChatInterface::self()->checkFilePermissions( QString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); + kdDebug() << "Creating private key... Storing to: " + TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true)) + "privkeys" << endl; + otrl_privkey_generate(OtrlChatInterface::self()->getUserstate(), TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys", accountname, protocol); + OtrlChatInterface::self()->checkFilePermissions( TQString(KGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); } |