36#include <QtCore/QCoreApplication>
38#ifndef USE_KPROCESS_FOR_KIOSLAVES
39static int sigpipe[ 2 ];
40static void sig_handler(
int sig_num)
43 KDE_signal( SIGHUP, SIG_IGN);
44 KDE_signal( SIGTERM, SIG_IGN);
45 fprintf(stderr,
"klauncher: Exiting on signal %d\n", sig_num);
47 write( sigpipe[ 1 ], &tmp, 1 );
51#if defined(Q_OS_DARWIN) || defined (Q_OS_MAC)
60 if (argc != 2 || memcmp(
argv[1],
"--fd=", 5) || !(launcherFd = atoi(
argv[1] + 5)))
62 fprintf(stderr,
"%s",
i18n(
"klauncher: This program is not supposed to be started manually.\n"
63 "klauncher: It is started automatically by kdeinit4.\n").toLocal8Bit().data());
68#if defined(Q_OS_DARWIN) || defined (Q_OS_MAC)
76 putenv(strdup(
"SESSION_MANAGER="));
79 const bool wasQtNoGlibSet = !qgetenv(
"QT_NO_GLIB").isEmpty();
80 if (!wasQtNoGlibSet) {
81 qputenv(
"QT_NO_GLIB",
"1");
85 QCoreApplication app(argc,
argv);
89 if (!wasQtNoGlibSet) {
90 qputenv(
"QT_NO_GLIB",
"");
96 QString service(QLatin1String(
"org.kde.klauncher"));
97 if (!QDBusConnection::sessionBus().isConnected()) {
98 kWarning() <<
"No DBUS session-bus found. Check if you have started the DBUS server.";
101 QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply =
102 QDBusConnection::sessionBus().interface()->registerService(service);
103 if (!reply.isValid())
105 kWarning() <<
"DBUS communication problem!";
108 if (reply == QDBusConnectionInterface::ServiceRegistered)
113 kWarning() <<
"Another instance of klauncher is already running!";
118 kWarning() <<
"Waiting for already running klauncher to exit.";
124#ifndef USE_KPROCESS_FOR_KIOSLAVES
129 QDBusConnection::sessionBus().registerObject(QString::fromLatin1(
"/"),
launcher);
131#ifndef USE_KPROCESS_FOR_KIOSLAVES
132 if (pipe(sigpipe) != 0) {
133 perror(
"klauncher: pipe failed.");
136 QSocketNotifier* signotif =
new QSocketNotifier( sigpipe[ 0 ], QSocketNotifier::Read,
launcher );
137 QObject::connect( signotif, SIGNAL(activated(
int)),
launcher, SLOT(destruct()));
138 KCrash::setEmergencySaveFunction(sig_handler);
139 KDE_signal( SIGHUP, sig_handler);
140 KDE_signal( SIGPIPE, SIG_IGN);
141 KDE_signal( SIGTERM, sig_handler);
QString componentName() const
QDebug perror(QDebug s, KDebugTag)
void mac_initialize_dbus()
int kdemain(int argc, char **argv)
QString i18n(const char *text)