summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2015-10-01 17:05:29 +0200
committerSlávek Banko <slavek.banko@axis.cz>2015-10-01 17:05:29 +0200
commit39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70 (patch)
treed6bc97f38d36892b14703c788cef782f13ee2a4d /src/main.cpp
downloadkooldock-39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70.tar.gz
kooldock-39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70.zip
Initial import of kooldock 0.4.7
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..411fad6
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Thu Jun 19 14:43:55 BST 2003
+ copyright : (C) 2003 by KoolDock team
+ email :
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <klocale.h>
+#include <kcrash.h>
+#include <kdebug.h>
+#include <kuniqueapplication.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <kmessagebox.h>
+
+#include "kooldock.h"
+
+#define KOOLDOCK_VERSION "0.4.7"
+QString argv0;
+
+#ifndef _ENABLE_DEBUG
+extern "C"
+{
+ static void crashHandler(int /*signal*/)
+ {
+ char cmd[1024];
+ fprintf(stderr, "kooldock: crashHandler called\n");
+ snprintf(cmd, 1025, "%s &", argv0.ascii());
+ system(cmd); // try to restart according to argv[0]
+ }
+}
+#endif
+
+static const char *description = I18N_NOOP("<center><b>KoolDock</b></center>A Kool Dock for KDE<br><br>KoolDock is based upon the original work of Dang Viet Dung, Ksmoothdock 2.1<br><br>");
+
+static KCmdLineOptions options[] =
+{
+ { "o", 0, 0 },
+ { "options", I18N_NOOP("Show configuration window on start"), 0 },
+ { "k", 0, 0 },
+ { "kill", I18N_NOOP("Kills all processes called Kooldock"), 0 },
+ {0, 0, 0}
+};
+
+int main(int argc, char *argv[])
+{
+ argv0=QString("%1").arg(argv[0]);
+
+ KAboutData aboutData( "kooldock", I18N_NOOP("KoolDock"),
+ KOOLDOCK_VERSION, description, KAboutData::License_GPL,
+ "(c) 2003, 2006 - KoolDock team", 0, "http://ktown.kde.cl/kooldock", "kooldock-devel@lists.kde.cl");
+ aboutData.addAuthor("Matias Fernandez",0, "radix@kde.cl");
+ aboutData.addAuthor("Francisco Guidi",0, "francisco@guidi.com", "http://francisco.guidi.com");
+ aboutData.addAuthor("Blase Stanek", 0, "bisiek@op.pl");
+ aboutData.addCredit("Mauricio Bahamonde", I18N_NOOP("Project Webmaster"), "elkrammer@kde.cl", "http://ktown.kde.cl/~elkrammer/");
+ aboutData.addCredit("Sebastian Sariego Benitez", I18N_NOOP("Icon and artwork"), "segfault@powers.cl", "http://segfault.kde.cl");
+ aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ #ifdef _ENABLE_DEBUG
+ KApplication::addCmdLineOptions();
+ #endif
+ #ifndef _ENABLE_DEBUG
+ KUniqueApplication::addCmdLineOptions();
+ #endif
+ if (QString("%1").arg(argv[1])=="-kill" || QString("%1").arg(argv[1])=="-k")
+ {
+ system("killall kooldock");
+ exit(0);
+ }
+
+ #ifndef _ENABLE_DEBUG
+ if (!KUniqueApplication::start())
+ {
+ fprintf(stderr, "Kooldock is already running!\n");
+ exit(0);
+ }
+ #endif
+
+ #ifndef _ENABLE_DEBUG
+ KUniqueApplication a;
+ #endif
+ #ifdef _ENABLE_DEBUG
+ KApplication a;
+ #endif
+ KoolDock *kooldock = new KoolDock();
+ a.setMainWidget(kooldock);
+
+ #ifndef _ENABLE_DEBUG
+ if(KCrash::crashHandler()!=0)
+ {
+ kdDebug(0) << "Installing crash handler" << endl;
+ KCrash::setEmergencySaveFunction(crashHandler); // Try to restart on crash
+ }
+ #endif
+
+ kooldock->setMainPath(argv0);
+ kooldock->setArgs(QString("%1").arg(argv[1]));
+ return a.exec();
+}