diff options
Diffstat (limited to 'src/torkapplet')
-rw-r--r-- | src/torkapplet/Makefile.am | 17 | ||||
-rw-r--r-- | src/torkapplet/tork_mnu.cpp | 203 | ||||
-rw-r--r-- | src/torkapplet/tork_mnu.h | 53 | ||||
-rw-r--r-- | src/torkapplet/torkmenu.desktop | 8 |
4 files changed, 281 insertions, 0 deletions
diff --git a/src/torkapplet/Makefile.am b/src/torkapplet/Makefile.am new file mode 100644 index 0000000..4542d3b --- /dev/null +++ b/src/torkapplet/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) +LIBS = + +kde_module_LTLIBRARIES = kickermenu_tork.la + +kickermenu_tork_la_SOURCES = tork_mnu.cpp ../functions.cpp +kickermenu_tork_la_LDFLAGS = $(all_libraries) -module -avoid-version +kickermenu_tork_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) $(LIB_KDECORE) -lDCOP $(LIB_QT) + +kickermenu_tork_la_METASOURCES = AUTO + +desktopmenu_DATA = torkmenu.desktop +desktopmenudir = $(kde_datadir)/kicker/menuext + +messages: + $(XGETTEXT) *.cpp -o $(podir)/libkickermenu_tork.pot + diff --git a/src/torkapplet/tork_mnu.cpp b/src/torkapplet/tork_mnu.cpp new file mode 100644 index 0000000..b354612 --- /dev/null +++ b/src/torkapplet/tork_mnu.cpp @@ -0,0 +1,203 @@ +/*************************************************************************** +** $Id: tork_mnu.cpp,v 1.7 2008/07/31 19:56:29 hoganrobert Exp $ + * Copyright (C) 2006 - 2008 Robert Hogan * + * [email protected] * + * * + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <stdlib.h> +#include <dirent.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> + +#include <qdir.h> +#include <qfileinfo.h> +#include <qstringlist.h> + +#include <kapplication.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kio/global.h> +#include <klocale.h> +#include <krun.h> +#include <kshell.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> +#include <dcopref.h> +#include <dcopclient.h> +#include <kdebug.h> +#include <klocale.h> +#include <krun.h> + +#include "tork_mnu.h" +#include "../functions.h" + +K_EXPORT_KICKER_MENUEXT(tork, TorkMenu) + +QValueVector<QString> torkifyApp(8); + + +TorkMenu::TorkMenu(QWidget *parent, const char *name, const QStringList& /* args */) + : KPanelMenu("", parent, name),m_kdestate(true) +{ + p_dcopServer= new DCOPClient(); + p_dcopServer->attach (); + +} + +TorkMenu::~TorkMenu() +{ + KGlobal::locale()->removeCatalogue("libkickermenu_tork"); + p_dcopServer->detach(); + delete p_dcopServer; + +} + +void TorkMenu::initialize() +{ + if (initialized()) + { + clear(); + } + else + { + kapp->iconLoader()->addAppDir("tork"); + } + + setInitialized(true); + + torkifyApp[5] = "Konversation"; + torkifyApp[2] = "Kopete"; + torkifyApp[4] = "Gaim"; + torkifyApp[3] = "Pidgin"; + torkifyApp[6] = "Konsole"; + torkifyApp[1] = "Opera"; + torkifyApp[0] = "Firefox"; + torkifyApp[7] = "Email"; + + QStringList paths = getProgramList(); + + + if (paths.contains("firefox")) + insertItem( SmallIcon("tork_firefox"), i18n( "Anonymous Firefox" ), 0,1 ); + if (paths.contains("opera")) + insertItem( SmallIcon("tork_opera"), i18n( "Anonymous Opera" ), 1,2 ); + if (paths.contains("kopete")) + insertItem( SmallIcon("kopete"), i18n( "Anonymous Kopete" ), 2,3 ); + if (paths.contains("pidgin")) + insertItem( SmallIcon("pidgin"), i18n( "Anonymous Pidgin" ), 3,4 ); + if (paths.contains("gaim")) + insertItem( SmallIcon("gaim"), i18n( "Anonymous Gaim" ), 4,5 ); + if (paths.contains("konversation")) + insertItem( SmallIcon("konversation"), i18n( "Anonymous Konversation" ), 5,6 ); + if (paths.contains("konsole")) + insertItem( SmallIcon("tork_konsole"), i18n( "Anonymous Konsole Session" ), 6,7 ); + insertSeparator(); + + + insertItem( SmallIcon("tork_mail"), i18n( "Send Anonymous Email" ), 7,8 ); + + insertSeparator(); + + insertItem( SmallIcon("tork_konqueroron"), i18n( "Anonymize KDE" ), 9,9 ); + + connect( this, SIGNAL( aboutToShow() ), SLOT( showPopup() )); + +} + +void TorkMenu::showPopup() +{ + bool anonymized = false; + + + if (p_dcopServer->isApplicationRegistered ("tork")) + { + DCOPRef tork( "tork", "DCOPTork" ); + anonymized = tork.call( "getKDESetting" ); + } + + if (anonymized) + changeItem(9, SmallIcon("tork_konqueroroff"), i18n( "De-Anonymize KDE" )); + else + changeItem(9, SmallIcon("tork_konqueroron"), i18n( "Anonymize KDE" )); + + +} + +void TorkMenu::slotExec(int id) +{ + + m_torkrunning = false; + if (p_dcopServer->isApplicationRegistered ("tork")) + m_torkrunning = true; + + + switch(id) + { + case 9: + anonymizeKDE(); break; + default: + anonymousApp(id);break; + } + +} + +void TorkMenu::anonymousApp(int id) +{ + + QString app = torkifyApp[id]; + app.prepend("anonymous"); + + if (m_torkrunning){ + DCOPRef("tork*", "DCOPTork").send("startEverything"); + DCOPRef("tork*", "DCOPTork").send(QCString(app)); + }else + KRun::runCommand( QString("tork --%1").arg(app), "tork", "tork" ); + +} + + +void TorkMenu::anonymizeKDE() +{ + if (m_torkrunning){ + DCOPRef("tork*", "DCOPTork").send("startEverything"); + DCOPRef("tork*", "DCOPTork").send("toggleKDESetting"); + }else + KRun::runCommand( "tork --toggleKDE", "tork", "tork" ); + +// if (m_kdestate) +// changeItem(9, SmallIcon("tork_konqueroroff"), i18n( "De-Anonymize KDE" )); +// else +// changeItem(9, SmallIcon("tork_konqueroron"), i18n( "Anonymize KDE" )); +// +// m_kdestate = !m_kdestate; + +} + +QStringList TorkMenu::getProgramList() +{ + + //Check for the existence of anonymizable/helper programs first. + QStringList programList; + programList << "firefox" << "kopete" << "gaim" << + "pidgin" << "opera" << "konversation"; + + return findPrograms(programList); +} + +#include "tork_mnu.moc" diff --git a/src/torkapplet/tork_mnu.h b/src/torkapplet/tork_mnu.h new file mode 100644 index 0000000..fe49b40 --- /dev/null +++ b/src/torkapplet/tork_mnu.h @@ -0,0 +1,53 @@ +/*************************************************************************** +** $Id: tork_mnu.h,v 1.5 2008/07/31 19:56:29 hoganrobert Exp $ + * Copyright (C) 2006 - 2008 Robert Hogan * + * [email protected] * + * * + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + + +#ifndef _tork_mnu_h_ +#define _tork_mnu_h_ + +#include <qvaluevector.h> + +#include <kpanelmenu.h> +#include <klibloader.h> +#include <dcopclient.h> + + +class TorkMenu : public KPanelMenu/*, public KPReloadObject*/ +{ + Q_OBJECT + +public: + TorkMenu(QWidget *parent, const char *name, const QStringList& /* args */); + ~TorkMenu(); + void anonymousApp(int id); + void anonymizeKDE(); + bool m_kdestate; + bool m_torkrunning; + DCOPClient* p_dcopServer; + QStringList getProgramList(); +protected slots: + void initialize(); + void slotExec(int id); + void showPopup(); +}; + +#endif + diff --git a/src/torkapplet/torkmenu.desktop b/src/torkapplet/torkmenu.desktop new file mode 100644 index 0000000..a30c5d7 --- /dev/null +++ b/src/torkapplet/torkmenu.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=TorK +Type=Application +Comment=Menu For Managing TorK +Icon=tork + +X-KDE-Library=kickermenu_tork +X-KDE-AuthorizeAction=shell_access |