summaryrefslogtreecommitdiffstats
path: root/KMFSysTray/kmfsystray.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 01:04:17 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 01:04:17 +0000
commitc3b707c026782768bd8c0e6ae6b574fe8a36802d (patch)
tree5ca6782031b1546c788290cc0b95524369ff01ea /KMFSysTray/kmfsystray.cpp
downloadkmyfirewall-c3b707c026782768bd8c0e6ae6b574fe8a36802d.tar.gz
kmyfirewall-c3b707c026782768bd8c0e6ae6b574fe8a36802d.zip
Added old abandoned KDE3 version of kmyfirewall
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmyfirewall@1091559 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'KMFSysTray/kmfsystray.cpp')
-rw-r--r--KMFSysTray/kmfsystray.cpp166
1 files changed, 166 insertions, 0 deletions
diff --git a/KMFSysTray/kmfsystray.cpp b/KMFSysTray/kmfsystray.cpp
new file mode 100644
index 0000000..bea6399
--- /dev/null
+++ b/KMFSysTray/kmfsystray.cpp
@@ -0,0 +1,166 @@
+/**************************************************************************
+* Copyright (C) 2005 by Christian Hubinger *
+* *
+* 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. *
+***************************************************************************/
+
+
+// QT includes
+#include <qlcdnumber.h>
+#include <qlayout.h>
+
+// KDE includes
+#include <kglobal.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <kconfig.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <dcopclient.h>
+#include <kdebug.h>
+#include <kpopupmenu.h>
+#include <kiconloader.h>
+#include <kprocess.h>
+
+// Project includes
+#include "kmfsystray.h"
+#include "kmfiptwatcher.h"
+#include "mainwidget.h"
+
+#include "../core/kmfiptdoc.h"
+#include "../core/kmfappstate.h"
+
+KMFSysTray::KMFSysTray( QWidget* w ) : KSystemTray ( w ) , DCOPObject( "KMFSysTray" ) {
+ mainView = w;
+ ksConfig = kapp->config();
+ KMFIPTWatcher *watch = new KMFIPTWatcher( this, "KMFIPTWatcher" );
+
+ baseIcon = KSystemTray::loadIcon( "kmyfirewall" );
+ setPixmap( baseIcon );
+
+ // Connect the watch deamon
+ connect( watch, SIGNAL( sigUpdateActive( bool ) ), this, SLOT( slotSetRunningStatus( bool ) ) );
+ connect( watch, SIGNAL( sigUpdateRuleCount( const QString&, const QString&, int ) ),
+ this, SIGNAL( sigUpdateRuleCount( const QString&, const QString&, int ) ) );
+
+ connect( watch, SIGNAL( sigUpdateIPTDoc( KMFIPTDoc* ) ),
+ this, SIGNAL( sigUpdateIPTDoc( KMFIPTDoc* ) ) );
+
+ connect( this, SIGNAL( sigQueryDetails( bool ) ), watch, SLOT( slotQueryDetails( bool ) ) );
+
+ // Connect view
+ connect( w, SIGNAL( closing() ), this, SLOT ( slotDetailsClosed() ) );
+ connect( w, SIGNAL( showing() ), this, SLOT ( slotQueryDetails() ) );
+ connect( this, SIGNAL( sigUpdateIPTDoc( KMFIPTDoc* ) ), w, SLOT( slotLoadDoc( KMFIPTDoc* ) ) );
+
+
+ initMenu();
+
+ show();
+ emit sigQueryDetails( false );
+ KMFAppState::setUpAndRunning( true );
+ KMFAppState::setHasOpenDoc( true );
+}
+
+
+KMFSysTray::~KMFSysTray() {}
+
+void KMFSysTray::initMenu() {
+ KPopupMenu* menu = contextMenu ();
+ menu->insertItem( KGlobal::iconLoader()->loadIcon( "kmyfirewall", KIcon::Small ), i18n( "Launch KMyFirewall..."), this, SLOT( slotLaunchKMF() ), CTRL+Key_K );
+
+}
+
+void KMFSysTray::slotSetRunningStatus( bool on ) {
+ if ( on ) {
+ baseIcon = KSystemTray::loadIcon( "kmyfirewall" );
+ } else {
+ baseIcon = KSystemTray::loadIcon( "kmyfirewall" );
+ }
+ setPixmap( baseIcon );
+}
+
+
+
+void KMFSysTray::slotLaunchKMF () {
+ KProcess *childproc = new KProcess();
+ *childproc << "kdesu";
+ *childproc << "kmyfirewall";
+ childproc->start( KProcess:: DontCare, KProcess::NoCommunication );
+}
+
+void KMFSysTray::slotShowDetails() {
+ kdDebug() << "MFSysTray::slotshowDetails()" << endl;
+ slotQueryDetails();
+ mainView->show();
+
+}
+
+void KMFSysTray::slotQueryDetails() {
+ emit sigQueryDetails( true );
+}
+
+void KMFSysTray::slotDetailsClosed() {
+ kdDebug() << "KMFSysTray::slotDetailsClosed()" << endl;
+ emit sigQueryDetails( false );
+}
+
+void KMFSysTray::about() {
+/* if(!_aboutData) {
+ _aboutData = new KAboutData("KMFSysTray", I18N_NOOP("KMFSysTray"),
+ "1.0", I18N_NOOP("KMyFirewall Pannel Applet.\n\n"
+ "Some basic inform<tion about your running iptables rules"),
+ KAboutData::License_GPL_V2, "(c) 2005, Christian Hubinger");
+ _aboutData->addAuthor("Christian Hubinger", 0, "[email protected]");
+
+ }
+ KAboutApplication dialog(_aboutData);
+ dialog.show();*/
+}
+
+
+void KMFSysTray::help() {
+ KMessageBox::information( 0, i18n( "This is a help box" ) );
+}
+
+
+void KMFSysTray::preferences() {
+ KMessageBox::information( 0, i18n( "This is a preferences box" ) );
+}
+
+int KMFSysTray::widthForHeight( int ) const {
+ return width();
+}
+
+int KMFSysTray::heightForWidth( int ) const {
+ return height();
+}
+
+void KMFSysTray::resizeEvent( QResizeEvent *e ) {}
+
+
+// extern "C" {
+// KPanelApplet * init( QWidget * parent, const QString & configFile ) {
+// KGlobal::locale() ->insertCatalogue( "kmfsystray" );
+// return new KMFSysTray( configFile, KPanelApplet::Normal,
+// KPanelApplet::About | KPanelApplet::Help | KPanelApplet::Preferences,
+// parent, "kmfsystray" );
+// }
+// }
+
+