Example #1
0
void MainWindow::addTimerToTable(Timer* timer)
{
    TableItem* itemStatus = new TableItem(QString());

    QString filename      = timer->getFilename();
    QString displayedName = QFileInfo(filename).completeBaseName();
    TableItem* itemName   = new TableItem(displayedName);

    int period              = timer->getPeriod();
    QString displayedPeriod = QString("%1:%2").arg(period / 60, 2, 10, QChar('0')).arg(period % 60, 2, 10, QChar('0'));
    TableItem* itemPeriod   = new TableItem(displayedPeriod);

    QKeySequence keySequence = timer->getKeySequence();
    QString displayedHotkey  = keySequence.toString();
    TableItem* itemHotkey    = new TableItem(displayedHotkey);

    int row = this->timerTable->rowCount();
    this->timerTable->insertRow(row);
    this->timerTable->setItem(row, COLUMN_STATUS, itemStatus);
    this->timerTable->setItem(row, COLUMN_NAME, itemName);
    this->timerTable->setItem(row, COLUMN_PERIOD, itemPeriod);
    this->timerTable->setItem(row, COLUMN_HOTKEY, itemHotkey);

    QVariant data = QVariant::fromValue<Timer*>(timer);
    this->timerTable->item(row, DATA_COLUMN)->setData(TIMER_PTR, data);

    setTimerStatus(timer, STATUS_STOPPED);
}
Example #2
0
void AlarmDaemon::calendarLoaded(ADCalendar *cal, bool success)
{
    if(success)
        kdDebug(5900) << "Calendar reloaded" << endl;
    notifyCalStatus(cal);       // notify KAlarm
    setTimerStatus();
    checkAlarms(cal);
}
Example #3
0
/******************************************************************************
* Start monitoring alarms.
*/
void AlarmDaemon::startMonitoring()
{
    // Set up the alarm timer
    mAlarmTimer = new QTimer(this);
    connect(mAlarmTimer, SIGNAL(timeout()), SLOT(checkAlarmsSlot()));
    setTimerStatus();

    // Start monitoring calendar files.
    // They are monitored until their client application registers, upon which
    // monitoring ceases until KAlarm tells the daemon to monitor it.
    checkAlarms();
}
Example #4
0
/******************************************************************************
* DCOP call to add an application to the list of client applications,
* and add it to the config file.
* 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::registerApp(const QCString &appName, const QString &appTitle,
                              const QCString &dcopObject, const QString &calendarUrl,
                              bool startClient)
{
    kdDebug(5900) << "AlarmDaemon::registerApp(" << appName << ", " << appTitle << ", "
                  <<  dcopObject << ", " << startClient << ")" << endl;
    KAlarmd::RegisterResult result;
    if(appName.isEmpty())
        result = KAlarmd::FAILURE;
    else if(startClient  &&  KStandardDirs::findExe(appName).isNull())
    {
        kdError() << "AlarmDaemon::registerApp(): app not found" << endl;
        result = KAlarmd::NOT_FOUND;
    }
    else
    {
        ADCalendar *keepCal = 0;
        ClientInfo *client = ClientInfo::get(appName);
        if(client)
        {
            // The application is already a client.
            // If it's the same calendar file, don't delete its calendar object.
            if(client->calendar()  &&  client->calendar()->urlString() == calendarUrl)
            {
                keepCal = client->calendar();
                client->detachCalendar();
            }
            ClientInfo::remove(appName);    // this deletes the calendar if not detached
        }

        if(keepCal)
            client = new ClientInfo(appName, appTitle, dcopObject, keepCal, startClient);
        else
            client = new ClientInfo(appName, appTitle, dcopObject, calendarUrl, startClient);
        client->calendar()->setUnregistered(false);
        ADConfigData::writeClient(appName, client);

        ADConfigData::enableAutoStart(true);
        setTimerStatus();
        notifyCalStatus(client->calendar());
        result = KAlarmd::SUCCESS;
    }

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