Added controlled conversions to char* instead of automatic ascii conversions.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 3 years ago
parent efa509c5a4
commit 07a5ffc33a
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -96,7 +96,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"), TQt::WType_Dialog | TQt::WStyle_StaysOnTop ); PrivKeyPopup *popup = new PrivKeyPopup( session->view()->mainWidget(), i18n("Generating private key").utf8(), TQt::WType_Dialog | TQt::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();
@ -192,7 +192,7 @@ static void new_fingerprint(void *opdata, OtrlUserState us, const char *accountn
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, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
} }
static void gone_secure(void *opdata, ConnContext *context){ static void gone_secure(void *opdata, ConnContext *context){
@ -340,7 +340,7 @@ void handle_smp_event(void *opdata, OtrlSMPEvent smp_event, ConnContext *context
case OTRL_SMPEVENT_NONE: case OTRL_SMPEVENT_NONE:
break; break;
case OTRL_SMPEVENT_ASK_FOR_SECRET: { case OTRL_SMPEVENT_ASK_FOR_SECRET: {
SMPPopup *popup = new SMPPopup( chatSession->view()->mainWidget(), i18n("Enter authentication secret"), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, chatSession, false ); SMPPopup *popup = new SMPPopup( chatSession->view()->mainWidget(), i18n("Enter authentication secret").utf8(), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, chatSession, false );
popup->show(); popup->show();
break; break;
} }
@ -487,7 +487,7 @@ void handle_msg_event(void *opdata, OtrlMessageEvent msg_event, ConnContext *con
void create_instag(void *opdata, const char *accountname, const char *protocol){ void create_instag(void *opdata, const char *accountname, const char *protocol){
Q_UNUSED(opdata) Q_UNUSED(opdata)
otrl_instag_generate(OtrlChatInterface::self()->getUserstate(), TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "instags", accountname, protocol); otrl_instag_generate(OtrlChatInterface::self()->getUserstate(), TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("instags").local8Bit(), accountname, protocol);
} }
#endif // HAVE_LIBOTR_0400 #endif // HAVE_LIBOTR_0400
@ -576,12 +576,12 @@ OtrlChatInterface::OtrlChatInterface(){
userstate = otrl_userstate_create(); userstate = otrl_userstate_create();
otrl_privkey_read( userstate, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); otrl_privkey_read( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("privkeys").local8Bit() );
otrl_privkey_read_fingerprints(userstate, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); otrl_privkey_read_fingerprints(userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit(), NULL, NULL);
#ifdef HAVE_LIBOTR_0400 #ifdef HAVE_LIBOTR_0400
otrl_instag_read(userstate, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "instags"); otrl_instag_read(userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("instags").local8Bit());
unsigned int interval = otrl_message_poll_get_default_interval(userstate); unsigned int interval = otrl_message_poll_get_default_interval(userstate);
forwardSecrecyTimerStart(interval); forwardSecrecyTimerStart(interval);
@ -661,7 +661,7 @@ int OtrlChatInterface::decryptMessage( TQString *msg, TQString 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"), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, chatSession, false ); SMPPopup *popup = new SMPPopup( chatSession->view()->mainWidget(), i18n("Enter authentication secret").utf8(), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, chatSession, false );
popup->show(); popup->show();
} }
} }
@ -736,7 +736,7 @@ TQString OtrlChatInterface::encryptMessage( TQString msg, TQString accountId,
TQString protocol, TQString contactId , Kopete::ChatSession *chatSession ){ TQString protocol, TQString 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.latin1() ) == OTRL_MSGTYPE_NOTOTR ){
msg.replace( TQString("<"), TQString("&lt;"), false ); msg.replace( TQString("<"), TQString("&lt;"), false );
#ifdef HAVE_LIBOTR_0400 #ifdef HAVE_LIBOTR_0400
otrl_instag_t instance = chatSession->property("otr-instag").toUInt(); otrl_instag_t instance = chatSession->property("otr-instag").toUInt();
@ -754,7 +754,7 @@ TQString OtrlChatInterface::encryptMessage( TQString msg, TQString accountId,
} }
} }
} }
OtrlMessageType type = otrl_proto_message_type( msg ); OtrlMessageType type = otrl_proto_message_type( msg.latin1() );
if( type == OTRL_MSGTYPE_NOTOTR | type == OTRL_MSGTYPE_TAGGEDPLAINTEXT ){ if( type == OTRL_MSGTYPE_NOTOTR | type == OTRL_MSGTYPE_TAGGEDPLAINTEXT ){
msg.replace( "&lt;", "<", false ); msg.replace( "&lt;", "<", false );
} }
@ -772,9 +772,9 @@ TQString OtrlChatInterface::getDefaultQuery( TQString accountId ){
void OtrlChatInterface::disconnectSession( Kopete::ChatSession *chatSession ){ void OtrlChatInterface::disconnectSession( Kopete::ChatSession *chatSession ){
#ifdef HAVE_LIBOTR_0400 #ifdef HAVE_LIBOTR_0400
otrl_instag_t instance = chatSession->property("otr-instag").toUInt(); otrl_instag_t instance = chatSession->property("otr-instag").toUInt();
otrl_message_disconnect( userstate, &ui_ops, chatSession, chatSession->account()->accountId().latin1(), chatSession->account()->protocol()->displayName().latin1(), chatSession->members().getFirst()->contactId(), instance ); otrl_message_disconnect( userstate, &ui_ops, chatSession, chatSession->account()->accountId().latin1(), chatSession->account()->protocol()->displayName().latin1(), chatSession->members().getFirst()->contactId().latin1(), instance );
#else // HAVE_LIBOTR_0400 #else // HAVE_LIBOTR_0400
otrl_message_disconnect( userstate, &ui_ops, chatSession, chatSession->account()->accountId().latin1(), chatSession->account()->protocol()->displayName().latin1(), chatSession->members().getFirst()->contactId() ); otrl_message_disconnect( userstate, &ui_ops, chatSession, chatSession->account()->accountId().latin1(), chatSession->account()->protocol()->displayName().latin1(), chatSession->members().getFirst()->contactId().latin1() );
#endif // HAVE_LIBOTR_0400 #endif // HAVE_LIBOTR_0400
OTRPlugin::plugin()->emitGoneSecure( chatSession, false ); OTRPlugin::plugin()->emitGoneSecure( chatSession, false );
@ -810,9 +810,9 @@ int OtrlChatInterface::privState( Kopete::ChatSession *session ){
#ifdef HAVE_LIBOTR_0400 #ifdef HAVE_LIBOTR_0400
otrl_instag_t instance = session->property("otr-instag").toUInt(); otrl_instag_t instance = session->property("otr-instag").toUInt();
context = otrl_context_find(userstate, session->members().getFirst()->contactId(), session->account()->accountId(), session->account()->protocol()->displayName(), instance, 0, NULL, NULL, NULL); context = otrl_context_find(userstate, session->members().getFirst()->contactId().latin1(), session->account()->accountId().latin1(), session->account()->protocol()->displayName().latin1(), instance, 0, NULL, NULL, NULL);
#else // HAVE_LIBOTR_0400 #else // HAVE_LIBOTR_0400
context = otrl_context_find(userstate, session->members().getFirst()->contactId(), session->account()->accountId(), session->account()->protocol()->displayName(), 0, NULL, NULL, NULL); context = otrl_context_find(userstate, session->members().getFirst()->contactId().latin1(), session->account()->accountId().latin1(), session->account()->protocol()->displayName().latin1(), 0, NULL, NULL, NULL);
#endif // HAVE_LIBOTR_0400 #endif // HAVE_LIBOTR_0400
if( context ){ if( context ){
@ -853,7 +853,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);
#endif // HAVE_LIBOTR_0400 #endif // HAVE_LIBOTR_0400
SMPPopup *popup = new SMPPopup( session->view()->mainWidget(), i18n("Enter authentication secret"), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, session, true ); SMPPopup *popup = new SMPPopup( session->view()->mainWidget(), i18n("Enter authentication secret").utf8(), TQString::null, TQt::WType_Dialog | TQt::WStyle_StaysOnTop, context, session, true );
popup->show(); popup->show();
} }
@ -868,7 +868,7 @@ 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, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
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;
@ -880,7 +880,8 @@ Fingerprint *OtrlChatInterface::findFingerprint( TQString account ){
for( context = userstate->context_root; context != NULL; context = context->next ){ for( context = userstate->context_root; context != NULL; context = context->next ){
kdDebug() << context->username << endl; kdDebug() << context->username << endl;
if( strcmp( context->username, account ) == 0 ){ if (context->username == account)
{
kdDebug() << "found Context" << endl; kdDebug() << "found Context" << endl;
return context->active_fingerprint ? context->active_fingerprint : NULL; return context->active_fingerprint ? context->active_fingerprint : NULL;
} }
@ -894,7 +895,8 @@ TQString OtrlChatInterface::findActiveFingerprint( Kopete::ChatSession *session
for( context = userstate->context_root; context != NULL; context = context->next ){ for( context = userstate->context_root; context != NULL; context = context->next ){
kdDebug() << context->username << endl; kdDebug() << context->username << endl;
if( strcmp( context->username, session->members().getFirst()->contactId() ) == 0 ){ if (context->username == session->members().getFirst()->contactId())
{
// otrl_privkey_hash_to_human( hash, context->fingerprint_root.next->fingerprint ); // otrl_privkey_hash_to_human( hash, context->fingerprint_root.next->fingerprint );
otrl_privkey_hash_to_human( hash, context->active_fingerprint->fingerprint ); otrl_privkey_hash_to_human( hash, context->active_fingerprint->fingerprint );
return hash; return hash;
@ -940,13 +942,13 @@ 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, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); otrl_privkey_read( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("privkeys").local8Bit() );
file = ""; file = "";
line = ""; line = "";
// Updating fingerprints from <=0.3 // Updating fingerprints from <=0.3
kdDebug() << "updating fingerprints" << endl; kdDebug() << "updating fingerprints" << endl;
TQFile fingerprintfile( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); TQFile fingerprintfile( TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
if( fingerprintfile.open( IO_ReadWrite ) ){ if( fingerprintfile.open( IO_ReadWrite ) ){
kdDebug() << "file open" << endl; kdDebug() << "file open" << endl;
@ -964,7 +966,7 @@ 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, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints", NULL, NULL); otrl_privkey_read_fingerprints(userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit(), NULL, NULL);
} }
@ -980,7 +982,7 @@ void OtrlChatInterface::checkFilePermissions( TQString file ){
privkeysInfo.permission( TQFileInfo::WriteOther ) | privkeysInfo.permission( TQFileInfo::WriteOther ) |
privkeysInfo.permission( TQFileInfo::ExeOther ) ){ privkeysInfo.permission( TQFileInfo::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.local8Bit(), 0600);
} }
} }
@ -1065,8 +1067,8 @@ KeyGenThread::KeyGenThread( TQString accountname, TQString protocol ){
void KeyGenThread::run() void KeyGenThread::run()
{ {
kdDebug() << "Creating private key... Storing to: " + TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true)) + "privkeys" << endl; kdDebug() << "Creating private key... Storing to: " + TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true)) + "privkeys" << endl;
otrl_privkey_generate(OtrlChatInterface::self()->getUserstate(), TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys", accountname, protocol); otrl_privkey_generate(OtrlChatInterface::self()->getUserstate(), TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("privkeys").local8Bit(), accountname.latin1(), protocol.latin1());
OtrlChatInterface::self()->checkFilePermissions( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" ); OtrlChatInterface::self()->checkFilePermissions( TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("privkeys").local8Bit() );
} }
#include "otrlchatinterface.moc" #include "otrlchatinterface.moc"

@ -83,7 +83,7 @@ bool OtrlConfInterface::hasPrivFingerprint( TQString accountId, TQString protoco
void OtrlConfInterface::generateNewPrivKey( TQString accountId, TQString protocol ){ void OtrlConfInterface::generateNewPrivKey( TQString accountId, TQString protocol ){
PrivKeyPopup *popup = new PrivKeyPopup( preferencesDialog, i18n("Generating private key"), TQt::WType_Dialog | TQt::WStyle_StaysOnTop ); PrivKeyPopup *popup = new PrivKeyPopup( preferencesDialog, i18n("Generating private key").utf8(), TQt::WType_Dialog | TQt::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();
@ -115,7 +115,7 @@ TQValueList<TQString[5]> OtrlConfInterface::readAllFingerprints(){
entry[1] = i18n("Unused"); entry[1] = i18n("Unused");
} else { } else {
if (context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) { if (context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
if (context->active_fingerprint->trust && context->active_fingerprint->trust[0] != NULL) { if (context->active_fingerprint->trust && context->active_fingerprint->trust[0] != 0) {
entry[1] = i18n("Private"); entry[1] = i18n("Private");
} else { } else {
entry[1] = i18n("Unverified"); entry[1] = i18n("Unverified");
@ -149,7 +149,7 @@ void OtrlConfInterface::verifyFingerprint( TQString strFingerprint, 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, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
} else { } else {
kdDebug() << "could not find fingerprint" << endl; kdDebug() << "could not find fingerprint" << endl;
} }
@ -158,7 +158,7 @@ void OtrlConfInterface::verifyFingerprint( TQString strFingerprint, bool trust )
bool OtrlConfInterface::isVerified( TQString strFingerprint ){ bool OtrlConfInterface::isVerified( TQString strFingerprint ){
Fingerprint *fingerprint; Fingerprint *fingerprint;
fingerprint = findFingerprint( strFingerprint ); fingerprint = findFingerprint( strFingerprint.latin1() );
if( fingerprint->trust && fingerprint->trust[0] ){ if( fingerprint->trust && fingerprint->trust[0] ){
kdDebug() << "found trust" << endl; kdDebug() << "found trust" << endl;
@ -175,7 +175,7 @@ void OtrlConfInterface::forgetFingerprint( TQString strFingerprint ){
fingerprint = findFingerprint( strFingerprint ); fingerprint = findFingerprint( strFingerprint );
otrl_context_forget_fingerprint( fingerprint, 1 ); otrl_context_forget_fingerprint( fingerprint, 1 );
otrl_privkey_write_fingerprints( userstate, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" ); otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
} }
Fingerprint *OtrlConfInterface::findFingerprint( TQString strFingerprint ){ Fingerprint *OtrlConfInterface::findFingerprint( TQString strFingerprint ){

@ -74,7 +74,7 @@ void SMPPopup::openHelp()
} }
void SMPPopup::manualAuth(){ void SMPPopup::manualAuth(){
VerifyPopup *vfPopup = new VerifyPopup(this, i18n("Verify Fingerprint"), session); VerifyPopup *vfPopup = new VerifyPopup(this, i18n("Verify Fingerprint").utf8(), session);
vfPopup->show(); vfPopup->show();
this->close(); this->close();
} }

Loading…
Cancel
Save