@ -44,14 +44,14 @@
# include <kanimwidget.h>
# include <kanimwidget.h>
# include <kpushbutton.h>
# include <kpushbutton.h>
# include < qvbox.h>
# include < t qvbox.h>
# include < qlabel.h>
# include < t qlabel.h>
# include < qnamespace.h>
# include < t qnamespace.h>
# include < qeventloop.h>
# include < t qeventloop.h>
# include < qapplication.h>
# include < t qapplication.h>
# include < qfile.h>
# include < t qfile.h>
# include < qfileinfo.h>
# include < t qfileinfo.h>
# include < qptrlist.h>
# include < t qptrlist.h>
# include "otrlchatinterface.h"
# include "otrlchatinterface.h"
# include "otrguiclient.h"
# include "otrguiclient.h"
@ -74,7 +74,7 @@ static OtrlPolicy policy(void *opdata, ConnContext *context){
kdDebug ( ) < < " Disabling OTR for: " < < session - > protocol ( ) - > pluginId ( ) < < endl ;
kdDebug ( ) < < " Disabling OTR for: " < < session - > protocol ( ) - > pluginId ( ) < < endl ;
return OTRL_POLICY_NEVER ;
return OTRL_POLICY_NEVER ;
}
}
QString policy = session - > members ( ) . getFirst ( ) - > metaContact ( ) - > pluginData ( OTRPlugin : : plugin ( ) , " otr_policy " ) ;
T QString policy = session - > members ( ) . getFirst ( ) - > metaContact ( ) - > pluginData ( OTRPlugin : : plugin ( ) , " otr_policy " ) ;
switch ( policy . toInt ( & noerr , 10 ) ) {
switch ( policy . toInt ( & noerr , 10 ) ) {
case 1 :
case 1 :
return OTRL_POLICY_ALWAYS ;
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 ) ;
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 " ) , T Qt: : WStyle_Dialog | T Qt: : WStyle_StaysOnTop ) ;
KAnimWidget * anim = new KAnimWidget ( " kde " , 72 , popup - > animFrame , " kopete " ) ;
KAnimWidget * anim = new KAnimWidget ( " kde " , 72 , popup - > animFrame , " kopete " ) ;
anim - > start ( ) ;
anim - > start ( ) ;
anim - > show ( ) ;
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 * keyGenThread = new KeyGenThread ( accountname , protocol ) ;
keyGenThread - > start ( ) ;
keyGenThread - > start ( ) ;
while ( ! keyGenThread - > wait ( 100 ) ) {
while ( ! keyGenThread - > wait ( 100 ) ) {
qApp- > eventLoop ( ) - > processEvents ( QEventLoop: : ExcludeUserInput | QEventLoop: : ExcludeSocketNotifiers , 100 ) ;
t qApp- > eventLoop ( ) - > processEvents ( T QEventLoop: : ExcludeUserInput | T QEventLoop: : ExcludeSocketNotifiers , 100 ) ;
}
}
popup - > setCloseLock ( false ) ;
popup - > setCloseLock ( false ) ;
popup - > close ( ) ;
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 ) {
static int is_logged_in ( void * opdata , const char * accountname , const char * protocol , const char * recipient ) {
Kopete : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
Kopete : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
for ( QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
for ( T QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
if ( contact - > contactId ( ) . compare ( recipient ) = = 0 ) {
if ( contact - > contactId ( ) . compare ( recipient ) = = 0 ) {
Kopete : : OnlineStatus status = session - > contactOnlineStatus ( contact ) ;
Kopete : : OnlineStatus status = session - > contactOnlineStatus ( contact ) ;
if ( status = = Kopete : : OnlineStatus : : Unknown ) {
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 ) {
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, T QString(accountname) + ":" + T QString(protocol) + ":" + T QString(recipient) + ":" + T QString(message) );
Kopete : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
Kopete : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
for ( QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
for ( T QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
if ( contact - > contactId ( ) . compare ( recipient ) = = 0 ) {
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 , T QString( message ) , Kopete : : Message : : Outbound ) ;
session - > sendMessage ( msg ) ;
session - > sendMessage ( msg ) ;
return ;
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 ) {
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 , T QString( primary ) + T QString( secondary ) , T QString( title ) ) ;
}
}
static int display_otr_message ( void * opdata , const char * accountname , const char * protocol , const char * username , const char * message ) {
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 : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
Kopete : : ContactPtrList list = session - > members ( ) ;
for ( QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
for ( T QPtrListIterator< Kopete : : Contact > it ( list ) ; Kopete : : Contact * contact = it . current ( ) ; + + it ) {
if ( contact - > contactId ( ) . compare ( username ) = = 0 ) {
if ( contact - > contactId ( ) . compare ( username ) = = 0 ) {
Kopete : : Message msg ( session - > members ( ) . getFirst ( ) , session - > account ( ) - > myself ( ) , QString( message ) , Kopete : : Message : : Internal ) ;
Kopete : : Message msg ( session - > members ( ) . getFirst ( ) , session - > account ( ) - > myself ( ) , T QString( message ) , Kopete : : Message : : Internal ) ;
msg . setBody ( QString( message ) , Kopete : : Message : : RichText ) ;
msg . setBody ( T QString( message ) , Kopete : : Message : : RichText ) ;
session - > appendMessage ( msg ) ;
session - > appendMessage ( msg ) ;
return 0 ;
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 ] ) {
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 ;
kdDebug ( ) < < " Received a new Fingerprint " < < endl ;
Kopete : : ChatSession * session = ( ( Kopete : : ChatSession * ) opdata ) ;
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> " ) . tq arg( session - > members ( ) . getFirst ( ) - > contactId ( ) ) , Kopete : : Message : : Internal , Kopete : : Message : : RichText ) ;
session - > appendMessage ( msg ) ;
session - > appendMessage ( msg ) ;
}
}
static void write_fingerprints ( void * opdata ) {
static void write_fingerprints ( void * opdata ) {
kdDebug ( ) < < " Writing fingerprints " < < endl ;
kdDebug ( ) < < " Writing fingerprints " < < endl ;
otrl_privkey_write_fingerprints ( userstate , QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
otrl_privkey_write_fingerprints ( userstate , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
}
}
static void gone_secure ( void * opdata , ConnContext * context ) {
static void gone_secure ( void * opdata , ConnContext * context ) {
@ -257,11 +257,11 @@ OtrlChatInterface::OtrlChatInterface(){
userstate = otrl_userstate_create ( ) ;
userstate = otrl_userstate_create ( ) ;
otrl_privkey_read ( userstate , QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
otrl_privkey_read ( userstate , T QString( 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 , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " , NULL , NULL ) ;
}
}
@ -284,8 +284,8 @@ OtrlUserState OtrlChatInterface::getUserstate(){
}
}
int OtrlChatInterface : : decryptMessage ( QString * msg , QString accountId ,
int OtrlChatInterface : : decryptMessage ( T QString * msg , T QString accountId ,
QString protocol , QString contactId , Kopete : : ChatSession * chatSession ) {
T QString protocol , T QString contactId , Kopete : : ChatSession * chatSession ) {
int ignoremessage ;
int ignoremessage ;
char * newMessage = NULL ;
char * newMessage = NULL ;
@ -300,7 +300,7 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId,
tlv = otrl_tlv_find ( tlvs , OTRL_TLV_DISCONNECTED ) ;
tlv = otrl_tlv_find ( tlvs , OTRL_TLV_DISCONNECTED ) ;
if ( tlv ) {
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. " ) . tq arg( chatSession - > members ( ) . getFirst ( ) - > contactId ( ) ) , Kopete : : Message : : Internal , Kopete : : Message : : RichText ) ;
chatSession - > appendMessage ( msg ) ;
chatSession - > appendMessage ( msg ) ;
OTRPlugin : : plugin ( ) - > emitGoneSecure ( chatSession , 3 ) ;
OTRPlugin : : plugin ( ) - > emitGoneSecure ( chatSession , 3 ) ;
@ -315,7 +315,7 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId,
if ( nextMsg ! = OTRL_SMP_EXPECT1 ) {
if ( nextMsg ! = OTRL_SMP_EXPECT1 ) {
abortSMP ( context , chatSession ) ;
abortSMP ( context , chatSession ) ;
} else {
} 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 " ) , T Qt: : WStyle_Dialog | T Qt: : WStyle_StaysOnTop , context , chatSession , false ) ;
popup - > show ( ) ;
popup - > show ( ) ;
}
}
}
}
@ -378,42 +378,42 @@ int OtrlChatInterface::decryptMessage( QString *msg, QString accountId,
if ( ! ignoremessage ) {
if ( ! ignoremessage ) {
// message is decrypted
// message is decrypted
if ( newMessage ! = NULL ) {
if ( newMessage ! = NULL ) {
* msg = QString: : fromUtf8 ( newMessage ) ;
* msg = T QString: : fromUtf8 ( newMessage ) ;
otrl_message_free ( newMessage ) ;
otrl_message_free ( newMessage ) ;
msg - > replace( ' \n ' , " <br> " , false ) ;
msg - > tq replace( TQString ( ' \n ' ) , TQString ( " <br> " ) , false ) ;
}
}
}
}
return ignoremessage ;
return ignoremessage ;
}
}
QString OtrlChatInterface : : encryptMessage ( QString msg , QString accountId ,
T QString OtrlChatInterface : : encryptMessage ( T QString msg , T QString accountId ,
QString protocol , QString contactId , Kopete : : ChatSession * chatSession ) {
T QString protocol , T QString contactId , Kopete : : ChatSession * chatSession ) {
int err ;
int err ;
char * newMessage ;
char * newMessage ;
if ( otrl_proto_message_type ( msg ) = = OTRL_MSGTYPE_NOTOTR ) {
if ( otrl_proto_message_type ( msg ) = = OTRL_MSGTYPE_NOTOTR ) {
msg . replace( ' < ' , " < " , false ) ;
msg . tq replace( TQString ( ' < ' ) , TQString ( " < " ) , false ) ;
err = otrl_message_sending ( userstate , & ui_ops , chatSession , accountId . latin1 ( ) , protocol . latin1 ( ) , contactId . latin1 ( ) , msg . utf8 ( ) , NULL , & newMessage , NULL , NULL ) ;
err = otrl_message_sending ( userstate , & ui_ops , chatSession , accountId . latin1 ( ) , protocol . latin1 ( ) , contactId . latin1 ( ) , msg . utf8 ( ) , NULL , & newMessage , NULL , NULL ) ;
if ( err ! = 0 ) {
if ( err ! = 0 ) {
msg = i18n ( " Encryption error " ) ;
msg = i18n ( " Encryption error " ) ;
} else {
} else {
if ( newMessage ! = NULL ) {
if ( newMessage ! = NULL ) {
msg = QString: : fromUtf8 ( newMessage ) ;
msg = T QString: : fromUtf8 ( newMessage ) ;
otrl_message_free ( newMessage ) ;
otrl_message_free ( newMessage ) ;
}
}
}
}
}
}
OtrlMessageType type = otrl_proto_message_type ( msg ) ;
OtrlMessageType type = otrl_proto_message_type ( msg ) ;
if ( type = = OTRL_MSGTYPE_NOTOTR | type = = OTRL_MSGTYPE_TAGGEDPLAINTEXT ) {
if ( type = = OTRL_MSGTYPE_NOTOTR | type = = OTRL_MSGTYPE_TAGGEDPLAINTEXT ) {
msg . replace( " < " , " < " , false ) ;
msg . tq replace( " < " , " < " , false ) ;
}
}
return msg ;
return msg ;
}
}
QString OtrlChatInterface : : getDefaultQuery ( QString accountId ) {
T QString OtrlChatInterface : : getDefaultQuery ( T QString accountId ) {
char * message ;
char * message ;
message = otrl_proto_default_query_msg ( accountId . latin1 ( ) , OTRL_POLICY_ALLOW_V2 ) ;
message = otrl_proto_default_query_msg ( accountId . latin1 ( ) , OTRL_POLICY_ALLOW_V2 ) ;
QString msg ( message ) ;
T QString msg ( message ) ;
otrl_message_free ( message ) ;
otrl_message_free ( message ) ;
return msg ;
return msg ;
}
}
@ -423,12 +423,12 @@ void OtrlChatInterface::disconnectSession( Kopete::ChatSession *chatSession ){
OTRPlugin : : plugin ( ) - > emitGoneSecure ( chatSession , false ) ;
OTRPlugin : : plugin ( ) - > emitGoneSecure ( chatSession , false ) ;
Kopete : : Message msg ( chatSession - > account ( ) - > myself ( ) , chatSession - > members ( ) . getFirst ( ) , i18n ( " Terminating OTR session. " ) , Kopete : : Message : : Internal ) ;
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( T QString( message ), Kopete::Message::RichText );
chatSession - > appendMessage ( msg ) ;
chatSession - > appendMessage ( msg ) ;
}
}
bool OtrlChatInterface : : shouldDiscard ( QString message ) {
bool OtrlChatInterface : : shouldDiscard ( T QString message ) {
if ( ! message . isEmpty ( ) & & ! message . isNull ( ) ) {
if ( ! message . isEmpty ( ) & & ! message . isNull ( ) ) {
switch ( otrl_proto_message_type ( message . latin1 ( ) ) ) {
switch ( otrl_proto_message_type ( message . latin1 ( ) ) ) {
case OTRL_MSGTYPE_TAGGEDPLAINTEXT :
case OTRL_MSGTYPE_TAGGEDPLAINTEXT :
@ -470,11 +470,11 @@ int OtrlChatInterface::privState( Kopete::ChatSession *session ){
return 0 ;
return 0 ;
}
}
QString OtrlChatInterface : : formatContact ( QString contactId ) {
T QString OtrlChatInterface : : formatContact ( T QString contactId ) {
Kopete : : MetaContact * metaContact = Kopete : : ContactList : : self ( ) - > findMetaContactByContactId ( contactId ) ;
Kopete : : MetaContact * metaContact = Kopete : : ContactList : : self ( ) - > findMetaContactByContactId ( contactId ) ;
if ( metaContact ) {
if ( metaContact ) {
QString displayName = metaContact - > displayName ( ) ;
T QString displayName = metaContact - > displayName ( ) ;
if ( ( displayName ! = contactId ) & & ! displayName . isNull ( ) ) {
if ( ( displayName ! = contactId ) & & ! displayName . isNull ( ) ) {
return displayName + " ( " + contactId + " ) " ;
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 ) ;
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 " ) , T Qt: : WStyle_Dialog | T Qt: : WStyle_StaysOnTop , context , session , true ) ;
popup - > show ( ) ;
popup - > show ( ) ;
@ -504,14 +504,14 @@ void OtrlChatInterface::setTrust( Kopete::ChatSession *session, bool trust ){
otrl_context_set_trust ( fingerprint , NULL ) ;
otrl_context_set_trust ( fingerprint , NULL ) ;
}
}
kdDebug ( ) < < " Writing fingerprints " < < endl ;
kdDebug ( ) < < " Writing fingerprints " < < endl ;
otrl_privkey_write_fingerprints ( userstate , QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
otrl_privkey_write_fingerprints ( userstate , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
OTRPlugin : : plugin ( ) - > emitGoneSecure ( session , privState ( session ) ) ;
OTRPlugin : : plugin ( ) - > emitGoneSecure ( session , privState ( session ) ) ;
} else {
} else {
kdDebug ( ) < < " could not find fingerprint " < < endl ;
kdDebug ( ) < < " could not find fingerprint " < < endl ;
}
}
}
}
Fingerprint * OtrlChatInterface : : findFingerprint ( QString account ) {
Fingerprint * OtrlChatInterface : : findFingerprint ( T QString account ) {
ConnContext * context ;
ConnContext * context ;
for ( context = userstate - > context_root ; context ! = NULL ; context = context - > next ) {
for ( context = userstate - > context_root ; context ! = NULL ; context = context - > next ) {
@ -524,7 +524,7 @@ Fingerprint *OtrlChatInterface::findFingerprint( QString account ){
return NULL ;
return NULL ;
}
}
QString OtrlChatInterface : : findActiveFingerprint ( Kopete : : ChatSession * session ) {
T QString OtrlChatInterface : : findActiveFingerprint ( Kopete : : ChatSession * session ) {
ConnContext * context ;
ConnContext * context ;
char hash [ 45 ] ;
char hash [ 45 ] ;
@ -555,16 +555,16 @@ bool OtrlChatInterface::isVerified( Kopete::ChatSession *session ){
void OtrlChatInterface : : updateKeyfile ( Kopete : : Account * account ) {
void OtrlChatInterface : : updateKeyfile ( Kopete : : Account * account ) {
// Updating private keys from <=0.3
// Updating private keys from <=0.3
kdDebug ( ) < < " updating keys " < < endl ;
kdDebug ( ) < < " updating keys " < < endl ;
QFile keyfile ( QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
T QFile keyfile ( T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
QString line ;
T QString line ;
QString file ;
T QString file ;
if ( keyfile . open ( IO_ReadWrite ) ) {
if ( keyfile . open ( IO_ReadWrite ) ) {
kdDebug ( ) < < " file open " < < endl ;
kdDebug ( ) < < " file open " < < endl ;
while ( keyfile . readLine ( line , 200 ) ! = - 1 ) {
while ( keyfile . readLine ( line , 200 ) ! = - 1 ) {
if ( line . find( " protocol " ) ! = - 1 ) {
if ( line . tq find( " protocol " ) ! = - 1 ) {
if ( line . find( account - > accountLabel ( ) ) ! = - 1 ) {
if ( line . tq find( account - > accountLabel ( ) ) ! = - 1 ) {
line . replace( account - > accountLabel ( ) , account - > protocol ( ) - > displayName ( ) ) ;
line . tq replace( account - > accountLabel ( ) , account - > protocol ( ) - > displayName ( ) ) ;
kdDebug ( ) < < " Successfully updated keyfile for account " < < account - > accountId ( ) < < endl ;
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 . writeBlock ( file . latin1 ( ) , file . length ( ) ) ;
keyfile . close ( ) ;
keyfile . close ( ) ;
otrl_privkey_forget_all ( userstate ) ;
otrl_privkey_forget_all ( userstate ) ;
otrl_privkey_read ( userstate , QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
otrl_privkey_read ( userstate , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
file = " " ;
file = " " ;
line = " " ;
line = " " ;
// Updating fingerprints from <=0.3
// Updating fingerprints from <=0.3
kdDebug ( ) < < " updating fingerprints " < < endl ;
kdDebug ( ) < < " updating fingerprints " < < endl ;
QFile fingerprintfile ( QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
T QFile fingerprintfile ( T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " ) ;
if ( fingerprintfile . open ( IO_ReadWrite ) ) {
if ( fingerprintfile . open ( IO_ReadWrite ) ) {
kdDebug ( ) < < " file open " < < endl ;
kdDebug ( ) < < " file open " < < endl ;
while ( fingerprintfile . readLine ( line , 200 ) ! = - 1 ) {
while ( fingerprintfile . readLine ( line , 200 ) ! = - 1 ) {
int pos = line . findRev( account - > accountLabel ( ) ) ;
int pos = line . tq findRev( account - > accountLabel ( ) ) ;
if ( pos ! = - 1 ) {
if ( pos ! = - 1 ) {
line . replace( pos , account - > accountLabel ( ) . length ( ) , account - > protocol ( ) - > displayName ( ) ) ;
line . tq replace( pos , account - > accountLabel ( ) . length ( ) , account - > protocol ( ) - > displayName ( ) ) ;
kdDebug ( ) < < " Successfully updated fingerprint for account " < < account - > accountId ( ) < < endl ;
kdDebug ( ) < < " Successfully updated fingerprint for account " < < account - > accountId ( ) < < endl ;
}
}
file . append ( line ) ;
file . append ( line ) ;
@ -600,21 +600,21 @@ void OtrlChatInterface::updateKeyfile( Kopete::Account *account ){
fingerprintfile . writeBlock ( file . latin1 ( ) , file . length ( ) ) ;
fingerprintfile . writeBlock ( file . latin1 ( ) , file . length ( ) ) ;
fingerprintfile . close ( ) ;
fingerprintfile . close ( ) ;
otrl_context_forget_all ( userstate ) ;
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 , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " fingerprints " , NULL , NULL ) ;
}
}
void OtrlChatInterface : : checkFilePermissions ( QString file ) {
void OtrlChatInterface : : checkFilePermissions ( T QString file ) {
if ( QFile: : exists ( file ) ) {
if ( T QFile: : exists ( file ) ) {
QFile privkeys ( file ) ;
T QFile privkeys ( file ) ;
QFileInfo privkeysInfo ( privkeys ) ;
T QFileInfo privkeysInfo ( privkeys ) ;
if ( ! privkeysInfo . permission ( QFileInfo: : ReadOwner | QFileInfo: : WriteOwner ) |
if ( ! privkeysInfo . permission ( T QFileInfo: : ReadOwner | T QFileInfo: : WriteOwner ) |
privkeysInfo . permission ( QFileInfo: : ReadGroup ) |
privkeysInfo . permission ( T QFileInfo: : ReadGroup ) |
privkeysInfo . permission ( QFileInfo: : WriteGroup ) |
privkeysInfo . permission ( T QFileInfo: : WriteGroup ) |
privkeysInfo . permission ( QFileInfo: : ExeGroup ) |
privkeysInfo . permission ( T QFileInfo: : ExeGroup ) |
privkeysInfo . permission ( QFileInfo: : ReadOther ) |
privkeysInfo . permission ( T QFileInfo: : ReadOther ) |
privkeysInfo . permission ( QFileInfo: : WriteOther ) |
privkeysInfo . permission ( T QFileInfo: : WriteOther ) |
privkeysInfo . permission ( QFileInfo: : ExeOther ) ) {
privkeysInfo . permission ( T QFileInfo: : ExeOther ) ) {
kdDebug ( ) < < " Permissions of OTR storage file are wrong! Correcting... " < < endl ;
kdDebug ( ) < < " Permissions of OTR storage file are wrong! Correcting... " < < endl ;
chmod ( file , 0600 ) ;
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, T QString fingerprint ){
kdDebug ( ) < < " searching for Fingerprint " < < endl ;
kdDebug ( ) < < " searching for Fingerprint " < < endl ;
if ( fingerprint ! = NULL ) {
if ( fingerprint ! = NULL ) {
int doVerify = KMessageBox : : questionYesNo (
int doVerify = KMessageBox : : questionYesNo (
NULL ,
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: " ) . tq arg( formatContact ( session - > members ( ) . getFirst ( ) - > contactId ( ) ) ) + " \n \n " + fingerprint + " \n \n " + i18n ( " Are you sure you want to trust this fingerprint? " ) ,
i18n ( " Verify fingerprint " ) ) ;
i18n ( " Verify fingerprint " ) ) ;
if ( doVerify = = KMessageBox : : Yes ) {
if ( doVerify = = KMessageBox : : Yes ) {
return true ;
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 , T QString secret , bool initiate ) {
if ( 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 ) ;
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 ( ) ) ;
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 : : KeyGenThread ( QString accountname , QString protocol ) {
KeyGenThread : : KeyGenThread ( T QString accountname , T QString protocol ) {
this - > accountname = accountname ;
this - > accountname = accountname ;
this - > protocol = protocol ;
this - > protocol = protocol ;
}
}
@ -678,8 +678,8 @@ KeyGenThread::KeyGenThread( QString accountname, QString protocol ){
void KeyGenThread : : run ( )
void KeyGenThread : : run ( )
{
{
kdDebug ( ) < < " Creating private key... Storing to: " + QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " < < endl ;
kdDebug ( ) < < " Creating private key... Storing to: " + T 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 ) ;
otrl_privkey_generate ( OtrlChatInterface : : self ( ) - > getUserstate ( ) , T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " , accountname , protocol ) ;
OtrlChatInterface : : self ( ) - > checkFilePermissions ( QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
OtrlChatInterface : : self ( ) - > checkFilePermissions ( T QString( KGlobal : : dirs ( ) - > saveLocation ( " data " , " kopete_otr/ " , true ) ) + " privkeys " ) ;
}
}