summaryrefslogtreecommitdiffstats
path: root/certmanager/kwatchgnupg
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /certmanager/kwatchgnupg
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'certmanager/kwatchgnupg')
-rw-r--r--certmanager/kwatchgnupg/Makefile.am30
-rw-r--r--certmanager/kwatchgnupg/aboutdata.cpp73
-rw-r--r--certmanager/kwatchgnupg/aboutdata.h43
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupg.pngbin0 -> 1137 bytes
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupg2.pngbin0 -> 1280 bytes
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupgconfig.cpp206
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupgconfig.h68
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp292
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupgmainwin.h78
-rw-r--r--certmanager/kwatchgnupg/kwatchgnupgui.rc21
-rw-r--r--certmanager/kwatchgnupg/main.cpp96
-rw-r--r--certmanager/kwatchgnupg/tray.cpp66
-rw-r--r--certmanager/kwatchgnupg/tray.h55
13 files changed, 1028 insertions, 0 deletions
diff --git a/certmanager/kwatchgnupg/Makefile.am b/certmanager/kwatchgnupg/Makefile.am
new file mode 100644
index 00000000..a727fa70
--- /dev/null
+++ b/certmanager/kwatchgnupg/Makefile.am
@@ -0,0 +1,30 @@
+KDE_CXXFLAGS = -DLIBKLEOPATRA_NO_COMPAT
+
+INCLUDES = -I$(top_srcdir)/certmanager/lib -I$(top_srcdir)/libkdenetwork $(GPGME_CFLAGS) $(all_includes)
+
+bin_PROGRAMS = kwatchgnupg
+
+kwatchgnupg_SOURCES = \
+ kwatchgnupgmainwin.cpp \
+ kwatchgnupgconfig.cpp \
+ aboutdata.cpp \
+ tray.cpp \
+ main.cpp
+
+METASOURCES = AUTO
+
+kwatchgnupg_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kwatchgnupg_LDADD = ../conf/libconf.la ../lib/libkleopatra.la $(LIB_KUTILS) $(LIB_KABC)
+
+rcdir = $(kde_datadir)/kwatchgnupg
+rc_DATA = kwatchgnupgui.rc
+
+
+pics_DATA = kwatchgnupg.png kwatchgnupg2.png
+
+picsdir = $(kde_datadir)/kwatchgnupg/pics
+
+EXTRA_DIST = $(pics_DATA)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kwatchgnupg.pot
diff --git a/certmanager/kwatchgnupg/aboutdata.cpp b/certmanager/kwatchgnupg/aboutdata.cpp
new file mode 100644
index 00000000..4bde5219
--- /dev/null
+++ b/certmanager/kwatchgnupg/aboutdata.cpp
@@ -0,0 +1,73 @@
+/*
+ aboutdata.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2004 Klar�vdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include "aboutdata.h"
+
+#include <klocale.h>
+
+static const char kwatchgnupg_version[] = "1.0";
+static const char description[] = I18N_NOOP("GnuPG log viewer");
+
+struct about_data {
+ const char * name;
+ const char * desc;
+ const char * email;
+ const char * web;
+};
+
+static const about_data authors[] = {
+ { "Steffen Hansen", I18N_NOOP("Original Author"), "hansen@kde.org", 0 },
+};
+
+#if 0
+// can't create zero size array - doesn't compile
+static const about_data credits[] = {
+ // PENDING(steffen) add stuff
+};
+#endif
+
+AboutData::AboutData()
+ : KAboutData( "kwatchgnupg", I18N_NOOP("KWatchGnuPG"),
+ kwatchgnupg_version, description, License_GPL,
+ "(c) 2004 Klar\xC3\xA4lvdalens Datakonsult AB\n" )
+{
+ using ::authors;
+ //using ::credits;
+ for ( unsigned int i = 0 ; i < sizeof authors / sizeof *authors ; ++i )
+ addAuthor( authors[i].name, authors[i].desc,
+ authors[i].email, authors[i].web );
+#if 0
+ for ( unsigned int i = 0 ; i < sizeof credits / sizeof *credits ; ++i )
+ addCredit( credits[i].name, credits[i].desc,
+ credits[i].email, credits[i].web );
+#endif
+}
diff --git a/certmanager/kwatchgnupg/aboutdata.h b/certmanager/kwatchgnupg/aboutdata.h
new file mode 100644
index 00000000..0e1f9f63
--- /dev/null
+++ b/certmanager/kwatchgnupg/aboutdata.h
@@ -0,0 +1,43 @@
+/*
+ aboutdata.h
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef ABOUTDATA_H
+#define ABOUTDATA_H
+
+#include <kaboutdata.h>
+
+class AboutData : public KAboutData {
+public:
+ AboutData();
+};
+
+#endif // ABOUTDATA_H
diff --git a/certmanager/kwatchgnupg/kwatchgnupg.png b/certmanager/kwatchgnupg/kwatchgnupg.png
new file mode 100644
index 00000000..fbc255ce
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupg.png
Binary files differ
diff --git a/certmanager/kwatchgnupg/kwatchgnupg2.png b/certmanager/kwatchgnupg/kwatchgnupg2.png
new file mode 100644
index 00000000..59efb5dd
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupg2.png
Binary files differ
diff --git a/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp b/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp
new file mode 100644
index 00000000..b621e92b
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp
@@ -0,0 +1,206 @@
+/*
+ kwatchgnupgconfig.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include "kwatchgnupgconfig.h"
+
+#include <klocale.h>
+#include <kurlrequester.h>
+#include <kconfig.h>
+#include <kapplication.h>
+
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qvgroupbox.h>
+
+static const char* log_levels[] = { "none", "basic", "advanced", "expert", "guru" };
+
+static int log_level_to_int( const QString& loglevel )
+{
+ if( loglevel == "none" ) {
+ return 0;
+ } else if( loglevel == "basic" ) {
+ return 1;
+ } else if( loglevel == "advanced" ) {
+ return 2;
+ } else if( loglevel == "expert" ) {
+ return 3;
+ } else if( loglevel == "guru" ) {
+ return 4;
+ } else {
+ // default
+ return 1;
+ }
+}
+
+KWatchGnuPGConfig::KWatchGnuPGConfig( QWidget* parent, const char* name )
+ : KDialogBase( Plain, i18n("Configure KWatchGnuPG"),
+ Ok|Cancel, Ok, parent, name )
+{
+ // tmp vars:
+ QWidget * w;
+ QGridLayout * glay;
+ QGroupBox * group;
+
+ QWidget * top = plainPage();
+
+ QVBoxLayout * vlay = new QVBoxLayout( top, 0, spacingHint() );
+
+ group = new QVGroupBox( i18n("WatchGnuPG"), top );
+ group->layout()->setSpacing( spacingHint() );
+
+ w = new QWidget( group );
+
+ glay = new QGridLayout( w, 3, 2, 0, spacingHint() );
+ glay->setColStretch( 1, 1 );
+
+ int row = -1;
+
+ ++row;
+ mExeED = new KURLRequester( w );
+ glay->addWidget( new QLabel( mExeED, i18n("&Executable:"), w ), row, 0 );
+ glay->addWidget( mExeED, row, 1 );
+ connect( mExeED, SIGNAL(textChanged(const QString&)), SLOT(slotChanged()) );
+
+ ++row;
+ mSocketED = new KURLRequester( w );
+ glay->addWidget( new QLabel( mSocketED, i18n("&Socket:"), w ), row, 0 );
+ glay->addWidget( mSocketED, row, 1 );
+ connect( mSocketED, SIGNAL(textChanged(const QString&)), SLOT(slotChanged()) );
+
+ ++row;
+ mLogLevelCB = new QComboBox( false, w );
+ mLogLevelCB->insertItem( i18n("None") );
+ mLogLevelCB->insertItem( i18n("Basic") );
+ mLogLevelCB->insertItem( i18n("Advanced") );
+ mLogLevelCB->insertItem( i18n("Expert") );
+ mLogLevelCB->insertItem( i18n("Guru") );
+ glay->addWidget( new QLabel( mLogLevelCB, i18n("Default &log level:"), w ), row, 0 );
+ glay->addWidget( mLogLevelCB, row, 1 );
+ connect( mLogLevelCB, SIGNAL(activated(int)), SLOT(slotChanged()) );
+
+ vlay->addWidget( group );
+
+ /******************* Log Window group *******************/
+ group = new QVGroupBox( i18n("Log Window"), top );
+ group->layout()->setSpacing( spacingHint() );
+
+ w = new QWidget( group );
+
+ glay = new QGridLayout( w, 2, 3, 0, spacingHint() );
+ glay->setColStretch( 1, 1 );
+
+ row = -1;
+
+ ++row;
+ mLoglenSB = new QSpinBox( 0, 1000000, 100, w );
+ mLoglenSB->setSuffix( i18n("history size spinbox suffix"," lines") );
+ mLoglenSB->setSpecialValueText( i18n("unlimited") );
+ glay->addWidget( new QLabel( mLoglenSB, i18n("&History size:"), w ), row, 0 );
+ glay->addWidget( mLoglenSB, row, 1 );
+ QPushButton * button = new QPushButton( i18n("Set &Unlimited"), w );
+ glay->addWidget( button, row, 2 );
+
+ connect( mLoglenSB, SIGNAL(valueChanged(int)), SLOT(slotChanged()) );
+ connect( button, SIGNAL(clicked()), SLOT(slotSetHistorySizeUnlimited()) );
+
+ ++row;
+ mWordWrapCB = new QCheckBox( i18n("Enable &word wrapping"), w );
+ mWordWrapCB->hide(); // QTextEdit doesn't support word wrapping in LogText mode
+ glay->addMultiCellWidget( mWordWrapCB, row, row, 0, 2 );
+
+ connect( mWordWrapCB, SIGNAL(clicked()), SLOT(slotChanged()) );
+
+ vlay->addWidget( group );
+ vlay->addStretch( 1 );
+
+ connect( this, SIGNAL(applyClicked()), SLOT(slotSave()) );
+ connect( this, SIGNAL(okClicked()), SLOT(slotSave()) );
+}
+
+void KWatchGnuPGConfig::slotSetHistorySizeUnlimited() {
+ mLoglenSB->setValue( 0 );
+}
+
+void KWatchGnuPGConfig::loadConfig()
+{
+ KConfig* config = kapp->config();
+ config->setGroup("WatchGnuPG");
+ mExeED->setURL( config->readEntry( "Executable", "watchgnupg" ) );
+ mSocketED->setURL( config->readEntry( "Socket", QDir::home().canonicalPath()
+ + "/.gnupg/log-socket") );
+ mLogLevelCB->setCurrentItem( log_level_to_int( config->readEntry( "LogLevel", "basic" ) ) );
+
+ config->setGroup("LogWindow");
+ mLoglenSB->setValue( config->readNumEntry( "MaxLogLen", 10000 ) );
+ mWordWrapCB->setChecked( config->readBoolEntry("WordWrap", false ) );
+
+ config->setGroup( QString::null );
+ enableButtonOK( false );
+ enableButtonApply( false );
+}
+
+void KWatchGnuPGConfig::saveConfig()
+{
+ KConfig* config = kapp->config();
+ config->setGroup("WatchGnuPG");
+ config->writeEntry( "Executable", mExeED->url() );
+ config->writeEntry( "Socket", mSocketED->url() );
+ config->writeEntry( "LogLevel", log_levels[mLogLevelCB->currentItem()] );
+
+ config->setGroup("LogWindow");
+ config->writeEntry( "MaxLogLen", mLoglenSB->value() );
+ config->writeEntry( "WordWrap", mWordWrapCB->isChecked() );
+
+ config->setGroup( QString::null );
+ config->sync();
+ enableButtonOK( false );
+ enableButtonApply( false );
+}
+
+void KWatchGnuPGConfig::slotChanged()
+{
+ enableButtonOK( true );
+ enableButtonApply( true );
+}
+
+void KWatchGnuPGConfig::slotSave()
+{
+ saveConfig();
+ emit reconfigure();
+}
+
+#include "kwatchgnupgconfig.moc"
diff --git a/certmanager/kwatchgnupg/kwatchgnupgconfig.h b/certmanager/kwatchgnupg/kwatchgnupgconfig.h
new file mode 100644
index 00000000..4a93b463
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupgconfig.h
@@ -0,0 +1,68 @@
+/*
+ kwatchgnupgconfig.h
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef KWATCHGNUPGCONFIG_H
+#define KWATCHGNUPGCONFIG_H
+
+#include <kdialogbase.h>
+
+class QCheckBox;
+class QComboBox;
+class QSpinBox;
+class KURLRequester;
+
+class KWatchGnuPGConfig : public KDialogBase {
+ Q_OBJECT
+public:
+ KWatchGnuPGConfig( QWidget* parent, const char* name = 0 );
+
+ void loadConfig();
+ void saveConfig();
+
+signals:
+ void reconfigure();
+
+private slots:
+ void slotChanged();
+ void slotSave();
+ void slotSetHistorySizeUnlimited();
+
+private:
+ KURLRequester* mExeED;
+ KURLRequester* mSocketED;
+ QComboBox* mLogLevelCB;
+ QSpinBox* mLoglenSB;
+ QCheckBox* mWordWrapCB;
+};
+
+#endif /* KWATCHGNUPGCONFIG_H */
+
diff --git a/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp b/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp
new file mode 100644
index 00000000..19bda278
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp
@@ -0,0 +1,292 @@
+/*
+ kwatchgnupgmainwin.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klar�vdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include "kwatchgnupgmainwin.h"
+#include "kwatchgnupgconfig.h"
+#include "tray.h"
+
+#include <kleo/cryptobackendfactory.h>
+#include <kleo/cryptoconfig.h>
+
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kaction.h>
+#include <kstdaction.h>
+#include <kprocio.h>
+#include <kconfig.h>
+#include <kfiledialog.h>
+#include <kedittoolbar.h>
+#include <kkeydialog.h>
+
+#include <qtextedit.h>
+#include <qdir.h>
+#include <qeventloop.h>
+#include <qtimer.h>
+#include <qtextcodec.h>
+
+#define WATCHGNUPGBINARY "watchgnupg"
+#define WATCHGNUPGSOCKET ( QDir::home().canonicalPath() + "/.gnupg/log-socket")
+
+KWatchGnuPGMainWindow::KWatchGnuPGMainWindow( QWidget* parent, const char* name )
+ : KMainWindow( parent, name, WType_TopLevel ), mConfig(0)
+{
+ createActions();
+ createGUI();
+
+ mCentralWidget = new QTextEdit( this, "central log view" );
+ mCentralWidget->setTextFormat( QTextEdit::LogText );
+ setCentralWidget( mCentralWidget );
+
+ mWatcher = new KProcIO( QTextCodec::codecForMib( 106 /*utf-8*/ ) );
+ connect( mWatcher, SIGNAL( processExited(KProcess*) ),
+ this, SLOT( slotWatcherExited() ) );
+ connect( mWatcher, SIGNAL( readReady(KProcIO*) ),
+ this, SLOT( slotReadStdout() ) );
+
+ slotReadConfig();
+ mSysTray = new KWatchGnuPGTray( this );
+ mSysTray->show();
+ connect( mSysTray, SIGNAL( quitSelected() ),
+ this, SLOT( slotQuit() ) );
+ setAutoSaveSettings();
+}
+
+KWatchGnuPGMainWindow::~KWatchGnuPGMainWindow()
+{
+ delete mWatcher;
+}
+
+void KWatchGnuPGMainWindow::slotClear()
+{
+ mCentralWidget->clear();
+ mCentralWidget->append( tr("[%1] Log cleared").arg( QDateTime::currentDateTime().toString(Qt::ISODate) ) );
+}
+
+void KWatchGnuPGMainWindow::createActions()
+{
+ (void)new KAction( i18n("C&lear History"), "history_clear", CTRL+Key_L,
+ this, SLOT( slotClear() ),
+ actionCollection(), "clear_log" );
+ (void)KStdAction::saveAs( this, SLOT(slotSaveAs()), actionCollection() );
+ (void)KStdAction::close( this, SLOT(close()), actionCollection() );
+ (void)KStdAction::quit( this, SLOT(slotQuit()), actionCollection() );
+ (void)KStdAction::preferences( this, SLOT(slotConfigure()), actionCollection() );
+ ( void )KStdAction::keyBindings(this, SLOT(configureShortcuts()), actionCollection());
+ ( void )KStdAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
+
+#if 0
+ (void)new KAction( i18n("Configure KWatchGnuPG..."), QString::fromLatin1("configure"),
+ 0, this, SLOT( slotConfigure() ),
+ actionCollection(), "configure" );
+#endif
+
+}
+
+void KWatchGnuPGMainWindow::configureShortcuts()
+{
+ KKeyDialog::configure( actionCollection(), this );
+}
+
+void KWatchGnuPGMainWindow::slotConfigureToolbars()
+{
+ KEditToolbar dlg( factory() );
+
+ dlg.exec();
+}
+
+void KWatchGnuPGMainWindow::startWatcher()
+{
+ disconnect( mWatcher, SIGNAL( processExited(KProcess*) ),
+ this, SLOT( slotWatcherExited() ) );
+ if( mWatcher->isRunning() ) {
+ mWatcher->kill();
+ while( mWatcher->isRunning() ) {
+ kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
+ }
+ mCentralWidget->append(tr("[%1] Log stopped")
+ .arg( QDateTime::currentDateTime().toString(Qt::ISODate)));
+ }
+ mWatcher->clearArguments();
+ KConfig* config = kapp->config();
+ config->setGroup("WatchGnuPG");
+ *mWatcher << config->readEntry("Executable", WATCHGNUPGBINARY);
+ *mWatcher << "--force";
+ *mWatcher << config->readEntry("Socket", WATCHGNUPGSOCKET);
+ config->setGroup(QString::null);
+ if( !mWatcher->start() ) {
+ KMessageBox::sorry( this, i18n("The watchgnupg logging process could not be started.\nPlease install watchgnupg somewhere in your $PATH.\nThis log window is now completely useless." ) );
+ } else {
+ mCentralWidget->append( tr("[%1] Log started")
+ .arg( QDateTime::currentDateTime().toString(Qt::ISODate) ) );
+ }
+ connect( mWatcher, SIGNAL( processExited(KProcess*) ),
+ this, SLOT( slotWatcherExited() ) );
+}
+
+void KWatchGnuPGMainWindow::setGnuPGConfig()
+{
+ QStringList logclients;
+ // Get config object
+ Kleo::CryptoConfig* cconfig = Kleo::CryptoBackendFactory::instance()->config();
+ if ( !cconfig )
+ return;
+ //Q_ASSERT( cconfig );
+ KConfig* config = kapp->config();
+ config->setGroup("WatchGnuPG");
+ QStringList comps = cconfig->componentList();
+ for( QStringList::const_iterator it = comps.begin(); it != comps.end(); ++it ) {
+ Kleo::CryptoConfigComponent* comp = cconfig->component( *it );
+ Q_ASSERT(comp);
+ // Look for log-file entry in Debug group
+ Kleo::CryptoConfigGroup* group = comp->group("Debug");
+ if( group ) {
+ Kleo::CryptoConfigEntry* entry = group->entry("log-file");
+ if( entry ) {
+ entry->setStringValue( QString("socket://")+
+ config->readEntry("Socket",
+ WATCHGNUPGSOCKET ));
+ logclients << QString("%1 (%2)").arg(*it).arg(comp->description());
+ }
+ entry = group->entry("debug-level");
+ if( entry ) {
+ entry->setStringValue( config->readEntry("LogLevel", "basic") );
+ }
+ }
+ }
+ cconfig->sync(true);
+ if( logclients.isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("There are no components available that support logging." ) );
+ }
+}
+
+void KWatchGnuPGMainWindow::slotWatcherExited()
+{
+ if( KMessageBox::questionYesNo( this, i18n("The watchgnupg logging process died.\nDo you want to try to restart it?"), QString::null, i18n("Try Restart"), i18n("Do Not Try") ) == KMessageBox::Yes ) {
+ mCentralWidget->append( i18n("====== Restarting logging process =====") );
+ startWatcher();
+ } else {
+ KMessageBox::sorry( this, i18n("The watchgnupg logging process is not running.\nThis log window is now completely useless." ) );
+ }
+}
+
+void KWatchGnuPGMainWindow::slotReadStdout()
+{
+ if ( !mWatcher )
+ return;
+ QString str;
+ while( mWatcher->readln(str,false) > 0 ) {
+ mCentralWidget->append( str );
+ if( !isVisible() ) {
+ // Change tray icon to show something happened
+ // PENDING(steffen)
+ mSysTray->setAttention(true);
+ }
+ }
+ QTimer::singleShot( 0, this, SLOT(slotAckRead()) );
+}
+
+void KWatchGnuPGMainWindow::slotAckRead() {
+ if ( mWatcher )
+ mWatcher->ackRead();
+}
+
+void KWatchGnuPGMainWindow::show()
+{
+ mSysTray->setAttention(false);
+ KMainWindow::show();
+}
+
+void KWatchGnuPGMainWindow::slotSaveAs()
+{
+ QString filename = KFileDialog::getSaveFileName( QString::null, QString::null,
+ this, i18n("Save Log to File") );
+ if( filename.isEmpty() ) return;
+ QFile file(filename);
+ if( file.exists() ) {
+ if( KMessageBox::Yes !=
+ KMessageBox::warningYesNo( this, i18n("The file named \"%1\" already "
+ "exists. Are you sure you want "
+ "to overwrite it?").arg(filename),
+ i18n("Overwrite File"), i18n("Overwrite"), KStdGuiItem::cancel() ) ) {
+ return;
+ }
+ }
+ if( file.open( IO_WriteOnly ) ) {
+ QTextStream st(&file);
+ st << mCentralWidget->text();
+ file.close();
+ }
+}
+
+void KWatchGnuPGMainWindow::slotQuit()
+{
+ disconnect( mWatcher, SIGNAL( processExited(KProcess*) ),
+ this, SLOT( slotWatcherExited() ) );
+ mWatcher->kill();
+ kapp->quit();
+}
+
+void KWatchGnuPGMainWindow::slotConfigure()
+{
+ if( !mConfig ) {
+ mConfig = new KWatchGnuPGConfig( this, "config dialog" );
+ connect( mConfig, SIGNAL( reconfigure() ),
+ this, SLOT( slotReadConfig() ) );
+ }
+ mConfig->loadConfig();
+ mConfig->exec();
+}
+
+void KWatchGnuPGMainWindow::slotReadConfig()
+{
+ KConfig* config = kapp->config();
+ config->setGroup("LogWindow");
+ mCentralWidget->setWordWrap( config->readBoolEntry("WordWrap", false)
+ ?QTextEdit::WidgetWidth
+ :QTextEdit::NoWrap );
+ mCentralWidget->setMaxLogLines( config->readNumEntry( "MaxLogLen", 10000 ) );
+ setGnuPGConfig();
+ startWatcher();
+}
+
+bool KWatchGnuPGMainWindow::queryClose()
+{
+ if ( !kapp->sessionSaving() ) {
+ hide();
+ return false;
+ }
+ return KMainWindow::queryClose();
+}
+
+#include "kwatchgnupgmainwin.moc"
diff --git a/certmanager/kwatchgnupg/kwatchgnupgmainwin.h b/certmanager/kwatchgnupg/kwatchgnupgmainwin.h
new file mode 100644
index 00000000..2021a657
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupgmainwin.h
@@ -0,0 +1,78 @@
+/*
+ main.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef KWATCHGNUPGMAINWIN_H
+#define KWATCHGNUPGMAINWIN_H
+
+#include <kmainwindow.h>
+
+class KWatchGnuPGTray;
+class KWatchGnuPGConfig;
+class KProcIO;
+class QTextEdit;
+
+class KWatchGnuPGMainWindow : public KMainWindow {
+ Q_OBJECT
+public:
+ KWatchGnuPGMainWindow( QWidget* parent = 0, const char* name = 0 );
+ virtual ~KWatchGnuPGMainWindow();
+public slots:
+ void slotWatcherExited();
+ void slotReadStdout();
+ void slotAckRead();
+
+ void slotSaveAs();
+ void slotQuit();
+ void slotClear();
+
+ void slotConfigure();
+ void slotConfigureToolbars();
+ void configureShortcuts();
+ void slotReadConfig();
+
+ virtual void show();
+protected:
+ virtual bool queryClose();
+private:
+ void createActions();
+ void startWatcher();
+ void setGnuPGConfig();
+
+ KProcIO* mWatcher;
+
+ QTextEdit* mCentralWidget;
+ KWatchGnuPGTray* mSysTray;
+ KWatchGnuPGConfig* mConfig;
+};
+
+#endif /* KWATCHGNUPGMAINWIN_H */
+
diff --git a/certmanager/kwatchgnupg/kwatchgnupgui.rc b/certmanager/kwatchgnupg/kwatchgnupgui.rc
new file mode 100644
index 00000000..3e42a141
--- /dev/null
+++ b/certmanager/kwatchgnupg/kwatchgnupgui.rc
@@ -0,0 +1,21 @@
+<!DOCTYPE kpartgui ><kpartgui name="kwatchgnupg" version="7">
+<MenuBar>
+ <Menu name="file" >
+ <text>&amp;File</text>
+ <Action name="clear_log"/>
+ <Action name="print"/>
+ <Separator/>
+ <Action name="close"/>
+ <Action name="quit"/>
+ </Menu>
+</MenuBar>
+<ToolBar noMerge="1" name="mainToolBar" >
+ <text>Main Toolbar</text>
+ <Action name="file_save_as"/>
+ <Separator/>
+ <Action name="clear_log"/>
+ <Separator/>
+ <Action name="options_configure"/>
+</ToolBar>
+
+</kpartgui>
diff --git a/certmanager/kwatchgnupg/main.cpp b/certmanager/kwatchgnupg/main.cpp
new file mode 100644
index 00000000..7c25a8da
--- /dev/null
+++ b/certmanager/kwatchgnupg/main.cpp
@@ -0,0 +1,96 @@
+/*
+ main.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "aboutdata.h"
+#include "kwatchgnupgmainwin.h"
+
+#include <kuniqueapplication.h>
+#include <kcmdlineargs.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+
+class KWatchGnuPGApplication : public KUniqueApplication {
+public:
+ KWatchGnuPGApplication();
+ ~KWatchGnuPGApplication();
+ virtual int newInstance();
+private:
+ KWatchGnuPGMainWindow* mMainWin;
+};
+
+KWatchGnuPGApplication::KWatchGnuPGApplication()
+ : KUniqueApplication(), mMainWin(0)
+{
+}
+
+KWatchGnuPGApplication::~KWatchGnuPGApplication()
+{
+ delete mMainWin;
+}
+
+int KWatchGnuPGApplication::newInstance()
+{
+ if( !mMainWin ) {
+ mMainWin = new KWatchGnuPGMainWindow( 0, "kwatchgnupg mainwin" );
+ setMainWidget( mMainWin );
+ }
+ mMainWin->show();
+ return KUniqueApplication::newInstance();
+}
+
+int main( int argc, char** argv )
+{
+ AboutData aboutData;
+
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ static const KCmdLineOptions options[] = {
+ KCmdLineLastOption// End of options.
+ };
+ KCmdLineArgs::addCmdLineOptions( options );
+ KWatchGnuPGApplication::addCmdLineOptions();
+
+#if 0
+ if (!KWatchGnuPGApplication::start()) {
+ kdError() << "KWatchGnuPG is already running!" << endl;
+ return 0;
+ }
+#endif
+ KWatchGnuPGApplication app;
+ return app.exec();
+}
diff --git a/certmanager/kwatchgnupg/tray.cpp b/certmanager/kwatchgnupg/tray.cpp
new file mode 100644
index 00000000..62024b14
--- /dev/null
+++ b/certmanager/kwatchgnupg/tray.cpp
@@ -0,0 +1,66 @@
+/*
+ main.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include "tray.h"
+#include "kwatchgnupgmainwin.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <qtooltip.h>
+
+KWatchGnuPGTray::KWatchGnuPGTray( KWatchGnuPGMainWindow* mainwin )
+ : KSystemTray( mainwin, "KWatchGnuPG Tray Window" )
+{
+ kdDebug() << "KWatchGnuPGTray::KWatchGnuPGTray" << endl;
+
+ KGlobal::iconLoader()->addAppDir( "kwatchgnupg" );
+
+ mNormalPix = loadIcon("kwatchgnupg");
+ mAttentionPix = loadIcon("kwatchgnupg2");
+
+ setPixmap( mNormalPix );
+ QToolTip::add( this, i18n("KWatchGnuPG Log Viewer") );
+}
+
+KWatchGnuPGTray::~KWatchGnuPGTray()
+{
+}
+
+void KWatchGnuPGTray::setAttention( bool att )
+{
+ if( att ) setPixmap( mAttentionPix );
+ else setPixmap( mNormalPix );
+}
+
+#include "tray.moc"
diff --git a/certmanager/kwatchgnupg/tray.h b/certmanager/kwatchgnupg/tray.h
new file mode 100644
index 00000000..7f220eca
--- /dev/null
+++ b/certmanager/kwatchgnupg/tray.h
@@ -0,0 +1,55 @@
+/*
+ main.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
+
+ Kleopatra 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.
+
+ Kleopatra 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
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef TRAY_H
+#define TRAY_H
+
+#include <ksystemtray.h>
+#include <qpixmap.h>
+
+class KWatchGnuPGMainWindow;
+
+class KWatchGnuPGTray : public KSystemTray {
+ Q_OBJECT
+public:
+ KWatchGnuPGTray( KWatchGnuPGMainWindow* mainwin );
+ virtual ~KWatchGnuPGTray();
+
+public slots:
+ void setAttention( bool att );
+private:
+ QPixmap mNormalPix;
+ QPixmap mAttentionPix;
+};
+
+#endif /* TRAY_H */
+