Esempio n. 1
0
bool Scheduler::acceptRequest(IncidenceBase *newIncBase, ScheduleMessage::Status /* status */)
{
    if (newIncBase->type()=="FreeBusy") {
        // reply to this request is handled in korganizer's incomingdialog
        return true;
    }
    Incidence *newInc = dynamic_cast<Incidence *>( newIncBase );
    if ( newInc ) {
        bool res = true;
        Incidence *exInc = mCalendar->incidenceFromSchedulingID( newIncBase->uid() );
        if ( exInc ) {
            res = false;
            if ( (newInc->revision() > exInc->revision()) ||
                    (newInc->revision() == exInc->revision() &&
                     newInc->lastModified()>exInc->lastModified()) ) {
                mCalendar->deleteIncidence( exInc );
                res = true;
            }
        }
        if ( res ) {
            // Move the uid to be the schedulingID and make a unique UID
            newInc->setSchedulingID( newInc->uid() );
            newInc->setUid( CalFormat::createUniqueId() );

            mCalendar->addIncidence(newInc);
        }
        deleteTransaction( newIncBase );
        return res;
    }
    return false;
}
Esempio n. 2
0
QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
        Scheduler::Method method)
{
    icalcomponent *message = 0;

    // Handle scheduling ID being present
    if(incidence->type() == "Event" || incidence->type() == "Todo")
    {
        Incidence *i = static_cast<Incidence *>(incidence);
        if(i->schedulingID() != i->uid())
        {
            // We have a separation of scheduling ID and UID
            i = i->clone();
            i->setUid(i->schedulingID());
            i->setSchedulingID(QString::null);

            // Build the message with the cloned incidence
            message = mImpl->createScheduleComponent(i, method);

            // And clean up
            delete i;
        }
    }

    if(message == 0)
        message = mImpl->createScheduleComponent(incidence, method);

    // FIXME TODO: Don't we have to free message? What about the ical_string? MEMLEAK
    QString messageText = QString::fromUtf8(icalcomponent_as_ical_string(message));

#if 0
    kdDebug(5800) << "ICalFormat::createScheduleMessage: message START\n"
                  << messageText
                  << "ICalFormat::createScheduleMessage: message END" << endl;
#endif

    return messageText;
}