コード例 #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;
}
コード例 #2
0
void ResourceGroupware::slotJobResult( KJob *job )
{
  kDebug() <<"ResourceGroupware::slotJobResult():";

  if ( job->error() ) {
    mIsShowingError = true;
    loadError( job->errorString() );
    mIsShowingError = false;
  } else {
    disableChangeNotification();

    clearCache();

     // FIXME: This does not take into account the time zone!
    CalendarLocal calendar;
    ICalFormat ical;
    if ( !ical.fromString( &calendar, mJobData ) ) {
      loadError( i18n("Error parsing calendar data.") );
    } else {
      Incidence::List incidences = calendar.incidences();
      Incidence::List::ConstIterator it;
      for( it = incidences.begin(); it != incidences.end(); ++it ) {
//        kDebug() <<"INCIDENCE:" << (*it)->summary();
        Incidence *i = (*it)->clone();
        QString remote = (*it)->customProperty( "GWRESOURCE", "UID" );
        QString local = idMapper().localId( remote );
        if ( local.isEmpty() ) {
          idMapper().setRemoteId( i->uid(), remote );
        } else {
          i->setUid( local );
        }
        addIncidence( i );
      }
    }
    saveToCache();
    enableChangeNotification();

    clearChanges();

    emit resourceChanged( this );
    emit resourceLoaded( this );
  }

  mDownloadJob = 0;
  if ( mProgress ) mProgress->setComplete();
  mProgress = 0;
}
コード例 #3
0
ファイル: icalformat.cpp プロジェクト: serghei/kde3-kdepim
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;
}
コード例 #4
0
void KCalResourceSlox::slotUploadResult( KJob *job )
{
  kDebug();

  if ( job->error() ) {
    saveError( job->errorString() );
  } else {
    kDebug() << "success";

    if ( !mUploadJob )
    {
        kDebug() << "mUploadJob was 0";
        return;
    }

    QDomDocument doc = mUploadJob->response();

    kDebug() << "UPLOAD RESULT:";
    kDebug() << doc.toString( 2 );

    QDomElement docElement = doc.documentElement();

    QDomNode responseNode;
    for( responseNode = docElement.firstChild(); !responseNode.isNull();
         responseNode = responseNode.nextSibling() ) {
      QDomElement responseElement = responseNode.toElement();
      if ( responseElement.tagName() == "response" ) {
        QDomNode propstat = responseElement.namedItem( "propstat" );
        if ( propstat.isNull() ) {
          kError() << "Unable to find propstat tag.";
          continue;
        }

        QDomNode status = propstat.namedItem( "status" );
        if ( !status.isNull() ) {
          QDomElement statusElement = status.toElement();
          QString response = statusElement.text();
        if ( !response.contains( "200" ) ) {
            QString error = '\'' + mUploadedIncidence->summary() + "'\n";
            error += response;
            QDomNode dn = propstat.namedItem( "responsedescription" );
            QString d = dn.toElement().text();
            if ( !d.isEmpty() ) error += '\n' + d;
            saveError( error );
            continue;
          }
        }

        QDomNode prop = propstat.namedItem( "prop" );
        if ( prop.isNull() ) {
          kError() << "Unable to find WebDAV property";
          continue;
        }

        QDomNode sloxIdNode = prop.namedItem( fieldName( ObjectId ) );
        if ( sloxIdNode.isNull() ) {
          kError() << "Unable to find SLOX id.";
          continue;
        }
        QDomElement sloxIdElement = sloxIdNode.toElement();
        QString sloxId = sloxIdElement.text();
        kDebug() << "SLOXID:" << sloxId;

        if ( mUploadIsDelete ) {
          kDebug() << "Incidence deleted";
        } else {
          QDomNode clientIdNode = prop.namedItem( fieldName( ClientId ) );
          if ( clientIdNode.isNull() ) {
            kError() << "Unable to find client id.";
            continue;
          }
          QDomElement clientidElement = clientIdNode.toElement();
          QString clientId = clientidElement.text();

          kDebug() << "CLIENTID:" << clientId;

          Incidence *i = mUploadedIncidence->clone();
          QString uid;
          if ( i->type() == "Event" ) uid = sloxIdToEventUid( sloxId );
          else if ( i->type() == "Todo" ) uid = sloxIdToTodoUid( sloxId );
          else {
            kError() << "Unknown type:"
                     << i->type();
          }
          i->setUid( uid );
          i->setCustomProperty( "SLOX", "ID", sloxId );

          if ( type() == "ox" ) {
            // Update the last_modified property
            const QDomNode lastModifiedNode = prop.namedItem( fieldName( LastModified ) );
            if ( !lastModifiedNode.isNull() ) {
              const QDomElement lastModifiedElement = lastModifiedNode.toElement();
              const QString lastModified = lastModifiedElement.text();
              i->setCustomProperty( "SLOX", "LastModified", lastModified );
            }
          }

          disableChangeNotification();
          calendar()->deleteIncidence( mUploadedIncidence );
          calendar()->addIncidence( i );
          saveToCache();
          enableChangeNotification();

          emit resourceChanged( this );
        }
      }
    }
  }

  mUploadJob = 0;

  mUploadProgress->setComplete();
  mUploadProgress = 0;

  clearChange( mUploadedIncidence );

  uploadIncidences();
}