00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <klocale.h>
00024 #include <kdebug.h>
00025 #include <kmessagebox.h>
00026 #include <kstandarddirs.h>
00027
00028 #include "calhelper.h"
00029 #include "event.h"
00030 #include "todo.h"
00031 #include "freebusy.h"
00032 #include "icalformat.h"
00033 #include "calendar.h"
00034 #include "calendarresources.h"
00035 #include "freebusycache.h"
00036 #include "assignmentvisitor.h"
00037
00038 #include "scheduler.h"
00039
00040 using namespace KCal;
00041
00042 ScheduleMessage::ScheduleMessage(IncidenceBase *incidence,int method,ScheduleMessage::Status status)
00043 {
00044 mIncidence = incidence;
00045 mMethod = method;
00046 mStatus = status;
00047 }
00048
00049 QString ScheduleMessage::statusName(ScheduleMessage::Status status)
00050 {
00051 switch (status) {
00052 case PublishUpdate:
00053 return i18n("Updated Publish");
00054 case PublishNew:
00055 return i18n("Publish");
00056 case Obsolete:
00057 return i18n("Obsolete");
00058 case RequestNew:
00059 return i18n("New Request");
00060 case RequestUpdate:
00061 return i18n("Updated Request");
00062 default:
00063 return i18n("Unknown Status: %1").arg(QString::number(status));
00064 }
00065 }
00066
00067 struct Scheduler::Private
00068 {
00069 Private() : mFreeBusyCache( 0 ) {}
00070
00071 FreeBusyCache *mFreeBusyCache;
00072 };
00073
00074 Scheduler::Scheduler(Calendar *calendar)
00075 {
00076 mCalendar = calendar;
00077 mFormat = new ICalFormat();
00078 mFormat->setTimeZone( calendar->timeZoneId(), !calendar->isLocalTime() );
00079
00080 d = new Private;
00081 }
00082
00083 Scheduler::~Scheduler()
00084 {
00085 delete d;
00086
00087 delete mFormat;
00088 }
00089
00090 void Scheduler::setFreeBusyCache( FreeBusyCache *c )
00091 {
00092 d->mFreeBusyCache = c;
00093 }
00094
00095 FreeBusyCache *Scheduler::freeBusyCache() const
00096 {
00097 return d->mFreeBusyCache;
00098 }
00099
00100 bool Scheduler::acceptTransaction( IncidenceBase *incidence,
00101 Method method,
00102 ScheduleMessage::Status status,
00103 const QString &attendee )
00104 {
00105 kdDebug(5800) << "Scheduler::acceptTransaction, method="
00106 << methodName( method ) << endl;
00107
00108 switch (method) {
00109 case Publish:
00110 return acceptPublish(incidence, status, method);
00111 case Request:
00112 return acceptRequest( incidence, status, attendee );
00113 case Add:
00114 return acceptAdd(incidence, status);
00115 case Cancel:
00116 return acceptCancel(incidence, status, attendee );
00117 case Declinecounter:
00118 return acceptDeclineCounter(incidence, status);
00119 case Reply:
00120 return acceptReply(incidence, status, method);
00121 case Refresh:
00122 return acceptRefresh(incidence, status);
00123 case Counter:
00124 return acceptCounter(incidence, status);
00125 default:
00126 break;
00127 }
00128 deleteTransaction(incidence);
00129 return false;
00130 }
00131
00132 QString Scheduler::methodName(Method method)
00133 {
00134 switch (method) {
00135 case Publish:
00136 return QString::fromLatin1("Publish");
00137 case Request:
00138 return QString::fromLatin1("Request");
00139 case Refresh:
00140 return QString::fromLatin1("Refresh");
00141 case Cancel:
00142 return QString::fromLatin1("Cancel");
00143 case Add:
00144 return QString::fromLatin1("Add");
00145 case Reply:
00146 return QString::fromLatin1("Reply");
00147 case Counter:
00148 return QString::fromLatin1("Counter");
00149 case Declinecounter:
00150 return QString::fromLatin1("Decline Counter");
00151 default:
00152 return QString::fromLatin1("Unknown");
00153 }
00154 }
00155
00156 QString Scheduler::translatedMethodName(Method method)
00157 {
00158 switch (method) {
00159 case Publish:
00160 return i18n("Publish");
00161 case Request:
00162 return i18n("Request");
00163 case Refresh:
00164 return i18n("Refresh");
00165 case Cancel:
00166 return i18n("Cancel");
00167 case Add:
00168 return i18n("Add");
00169 case Reply:
00170 return i18n("Reply");
00171 case Counter:
00172 return i18n("counter proposal","Counter");
00173 case Declinecounter:
00174 return i18n("decline counter proposal","Decline Counter");
00175 default:
00176 return i18n("Unknown");
00177 }
00178 }
00179
00180 bool Scheduler::deleteTransaction(IncidenceBase *)
00181 {
00182 return true;
00183 }
00184
00185 bool Scheduler::acceptPublish( IncidenceBase *newIncBase,
00186 ScheduleMessage::Status status, Method method )
00187 {
00188 if( newIncBase->type() == "FreeBusy" ) {
00189 return acceptFreeBusy( newIncBase, method );
00190 }
00191
00192 bool res = false;
00193 kdDebug(5800) << "Scheduler::acceptPublish, status="
00194 << ScheduleMessage::statusName( status ) << endl;
00195 Incidence *newInc = static_cast<Incidence *>( newIncBase );
00196 Incidence *calInc = mCalendar->incidence( newIncBase->uid() );
00197 switch ( status ) {
00198 case ScheduleMessage::Unknown:
00199 case ScheduleMessage::PublishNew:
00200 case ScheduleMessage::PublishUpdate:
00201 if ( calInc && newInc ) {
00202 if ( (newInc->revision() > calInc->revision()) ||
00203 (newInc->revision() == calInc->revision() &&
00204 newInc->lastModified() > calInc->lastModified() ) ) {
00205 AssignmentVisitor visitor;
00206 const QString oldUid = calInc->uid();
00207 if ( !visitor.assign( calInc, newInc ) ) {
00208 kdError(5800) << "assigning different incidence types" << endl;
00209 } else {
00210 calInc->setUid( oldUid );
00211 calInc->setSchedulingID( newInc->uid() );
00212 res = true;
00213 }
00214 }
00215 }
00216 break;
00217 case ScheduleMessage::Obsolete:
00218 res = true;
00219 break;
00220 default:
00221 break;
00222 }
00223 deleteTransaction( newIncBase );
00224 return res;
00225 }
00226
00227 bool Scheduler::acceptRequest( IncidenceBase *incidence,
00228 ScheduleMessage::Status status,
00229 const QString &attendee )
00230 {
00231 Incidence *inc = static_cast<Incidence *>(incidence);
00232 if ( !inc )
00233 return false;
00234 if (inc->type()=="FreeBusy") {
00235
00236 return true;
00237 }
00238
00239 Incidence::List existingIncidences = mCalendar->incidencesFromSchedulingID( inc->uid() );
00240 kdDebug(5800) << "Scheduler::acceptRequest status=" << ScheduleMessage::statusName( status )
00241 << ": found " << existingIncidences.count() << " incidences with schedulingID "
00242 << inc->schedulingID() << endl;
00243
00244
00245 if ( existingIncidences.count() > 1 ) {
00246
00247
00248
00249
00250 kdDebug(5800) << "Scheduler::acceptRequest: found more than one existing incidence!" << endl;
00251 Incidence::List existingIncidencesCopy;
00252 Incidence::List::ConstIterator it = existingIncidences.begin();
00253 for ( ; it != existingIncidences.end() ; ++it ) {
00254 Incidence *i = *it;
00255 if ( CalHelper::isMyCalendarIncidence( mCalendar, i ) ) {
00256 existingIncidencesCopy.prepend( i );
00257 } else {
00258 existingIncidencesCopy.append( i );
00259 }
00260 }
00261 existingIncidences = existingIncidencesCopy;
00262 }
00263
00264 Incidence::List::ConstIterator incit = existingIncidences.begin();
00265 for ( ; incit != existingIncidences.end() ; ++incit ) {
00266 Incidence* const i = *incit;
00267 kdDebug(5800) << "Considering this found event ("
00268 << ( i->isReadOnly() ? "readonly" : "readwrite" )
00269 << ") :" << mFormat->toString( i ) << endl;
00270
00271 if ( i->isReadOnly() )
00272 continue;
00273 if ( i->revision() <= inc->revision() ) {
00274
00275 bool isUpdate = true;
00276
00277
00278
00279
00280
00281 kdDebug(5800) << "looking in " << i->uid() << "'s attendees" << endl;
00282
00283
00284
00285 const KCal::Attendee::List attendees = i->attendees();
00286 KCal::Attendee::List::ConstIterator ait;
00287 for ( ait = attendees.begin(); ait != attendees.end(); ++ait ) {
00288 if( (*ait)->email() == attendee && (*ait)->status() == Attendee::NeedsAction ) {
00289
00290
00291 kdDebug(5800) << "ignoring " << i->uid() << " since I'm still NeedsAction there" << endl;
00292 isUpdate = false;
00293 break;
00294 }
00295 }
00296 if ( isUpdate ) {
00297 if ( i->revision() == inc->revision() &&
00298 i->lastModified() > inc->lastModified() ) {
00299
00300 kdDebug(5800) << "This isn't an update - the found incidence was modified more recently" << endl;
00301 deleteTransaction(incidence);
00302 return false;
00303 }
00304 kdDebug(5800) << "replacing existing incidence " << i->uid() << endl;
00305 bool res = true;
00306 AssignmentVisitor visitor;
00307 const QString oldUid = i->uid();
00308 Incidence *incidenceCopy = inc->clone();
00309 incidenceCopy->setSyncStatus( i->syncStatus() );
00310 const bool incidencesAreEqual = ( *i == *incidenceCopy );
00311
00312 if ( !incidencesAreEqual ) {
00313 kdDebug(5800) << "Scheduler::acceptRequest(): incidences are different, assigning" << endl;
00314 if ( visitor.assign( i, incidenceCopy ) ) {
00315 i->startUpdates();
00316 i->setUids( oldUid, incidenceCopy->uid() );
00317 i->endUpdates();
00318 } else {
00319 kdError(5800) << "assigning different incidence types" << endl;
00320 res = false;
00321 }
00322 delete incidenceCopy;
00323 } else {
00324 kdDebug() << "Scheduler::acceptRequest(): incidences are equal, skipping." << endl;
00325 }
00326
00327 deleteTransaction( incidence );
00328 return res;
00329 }
00330 } else {
00331
00332 kdDebug(5800) << "This isn't an update - the found incidence has a bigger revision number" << endl;
00333 deleteTransaction(incidence);
00334 return false;
00335 }
00336 }
00337
00338
00339 inc->setSchedulingID( inc->uid() );
00340 inc->setUid( CalFormat::createUniqueId() );
00341
00342 if ( existingIncidences.count() == 0 && inc->revision() > 0 ) {
00343 KMessageBox::information(
00344 0,
00345 i18n( "<qt>"
00346 "You accepted an invitation update, but an earlier version of the "
00347 "item could not be found in your calendar.<p>"
00348 "This may have occurred because:<ul>"
00349 "<li>the organizer did not include you in the original invitation</li>"
00350 "<li>you did not accept the original invitation yet</li>"
00351 "<li>you deleted the original invitation from your calendar</li>"
00352 "<li>you no longer have access to the calendar containing the invitation</li>"
00353 "</ul>"
00354 "This is not a problem, but we thought you should know.</qt>" ),
00355 i18n( "Cannot find invitation to be updated" ), "AcceptCantFindIncidence" );
00356 }
00357 kdDebug(5800) << "Storing new incidence with scheduling uid=" << inc->schedulingID()
00358 << " and uid=" << inc->uid() << endl;
00359
00360 CalendarResources *stdcal = dynamic_cast<CalendarResources *>( mCalendar );
00361 if( stdcal && !stdcal->hasCalendarResources() ) {
00362 KMessageBox::sorry(
00363 0,
00364 i18n( "No calendars found, unable to save the invitation." ) );
00365 return false;
00366 }
00367
00368
00369
00370
00371
00372 QWidget *tmpparent = 0;
00373 if ( stdcal ) {
00374 tmpparent = stdcal->dialogParentWidget();
00375 stdcal->setDialogParentWidget( 0 );
00376 }
00377
00378 TryAgain:
00379 bool success = false;
00380 if ( stdcal ) {
00381 success = stdcal->addIncidence( inc );
00382 } else {
00383 success = mCalendar->addIncidence( inc );
00384 }
00385
00386 if ( !success ) {
00387 ErrorFormat *e = stdcal ? stdcal->exception() : 0;
00388
00389 if ( e && e->errorCode() == KCal::ErrorFormat::UserCancel &&
00390 KMessageBox::warningYesNo(
00391 0,
00392 i18n( "You canceled the save operation. Therefore, the appointment will not be "
00393 "stored in your calendar even though you accepted the invitation. "
00394 "Are you certain you want to discard this invitation? " ),
00395 i18n( "Discard this invitation?" ),
00396 i18n( "Discard" ), i18n( "Go Back to Folder Selection" ) ) == KMessageBox::Yes ) {
00397 KMessageBox::information(
00398 0,
00399 i18n( "The invitation \"%1\" was not saved to your calendar "
00400 "but you are still listed as an attendee for that appointment.\n"
00401 "If you mistakenly accepted the invitation or do not plan to attend, please notify "
00402 "the organizer %2 and ask them to remove you from the attendee list.").
00403 arg( inc->summary(), inc->organizer().fullName() ) );
00404 deleteTransaction( incidence );
00405 return true;
00406 } else {
00407 goto TryAgain;
00408 }
00409
00410
00411
00412 if ( !e ||
00413 ( e && ( e->errorCode() != KCal::ErrorFormat::UserCancel &&
00414 e->errorCode() != KCal::ErrorFormat::NoWritableFound ) ) ) {
00415 QString errMessage = i18n( "Unable to save %1 \"%2\"." ).
00416 arg( i18n( inc->type() ) ).
00417 arg( inc->summary() );
00418 KMessageBox::sorry( 0, errMessage );
00419 }
00420 return false;
00421 }
00422
00423 deleteTransaction( incidence );
00424 return true;
00425 }
00426
00427 bool Scheduler::acceptAdd(IncidenceBase *incidence,ScheduleMessage::Status )
00428 {
00429 deleteTransaction(incidence);
00430 return false;
00431 }
00432
00433 bool Scheduler::acceptCancel( IncidenceBase *incidence,
00434 ScheduleMessage::Status status,
00435 const QString &attendee )
00436 {
00437 Incidence *inc = static_cast<Incidence *>( incidence );
00438 if ( !inc ) {
00439 return false;
00440 }
00441
00442 if ( inc->type() == "FreeBusy" ) {
00443
00444 return true;
00445 }
00446
00447 const Incidence::List existingIncidences = mCalendar->incidencesFromSchedulingID( inc->uid() );
00448 kdDebug(5800) << "Scheduler::acceptCancel="
00449 << ScheduleMessage::statusName( status )
00450 << ": found " << existingIncidences.count()
00451 << " incidences with schedulingID " << inc->schedulingID()
00452 << endl;
00453
00454
00455
00456 Incidence::List myExistingIncidences;
00457 Incidence::List::ConstIterator incit = existingIncidences.begin();
00458 for ( ; incit != existingIncidences.end() ; ++incit ) {
00459 Incidence *i = *incit;
00460 if ( CalHelper::isMyCalendarIncidence( mCalendar, i ) ) {
00461 myExistingIncidences.append( i );
00462 }
00463 }
00464
00465 bool ret = false;
00466 incit = myExistingIncidences.begin();
00467 for ( ; incit != myExistingIncidences.end() ; ++incit ) {
00468 Incidence *i = *incit;
00469 kdDebug(5800) << "Considering this found event ("
00470 << ( i->isReadOnly() ? "readonly" : "readwrite" )
00471 << ") :" << mFormat->toString( i ) << endl;
00472
00473
00474 if ( i->isReadOnly() ) {
00475 continue;
00476 }
00477
00478
00479
00480
00481
00482
00483
00484 kdDebug(5800) << "looking in " << i->uid() << "'s attendees" << endl;
00485
00486
00487
00488
00489 bool isMine = true;
00490 const KCal::Attendee::List attendees = i->attendees();
00491 KCal::Attendee::List::ConstIterator ait;
00492 for ( ait = attendees.begin(); ait != attendees.end(); ++ait ) {
00493 if ( (*ait)->email() == attendee &&
00494 (*ait)->status() == Attendee::NeedsAction ) {
00495
00496
00497 kdDebug(5800) << "ignoring " << i->uid()
00498 << " since I'm still NeedsAction there" << endl;
00499 isMine = false;
00500 break;
00501 }
00502 }
00503
00504 if ( isMine ) {
00505 kdDebug(5800) << "removing existing incidence " << i->uid() << endl;
00506 if ( i->type() == "Event" ) {
00507 Event *event = mCalendar->event( i->uid() );
00508 ret = ( event && mCalendar->deleteEvent( event ) );
00509 } else if ( i->type() == "Todo" ) {
00510 Todo *todo = mCalendar->todo( i->uid() );
00511 ret = ( todo && mCalendar->deleteTodo( todo ) );
00512 }
00513 deleteTransaction( incidence );
00514 return ret;
00515 }
00516 }
00517
00518
00519 if ( myExistingIncidences.count() > 0 && inc->revision() > 0 ) {
00520 KMessageBox::information(
00521 0,
00522 i18n( "The event or task could not be removed from your calendar. "
00523 "Maybe it has already been deleted or is not owned by you. "
00524 "Or it might belong to a read-only or disabled calendar." ) );
00525 }
00526 deleteTransaction( incidence );
00527 return ret;
00528 }
00529
00530 bool Scheduler::acceptCancel(IncidenceBase *incidence,ScheduleMessage::Status )
00531 {
00532 const IncidenceBase *toDelete = mCalendar->incidenceFromSchedulingID( incidence->uid() );
00533
00534 bool ret = true;
00535 if ( toDelete ) {
00536 if ( toDelete->type() == "Event" ) {
00537 Event *event = mCalendar->event( toDelete->uid() );
00538 ret = ( event && mCalendar->deleteEvent( event ) );
00539 } else if ( toDelete->type() == "Todo" ) {
00540 Todo *todo = mCalendar->todo( toDelete->uid() );
00541 ret = ( todo && mCalendar->deleteTodo( todo ) );
00542 }
00543 } else {
00544
00545
00546 Incidence *inc = static_cast<Incidence *>( incidence );
00547 if ( inc->revision() > 0 ) {
00548 ret = false;
00549 }
00550 }
00551
00552 if ( !ret ) {
00553 KMessageBox::information(
00554 0,
00555 i18n( "The event or task to be canceled could not be removed from your calendar. "
00556 "Maybe it has already been deleted or is not owned by you. "
00557 "Or it might belong to a read-only or disabled calendar." ) );
00558 }
00559 deleteTransaction(incidence);
00560 return ret;
00561 }
00562
00563 bool Scheduler::acceptDeclineCounter(IncidenceBase *incidence,ScheduleMessage::Status )
00564 {
00565 deleteTransaction(incidence);
00566 return false;
00567 }
00568
00569
00570
00571
00572
00573
00574
00575 bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status , Method method)
00576 {
00577 if(incidence->type()=="FreeBusy") {
00578 return acceptFreeBusy(incidence, method);
00579 }
00580 bool ret = false;
00581 Event *ev = mCalendar->event(incidence->uid());
00582 Todo *to = mCalendar->todo(incidence->uid());
00583
00584
00585 if ( !ev && !to ) {
00586 const Incidence::List list = mCalendar->incidences();
00587 for ( Incidence::List::ConstIterator it = list.begin(), end = list.end(); it != end; ++it ) {
00588 if ( (*it)->schedulingID() == incidence->uid() ) {
00589 ev = dynamic_cast<Event*>( *it );
00590 to = dynamic_cast<Todo*>( *it );
00591 break;
00592 }
00593 }
00594 }
00595
00596 if (ev || to) {
00597
00598 kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl;
00599 Attendee::List attendeesIn = incidence->attendees();
00600 Attendee::List attendeesEv;
00601 Attendee::List attendeesNew;
00602 if (ev) attendeesEv = ev->attendees();
00603 if (to) attendeesEv = to->attendees();
00604 Attendee::List::ConstIterator inIt;
00605 Attendee::List::ConstIterator evIt;
00606 for ( inIt = attendeesIn.begin(); inIt != attendeesIn.end(); ++inIt ) {
00607 Attendee *attIn = *inIt;
00608 bool found = false;
00609 for ( evIt = attendeesEv.begin(); evIt != attendeesEv.end(); ++evIt ) {
00610 Attendee *attEv = *evIt;
00611 if (attIn->email().lower()==attEv->email().lower()) {
00612
00613 kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl;
00614 attEv->setStatus(attIn->status());
00615 attEv->setDelegate(attIn->delegate());
00616 attEv->setDelegator(attIn->delegator());
00617 Incidence *incidence = ev ? static_cast<Incidence*>( ev ) :
00618 static_cast<Incidence*>( to );
00619 incidence->setFieldDirty( Incidence::FieldAttendees );
00620 ret = true;
00621 found = true;
00622 }
00623 }
00624 if ( !found && attIn->status() != Attendee::Declined )
00625 attendeesNew.append( attIn );
00626 }
00627
00628 bool attendeeAdded = false;
00629 for ( Attendee::List::ConstIterator it = attendeesNew.constBegin(); it != attendeesNew.constEnd(); ++it ) {
00630 Attendee* attNew = *it;
00631 QString msg = i18n("%1 wants to attend %2 but was not invited.").arg( attNew->fullName() )
00632 .arg( ev ? ev->summary() : to->summary() );
00633 if ( !attNew->delegator().isEmpty() )
00634 msg = i18n("%1 wants to attend %2 on behalf of %3.").arg( attNew->fullName() )
00635 .arg( ev ? ev->summary() : to->summary() )
00636 .arg( attNew->delegator() );
00637 if ( KMessageBox::questionYesNo( 0, msg, i18n("Uninvited attendee"),
00638 KGuiItem(i18n("Accept Attendance")), KGuiItem(i18n("Reject Attendance")) )
00639 != KMessageBox::Yes )
00640 {
00641 KCal::Incidence *cancel = dynamic_cast<Incidence*>( incidence );
00642 if ( cancel )
00643 cancel->addComment( i18n( "The organizer rejected your attendance at this meeting." ) );
00644 performTransaction( cancel ? cancel : incidence, Scheduler::Cancel, attNew->fullName() );
00645 delete cancel;
00646 continue;
00647 }
00648
00649 Attendee *a = new Attendee( attNew->name(), attNew->email(), attNew->RSVP(),
00650 attNew->status(), attNew->role(), attNew->uid() );
00651 a->setDelegate( attNew->delegate() );
00652 a->setDelegator( attNew->delegator() );
00653 if ( ev )
00654 ev->addAttendee( a );
00655 else if ( to )
00656 to->addAttendee( a );
00657 ret = true;
00658 attendeeAdded = true;
00659 }
00660
00661
00662 if ( attendeeAdded ) {
00663 bool sendMail = false;
00664 if ( ev || to ) {
00665 if ( KMessageBox::questionYesNo( 0, i18n( "An attendee was added to the incidence. "
00666 "Do you want to email the attendees an update message?" ),
00667 i18n( "Attendee Added" ), i18n( "Send Messages" ),
00668 i18n( "Do Not Send" ) ) == KMessageBox::Yes ) {
00669 sendMail = true;
00670 }
00671 }
00672
00673 if ( ev ) {
00674 ev->setRevision( ev->revision() + 1 );
00675 if ( sendMail )
00676 performTransaction( ev, Scheduler::Request );
00677 }
00678 if ( to ) {
00679 to->setRevision( to->revision() + 1 );
00680 if ( sendMail )
00681 performTransaction( to, Scheduler::Request );
00682 }
00683 }
00684
00685 if ( ret ) {
00686
00687
00688 if ( ev )
00689 ev->updated();
00690 else if ( to )
00691 to->updated();
00692 }
00693 if ( to ) {
00694
00695
00696 Todo *update = dynamic_cast<Todo*> ( incidence );
00697 Q_ASSERT( update );
00698 if ( update && ( to->percentComplete() != update->percentComplete() ) ) {
00699 to->setPercentComplete( update->percentComplete() );
00700 to->updated();
00701 }
00702 }
00703 } else
00704 kdError(5800) << "No incidence for scheduling\n";
00705 if (ret) deleteTransaction(incidence);
00706 return ret;
00707 }
00708
00709 bool Scheduler::acceptRefresh(IncidenceBase *incidence,ScheduleMessage::Status )
00710 {
00711
00712 deleteTransaction(incidence);
00713 return false;
00714 }
00715
00716 bool Scheduler::acceptCounter(IncidenceBase *incidence,ScheduleMessage::Status )
00717 {
00718 deleteTransaction(incidence);
00719 return false;
00720 }
00721
00722 bool Scheduler::acceptFreeBusy(IncidenceBase *incidence, Method method)
00723 {
00724 if ( !d->mFreeBusyCache ) {
00725 kdError() << "KCal::Scheduler: no FreeBusyCache." << endl;
00726 return false;
00727 }
00728
00729 FreeBusy *freebusy = static_cast<FreeBusy *>(incidence);
00730
00731 kdDebug(5800) << "acceptFreeBusy:: freeBusyDirName: " << freeBusyDir() << endl;
00732
00733 Person from;
00734 if(method == Scheduler::Publish) {
00735 from = freebusy->organizer();
00736 }
00737 if((method == Scheduler::Reply) && (freebusy->attendeeCount() == 1)) {
00738 Attendee *attendee = freebusy->attendees().first();
00739 from = attendee->email();
00740 }
00741
00742 if ( !d->mFreeBusyCache->saveFreeBusy( freebusy, from ) ) return false;
00743
00744 deleteTransaction(incidence);
00745 return true;
00746 }