Signed-off-by: gregory guy <gregory-tde@laposte.net>feat/add_kopete-otr_plugin
@ -0,0 +1,2 @@
|
||||
/* Defined if libotr >= 4.0.0 */
|
||||
#cmakedefine HAVE_LIBOTR_0400 1
|
@ -0,0 +1,3 @@
|
||||
##### create translation templates ##############
|
||||
|
||||
tde_l10n_create_template( "messages/kopete_otr" )
|
@ -0,0 +1,125 @@
|
||||
add_subdirectory( pics )
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${TDE_INCLUDE_DIR}
|
||||
${TQT_INCLUDE_DIRS}
|
||||
${LIBOTR_INCLUDE_DIRS}
|
||||
${CMAKE_BINARY_DIR}/kopete
|
||||
${CMAKE_SOURCE_DIR}/kopete/libkopete
|
||||
${CMAKE_SOURCE_DIR}/kopete/libkopete/ui
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${TQT_LIBRARY_DIRS}
|
||||
${TDE_LIB_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### kotr_kcfgc (static)
|
||||
|
||||
tde_add_library( kotr_kcfgc STATIC_PIC AUTOMOC
|
||||
|
||||
SOURCES
|
||||
kopete_otr.kcfgc
|
||||
)
|
||||
|
||||
|
||||
##### kotr (shared)
|
||||
|
||||
tde_add_library( kotr SHARED AUTOMOC
|
||||
|
||||
SOURCES
|
||||
otrplugin.cpp
|
||||
otrguiclient.cpp
|
||||
otrlchatinterface.cpp
|
||||
otrlconfinterface.cpp
|
||||
privkeypopup.cpp
|
||||
privkeypopupui.ui
|
||||
smppopup.cpp
|
||||
smppopupui.ui
|
||||
verifypopup.cpp
|
||||
verifypopupui.ui
|
||||
|
||||
LINK
|
||||
kotr_kcfgc-static
|
||||
tdecore-shared
|
||||
tdeui-shared
|
||||
tdeio-shared
|
||||
kopete-shared
|
||||
${LIBOTR_LIBRARIES}
|
||||
|
||||
VERSION 0.0.0
|
||||
|
||||
DESTINATION ${LIB_INSTALL_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### kcm_kopete_otr (kpart)
|
||||
|
||||
tde_add_kpart( kcm_kopete_otr AUTOMOC
|
||||
|
||||
SOURCES
|
||||
otrpreferences.cpp
|
||||
otrprefs.ui
|
||||
LINK
|
||||
kotr_kcfgc-static
|
||||
kotr-shared
|
||||
tdecore-shared
|
||||
tdeui-shared
|
||||
tdehtml-shared
|
||||
kopete-shared
|
||||
${LIBOTR_LIBRARIES}
|
||||
|
||||
DESTINATION ${PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### kopete_otr (kpart)
|
||||
|
||||
tde_add_kpart( kopete_otr AUTOMOC
|
||||
|
||||
SOURCES
|
||||
otrplugin-factory.cpp
|
||||
|
||||
LINK
|
||||
kotr-shared
|
||||
tdecore-shared
|
||||
tdeui-shared
|
||||
tdehtml-shared
|
||||
kopete-shared
|
||||
${LIBOTR_LIBRARIES}
|
||||
|
||||
DESTINATION ${PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### other data
|
||||
|
||||
install(
|
||||
FILES otrchatui.rc otrui.rc
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kopete_otr
|
||||
)
|
||||
|
||||
install(
|
||||
FILES kopete_otr.kcfg
|
||||
DESTINATION ${KCFG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
|
||||
#### desktop files
|
||||
|
||||
tde_create_translated_desktop(
|
||||
SOURCE kopete_otr.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}
|
||||
PO_DIR kopete_otr-desktops
|
||||
)
|
||||
|
||||
tde_create_translated_desktop(
|
||||
SOURCE kopete_otr_config.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/tdeconfiguredialog
|
||||
PO_DIR kopete_otr-desktops
|
||||
)
|
@ -0,0 +1,20 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Type=Service
|
||||
X-Kopete-Version=1000900
|
||||
Icon=kopete_otr
|
||||
X-TDE-ServiceTypes=Kopete/Plugin
|
||||
X-TDE-Library=kopete_otr
|
||||
X-TDE-PluginInfo-Author=Michael Zanetti
|
||||
X-TDE-PluginInfo-Email=michael_zanetti@gmx.net
|
||||
X-TDE-PluginInfo-Name=kopete_otr
|
||||
X-TDE-PluginInfo-Version=0.7
|
||||
X-TDE-PluginInfo-Website=http://kopete-otr.follefuder.org
|
||||
X-TDE-PluginInfo-Category=Plugins
|
||||
X-TDE-PluginInfo-Depends=
|
||||
X-TDE-PluginInfo-License=GPL
|
||||
X-TDE-PluginInfo-EnabledByDefault=false
|
||||
Comment=Encrypt chat sessions with Off-The-Record encryption
|
||||
Comment[de]=Verschlüsselt Chat-Sitzungen mit Off-The-Record Verschlüsselung
|
||||
Name=OTR
|
||||
Name[de]=OTR
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg>
|
||||
<kcfgfile name="kopete_otr"/>
|
||||
<group name="Policy">
|
||||
<entry name="rbAlways" type="Bool">
|
||||
<label>Always encrypt outgoing messages</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="rbOpportunistic" type="Bool">
|
||||
<label>Automatically encrypt mesages if the other side supports OTR</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="rbManual" type="Bool">
|
||||
<label>Encrypt mesages if the other side requests an OTR connection</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="rbNever" type="Bool">
|
||||
<label>Never encrypt outgoing messages</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
@ -0,0 +1,7 @@
|
||||
File=kopete_otr.kcfg
|
||||
ClassName=KopeteOtrKcfg
|
||||
Singleton=true
|
||||
Mutators=true
|
||||
MemberVariables=private
|
||||
ItemAccessors=true
|
||||
GlobalEnums=true
|
@ -0,0 +1,16 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Type=Service
|
||||
Icon=kopete_otr
|
||||
X-TDE-ServiceTypes=TDECModule
|
||||
|
||||
X-TDE-ModuleType=Library
|
||||
X-TDE-Library=kopete_otr
|
||||
X-TDE-FactoryName=OTRPreferencesFactory
|
||||
X-TDE-ParentApp=kopete_otr
|
||||
X-TDE-ParentComponents=kopete_otr
|
||||
|
||||
Comment=Encrypt chat sessions with Off-The-Record encryption
|
||||
Comment[de]=Verschlüsselt Chat-Sitzungen mit Off-The-Record Verschlüsselung
|
||||
Name=OTR
|
||||
Name[de]=OTR
|
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="kopete_otr" version="1">
|
||||
<MenuBar>
|
||||
<Menu name="tools"><text>&Tools</text>
|
||||
<Menu name="otr_menu"><text>OTR Encryption</text>
|
||||
<Action name="enable_otr" />
|
||||
<Action name="disable_otr" />
|
||||
<Action name="verify_fingerprint"/>
|
||||
</Menu>
|
||||
</Menu>
|
||||
</MenuBar>
|
||||
|
||||
<ToolBar name="mainToolBar">
|
||||
<text>OTR Encryption</text>
|
||||
<Separator name="separator_0" />
|
||||
<Action name="otr_settings" />
|
||||
<Separator name="separator_0" />
|
||||
</ToolBar>
|
||||
</kpartgui>
|
@ -0,0 +1,129 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tdeaction.h>
|
||||
#include <tdelocale.h>
|
||||
#include <tdeactionclasses.h>
|
||||
#include <kopetechatsession.h>
|
||||
#include <kopeteview.h>
|
||||
#include <kopetemessage.h>
|
||||
#include <kdebug.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <tdemessagebox.h>
|
||||
|
||||
|
||||
#include "otrguiclient.h"
|
||||
#include "otrplugin.h"
|
||||
|
||||
/**
|
||||
* @author Frank Scheffold
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
|
||||
OtrGUIClient::OtrGUIClient( Kopete::ChatSession *parent, const char *name )
|
||||
: TQObject( parent, name ), KXMLGUIClient( parent )
|
||||
{
|
||||
setInstance( OTRPlugin::plugin()->instance() );
|
||||
|
||||
connect( OTRPlugin::plugin(),
|
||||
TQT_SIGNAL( destroyed( TQObject * ) ), this,
|
||||
TQT_SLOT( deleteLater() )
|
||||
|
||||
);
|
||||
|
||||
connect(this, TQT_SIGNAL( signalOtrChatsession(Kopete::ChatSession*, bool) ), OTRPlugin::plugin(), TQT_SLOT(slotEnableOtr(Kopete::ChatSession*, bool)));
|
||||
|
||||
connect( OTRPlugin::plugin(), TQT_SIGNAL( goneSecure( Kopete::ChatSession *, int ) ),
|
||||
this, TQT_SLOT( encryptionEnabled( Kopete::ChatSession *, int ) ) );
|
||||
|
||||
connect( this, TQT_SIGNAL( signalVerifyFingerprint( Kopete::ChatSession * ) ), OTRPlugin::plugin(), TQT_SLOT(slotVerifyFingerprint( Kopete::ChatSession * )) );
|
||||
|
||||
m_manager = parent;
|
||||
otrActionMenu = new TDEActionMenu(i18n("OTR Settings"),"otr_disabled", actionCollection(), "otr_settings");
|
||||
otrActionMenu->setDelayed( false );
|
||||
actionEnableOtr = new TDEAction(i18n( "Start OTR session" ), "otr_private", 0,this,TQT_SLOT(slotEnableOtr()),actionCollection(), "enable_otr");
|
||||
actionDisableOtr = new TDEAction(i18n("End OTR session"), "otr_disabled",0, this,TQT_SLOT(slotDisableOtr()), actionCollection(), "disable_otr");
|
||||
actionVerifyFingerprint = new TDEAction(i18n("Authenticate Contact"), "signature",0, this,TQT_SLOT(slotVerifyFingerprint()), actionCollection(), "verify_fingerprint");
|
||||
|
||||
otrActionMenu->insert(actionEnableOtr);
|
||||
otrActionMenu->insert(actionDisableOtr);
|
||||
otrActionMenu->insert(actionVerifyFingerprint);
|
||||
|
||||
setXMLFile("otrchatui.rc");
|
||||
|
||||
encryptionEnabled( parent, OtrlChatInterface::self()->privState(parent) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
OtrGUIClient::~OtrGUIClient()
|
||||
{
|
||||
}
|
||||
|
||||
void OtrGUIClient::slotEnableOtr()
|
||||
{
|
||||
emit signalOtrChatsession( m_manager, true );
|
||||
}
|
||||
void OtrGUIClient::slotDisableOtr()
|
||||
{
|
||||
emit signalOtrChatsession( m_manager, false );
|
||||
}
|
||||
|
||||
void OtrGUIClient::slotVerifyFingerprint(){
|
||||
emit signalVerifyFingerprint( m_manager );
|
||||
}
|
||||
|
||||
void OtrGUIClient::encryptionEnabled(Kopete::ChatSession *session, int state){
|
||||
if( session == m_manager ){
|
||||
switch(state){
|
||||
case 0:
|
||||
otrActionMenu->setIcon("otr_disabled");
|
||||
actionEnableOtr->setText( i18n("Start OTR session") );
|
||||
actionDisableOtr->setEnabled(false);
|
||||
actionVerifyFingerprint->setEnabled(false);
|
||||
break;
|
||||
case 1:
|
||||
otrActionMenu->setIcon("otr_unverified");
|
||||
actionEnableOtr->setText( i18n("Refresh OTR session") );
|
||||
actionDisableOtr->setEnabled(true);
|
||||
actionVerifyFingerprint->setEnabled(true);
|
||||
break;
|
||||
case 2:
|
||||
otrActionMenu->setIcon("otr_private");
|
||||
actionEnableOtr->setText( i18n("Refresh OTR session") );
|
||||
actionDisableOtr->setEnabled(true);
|
||||
actionVerifyFingerprint->setEnabled(true);
|
||||
break;
|
||||
case 3:
|
||||
otrActionMenu->setIcon("otr_finished");
|
||||
actionEnableOtr->setText( i18n("Start OTR session") );
|
||||
actionDisableOtr->setEnabled(true);
|
||||
actionVerifyFingerprint->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "otrguiclient.moc"
|
@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef OTRGUICLIENT_H
|
||||
#define OTRGUICLIENT_H
|
||||
|
||||
#include <tqobject.h>
|
||||
#include <kxmlguiclient.h>
|
||||
|
||||
//#include <tdeio/job.h>
|
||||
|
||||
#include <tdeglobal.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include <kopetemessage.h>
|
||||
#include <kopeteplugin.h>
|
||||
|
||||
|
||||
class TDEActionMenu;
|
||||
class TDEAction;
|
||||
|
||||
namespace Kopete { class ChatSession; }
|
||||
|
||||
/**
|
||||
* @author Frank Scheffold
|
||||
*/
|
||||
|
||||
|
||||
class OtrGUIClient : public TQObject, public KXMLGUIClient
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
OtrGUIClient( Kopete::ChatSession *parent, const char *name=0L );
|
||||
~OtrGUIClient();
|
||||
|
||||
|
||||
private:
|
||||
Kopete::ChatSession *m_manager;
|
||||
TDEActionMenu *otrActionMenu;
|
||||
TDEAction *actionEnableOtr;
|
||||
TDEAction *actionDisableOtr;
|
||||
TDEAction *actionVerifyFingerprint;
|
||||
|
||||
private slots:
|
||||
void slotEnableOtr();
|
||||
void slotDisableOtr();
|
||||
void encryptionEnabled( Kopete::ChatSession* session, int state );
|
||||
void slotVerifyFingerprint();
|
||||
|
||||
signals:
|
||||
void signalOtrChatsession( Kopete::ChatSession* session, bool enable );
|
||||
void signalVerifyFingerprint( Kopete::ChatSession *session );
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OTRLCHATINTERFACE_H
|
||||
#define OTRLCHATINTERFACE_H
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
#include <tqstring.h>
|
||||
#include <tqptrlist.h>
|
||||
#include <tqvaluelist.h>
|
||||
#include <tqthread.h>
|
||||
#include <tqmutex.h>
|
||||
#include <tqtimer.h>
|
||||
|
||||
#include <kopetechatsession.h>
|
||||
|
||||
extern "C" {
|
||||
#include <libotr/privkey.h>
|
||||
#include <libotr/proto.h>
|
||||
#include <libotr/message.h>
|
||||
#include <libotr/userstate.h>
|
||||
}
|
||||
|
||||
class KDE_EXPORT OtrlChatInterface: public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~OtrlChatInterface();
|
||||
static OtrlChatInterface *self();
|
||||
|
||||
int decryptMessage( TQString *msg, TQString accountId, TQString protocol, TQString contactId, Kopete::ChatSession *chatSession );
|
||||
TQString encryptMessage( TQString msg, TQString accountId,
|
||||
TQString protocol, TQString contactId , Kopete::ChatSession *chatSession );
|
||||
TQString getDefaultQuery( TQString accountId );
|
||||
void disconnectSession( Kopete::ChatSession *chatSession );
|
||||
void setPolicy( OtrlPolicy policy );
|
||||
bool shouldDiscard( TQString message );
|
||||
OtrlUserState getUserstate();
|
||||
int privState( Kopete::ChatSession *session );
|
||||
TQString formatContact(TQString contactId);
|
||||
bool isVerified( Kopete::ChatSession *session );
|
||||
void updateKeyfile( Kopete::Account *account );
|
||||
void checkFilePermissions( TQString file );
|
||||
// bool verifyQuestion( Kopete::ChatSession *session, TQString fingerprint );
|
||||
TQString findActiveFingerprint( Kopete::ChatSession *session );
|
||||
void verifyFingerprint( Kopete::ChatSession *session );
|
||||
void abortSMP( ConnContext *context, Kopete::ChatSession *session );
|
||||
void respondSMP( ConnContext *context, Kopete::ChatSession *session, TQString secret, bool initiate );
|
||||
void respondSMPQ( ConnContext *context, Kopete::ChatSession *session, TQString question, TQString secret, bool initiate );
|
||||
void setTrust( Kopete::ChatSession *session, bool trust );
|
||||
void forwardSecrecyTimerStart(int interval);
|
||||
void forwardSecrecyTimerStop();
|
||||
|
||||
private slots:
|
||||
void otrlMessagePoll();
|
||||
|
||||
private:
|
||||
OtrlChatInterface();
|
||||
static OtrlChatInterface *mSelf;
|
||||
Fingerprint *findFingerprint( TQString username );
|
||||
TQTimer m_forwardSecrecyTimer;
|
||||
};
|
||||
|
||||
class KeyGenThread : public TQThread {
|
||||
|
||||
private:
|
||||
TQString accountname;
|
||||
TQString protocol;
|
||||
|
||||
public:
|
||||
KeyGenThread( TQString accountname, TQString protocol );
|
||||
virtual void run();
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,236 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tqapplication.h>
|
||||
#include <tqeventloop.h>
|
||||
|
||||
#include <kopetechatsession.h>
|
||||
#include <kopeteaccount.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <tdemessagebox.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <tdelocale.h>
|
||||
#include <kanimwidget.h>
|
||||
|
||||
|
||||
#include "otrlconfinterface.h"
|
||||
#include "otrlchatinterface.h"
|
||||
#include "otrplugin.h"
|
||||
#include "privkeypopup.h"
|
||||
|
||||
|
||||
|
||||
/*********************** Konstruktor/Destruktor **********************/
|
||||
|
||||
OtrlConfInterface::OtrlConfInterface( TQWidget *preferencesDialog ){
|
||||
|
||||
this->preferencesDialog = preferencesDialog;
|
||||
|
||||
OTRL_INIT;
|
||||
|
||||
userstate = OtrlChatInterface::self()->getUserstate();
|
||||
|
||||
kdDebug() << "OtrlConfInterface created" << endl;
|
||||
}
|
||||
|
||||
OtrlConfInterface::~ OtrlConfInterface(){
|
||||
otrl_userstate_free(userstate);
|
||||
}
|
||||
|
||||
/*********************** Functions for kcm module ************************/
|
||||
|
||||
TQString OtrlConfInterface::getPrivFingerprint( TQString accountId, TQString protocol){
|
||||
// if (otrl_privkey_read(userstate, TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkey" ) == 0){
|
||||
char fingerprint[45];
|
||||
if( otrl_privkey_fingerprint( userstate, fingerprint, accountId.latin1(), protocol.latin1()) != 0 ){
|
||||
return fingerprint;
|
||||
}
|
||||
// }
|
||||
return i18n("No fingerprint present.");
|
||||
}
|
||||
|
||||
|
||||
bool OtrlConfInterface::hasPrivFingerprint( TQString accountId, TQString protocol ){
|
||||
char fingerprint[45];
|
||||
if( otrl_privkey_fingerprint( userstate, fingerprint, accountId.latin1(), protocol.latin1() ) != 0 ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void OtrlConfInterface::generateNewPrivKey( TQString accountId, TQString protocol ){
|
||||
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" );
|
||||
anim->start();
|
||||
anim->show();
|
||||
|
||||
popup->setCloseLock( true );
|
||||
popup->show();
|
||||
KeyGenThread *keyGenThread = new KeyGenThread ( accountId, protocol );
|
||||
keyGenThread->start();
|
||||
while( !keyGenThread->wait(100) ){
|
||||
tqApp->eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers, 100);
|
||||
}
|
||||
popup->setCloseLock( false );
|
||||
popup->close();
|
||||
}
|
||||
|
||||
TQValueList<TQStringList> OtrlConfInterface::readAllFingerprints(){
|
||||
ConnContext *context;
|
||||
Fingerprint *fingerprint;
|
||||
TQStringList entry;
|
||||
char hash[45];
|
||||
TQValueList<TQStringList> list;
|
||||
|
||||
for( context = userstate->context_root; context != NULL; context = context->next ){
|
||||
fingerprint = context->fingerprint_root.next;
|
||||
while( fingerprint ){
|
||||
entry.clear();
|
||||
entry << context->username;
|
||||
|
||||
if( ( context->msgstate == OTRL_MSGSTATE_ENCRYPTED ) && ( context->active_fingerprint != fingerprint ) ){
|
||||
entry << i18n("Unused");
|
||||
} else {
|
||||
if (context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
|
||||
if (context->active_fingerprint->trust && context->active_fingerprint->trust[0] != 0) {
|
||||
entry << i18n("Private");
|
||||
} else {
|
||||
entry << i18n("Unverified");
|
||||
}
|
||||
} else if (context && context->msgstate == OTRL_MSGSTATE_FINISHED) {
|
||||
entry << i18n("Finished");
|
||||
} else {
|
||||
entry << i18n("Not Private");
|
||||
}
|
||||
}
|
||||
entry << ((fingerprint->trust && fingerprint->trust[0]) ? i18n("Yes") : i18n("No"));
|
||||
otrl_privkey_hash_to_human( hash, fingerprint->fingerprint );
|
||||
entry << hash;
|
||||
entry << context->protocol;
|
||||
list << entry;
|
||||
fingerprint = fingerprint->next;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void OtrlConfInterface::verifyFingerprint( TQString strFingerprint, bool trust ){
|
||||
Fingerprint *fingerprint;
|
||||
|
||||
fingerprint = findFingerprint( strFingerprint );
|
||||
|
||||
if( fingerprint != 0 ){
|
||||
if( trust ){
|
||||
otrl_context_set_trust( fingerprint, "verified" );
|
||||
} else {
|
||||
otrl_context_set_trust( fingerprint, NULL );
|
||||
}
|
||||
kdDebug() << "Writing fingerprints" << endl;
|
||||
otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
|
||||
} else {
|
||||
kdDebug() << "could not find fingerprint" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool OtrlConfInterface::isVerified( TQString strFingerprint ){
|
||||
Fingerprint *fingerprint;
|
||||
|
||||
fingerprint = findFingerprint( strFingerprint.latin1() );
|
||||
|
||||
if( fingerprint->trust && fingerprint->trust[0] ){
|
||||
kdDebug() << "found trust" << endl;
|
||||
return true;
|
||||
} else {
|
||||
kdDebug() << "not trusted" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OtrlConfInterface::forgetFingerprint( TQString strFingerprint ){
|
||||
Fingerprint *fingerprint;
|
||||
|
||||
fingerprint = findFingerprint( strFingerprint );
|
||||
otrl_context_forget_fingerprint( fingerprint, 1 );
|
||||
otrl_privkey_write_fingerprints( userstate, TQString("%1%2").arg(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )).arg("fingerprints").local8Bit() );
|
||||
}
|
||||
|
||||
Fingerprint *OtrlConfInterface::findFingerprint( TQString strFingerprint ){
|
||||
// const char *cFingerprint = ;
|
||||
// Fingerprint *fingerprintRoot = &userstate->context_root->fingerprint_root;
|
||||
ConnContext *context;
|
||||
Fingerprint *fingerprint;
|
||||
Fingerprint *foundFingerprint = NULL;
|
||||
char hash[45];
|
||||
|
||||
for( context = userstate->context_root; context != NULL; context = context->next ){
|
||||
fingerprint = context->fingerprint_root.next;
|
||||
while( fingerprint ){
|
||||
otrl_privkey_hash_to_human(hash, fingerprint->fingerprint);
|
||||
if( strcmp( hash, strFingerprint.latin1()) == 0 ){
|
||||
foundFingerprint = fingerprint;
|
||||
}
|
||||
fingerprint = fingerprint->next;
|
||||
}
|
||||
}
|
||||
return foundFingerprint;
|
||||
}
|
||||
|
||||
bool OtrlConfInterface::isEncrypted( TQString strFingerprint ){
|
||||
Fingerprint *fingerprint;
|
||||
Fingerprint *tmpFingerprint;
|
||||
Fingerprint *foundFingerprint;
|
||||
ConnContext *context;
|
||||
ConnContext *foundContext = NULL;
|
||||
|
||||
context = userstate->context_root;
|
||||
|
||||
fingerprint = findFingerprint( strFingerprint );
|
||||
for( context = userstate->context_root; context != NULL; context = context->next ){
|
||||
tmpFingerprint = context->fingerprint_root.next;
|
||||
while( tmpFingerprint ){
|
||||
if( tmpFingerprint == fingerprint ){
|
||||
kdDebug() << "Found context" << endl;
|
||||
foundContext = context;
|
||||
foundFingerprint = tmpFingerprint;
|
||||
}
|
||||
tmpFingerprint = tmpFingerprint->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( foundContext && foundContext->msgstate != OTRL_MSGSTATE_ENCRYPTED ){
|
||||
return false;
|
||||
} else if( foundContext && foundFingerprint && foundContext->active_fingerprint == foundFingerprint ){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OTRLCONFINTERFACE_H
|
||||
#define OTRLCONFINTERFACE_H
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
#include <tqstring.h>
|
||||
#include <tqptrlist.h>
|
||||
#include <tqvaluelist.h>
|
||||
#include <tqthread.h>
|
||||
|
||||
#include <kopetechatsession.h>
|
||||
|
||||
extern "C" {
|
||||
#include <libotr/privkey.h>
|
||||
#include <libotr/proto.h>
|
||||
#include <libotr/message.h>
|
||||
#include <libotr/userstate.h>
|
||||
#include <libotr/context.h>
|
||||
}
|
||||
|
||||
class KDE_EXPORT OtrlConfInterface
|
||||
{
|
||||
|
||||
public:
|
||||
~OtrlConfInterface();
|
||||
OtrlConfInterface( TQWidget *preferencesDialog );
|
||||
|
||||
TQString getPrivFingerprint( TQString accountId, TQString protocol );
|
||||
void generateNewPrivKey( TQString accountId, TQString protocol );
|
||||
TQValueList<TQStringList> readAllFingerprints();
|
||||
bool hasPrivFingerprint( TQString accountId, TQString protocol);
|
||||
void forgetFingerprint( TQString strFingerprint );
|
||||
void verifyFingerprint( TQString strFingerprint, bool trust );
|
||||
bool isVerified( TQString strFingerprint );
|
||||
bool isEncrypted( TQString strFingerprint );
|
||||
|
||||
private:
|
||||
OtrlUserState userstate;
|
||||
TQWidget *preferencesDialog;
|
||||
|
||||
Fingerprint *findFingerprint( TQString strFingerprint );
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2021 by Slávek Banko *
|
||||
* *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kgenericfactory.h>
|
||||
#include <tdeaboutdata.h>
|
||||
|
||||
#include "otrplugin-factory.h"
|
||||
#include "otrplugin.h"
|
||||
|
||||
|
||||
// typedef KGenericFactory<OTRPlugin> OTRPluginFactory;
|
||||
static const TDEAboutData aboutdata("kopete_otr", I18N_NOOP("OTR") , "0.7" );
|
||||
K_EXPORT_COMPONENT_FACTORY( kopete_otr, OTRPluginFactory( &aboutdata ) )
|
||||
|
||||
TDEInstance *OTRPluginFactory::s_instance = 0;
|
||||
|
||||
OTRPluginFactory::OTRPluginFactory( const TDEAboutData *aboutdata )
|
||||
{
|
||||
s_instance = new TDEInstance( aboutdata );
|
||||
}
|
||||
|
||||
OTRPluginFactory::~OTRPluginFactory()
|
||||
{
|
||||
delete s_instance;
|
||||
}
|
||||
|
||||
KParts::Part *OTRPluginFactory::createPartObject( TQWidget * /*parentWidget*/,
|
||||
const char * /*widgetName*/,
|
||||
TQObject *parent,
|
||||
const char *name,
|
||||
const char * /*className*/,
|
||||
const TQStringList & args )
|
||||
{
|
||||
return (KParts::Part*) new OTRPlugin( instance(), parent, name, args);
|
||||
}
|
||||
|
||||
#include "otrplugin-factory.moc"
|
@ -0,0 +1,45 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2021 by Slávek Banko *
|
||||
* *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(OTRPLUGIN_FACTORY_H)
|
||||
#define OTRPLUGIN_FACTORY_H
|
||||
|
||||
#include <tdeparts/factory.h>
|
||||
|
||||
|
||||
class OTRPluginFactory : public KParts::Factory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OTRPluginFactory( const TDEAboutData* );
|
||||
virtual ~OTRPluginFactory();
|
||||
|
||||
virtual KParts::Part *createPartObject( TQWidget *parentWidget, const char *widgetName,
|
||||
TQObject *parent, const char *name,
|
||||
const char *className, const TQStringList &args );
|
||||
|
||||
static TDEInstance *instance() { return s_instance; }
|
||||
|
||||
private:
|
||||
static TDEInstance *s_instance;
|
||||
};
|
||||
|
||||
#endif /* OTRPLUGIN_FACTORY_H */
|
@ -0,0 +1,339 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tqstylesheet.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqregexp.h>
|
||||
#include <tqfile.h>
|
||||
#include <tqcolor.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <tdeaction.h>
|
||||
#include <tdeactionclasses.h>
|
||||
#include <tdepopupmenu.h>
|
||||
#include <tdeconfig.h>
|
||||
#include <kgenericfactory.h>
|
||||
#include <tdeversion.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <tdemessagebox.h>
|
||||
|
||||
#include <kopetemetacontact.h>
|
||||
#include <kopetecontactlist.h>
|
||||
#include <kopetechatsessionmanager.h>
|
||||
#include <kopetesimplemessagehandler.h>
|
||||
#include <kopeteuiglobal.h>
|
||||
#include <kopetecontact.h>
|
||||
#include <kopetemessage.h>
|
||||
#include <kopeteaccount.h>
|
||||
#include <kopeteaccountmanager.h>
|
||||
#include <kopetemessageevent.h>
|
||||
#include <kopeteprotocol.h>
|
||||
|
||||
#include "otrplugin.h"
|
||||
#include "otrguiclient.h"
|
||||
#include "otrlchatinterface.h"
|
||||
#include "kopete_otr.h"
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
|
||||
OTRPlugin::OTRPlugin( TDEInstance *instance, TQObject *parent, const char *name, const TQStringList & /* args */ )
|
||||
: Kopete::Plugin( instance, parent, name )
|
||||
{
|
||||
if( !pluginStatic_ )
|
||||
pluginStatic_=this;
|
||||
|
||||
m_inboundHandler = new OtrMessageHandlerFactory(this);
|
||||
|
||||
connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToSend( Kopete::Message & ) ),
|
||||
TQT_SLOT( slotOutgoingMessage( Kopete::Message & ) ) );
|
||||
// connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToDisplay( Kopete::Message & ) ),
|
||||
// this, TQT_SLOT( slotIncomingMessage( Kopete::Message & ) ) );
|
||||
|
||||
connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( chatSessionCreated( Kopete::ChatSession * ) ),
|
||||
this, TQT_SLOT( slotNewChatSessionWindow( Kopete::ChatSession * ) ) );
|
||||
TQObject::connect( this, TQT_SIGNAL( settingsChanged() ), this, TQT_SLOT( slotSettingsChanged() ) );
|
||||
|
||||
|
||||
|
||||
//initialize the otrlib and create the interface object
|
||||
otrlChatInterface = OtrlChatInterface::self();
|
||||
|
||||
//update key files when an account is ready to use
|
||||
if( TQFile::exists( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "privkey" ) &&
|
||||
!TQFile::exists( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "privkeys" ) ){
|
||||
kdDebug() << "Detected old format keyfile. Doing updates!" << endl;
|
||||
kdDebug() << "Reading old keyfile..." << endl;
|
||||
TQFile fpold( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkey" );
|
||||
TQString line;
|
||||
TQString file;
|
||||
if( fpold.open( IO_ReadWrite ) ){
|
||||
while( fpold.readLine( line, 100 ) != -1){
|
||||
file.append( line );
|
||||
}
|
||||
}
|
||||
kdDebug() << "Writing new keyfile" << endl;
|
||||
TQFile fpnew( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkeys" );
|
||||
fpnew.open( IO_ReadWrite );
|
||||
fpnew.writeBlock( file.latin1(), file.length() );
|
||||
fpnew.close();
|
||||
kdDebug() << "Writing backup for old keyfile" << endl;
|
||||
TQFile fpbup( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "privkey.old" );
|
||||
fpbup.open( IO_ReadWrite );
|
||||
fpbup.writeBlock( file.latin1(), file.length() );
|
||||
fpbup.close();
|
||||
kdDebug() << "Deleting old keyfile" << endl;
|
||||
fpold.remove();
|
||||
|
||||
kdDebug() << "Reading old fingerprintsfile..." << endl;
|
||||
TQFile fpfingerprintsold( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints" );
|
||||
line = "";
|
||||
file = "";
|
||||
if( fpfingerprintsold.open( IO_ReadWrite ) ){
|
||||
while( fpfingerprintsold.readLine( line, 100 ) != -1){
|
||||
file.append( line );
|
||||
}
|
||||
}
|
||||
kdDebug() << "Writing backup for old fingerprintsfile" << endl;
|
||||
TQFile fpfingerprintsbup( TQString(TDEGlobal::dirs()->saveLocation("data", "kopete_otr/", true )) + "fingerprints.old" );
|
||||
fpfingerprintsbup.open( IO_ReadWrite );
|
||||
fpfingerprintsbup.writeBlock( file.latin1(), file.length() );
|
||||
fpfingerprintsbup.close();
|
||||
|
||||
kdDebug() << "Waiting for accounts to update keyfile format" << endl;
|
||||
connect( Kopete::AccountManager::self(), TQT_SIGNAL( accountRegistered( Kopete::Account * ) ),
|
||||
this, TQT_SLOT( accountReady( Kopete::Account * ) ) );
|
||||
}
|
||||
|
||||
// Checking file Permissions
|
||||
OtrlChatInterface::self()->checkFilePermissions( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "privkeys" );
|
||||
OtrlChatInterface::self()->checkFilePermissions( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "fingerprints" );
|
||||
// Check also file permissions for eventuallly old beckup files
|
||||
OtrlChatInterface::self()->checkFilePermissions( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "privkey.old" );
|
||||
OtrlChatInterface::self()->checkFilePermissions( TQString( TDEGlobal::dirs()->saveLocation( "data", "kopete_otr/", true ) ) + "fingerprints.old" );
|
||||
|
||||
//setting the policy
|
||||
slotSettingsChanged();
|
||||
|
||||
//adding menu to contaclists menubar and contacts popup menu
|
||||
TQStringList policies;
|
||||
policies << i18n("&Default") << i18n("Al&ways") << i18n("&Opportunistic") << i18n("&Manual") << i18n("Ne&ver");
|
||||
otrPolicyMenu = new TDESelectAction( i18n( "&OTR Policy" ), TQString::fromLatin1("kopete_otr"), 0, actionCollection(), "otr_policy" );
|
||||
otrPolicyMenu->setItems( policies );
|
||||
otrPolicyMenu->popupMenu()->insertSeparator( 1 );
|
||||
otrPolicyMenu->setEnabled( false );
|
||||
connect( otrPolicyMenu, TQT_SIGNAL( activated() ), this, TQT_SLOT( slotSetPolicy() ) );
|
||||
connect( Kopete::ContactList::self(), TQT_SIGNAL( metaContactSelected( bool ) ), this, TQT_SLOT( slotSelectionChanged( bool ) ) );
|
||||
|
||||
|
||||
setXMLFile( "otrui.rc" );
|
||||
|
||||
|
||||
|
||||
//Add GUI action to all already existing kmm
|
||||
// (if the plugin is launched when kopete already runing)
|
||||
TQValueList<Kopete::ChatSession*> sessions =
|
||||
Kopete::ChatSessionManager::self()->sessions();
|
||||
TQValueListIterator<Kopete::ChatSession*> it;
|
||||
for (it= sessions.begin(); it!=sessions.end() ; ++it){
|
||||
slotNewChatSessionWindow( *it );
|
||||
}
|
||||
}
|
||||
|
||||
OTRPlugin::~OTRPlugin()
|
||||
{
|
||||
delete m_inboundHandler;
|
||||
pluginStatic_ = 0L;
|
||||
kdDebug() << "Exiting plugin" << endl;
|
||||
}
|
||||
|
||||
|
||||
OTRPlugin* OTRPlugin::plugin()
|
||||
{
|
||||
return pluginStatic_ ;
|
||||
}
|
||||
|
||||
OTRPlugin* OTRPlugin::pluginStatic_ = 0L;
|
||||
|
||||
|
||||
void OTRPlugin::slotNewChatSessionWindow( Kopete::ChatSession *KMM )
|
||||
{
|
||||
//Check if there is another user in the session.
|
||||
//If not it could be a Jabber-MUC
|
||||
//If there are more then one members it is a MUC
|
||||
// Also don't add the Button on an IRC window!
|
||||
if( KMM->members().count() == 1 && (KMM->protocol()) && ( KMM->protocol()->pluginId() != "IRCProtocol" ) ){
|
||||
new OtrGUIClient( KMM );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OTRPlugin::slotOutgoingMessage( Kopete::Message& msg )
|
||||
{
|
||||
if( msg.direction() == Kopete::Message::Outbound ){
|
||||
TQString plainBody = msg.plainBody();
|
||||
TQString accountId = msg.manager()->account()->accountId();
|
||||
Kopete::Contact *contact = msg.to().first();
|
||||
|
||||
TQString encBody = otrlChatInterface->encryptMessage( plainBody, accountId, msg.manager()->account()->protocol()->displayName(), contact->contactId(), msg.manager() );
|
||||
msg.setBody( encBody, Kopete::Message::Crypted );
|
||||
if( !msg.plainBody().isEmpty() ){
|
||||
messageCache.insert( encBody, plainBody );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OTRPlugin::slotEnableOtr( Kopete::ChatSession *session, bool enable ){
|
||||
|
||||
|
||||
if( enable ){
|
||||
TQString policy = session->members().getFirst()->metaContact()->pluginData( OTRPlugin::plugin(), "otr_policy" );
|
||||
bool noerr;
|
||||
KopeteOtrKcfg::self()->readConfig();
|
||||
if( policy.toInt( &noerr, 10 ) == 4 || ( policy.toInt( &noerr, 10 ) == 0 && KopeteOtrKcfg::self()->rbNever() ) ){
|
||||
Kopete::Message msg( session->account()->myself(), session->members(), i18n( "Your policy settings do not allow encrypted sessions to this contact." ), Kopete::Message::Internal, Kopete::Message::RichText );
|
||||
session->appendMessage( msg );
|
||||
} else {
|
||||
TQString body = otrlChatInterface->getDefaultQuery( session->account()->accountId() );
|
||||
Kopete::Message msg1( session->account()->myself(), session->members().getFirst(), TQString( body ), Kopete::Message::Outbound );
|
||||
if( otrlChatInterface->privState( session ) > 0 ){
|
||||
body = i18n("Attempting to refresh the OTR session with <b>%1</b>...").arg( otrlChatInterface->formatContact( session->members().getFirst()->contactId() ) );
|
||||
} else {
|
||||
body = i18n("Attempting to start a private OTR session with <b>%1</b>...").arg( otrlChatInterface->formatContact( session->members().getFirst()->contactId() ) );
|
||||
}
|
||||
Kopete::Message msg2( session->account()->myself(), session->members().getFirst(), body, Kopete::Message::Internal, Kopete::Message::RichText );
|
||||
|
||||
session->sendMessage( msg1 );
|
||||
session->appendMessage( msg2 );
|
||||
}
|
||||
} else {
|
||||
otrlChatInterface->disconnectSession( session );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OTRPlugin::slotVerifyFingerprint( Kopete::ChatSession *session ){
|
||||
otrlChatInterface->verifyFingerprint( session );
|
||||
}
|
||||
|
||||
void OTRPlugin::slotSettingsChanged(){
|
||||
KopeteOtrKcfg::self()->readConfig();
|
||||
if( KopeteOtrKcfg::self()->rbAlways() ){
|
||||
otrlChatInterface->setPolicy( OTRL_POLICY_ALWAYS );
|
||||
} else if( KopeteOtrKcfg::self()->rbOpportunistic() ){
|
||||
otrlChatInterface->setPolicy( OTRL_POLICY_OPPORTUNISTIC );
|
||||
} else if( KopeteOtrKcfg::self()->rbManual() ){
|
||||
otrlChatInterface->setPolicy( OTRL_POLICY_MANUAL );
|
||||
} else if( KopeteOtrKcfg::self()->rbNever() ){
|
||||
otrlChatInterface->setPolicy( OTRL_POLICY_NEVER );
|
||||
} else {
|
||||
otrlChatInterface->setPolicy( OTRL_POLICY_DEFAULT );
|
||||
}
|
||||
}
|
||||
|
||||
void OTRPlugin::emitGoneSecure( Kopete::ChatSession *session, int status){
|
||||
emit goneSecure( session, status );
|
||||
}
|
||||
|
||||
TQMap<TQString, TQString> OTRPlugin::getMessageCache(){
|
||||
return messageCache;
|
||||
}
|
||||
|
||||
void OtrMessageHandler::handleMessage( Kopete::MessageEvent *event ){
|
||||
Kopete::Message msg = event->message();
|
||||
Kopete::ChatSession *session = msg.manager();
|
||||
TQMap<TQString, TQString> messageCache = OTRPlugin::plugin()->getMessageCache();
|
||||
|
||||
if( msg.direction() == Kopete::Message::Inbound ){
|
||||
TQString body = msg.parsedBody();
|
||||
kdDebug() << "Received Message: " << msg.parsedBody() << endl;
|
||||
TQString accountId = msg.manager()->account()->accountId();
|
||||
TQString contactId = msg.from()->contactId();
|
||||
int ignoremessage = OtrlChatInterface::self()->decryptMessage( &body, accountId, msg.manager()->account()->protocol()->displayName(), contactId, msg.manager() );
|
||||
msg.setBody( body, Kopete::Message::RichText );
|
||||
if( ignoremessage | OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) ){
|
||||
event->discard();
|
||||
return;
|
||||
}
|
||||
} else if( msg.direction() == Kopete::Message::Outbound ){
|
||||
if( messageCache.contains( msg.plainBody() ) ){
|
||||
msg.setBody( messageCache[msg.plainBody()] );
|
||||
messageCache.remove( messageCache[msg.plainBody()] );
|
||||
if(messageCache.count() > 5) messageCache.clear();
|
||||
}
|
||||
// Check if Message is an OTR message. Should it be discarded or shown?
|
||||
if( OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) ){
|
||||
event->discard();
|
||||
kdDebug() << "discarding" << endl;
|
||||
return;
|
||||
}
|
||||
// If the message is sent while a Finished state libotr deletes the messagetext.
|
||||
// This prevents the empty message from beeing shown in out chatwindow
|
||||
if( msg.plainBody().isEmpty() ){
|
||||
event->discard();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event->setMessage( msg );
|
||||
|
||||
MessageHandler::handleMessage( event );
|
||||
}
|
||||
|
||||
|
||||
void OTRPlugin::slotSelectionChanged( bool single){
|
||||
otrPolicyMenu->setEnabled( single );
|
||||
|
||||
if ( !single )
|
||||
return;
|
||||
|
||||
Kopete::MetaContact *metaContact = Kopete::ContactList::self()->selectedMetaContacts().first();
|
||||
|
||||
TQString policy = metaContact->pluginData( this, "otr_policy" );
|
||||
|
||||
bool noerr;
|
||||
if ( !policy.isEmpty() && policy != "null" )
|
||||
otrPolicyMenu->setCurrentItem( policy.toInt( &noerr, 10 ));
|
||||
else
|
||||
otrPolicyMenu->setCurrentItem( 0 );
|
||||
|
||||
}
|
||||
|
||||
void OTRPlugin::slotSetPolicy(){
|
||||
kdDebug() << "Setting contact policy" << endl;
|
||||
Kopete::MetaContact *metaContact = Kopete::ContactList::self()->selectedMetaContacts().first();
|
||||
if( metaContact ){
|
||||
metaContact->setPluginData( this, "otr_policy", TQString::number( otrPolicyMenu->currentItem() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void OTRPlugin::accountReady( Kopete::Account *account ){
|
||||
kdDebug() << "Account " << account->accountId() << " ready. Calling update function."<< endl;
|
||||
otrlChatInterface->updateKeyfile( account );
|
||||
}
|
||||
|
||||
|
||||
#include "otrplugin.moc"
|
@ -0,0 +1,117 @@
|
||||
/***************************************************************************
|
||||
otrplugin.h - description
|
||||
-------------------
|
||||
begin : 11 03 2007
|
||||
copyright : (C) 2007-2007 by Michael Zanetti
|
||||
email : michael_zanetti@gmx.net
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OTRPLUGIN_H
|
||||
#define OTRPLUGIN_H
|
||||
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <kopeteplugin.h>
|
||||
#include <kopetemessagehandler.h>
|
||||
|
||||
#include "otrlchatinterface.h"
|
||||
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
class OTRPlugin;
|
||||
class TDESelectAction;
|
||||
|
||||
class OtrMessageHandler : public Kopete::MessageHandler
|
||||
{
|
||||
private:
|
||||
OTRPlugin *plugin;
|
||||
public:
|
||||
OtrMessageHandler( OTRPlugin *plugin ) : plugin(plugin) {
|
||||
kdDebug() << "MessageHandler created" << endl;
|
||||
}
|
||||
~OtrMessageHandler(){
|
||||
kdDebug() << "MessageHandler destroyed" << endl;
|
||||
}
|
||||
void handleMessage( Kopete::MessageEvent *event );
|
||||
};
|
||||
|
||||
class OtrMessageHandlerFactory : public Kopete::MessageHandlerFactory
|
||||
{
|
||||
private:
|
||||
OTRPlugin *plugin;
|
||||
OtrMessageHandler *messageHandler;
|
||||
public:
|
||||
OtrMessageHandlerFactory( OTRPlugin *plugin ) : plugin(plugin) {}
|
||||
Kopete::MessageHandler *create( Kopete::ChatSession *, Kopete::Message::MessageDirection direction )
|
||||
{
|
||||
return new OtrMessageHandler(plugin);
|
||||
}
|
||||
int filterPosition( Kopete::ChatSession *, Kopete::Message::MessageDirection )
|
||||
{
|
||||
return Kopete::MessageHandlerFactory::InStageToSent+1;
|
||||
}
|
||||
};
|
||||
|
||||
class KDE_EXPORT OTRPlugin : public Kopete::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static OTRPlugin *plugin();
|
||||
|
||||
OTRPlugin( TDEInstance *instance, TQObject *parent, const char *name, const TQStringList &args );
|
||||
~OTRPlugin();
|
||||
|
||||
void emitGoneSecure( Kopete::ChatSession *session, int status );
|
||||
TQMap<TQString, TQString> getMessageCache();
|
||||
|
||||
public slots:
|
||||
|
||||
void slotOutgoingMessage( Kopete::Message& msg );
|
||||
void slotEnableOtr( Kopete::ChatSession *session, bool enable );
|
||||
void slotSettingsChanged();
|
||||
void slotVerifyFingerprint( Kopete::ChatSession *session );
|
||||
|
||||
private slots:
|
||||
void slotNewChatSessionWindow(Kopete::ChatSession * );
|
||||
void slotSelectionChanged( bool single );
|
||||
void slotSetPolicy();
|
||||
void accountReady( Kopete::Account *account );
|
||||
|
||||
private:
|
||||
static OTRPlugin* pluginStatic_;
|
||||
OtrMessageHandlerFactory *m_inboundHandler;
|
||||
OtrlChatInterface *otrlChatInterface;
|
||||
TQMap<TQString, TQString> messageCache;
|
||||
TDESelectAction* otrPolicyMenu;
|
||||
|
||||
/* TDEActionMenu *otrPolicyMenuBar;
|
||||
TDEActionMenu *otrPolicyPopup;
|
||||
TDEAction *otrPolicyDefault;
|
||||
TDEAction *otrPolicyAlways;
|
||||
TDEAction *otrPolicyOpportunistic;
|
||||
TDEAction *otrPolicyManual;
|
||||
TDEAction *otrPolicyNever;
|
||||
// SessionManager manager
|
||||
*/
|
||||
|
||||
signals:
|
||||
void goneSecure( Kopete::ChatSession *session, int state );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,202 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tqlayout.h>
|
||||
#include <tqlabel.h>
|
||||
#include <tqmap.h>
|
||||
#include <tqptrlist.h>
|
||||
#include <tqcombobox.h>
|
||||
#include <tqstringlist.h>
|
||||
#include <tqtable.h>
|
||||
#include <tqpaintdevicemetrics.h>
|
||||
#include <tqvbox.h>
|
||||
#include <tqradiobutton.h>
|
||||
#include <tqtabwidget.h>
|
||||
|
||||
#include <kgenericfactory.h>
|
||||
#include <kurlrequester.h>
|
||||
#include <tdemessagebox.h>
|
||||
#include <tdeconfig.h>
|
||||
#include <tdeapplication.h>
|
||||
#include <kanimwidget.h>
|
||||
#include <kpassivepopup.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kactivelabel.h>
|
||||
|
||||
#include <kopeteaccountmanager.h>
|
||||
#include <kopeteaccount.h>
|
||||
#include <kopeteprotocol.h>
|
||||
|
||||
#include "otrprefs.h"
|
||||
#include "otrpreferences.h"
|
||||
#include "otrplugin.h"
|
||||
#include "kopete_otr.h"
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
typedef KGenericFactory<OTRPreferences> OTRPreferencesFactory;
|
||||
K_EXPORT_COMPONENT_FACTORY( kcm_kopete_otr, OTRPreferencesFactory("kcm_kopete_otr"))
|
||||
|
||||
OTRPreferences::OTRPreferences(TQWidget *parent, const char* /*name*/, const TQStringList &args)
|
||||
: TDECModule(OTRPreferencesFactory::instance(), parent, args)
|
||||
{
|
||||
( new TQVBoxLayout( this ) )->setAutoAdd( true );
|
||||
preferencesDialog = new OTRPrefsUI(this);
|
||||
|
||||
|
||||
this->addConfig( KopeteOtrKcfg::self(), preferencesDialog );
|
||||
KopeteOtrKcfg::self()->readConfig();
|
||||
load();
|
||||
|
||||
|
||||
|
||||
otrlConfInterface = new OtrlConfInterface( preferencesDialog );
|
||||
|
||||
connect( preferencesDialog->btGenFingerprint, TQT_SIGNAL(clicked()), TQT_SLOT(generateFingerprint()));
|
||||
connect( preferencesDialog->cbKeys, TQT_SIGNAL(activated(int)), TQT_SLOT(showPrivFingerprint(int)));
|
||||
connect( preferencesDialog->btVerify, TQT_SIGNAL(clicked()), TQT_SLOT(verifyFingerprint()));
|
||||
connect( preferencesDialog->twSettings, TQT_SIGNAL(currentChanged(TQWidget *)), TQT_SLOT(fillFingerprints()));
|
||||
connect( preferencesDialog->tbFingerprints, TQT_SIGNAL(currentChanged(int, int)), TQT_SLOT(updateButtons(int, int)));
|
||||
connect( preferencesDialog->btForget, TQT_SIGNAL( clicked() ), TQT_SLOT( forgetFingerprint() ) );
|
||||
|
||||
int index = 0;
|
||||
int accountnr = 0;
|
||||
TQPtrList<Kopete::Account> accounts = Kopete::AccountManager::self()->accounts();
|
||||
if( !accounts.isEmpty() ){
|
||||
for ( TQPtrListIterator<Kopete::Account> it( accounts );
|
||||
Kopete::Account *account = it.current();
|
||||
++it ){
|
||||
if ( account->protocol()->pluginId() != "IRCProtocol" ){
|
||||
preferencesDialog->cbKeys->insertItem(account->accountId() + " (" + account->protocol()->displayName() + ")");
|
||||
privKeys.insert(index++, accountnr);
|
||||
}
|
||||
accountnr++;
|
||||
}
|
||||
}
|
||||
showPrivFingerprint( preferencesDialog->cbKeys->currentItem() );
|
||||
|
||||
preferencesDialog->tbFingerprints->setColumnWidth( 0, 200 );
|
||||
preferencesDialog->tbFingerprints->setColumnWidth( 1, 80 );
|
||||
preferencesDialog->tbFingerprints->setColumnWidth( 2, 60 );
|
||||
preferencesDialog->tbFingerprints->setColumnWidth( 3, 400 );
|
||||
preferencesDialog->tbFingerprints->setColumnWidth( 4, 200 );
|
||||
|
||||
}
|
||||
|
||||
OTRPreferences::~OTRPreferences(){
|
||||
}
|
||||
|
||||
void OTRPreferences::generateFingerprint()
|
||||
{
|
||||
TQPtrList<Kopete::Account> accounts = Kopete::AccountManager::self()->accounts();
|
||||
|
||||
if( (accounts.isEmpty())){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Kopete::Account *account = accounts.at( privKeys[preferencesDialog->cbKeys->currentItem()] );
|
||||
|
||||
if ((otrlConfInterface->hasPrivFingerprint( account->accountId(), account->protocol()->displayName() ) ) && (KMessageBox::questionYesNo(this, i18n("Selected account already has a key. Do you want to create a new one?"), i18n("Overwrite key?")) !=3)) return;
|
||||
|
||||
otrlConfInterface->generateNewPrivKey( account->accountId(), account->protocol()->displayName() );
|
||||
showPrivFingerprint( preferencesDialog->cbKeys->currentItem() );
|
||||
}
|
||||
|
||||
void OTRPreferences::showPrivFingerprint( int accountnr )
|
||||
{
|
||||
TQPtrList<Kopete::Account> accounts = Kopete::AccountManager::self()->accounts();
|
||||
if( !accounts.isEmpty() ){
|
||||
Kopete::Account *account = accounts.at(privKeys[accountnr]);
|
||||
preferencesDialog->tlFingerprint->setText( otrlConfInterface->getPrivFingerprint( account->accountId(), account->protocol()->displayName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void OTRPreferences::fillFingerprints(){
|
||||
TQTable *fingerprintsTable = preferencesDialog->tbFingerprints;
|
||||
preferencesDialog->tbFingerprints->setNumRows(0);
|
||||
TQValueList<TQStringList> list = otrlConfInterface->readAllFingerprints();
|
||||
TQValueList<TQStringList>::iterator it;
|
||||
int j = 0;
|
||||
for( it = list.begin(); it != list.end(); ++it ){
|
||||
preferencesDialog->tbFingerprints->setNumRows( preferencesDialog->tbFingerprints->numRows() +1 );
|
||||
fingerprintsTable->setItem(j, 0, new TQAlignTableItem(fingerprintsTable, TQTableItem::Never,
|
||||
OtrlChatInterface::self()->formatContact((*it)[0]), TQt::AlignLeft));
|
||||
for( int i = 1; i < 5; i++ ){
|
||||
//preferencesDialog->tbFingerprints->setText(j, i, (*it)[i] );
|
||||
fingerprintsTable->setItem(j,i, new TQAlignTableItem(fingerprintsTable, TQTableItem::Never,(*it)[i],TQt::AlignLeft));
|
||||
}
|
||||
j++;
|
||||
}
|
||||
updateButtons( preferencesDialog->tbFingerprints->currentRow(), preferencesDialog->tbFingerprints->currentColumn() );
|
||||
}
|
||||
|
||||
void OTRPreferences::verifyFingerprint(){
|
||||
|
||||
int doVerify = KMessageBox::questionYesNo(
|
||||
this,
|
||||
i18n("Please contact %1 via another secure way and verify that the following Fingerprint is correct:").arg(preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 0 )) + "\n\n" + preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 3 ) + "\n\n" + i18n("Are you sure you want to trust this fingerprint?"), i18n("Verify fingerprint") );
|
||||
|
||||
|
||||
if( doVerify == KMessageBox::Yes ){
|
||||
otrlConfInterface->verifyFingerprint( preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 3 ), true );
|
||||
} else {
|
||||
otrlConfInterface->verifyFingerprint( preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 3 ), false );
|
||||
}
|
||||
fillFingerprints();
|
||||
}
|
||||
|
||||
void OTRPreferences::updateButtons( int row, int col ){
|
||||
if( row != -1 ){
|
||||
if( !otrlConfInterface->isEncrypted( preferencesDialog->tbFingerprints->text( row, 3 ) ) ){
|
||||
preferencesDialog->btForget->setEnabled( true );
|
||||
} else {
|
||||
preferencesDialog->btForget->setEnabled( false );
|
||||
}
|
||||
preferencesDialog->btVerify->setEnabled( true );
|
||||
} else {
|
||||
preferencesDialog->btVerify->setEnabled( false );
|
||||
preferencesDialog->btForget->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
void OTRPreferences::forgetFingerprint(){
|
||||
if( !otrlConfInterface->isEncrypted( preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 3 ) ) ){
|
||||
otrlConfInterface->forgetFingerprint( preferencesDialog->tbFingerprints->text( preferencesDialog->tbFingerprints->currentRow(), 3 ) );
|
||||
fillFingerprints();
|
||||
} else {
|
||||
updateButtons( preferencesDialog->tbFingerprints->currentRow(), preferencesDialog->tbFingerprints->currentColumn() );
|
||||
}
|
||||
}
|
||||
|
||||
TQAlignTableItem :: TQAlignTableItem( TQTable *table, EditType editType, const TQString& text, int alignment )
|
||||
: TQTableItem( table, editType, text ) {
|
||||
align = alignment;
|
||||
}
|
||||
|
||||
|
||||
#include "otrpreferences.moc"
|
@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti
|
||||
*
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OTRPREFERECES_H
|
||||
#define OTRPREFERECES_H
|
||||
|
||||
#include <tdecmodule.h>
|
||||
#include "otrlconfinterface.h"
|
||||
|
||||
/**
|
||||
* Preference widget for the OTR plugin
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
class OTRPreferences : public TDECModule {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OTRPreferences(TQWidget *parent = 0, const char *name = 0, const TQStringList &args = TQStringList());
|
||||
~OTRPreferences();
|
||||
|
||||
private:
|
||||
OTRPrefsUI *preferencesDialog;
|
||||
OtrlConfInterface *otrlConfInterface;
|
||||
TQMap<int, int> privKeys;
|
||||
|
||||
private slots: // Public slots
|
||||
void generateFingerprint();
|
||||
void showPrivFingerprint(int accountnr);
|
||||
void verifyFingerprint();
|
||||
void fillFingerprints();
|
||||
void updateButtons(int row, int col);
|
||||
void forgetFingerprint();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TQAlignTableItem : public TQTableItem {
|
||||
|
||||
public :
|
||||
TQAlignTableItem(TQTable *table, EditType editType, const TQString& text, int alignment);
|
||||
|
||||
private :
|
||||
int align;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,295 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>OTRPrefsUI</class>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>OTRPrefsUI</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>358</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Form1</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQTabWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>twSettings</cstring>
|
||||
</property>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>settings</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>&Settings</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQGroupBox" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupBox1</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Private Keys</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQPushButton" row="0" column="2">
|
||||
<property name="name">
|
||||
<cstring>btGenFingerprint</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Generate</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+G</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQComboBox" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>cbKeys</cstring>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Account:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KActiveLabel" row="1" column="0" rowspan="1" colspan="3">
|
||||
<property name="name">
|
||||
<cstring>tlFingerprint</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No Fingerprint</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQButtonGroup" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>bgPolicy</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Default Policy</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQRadioButton" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>kcfg_rbOpportunistic</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Opportunistic</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Encrypt messages automatically if the other side supports OTR</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQRadioButton" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>kcfg_rbNever</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ne&ver</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+V</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Never encrypt messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQRadioButton" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>kcfg_rbManual</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Manual</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+M</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Encrypt messages if the other side requests an OTR connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQRadioButton" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>kcfg_rbAlways</cstring>
|
||||
</property>
|
||||
<property name="autoMask">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Al&ways</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+W</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Always encrypt messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<spacer row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>spacer2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>161</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>fingerprints</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>K&nown Fingerprints</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQTable" row="0" column="0" rowspan="1" colspan="2">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Verified</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Fingerprint</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Protocol</string>
|
||||
</property>
|
||||
</column>
|
||||
<property name="name">
|
||||
<cstring>tbFingerprints</cstring>
|
||||
</property>
|
||||
<property name="numRows">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="numCols">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sorting">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>SingleRow</enum>
|
||||
</property>
|
||||
<property name="focusStyle">
|
||||
<enum>FollowStyle</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQPushButton" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>btVerify</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Verify Fingerprint</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+V</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQPushButton" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>btForget</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>F&orget Fingerprint</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<Q_SLOTS>
|
||||
<slot access="private">generateFingerprint()</slot>
|
||||
</Q_SLOTS>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kactivelabel.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE kpartgui>
|
||||
<kpartgui name="kopete_otr" version="1">
|
||||
<MenuBar>
|
||||
<Menu name="edit">
|
||||
<text>&Edit</text>
|
||||
<Action name="otr_policy" />
|
||||
</Menu>
|
||||
</MenuBar>
|
||||
<Menu name="contact_popup">
|
||||
<Action name="otr_policy" />
|
||||
</Menu>
|
||||
</kpartgui>
|
@ -0,0 +1,5 @@
|
||||
##### icons
|
||||
|
||||
tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/kopete_otr/icons )
|
||||
|
||||
tde_install_icons( kopete_otr )
|
After Width: | Height: | Size: 815 B |
After Width: | Height: | Size: 956 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 687 B |
After Width: | Height: | Size: 758 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 812 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 873 B |
After Width: | Height: | Size: 853 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#include "privkeypopup.h"
|
||||
|
||||
PrivKeyPopup::PrivKeyPopup(TQWidget* parent, const char* name, WFlags fl)
|
||||
: PrivKeyPopupUI(parent,name,fl)
|
||||
{
|
||||
}
|
||||
|
||||
PrivKeyPopup::~PrivKeyPopup()
|
||||
{
|
||||
}
|
||||
|
||||
void PrivKeyPopup::setCloseLock( bool locked ){
|
||||
closeLock = locked;
|
||||
}
|
||||
|
||||
void PrivKeyPopup::closeEvent( TQCloseEvent *e ){
|
||||
if( closeLock ){
|
||||
e->ignore();
|
||||
} else {
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
#include "privkeypopup.moc"
|
||||
|
@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* michael_zanetti@gmx.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PRIVKEYPOPUP_H
|
||||
#define PRIVKEYPOPUP_H
|
||||
|
||||
#include "privkeypopupui.h"
|
||||
|
||||
/**
|
||||
* @author Michael Zanetti
|
||||
*/
|
||||
|
||||
class PrivKeyPopup : public PrivKeyPopupUI
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrivKeyPopup(TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~PrivKeyPopup();
|
||||
void setCloseLock( bool locked );
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
bool closeLock;
|
||||
|
||||
void closeEvent( TQCloseEvent *e );
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>PrivKeyPopupUI</class>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>PrivKeyPopupUI</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>507</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Generating private key</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>tlWait</cstring>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>1</bold>
|
||||
<italic>1</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Please wait while generating the private key</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQFrame" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>animFrame</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>72</width>
|
||||
<height>72</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* michael_zanetti@gmx.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tqlabel.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <tdelocale.h>
|
||||
#include <klineedit.h>
|
||||
#include <kurl.h>
|
||||
#include <krun.h>
|
||||
|
||||
#include "smppopup.h"
|
||||
#include "verifypopup.h"
|
||||
|
||||
SMPPopup::SMPPopup(TQWidget* parent, const char* name, TQString title, WFlags fl, ConnContext *context, Kopete::ChatSession *session, bool initiate )
|
||||
: SMPPopupUI(parent,name,fl)
|
||||
{
|
||||
this->context = context;
|
||||
this->session = session;
|
||||
this->initiate = initiate;
|
||||
if (title.isNull()) {
|
||||
question = false;
|
||||
tlText->setText( i18n("Please enter the secret passphrase to authenticate %1:").arg(OtrlChatInterface::self()->formatContact(session->members().getFirst()->contactId())));
|
||||
}
|
||||
else {
|
||||
question = true;
|
||||
tlText->setText( title );
|
||||
}
|
||||
}
|
||||
|
||||
SMPPopup::~SMPPopup()
|
||||
{
|
||||
}
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
void SMPPopup::cancelSMP()
|
||||
{
|
||||
OtrlChatInterface::self()->abortSMP( context, session );
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SMPPopup::respondSMP()
|
||||
{
|
||||
if (question) {
|
||||
OtrlChatInterface::self()->respondSMPQ( context, session, tlText->text(), leSecret->text(), initiate );
|
||||
}
|
||||
else {
|
||||
OtrlChatInterface::self()->respondSMP( context, session, leSecret->text(), initiate );
|
||||
}
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SMPPopup::openHelp()
|
||||
{
|
||||
KURL *url = new KURL("http://www.cypherpunks.ca/otr/help/authenticate.php?lang=en");
|
||||
new KRun(*url, 0, false, true);
|
||||
}
|
||||
|
||||
void SMPPopup::manualAuth(){
|
||||
VerifyPopup *vfPopup = new VerifyPopup(this, i18n("Verify Fingerprint").utf8(), session);
|
||||
vfPopup->show();
|
||||
this->close();
|
||||
}
|
||||
|
||||
#include "smppopup.moc"
|
||||
|
@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* michael_zanetti@gmx.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SMPPOPUP_H
|
||||
#define SMPPOPUP_H
|
||||
|
||||
#include "kopetechatsession.h"
|
||||
|
||||
#include "smppopupui.h"
|
||||
#include "otrlchatinterface.h"
|
||||
|
||||
extern "C"{
|
||||
#include "libotr/proto.h"
|
||||
}
|
||||
|
||||
class SMPPopup : public SMPPopupUI
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SMPPopup(TQWidget* parent = 0, const char* name = 0, TQString title = TQString::null, WFlags fl = 0, ConnContext *context = 0, Kopete::ChatSession *session = 0, bool initiate = true );
|
||||
~SMPPopup();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
virtual void cancelSMP();
|
||||
virtual void respondSMP();
|
||||
virtual void openHelp();
|
||||
virtual void manualAuth();
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
ConnContext *context;
|
||||
Kopete::ChatSession *session;
|
||||
bool initiate;
|
||||
bool question;
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,191 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>SMPPopupUI</class>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>SMPPopupUI</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>536</width>
|
||||
<height>158</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Enter authentication secret</string>
|
||||
</property>
|
||||
<widget class="KPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbOK</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>110</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbCancel</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>110</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+C</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KLineEdit">
|
||||
<property name="name">
|
||||
<cstring>leSecret</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>70</y>
|
||||
<width>400</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel">
|
||||
<property name="name">
|
||||
<cstring>tlText</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>124</x>
|
||||
<y>10</y>
|
||||
<width>390</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Please enter the secret passphrase to authenticate this contact.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel">
|
||||
<property name="name">
|
||||
<cstring>pLIcon</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>image0</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbManual</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>110</y>
|
||||
<width>160</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Manual Authentication</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+M</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbHelp</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>110</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+H</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="PNG" length="1360">89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000517494441545885c5975d68544714c77f7b5db39b98adf95851a34913158dd1b452db2a488badb5155bfba22f3e54a4da421ffa609fa42fea83a0f8509fc5071529a894422988156cc552d4b40113129ae826249b8fc664f3b17befeede3b7766fa70633edc9bcdfa517ae0b2c3ec9df9ffce393367e6c2ff6c81671d70f6ecb5b052aa1ea80b0428d39acf95523d528a96870fdb2e9e3f7f7a0490ff09c09933df6f0f04025b57adaa0aad5cb98468743152cae3c9a4c5a347fdf4f58d904e9be75a5bef9fb87af5dc502120c142844f9ebc180e040207972faf5cba7bf756caca220402b3d9376d5acbe0e030376ffef9a5d65bde1d1a1af8f8f6ed9fe380c837f782f9c48f1d3b1f564a1f6c6c5cbd74dfbef7282e0e23a5249d4e639a2696656dcf64321886414545191b36d4313c3c1e0d85a2bb1c277bbdbfbf3b05a8e706d8b66df70735354bd7eddfbf13e089287d7d8f696fefa1ab6b60bb942eb69dc6b66d2291080d0d75c462f16830f84a4553d3ad5f0107d0cf0c70e4c877658661ec3d74e8138a8bc32493499249936bd76e73e7ce03f1e0415b4f2cd65bdad939581a8f274a4b4a0c5cd7211a8d5255554e6b6bfc3521c42f7d7db17f00d74f23ef1a504a6fddb8b18ecaca322ccbc2b66d2e5fbe4947c7c3aeebd72f350d0dc54da005d0070e1cfd7a74347978cf9e370887c3545757b3624505f5f56f7e71f7ee8d76c0f68330f2010821963534d4a1b5c6344d9a9b3be9ea8a8f5db870f2f7a1a1f828300e7403dd972e9dfa369148fc78efde437a7b7b0158bffe550c63613d100116fa69e405705df9eaaa55556432198410343777d2d3d3f13790054cc00292400a48f4f5751defee7e4c369b656c6c8cdada65048345af038b9e0bc0715c8a8b4308211042e03882f1f144122f9c4f2f2c75e3c6a576cbca2284606464844864118ee302143147bae74b018ee3e0380eaeeb22844029adf10a8cdfd6924208b4d64829a7c0f116bb6fd19b270202dbb6b16d7b7232172925ccb1a500ed385edd715d77123e6f1dca0fa0b5c6b66d1cc799f45ea1e7929e316626809e67806f5edace36d41b06cb7febed24db761129250b1c87cd65dd6cfe30b1a66aefdaf2c5c50b8461a0811d33c7fe31d049c59843d029412e2c62476d279f1d5d7d3800773e3d15bbcc53e9cbc94bd3e9865d0b17b025525343a4ba26bfbb9e1d9fef8554bc97546f2f89943cbfe344c73778bb47f946209d61cb9a8fdea7eaed46d08ff016fb8bd992b7d631d0b48c891bf70f03a7810120ed0b30616942e551b0aebc1471004c9b506c88096b11403990981320696adc4c3f64ad9723ee2a6819c44d2b92a606af204d2d7e9f0880b415647dcf8e6733a9a0fd31a46ca41364c2c7a7dc08581ad75690cdbf7fe7354742f728980e488deb289256ee96cc8d80a9716d099917888069c3401284f2a2a03c8009b300005782769f330552c1681a5236280d524f0168a9717d6e88fef7019127056ad20bada70bb2ab4048b09c59a2d3bf936d1ff30770d5740a828657aeb49e9e4ca9c94967b4fdfa6601f897e4390024d8024a439eb8d4d31ecd122db0efb922505234dd7e2a9fd30279fa72009e2502a1a0e7b9abc8c9a35f6e0b85f231dfe37860d800a3d203987aa43749bebe9cffa79f8154a8b00848a5e33ffdf05775ac71392b226970b39e074f56fdccf6938539ab9dfb5e7faa88b69152d28e6cc53b8ea7f291731cefac5f1aa9ad2c79a72868546b5dd0b7e35705bcc34446b4dcea787c6530998d0171bc4badaf8001848030de65723e88658500e09dff16308677937601fe058d04715d6cb9690e0000000049454e44ae426082</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pbCancel</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SMPPopupUI</receiver>
|
||||
<slot>cancelSMP()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbOK</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SMPPopupUI</receiver>
|
||||
<slot>respondSMP()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbHelp</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SMPPopupUI</receiver>
|
||||
<slot>openHelp()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbManual</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SMPPopupUI</receiver>
|
||||
<slot>manualAuth()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<Q_SLOTS>
|
||||
<slot>manualAuth()</slot>
|
||||
<slot>respondSMP()</slot>
|
||||
<slot>openHelp()</slot>
|
||||
<slot>cancelSMP()</slot>
|
||||
</Q_SLOTS>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
<includehint>klineedit.h</includehint>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* michael_zanetti@gmx.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "verifypopup.h"
|
||||
#include "otrlchatinterface.h"
|
||||
#include "otrplugin.h"
|
||||
|
||||
#include "tqlabel.h"
|
||||
|
||||
#include "tdelocale.h"
|
||||
#include "kactivelabel.h"
|
||||
#include "kcombobox.h"
|
||||
|
||||
#include "kopetechatsession.h"
|
||||
#include "kopetecontact.h"
|
||||
|
||||
VerifyPopup::VerifyPopup(TQWidget* parent, const char* name, Kopete::ChatSession *session, bool modal, WFlags fl)
|
||||
: VerifyPopupUI(parent,name, modal,fl)
|
||||
{
|
||||
this->session = session;
|
||||
alContact->setText(i18n("Verify fingerprint for %1.").arg(OtrlChatInterface::self()->formatContact(session->members().getFirst()->contactId())));
|
||||
alFingerprint->setText(i18n("The received fingerprint is:\n\n%1\n\nContact %2 via another secure channel and verify that this fingerprint is correct.").arg(OtrlChatInterface::self()->findActiveFingerprint(session)).arg(OtrlChatInterface::self()->formatContact(session->members().getFirst()->contactId())));
|
||||
alVerified->setText(i18n("verified that this is in fact the correct fingerprint for %1").arg(OtrlChatInterface::self()->formatContact(session->members().getFirst()->contactId())));
|
||||
cbVerify->insertItem(i18n("I have not"));
|
||||
cbVerify->insertItem(i18n("I have"));
|
||||
if( OtrlChatInterface::self()->isVerified(session)){
|
||||
cbVerify->setCurrentItem(1);
|
||||
} else {
|
||||
cbVerify->setCurrentItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
VerifyPopup::~VerifyPopup()
|
||||
{
|
||||
}
|
||||
|
||||
void VerifyPopup::cbChanged(){
|
||||
kdDebug() << "combobox changed" << endl;
|
||||
if( cbVerify->currentItem() == 0 ){
|
||||
OtrlChatInterface::self()->setTrust(session, false);
|
||||
} else {
|
||||
OtrlChatInterface::self()->setTrust(session, true);
|
||||
}
|
||||
OTRPlugin::plugin()->emitGoneSecure( session, OtrlChatInterface::self()->privState( session ) );
|
||||
}
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
#include "verifypopup.moc"
|
||||
|
@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Michael Zanetti *
|
||||
* michael_zanetti@gmx.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef VERIFYPOPUP_H
|
||||
#define VERIFYPOPUP_H
|
||||
|
||||
#include "verifypopupui.h"
|
||||
#include "kopetechatsession.h"
|
||||
|
||||
class VerifyPopup : public VerifyPopupUI
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VerifyPopup(TQWidget* parent = 0, const char* name = 0, Kopete::ChatSession *session = NULL, bool modal = FALSE, WFlags fl = 0 );
|
||||
~VerifyPopup();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
virtual void cbChanged();
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
Kopete::ChatSession *session;
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,113 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>VerifyPopupUI</class>
|
||||
<widget class="TQDialog">
|
||||
<property name="name">
|
||||
<cstring>VerifyPopupUI</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Verify Fingerprint</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="KPushButton" row="3" column="2">
|
||||
<property name="name">
|
||||
<cstring>pbOK</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="3" column="0" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>461</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="KActiveLabel" row="2" column="1" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>alVerified</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KComboBox" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>cbVerify</cstring>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KActiveLabel" row="0" column="0" rowspan="1" colspan="3">
|
||||
<property name="name">
|
||||
<cstring>alContact</cstring>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="1" column="0" rowspan="1" colspan="3">
|
||||
<property name="name">
|
||||
<cstring>alFingerprint</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cbVerify</sender>
|
||||
<signal>activated(int)</signal>
|
||||
<receiver>VerifyPopupUI</receiver>
|
||||
<slot>cbChanged()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbOK</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>VerifyPopupUI</receiver>
|
||||
<slot>close()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<Q_SLOTS>
|
||||
<slot>cbChanged()</slot>
|
||||
</Q_SLOTS>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
<includehint>kactivelabel.h</includehint>
|
||||
<includehint>kcombobox.h</includehint>
|
||||
<includehint>kactivelabel.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|