mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kded: start on demand as session D-Bus service
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0326a6026c
commit
0d2195c4d8
6 changed files with 31 additions and 96 deletions
|
@ -9,3 +9,4 @@ INCLUDE(MacroOptionalFindPackage)
|
|||
INCLUDE(MacroOptionalAddSubdirectory)
|
||||
INCLUDE(MacroAddFileDependencies)
|
||||
INCLUDE(MacroBoolTo01)
|
||||
INCLUDE(MacroDBusAddActivationService)
|
||||
|
|
|
@ -37,6 +37,8 @@ install(
|
|||
DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR}
|
||||
)
|
||||
|
||||
dbus_add_activation_service(org.kde.kded.service.in)
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(kbuildsycoca_SRCS
|
||||
|
|
100
kded/kded.cpp
100
kded/kded.cpp
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <kcrash.h>
|
||||
#include <kdeversion.h>
|
||||
#include <kuniqueapplication.h>
|
||||
#include <kapplication.h>
|
||||
#include <kapplication.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <kaboutdata.h>
|
||||
|
@ -116,6 +116,7 @@ Kded::Kded()
|
|||
QDBusConnection session = QDBusConnection::sessionBus();
|
||||
session.registerObject("/kbuildsycoca", this);
|
||||
session.registerObject("/kded", this);
|
||||
session.registerService("org.kde.kded");
|
||||
|
||||
qDBusAddSpyHook(messageFilter);
|
||||
|
||||
|
@ -212,12 +213,6 @@ void Kded::initModules()
|
|||
}
|
||||
}
|
||||
|
||||
// There will be a "phase 2" only if we're in the KDE startup.
|
||||
// If kded is restarted by its crashhandled or by hand,
|
||||
// then there will be no second phase autoload, so load
|
||||
// these modules now, if in a KDE session.
|
||||
const bool loadPhase2Now = (kde_running && qgetenv("KDED_STARTED_BY_KDEINIT").toInt() == 0);
|
||||
|
||||
// Preload kded modules.
|
||||
const KService::List kdedModules = KServiceTypeTrader::self()->query("KDEDModule");
|
||||
foreach (KService::Ptr service, kdedModules) {
|
||||
|
@ -240,7 +235,8 @@ void Kded::initModules()
|
|||
}
|
||||
case 2: // autoload delayed, only in KDE
|
||||
default: {
|
||||
if (!loadPhase2Now) {
|
||||
// "phase 2" only in KDE
|
||||
if (!kde_running) {
|
||||
prevent_autoload = true;
|
||||
}
|
||||
break;
|
||||
|
@ -646,56 +642,6 @@ void KBuildsycocaAdaptor::recreate()
|
|||
Kded::self()->recreate();
|
||||
}
|
||||
|
||||
class KDEDApplication : public KUniqueApplication
|
||||
{
|
||||
public:
|
||||
KDEDApplication();
|
||||
|
||||
int newInstance();
|
||||
|
||||
bool startup;
|
||||
};
|
||||
|
||||
KDEDApplication::KDEDApplication()
|
||||
: KUniqueApplication()
|
||||
, startup(true)
|
||||
{
|
||||
}
|
||||
|
||||
int KDEDApplication::newInstance()
|
||||
{
|
||||
if (startup) {
|
||||
startup = false;
|
||||
|
||||
// This long initialization has to be here, not in kdemain.
|
||||
// If it was in main, it would cause a dbus timeout when
|
||||
// our parent from KUniqueApplication tries to call our
|
||||
// newInstance method.
|
||||
|
||||
Kded *kded = Kded::self();
|
||||
|
||||
kded->recreate(true); // initial
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
XEvent e;
|
||||
e.xclient.type = ClientMessage;
|
||||
e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False);
|
||||
e.xclient.display = QX11Info::display();
|
||||
e.xclient.window = QX11Info::appRootWindow();
|
||||
e.xclient.format = 8;
|
||||
strcpy(e.xclient.data.b, "kded");
|
||||
XSendEvent(QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e);
|
||||
#endif
|
||||
|
||||
if (bCheckHostname) {
|
||||
(void) new KHostnameD(HostnamePollInterval); // Watch for hostname changes
|
||||
}
|
||||
} else {
|
||||
runBuildSycoca();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
KAboutData aboutData("kded" /*don't change this one to kded4! dbus registration should be org.kde.kded etc.*/,
|
||||
|
@ -708,8 +654,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
KCmdLineArgs::init(argc, argv, &aboutData);
|
||||
|
||||
KUniqueApplication::addCmdLineOptions();
|
||||
|
||||
KCmdLineArgs::addCmdLineOptions(options);
|
||||
|
||||
// WABA: Make sure not to enable session management.
|
||||
|
@ -721,20 +665,15 @@ int main(int argc, char *argv[])
|
|||
KComponentData componentData(&aboutData);
|
||||
KSharedConfig::Ptr config = componentData.config(); // Enable translations.
|
||||
|
||||
KApplication app;
|
||||
|
||||
KConfigGroup cg(config, "General");
|
||||
if (args->isSet("check")) {
|
||||
// KUniqueApplication not wanted here.
|
||||
KApplication app;
|
||||
checkStamps = cg.readEntry("CheckFileStamps", true);
|
||||
runBuildSycoca();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!KUniqueApplication::start()) {
|
||||
fprintf(stderr, "KDE Daemon (kded) already running.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Thiago: reenable if such a thing exists in QtDBus in the future
|
||||
//KUniqueApplication::dcopClient()->setQtBridgeEnabled(false);
|
||||
|
||||
|
@ -749,17 +688,28 @@ int main(int argc, char *argv[])
|
|||
|
||||
KDE_signal(SIGTERM, sighandler);
|
||||
KDE_signal(SIGHUP, sighandler);
|
||||
KDEDApplication k;
|
||||
k.setQuitOnLastWindowClosed(false);
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
kded->recreate(true); // initial
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
XEvent e;
|
||||
e.xclient.type = ClientMessage;
|
||||
e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False);
|
||||
e.xclient.display = QX11Info::display();
|
||||
e.xclient.window = QX11Info::appRootWindow();
|
||||
e.xclient.format = 8;
|
||||
strcpy(e.xclient.data.b, "kded");
|
||||
XSendEvent(QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e);
|
||||
#endif
|
||||
|
||||
if (bCheckHostname) {
|
||||
(void) new KHostnameD(HostnamePollInterval); // Watch for hostname changes
|
||||
}
|
||||
|
||||
KCrash::setFlags(KCrash::AutoRestart);
|
||||
|
||||
// Not sure why kded is created before KDEDApplication
|
||||
// but if it has to be, then it needs to be moved to the main thread
|
||||
// before it can use timers (DF)
|
||||
kded->moveToThread( k.thread() );
|
||||
|
||||
int result = k.exec(); // keep running
|
||||
int result = app.exec(); // keep running
|
||||
|
||||
delete kded;
|
||||
|
||||
|
|
3
kded/org.kde.kded.service.in
Normal file
3
kded/org.kde.kded.service.in
Normal file
|
@ -0,0 +1,3 @@
|
|||
[D-BUS Service]
|
||||
Name=org.kde.kded
|
||||
Exec=@CMAKE_INSTALL_PREFIX@/bin/kded4
|
|
@ -119,7 +119,6 @@ static struct {
|
|||
int exit_status;
|
||||
pid_t fork;
|
||||
pid_t launcher_pid;
|
||||
pid_t kded_pid;
|
||||
int n;
|
||||
char **argv;
|
||||
int (*func)(int, char *[]);
|
||||
|
@ -1355,8 +1354,6 @@ int kdeinit_xio_errhandler( Display *disp )
|
|||
{
|
||||
if (d.launcher_pid)
|
||||
kill(d.launcher_pid, SIGTERM);
|
||||
if (d.kded_pid)
|
||||
kill(d.kded_pid, SIGTERM);
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1486,6 @@ int main(int argc, char **argv)
|
|||
pid_t pid;
|
||||
bool do_fork = true;
|
||||
int launch_klauncher = 1;
|
||||
int launch_kded = 1;
|
||||
int keep_running = 1;
|
||||
d.suicide = false;
|
||||
|
||||
|
@ -1500,8 +1496,6 @@ int main(int argc, char **argv)
|
|||
safe_argv[i] = strcpy((char*)malloc(strlen(argv[i])+1), argv[i]);
|
||||
if (strcmp(safe_argv[i], "--no-klauncher") == 0)
|
||||
launch_klauncher = 0;
|
||||
if (strcmp(safe_argv[i], "--no-kded") == 0)
|
||||
launch_kded = 0;
|
||||
if (strcmp(safe_argv[i], "--no-fork") == 0)
|
||||
do_fork = false;
|
||||
if (strcmp(safe_argv[i], "--suicide") == 0)
|
||||
|
@ -1585,7 +1579,6 @@ int main(int argc, char **argv)
|
|||
|
||||
d.maxname = strlen(argv[0]);
|
||||
d.launcher_pid = 0;
|
||||
d.kded_pid = 0;
|
||||
d.wrapper = -1;
|
||||
d.accepted_fd = -1;
|
||||
d.debug_wait = false;
|
||||
|
@ -1618,18 +1611,6 @@ int main(int argc, char **argv)
|
|||
QFont::initialize();
|
||||
#endif
|
||||
|
||||
if (launch_kded)
|
||||
{
|
||||
setenv("KDED_STARTED_BY_KDEINIT", "1", true);
|
||||
pid = launch( 1, KDED_EXENAME, 0 );
|
||||
unsetenv("KDED_STARTED_BY_KDEINIT");
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "kdeinit4: Launched KDED, pid = %ld result = %d\n", (long) pid, d.result);
|
||||
#endif
|
||||
d.kded_pid = pid;
|
||||
handle_requests(pid);
|
||||
}
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if (safe_argv[i][0] == '+')
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#ifndef _KLAUNCHER_CMDS_H_
|
||||
#define _KLAUNCHER_CMDS_H_
|
||||
|
||||
#define KDED_EXENAME "kded4"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long cmd;
|
||||
|
|
Loading…
Add table
Reference in a new issue