Changeset View
Changeset View
Standalone View
Standalone View
akonadi/calendar/scheduler_p.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | case ScheduleMessage::Obsolete: | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
emit transactionFinished(result, errorString); | emit transactionFinished(result, errorString); | ||||
} | } | ||||
Incidence::List Scheduler::incidences(const Akonadi::CalendarBase::Ptr &calendar, const QString &schedulingUid, const QString &instanceIdentifier) | |||||
{ | |||||
Incidence::List result; | |||||
const Incidence::List incidences = calendar->rawIncidences(); | |||||
Incidence::List::const_iterator it = incidences.begin(); | |||||
for (; it != incidences.end(); ++it) { | |||||
if ( ((*it)->instanceIdentifier() == instanceIdentifier) | |||||
|| ((*it)->schedulingID() == schedulingUid)) { | |||||
result.append(*it); | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
void Scheduler::acceptRequest(const IncidenceBase::Ptr &incidenceBase, | void Scheduler::acceptRequest(const IncidenceBase::Ptr &incidenceBase, | ||||
const Akonadi::CalendarBase::Ptr &calendar, | const Akonadi::CalendarBase::Ptr &calendar, | ||||
ScheduleMessage::Status status, | ScheduleMessage::Status status, | ||||
const QString &email) | const QString &email) | ||||
{ | { | ||||
Incidence::Ptr incidence = incidenceBase.staticCast<Incidence>() ; | Incidence::Ptr incidence = incidenceBase.staticCast<Incidence>() ; | ||||
if (incidence->type() == IncidenceBase::TypeFreeBusy) { | if (incidence->type() == IncidenceBase::TypeFreeBusy) { | ||||
// reply to this request is handled in korganizer's incomingdialog | // reply to this request is handled in korganizer's incomingdialog | ||||
emit transactionFinished(ResultSuccess, QString()); | emit transactionFinished(ResultSuccess, QString()); | ||||
return; | return; | ||||
} | } | ||||
QString schedulingUid = incidence->uid(); | QString schedulingUid = incidence->uid(); | ||||
QString errorString; | QString errorString; | ||||
Result result = ResultSuccess; | Result result = ResultSuccess; | ||||
const Incidence::List existingIncidences = calendar->incidencesFromSchedulingID(schedulingUid); | const Incidence::List existingIncidences = incidences(calendar, schedulingUid, incidence->instanceIdentifier()); | ||||
kDebug() << "status=" << KCalUtils::Stringify::scheduleMessageStatus(status) //krazy:exclude=kdebug | kDebug() << "status=" << KCalUtils::Stringify::scheduleMessageStatus(status) //krazy:exclude=kdebug | ||||
<< ": found " << existingIncidences.count() | << ": found " << existingIncidences.count() | ||||
<< " incidences with schedulingID " << incidence->schedulingID() | << " incidences with schedulingID " << incidence->schedulingID() | ||||
<< "; uid was = " << schedulingUid; | << "; uid was = " << schedulingUid; | ||||
if (existingIncidences.isEmpty()) { | if (existingIncidences.isEmpty()) { | ||||
// Perfectly normal if the incidence doesn't exist. This is probably | // Perfectly normal if the incidence doesn't exist. This is probably | ||||
// a new invitation. | // a new invitation. | ||||
Show All 20 Lines | foreach(const KCalCore::Incidence::Ptr &existingIncidence, existingIncidences) { | ||||
// If you think we could check the value of "status" to be RequestNew: we can't. | // If you think we could check the value of "status" to be RequestNew: we can't. | ||||
// It comes from a similar check inside libical, where the event is compared to | // It comes from a similar check inside libical, where the event is compared to | ||||
// other events in the calendar. But if we have another version of the event around | // other events in the calendar. But if we have another version of the event around | ||||
// (e.g. shared folder for a group), the status could be RequestNew, Obsolete or Updated. | // (e.g. shared folder for a group), the status could be RequestNew, Obsolete or Updated. | ||||
kDebug() << "looking in " << existingUid << "'s attendees"; | kDebug() << "looking in " << existingUid << "'s attendees"; | ||||
// This is supposed to be a new request, not an update - however we want to update | // This is supposed to be a new request, not an update - however we want to update | ||||
// the existing one to handle the "clicking more than once on the invitation" case. | // the existing one to handle the "clicking more than once on the invitation" case. | ||||
// So check the attendee status of the attendee. | // So check the attendee status of the attendee. | ||||
/* | |||||
const Attendee::List attendees = existingIncidence->attendees(); | const Attendee::List attendees = existingIncidence->attendees(); | ||||
Attendee::List::ConstIterator ait; | Attendee::List::ConstIterator ait; | ||||
for (ait = attendees.begin(); ait != attendees.end(); ++ait) { | for (ait = attendees.begin(); ait != attendees.end(); ++ait) { | ||||
if ((*ait)->email() == email && (*ait)->status() == Attendee::NeedsAction) { | if ((*ait)->email() == email && (*ait)->status() == Attendee::NeedsAction) { | ||||
// This incidence wasn't created by me - it's probably in a shared folder | // This incidence wasn't created by me - it's probably in a shared folder | ||||
// and meant for someone else, ignore it. | // and meant for someone else, ignore it. | ||||
kDebug() << "ignoring " << existingUid << " since I'm still NeedsAction there"; | kDebug() << "ignoring " << existingUid << " since I'm still NeedsAction there"; | ||||
isUpdate = false; | isUpdate = false; | ||||
break; | break; | ||||
} | } | ||||
} | }*/ | ||||
mollekopf: If we can't restore this check somehow, the code and the comment above should be removed?
Or at… | |||||
if (isUpdate) { | if (isUpdate) { | ||||
if (existingRevision == incidence->revision() && | if (existingRevision == incidence->revision() && | ||||
existingIncidence->lastModified() > incidence->lastModified()) { | existingIncidence->lastModified() > incidence->lastModified()) { | ||||
// This isn't an update - the found incidence was modified more recently | // This isn't an update - the found incidence was modified more recently | ||||
errorString = i18n("This isn't an update. " | errorString = i18n("This isn't an update. " | ||||
"The found incidence was modified more recently."); | "The found incidence was modified more recently."); | ||||
kWarning() << errorString | kWarning() << errorString | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if (incidence->type() == IncidenceBase::TypeFreeBusy) { | ||||
return; | return; | ||||
} | } | ||||
if (incidence->type() == IncidenceBase::TypeJournal) { | if (incidence->type() == IncidenceBase::TypeJournal) { | ||||
emit transactionFinished(ResultUnsupported, QLatin1String("Unsupported incidence type")); | emit transactionFinished(ResultUnsupported, QLatin1String("Unsupported incidence type")); | ||||
return; | return; | ||||
} | } | ||||
const Incidence::List existingIncidences = calendar->incidencesFromSchedulingID(incidence->uid()); | const Incidence::List existingIncidences = incidences(calendar, incidence->uid(), incidence->instanceIdentifier()); | ||||
kDebug() << "Scheduler::acceptCancel=" | kDebug() << "Scheduler::acceptCancel=" | ||||
<< KCalUtils::Stringify::scheduleMessageStatus(status) //krazy2:exclude=kdebug | << KCalUtils::Stringify::scheduleMessageStatus(status) //krazy2:exclude=kdebug | ||||
<< ": found " << existingIncidences.count() | << ": found " << existingIncidences.count() | ||||
<< " incidences with schedulingID " << incidence->schedulingID(); | << " incidences with schedulingID " << incidence->schedulingID(); | ||||
Result result = ResultIncidenceToDeleteNotFound; | Result result = ResultIncidenceToDeleteNotFound; | ||||
QString errorString = i18n("Could not find incidence to delete."); | QString errorString = i18n("Could not find incidence to delete."); | ||||
foreach(const KCalCore::Incidence::Ptr &existingIncidence, existingIncidences) { | foreach(const KCalCore::Incidence::Ptr &existingIncidence, existingIncidences) { | ||||
kDebug() << "Considering this found event (" | kDebug() << "Considering this found event (" | ||||
<< (existingIncidence->isReadOnly() ? "readonly" : "readwrite") | << (existingIncidence->isReadOnly() ? "readonly" : "readwrite") | ||||
<< ") :" << mFormat->toString(existingIncidence); | << ") :" << mFormat->toString(existingIncidence); | ||||
// If it's readonly, we can't possible remove it. | // If it's readonly, we can't possible remove it. | ||||
if (existingIncidence->isReadOnly()) { | if (existingIncidence->isReadOnly()) { | ||||
continue; | continue; | ||||
} | } | ||||
const QString existingUid = existingIncidence->uid(); | const QString existingUid = existingIncidence->uid(); | ||||
/* | |||||
// Code for new invitations: | // Code for new invitations: | ||||
// We cannot check the value of "status" to be RequestNew because | // We cannot check the value of "status" to be RequestNew because | ||||
// "status" comes from a similar check inside libical, where the event | // "status" comes from a similar check inside libical, where the event | ||||
// is compared to other events in the calendar. But if we have another | // is compared to other events in the calendar. But if we have another | ||||
// version of the event around (e.g. shared folder for a group), the | // version of the event around (e.g. shared folder for a group), the | ||||
// status could be RequestNew, Obsolete or Updated. | // status could be RequestNew, Obsolete or Updated. | ||||
kDebug() << "looking in " << existingUid << "'s attendees"; | kDebug() << "looking in " << existingUid << "'s attendees"; | ||||
// This is supposed to be a new request, not an update - however we want | // This is supposed to be a new request, not an update - however we want | ||||
// to update the existing one to handle the "clicking more than once | // to update the existing one to handle the "clicking more than once | ||||
// on the invitation" case. So check the attendee status of the attendee. | // on the invitation" case. So check the attendee status of the attendee. | ||||
bool isMine = true; | bool isMine = true; | ||||
const Attendee::List attendees = existingIncidence->attendees(); | const Attendee::List attendees = existingIncidence->attendees(); | ||||
foreach(const KCalCore::Attendee::Ptr &attendee, attendees) { | foreach(const KCalCore::Attendee::Ptr &attendee, attendees) { | ||||
if (attendee->email() == attendeeEmail && | if (attendee->email() == attendeeEmail && | ||||
attendee->status() == Attendee::NeedsAction) { | attendee->status() == Attendee::NeedsAction) { | ||||
// This incidence wasn't created by me - it's probably in a shared | // This incidence wasn't created by me - it's probably in a shared | ||||
// folder and meant for someone else, ignore it. | // folder and meant for someone else, ignore it. | ||||
kDebug() << "ignoring " << existingUid << " since I'm still NeedsAction there"; | kDebug() << "ignoring " << existingUid << " since I'm still NeedsAction there"; | ||||
isMine = false; | isMine = false; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (!isMine) { | if (!isMine) { | ||||
continue; | continue; | ||||
} | }*/ | ||||
mollekopfUnsubmitted Not Done Inline ActionsIf we can't restore this check somehow, the code and the comment above should be removed? mollekopf: If we can't restore this check somehow, the code and the comment above should be removed?
Or at… | |||||
kDebug() << "removing existing incidence " << existingUid; | kDebug() << "removing existing incidence " << existingUid; | ||||
if (incidence->hasRecurrenceId()) { | if (incidence->hasRecurrenceId()) { | ||||
Incidence::Ptr existingInstance = calendar->incidence(incidence->instanceIdentifier()); | Incidence::Ptr existingInstance = calendar->incidence(incidence->instanceIdentifier()); | ||||
if (existingInstance) { | if (existingInstance) { | ||||
existingInstance->setStatus(Incidence::StatusCanceled); | existingInstance->setStatus(Incidence::StatusCanceled); | ||||
result = calendar->modifyIncidence(existingInstance) ? ResultSuccess : ResultModifyingError; | result = calendar->modifyIncidence(existingInstance) ? ResultSuccess : ResultModifyingError; | ||||
▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines |
If we can't restore this check somehow, the code and the comment above should be removed?
Or at least it should become a FIXME explaining why we had to disable this and how it should be fixed better