Example #1
0
/******************************************************************************
* DCOP call to change whether KAlarm should be started when an event needs to
* be notified to it.
* N.B. This method must not return a bool because DCOPClient::call() can cause
*      a hang if the daemon happens to send a notification to KAlarm at the
*      same time as KAlarm calls this DCCOP method.
*/
void AlarmDaemon::registerChange(const QCString &appName, bool startClient)
{
    kdDebug(5900) << "AlarmDaemon::registerChange(" << appName << ", " << startClient << ")" << endl;
    KAlarmd::RegisterResult result;
    ClientInfo *client = ClientInfo::get(appName);
    if(!client)
        return;    // can't access client to tell it the result
    if(startClient  &&  KStandardDirs::findExe(appName).isNull())
    {
        kdError() << "AlarmDaemon::registerChange(): app not found" << endl;
        result = KAlarmd::NOT_FOUND;
    }
    else
    {
        client->setStartClient(startClient);
        ADConfigData::writeClient(appName, client);
        result = KAlarmd::SUCCESS;
    }

    // Notify the client of whether the call succeeded.
    AlarmGuiIface_stub stub(appName, client->dcopObject());
    stub.registered(true, result, DAEMON_VERSION_NUM);
    kdDebug(5900) << "AlarmDaemon::registerChange() -> " << result << endl;
}