1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/***************************************************************************
copyright : (C) 1997-2000 by Peter Putzer
email : putzer@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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; version 2. *
* *
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include "ksvapplication.h"
#include "ksv_conf.h"
#include "ksvconfigwizard.h"
#include "TopWidget.h"
#include "version.h"
using namespace std;
#if (defined(DEBUG) && !(defined(NDEBUG) || defined(NO_DEBUG)))
#define KSYSV_DEBUG(x) x
#else
#define KSYSV_DEBUG(x) do { } while (0)
#endif
static void myMessageOutput( TQtMsgType type, const char *msg )
{
switch ( type ) {
case TQtDebugMsg:
KSYSV_DEBUG(cerr << "Debug: " << msg << endl);
break;
case TQtWarningMsg:
KSYSV_DEBUG(cerr << "Warning: " << msg << endl);
break;
case TQtFatalMsg:
cerr << "Fatal: " << msg << endl;
abort(); // dump core on purpose
}
}
int main( int argc, char **argv ) {
// install own message handler that ignores debug-msg when DEBUG is not defined
tqInstallMsgHandler(myMessageOutput);
KAboutData about("ksysv", I18N_NOOP("SysV-Init Editor"), KSYSV_VERSION_STRING,
I18N_NOOP ("Editor for Sys-V like init configurations"),
KAboutData::License_GPL,
"Copyright (c) 1997-2000, Peter Putzer.",
I18N_NOOP ("Similar to Red Hat's" \
"\"tksysv\", but SysV-Init Editor allows\n" \
"drag-and-drop, as well as keyboard use."));
about.addAuthor ("Peter Putzer", I18N_NOOP("Main developer"), "putzer@kde.org");
ksv::about = &about;
TDECmdLineArgs::init(argc, argv, &about);
KUniqueApplication::addCmdLineOptions ();
if (!KUniqueApplication::start()) {
cerr << "SysV-Init Editor is already running!" << endl;
return -1;
}
KSVApplication app;
// session-management
if (kapp->isRestored())
RESTORE(KSVTopLevel)
else
{
KSVConfig* conf = KSVConfig::self();
if (!conf->isConfigured())
{
KSVConfigWizard* w = new KSVConfigWizard(0, "ConfigWizard", true);
w->exec();
conf->setConfigured(true);
conf->setRunlevelPath (w->runlevelPath());
conf->setScriptPath (w->servicesPath());
conf->writeSettings();
}
KSVTopLevel* top = new KSVTopLevel();
app.setMainWidget(top);
top->show();
}
// end session-management
return app.exec();
}
|