Ejemplo n.º 1
0
ngwt__Recipient *IncidenceConverter::createRecipient(const QString &name,
        const QString &email, const QString &uuid)
{
    ngwt__Recipient *recipient = soap_new_ngwt__Recipient(soap(), -1);

    recipient->recipientStatus = 0;
    if(!uuid.isEmpty()) recipient->uuid = qStringToString(uuid);
    else recipient->uuid = 0;
    if(!name.isEmpty())
    {
        kdDebug() << "- recipient name: " << name << endl;
        recipient->displayName = qStringToString(name);
    }
    else
    {
        recipient->displayName = 0;
    }
    if(!email.isEmpty())
    {
        kdDebug() << "- recipient email: " << email << endl;
        recipient->email = qStringToString(email);
    }
    else
    {
        recipient->email = 0;
    }
    recipient->distType = TO;
    recipient->recipType = User_;
    recipient->acceptLevel = 0;
    return recipient;
}
Ejemplo n.º 2
0
ngwt__Note *IncidenceConverter::convertToNote(KCal::Journal *journal)
{
    if(!journal)
        return 0;
    ngwt__Note *note = soap_new_ngwt__Note(soap(), -1);
    note->startDate = 0;

    if(!convertToCalendarItem(journal, note))
    {
        soap_dealloc(soap(), note);
        return 0;
    }

    if(journal->doesFloat())
    {
        if(journal->dtStart().isValid())
            note->startDate = qDateToString(journal->dtStart().date());
    }
    else
    {
        if(journal->dtStart().isValid())
            note->startDate = qDateTimeToString(journal->dtStart(), mTimezone);
    }

    if(!note->subject)
        note->subject = qStringToString(QString("NO SUBJECT"));
    return note;
}
ngwt__Task* IncidenceConverter::convertToTask( KCal::Todo* todo )
{
  if ( !todo )
    return 0;
  ngwt__Task* task = soap_new_ngwt__Task( soap(), -1 );
  task->startDate = 0;
  task->dueDate = 0;
  task->assignedDate = 0;
  task->taskPriority = 0;
  task->completed = 0;

  if ( !convertToCalendarItem( todo, task ) ) {
    soap_dealloc( soap(), task );
    return 0;
  }

  if ( todo->dtStart().isValid() )
    task->startDate = kDateTimeToString( todo->dtStart(), mTimeSpec );

  if ( todo->hasDueDate() ) {
    task->dueDate = kDateTimeToString( todo->dtDue() );
  }

  // FIXME: Restore custom priorities
  QString priority = QString::number( todo->priority() );
  task->taskPriority = qStringToString( priority );

  task->completed = (bool*)soap_malloc( soap(), 1 );
  if ( todo->isCompleted() )
    (*task->completed) = true;
  else
    (*task->completed) = false;

  return task;
}
Ejemplo n.º 4
0
void IncidenceConverter::setAttendees(KCal::Incidence *incidence,
                                      ngwt__CalendarItem *item)
{
    item->distribution = soap_new_ngwt__Distribution(soap(), -1);

    item->distribution->from = soap_new_ngwt__From(soap(), -1);

    // ngwt__From
    item->distribution->from->replyTo = 0;
    // ngwt__NameAndEmail
    item->distribution->from->displayName = 0;
    item->distribution->from->email = 0;
    item->distribution->from->uuid = 0;

    item->distribution->from->displayName = qStringToString(incidence->organizer().name());
    item->distribution->from->email = qStringToString(incidence->organizer().email());

    if(!mFromName.isEmpty()) item->distribution->from->displayName = qStringToString(mFromName);
    if(!mFromEmail.isEmpty()) item->distribution->from->email = qStringToString(mFromEmail);
    if(!mFromUuid.isEmpty()) item->distribution->from->uuid = qStringToString(mFromUuid);

    QString to; // To list consists of display names of organizer and attendees separated by ";  "
    to += incidence->organizer().name();
    item->distribution->sendoptions = soap_new_ngwt__SendOptions(soap(), -1);

    item->distribution->sendoptions->requestReply = 0;
    item->distribution->sendoptions->mimeEncoding = 0;
    item->distribution->sendoptions->notification = 0;

    item->distribution->sendoptions->statusTracking = soap_new_ngwt__StatusTracking(soap(),
            -1);

    item->distribution->sendoptions->statusTracking->autoDelete = nullptr;
    item->distribution->sendoptions->statusTracking->__item = All_;

    item->distribution->recipients = soap_new_ngwt__RecipientList(soap(), -1);
    item->distribution->recipients->recipient = *(soap_new_std__vectorTemplateOfPointerTongwt__Recipient(soap(), -1));

    KCal::Attendee::List attendees = incidence->attendees();
    KCal::Attendee::List::ConstIterator it;
    for(it = attendees.begin(); it != attendees.end(); ++it)
    {
        if(!to.isEmpty())
            to += QString::fromLatin1(";  %1").arg((*it)->name());
        kdDebug() << "IncidenceConverter::setAttendees(), adding " << (*it)->fullName()
                  << endl;
        QString uuid;
        QValueList<KABC::Addressee> addList = KABC::StdAddressBook::self()->findByEmail((*it)->email());
        if(!addList.first().isEmpty())
            uuid = addList.first().custom("GWRESOURCE", "UUID");   //uuid may be mandatory for the recipients list to be stored on the server...
        item->distribution->recipients->recipient.push_back(createRecipient((*it)->name(), (*it)->email(), uuid));
    }
    item->distribution->to = qStringToString(to);
    item->distribution->cc = 0;
    item->distribution->bc = 0;
}
Ejemplo n.º 5
0
void IncidenceConverter::getAttendees(ngwt__CalendarItem *item, KCal::Incidence *incidence)
{
    kdDebug() << "IncidenceConverter::getAttendees()" << (item->subject ? item->subject->c_str() : "no subject")
              << endl;

    if(item->distribution && item->distribution->from)
    {
        kdDebug() << "-- from" << endl;
        KCal::Person organizer(stringToQString(item->distribution->from->displayName),
                               stringToQString(item->distribution->from->email));
        incidence->setOrganizer(organizer);
    }

    if(item->distribution && item->distribution->recipients)
    {
        kdDebug() << "-- recipients" << endl;
        std::vector<ngwt__Recipient *> recipients = item->distribution->recipients->recipient;
        std::vector<ngwt__Recipient *>::const_iterator it;

        for(it = recipients.begin(); it != recipients.end(); ++it)
        {
            ngwt__Recipient *recipient = *it;
            kdDebug() << "---- recipient " << recipient->email->c_str() << endl;
            KCal::Attendee *attendee = new KCal::Attendee(
                stringToQString(recipient->displayName),
                stringToQString(recipient->email));

            // set our status
            if(emailsMatch(stringToQString(recipient->email), mFromEmail))
                if(item->status->accepted)
                    attendee->setStatus((*item->status->accepted) ? KCal::Attendee::Accepted : KCal::Attendee::NeedsAction);
                else
                    kdDebug() << "---- found ourselves, but not accepted" << endl;
            else
                kdDebug() << "---- '" <<  "' != '" << (qStringToString(mFromEmail))->c_str() << "'" << endl;

            incidence->addAttendee(attendee);
        }
    }
}
Ejemplo n.º 6
0
bool IncidenceConverter::convertToCalendarItem(KCal::Incidence *incidence, ngwt__CalendarItem *item)
{
    kdDebug() << k_funcinfo << endl;
    //TODO: support the new iCal standard recurrence rule

    // ngwt__CalendarItem
    item->rdate = 0;
    item->rrule = 0;
    item->exdate = 0;
    item->recurrenceKey = 0;
    item->iCalId = 0;
    // ngwt__Mail
    item->subject = 0;
    item->originalSubject = 0;
    item->subjectPrefix = 0;
    item->distribution = 0;
    item->message = 0;
    item->attachments = 0;
    item->options = 0;
    item->link = 0;
    item->hasAttachment = false;
    item->size = 0;
    item->subType = 0;
    item->nntpOrImap = 0;
    item->smimeType = 0;
    // ngwt__BoxEntry
    item->status = 0;
    item->thread = 0;
    item->msgId = 0;
    item->messageId = 0;
    item->source = 0;
    item->returnSentItemsId = 0;
    item->delivered = 0;
    item->class_ = 0;
    item->security = 0;
    item->comment = 0;
    // ngwt__ContainerItem
    item->categories = 0;
    item->created = 0;
    item->customs = 0;
    // ngwt__Item
    item->id = 0;
    item->name = 0;
    item->version = 0;
    item->modified = 0;
    item->changes = 0;

    QString id = incidence->customProperty("GWRESOURCE", "UID");
    if(!id.isEmpty()) item->id = qStringToString(id);

    // Container
    if(!incidence->customProperty("GWRESOURCE", "CONTAINER").isEmpty())
    {
        std::vector<ngwt__ContainerRef *> *container = soap_new_std__vectorTemplateOfPointerTongwt__ContainerRef(soap(), -1);
        ngwt__ContainerRef *containerRef = soap_new_ngwt__ContainerRef(soap(), -1);
        containerRef->deleted = 0;
        containerRef->__item = incidence->customProperty("GWRESOURCE", "CONTAINER").utf8();
        container->push_back(containerRef);

        item->container = *container;
    }

    // secrecy
    item->class_ = (ngwt__ItemClass *)soap_malloc(soap(), sizeof(ngwt__ItemClass));
    switch(incidence->secrecy())
    {
        case KCal::Event::SecrecyPublic:
            *item->class_ = Public;
            break;
        case KCal::Event::SecrecyPrivate:
            *item->class_ = Private;
            break;
        case KCal::Event::SecrecyConfidential:
            *item->class_ = Private;
            break;
    }

    // options
    item->options = soap_new_ngwt__ItemOptions(soap(), -1);
    item->options->concealSubject = 0;
    item->options->delayDeliveryUntil = 0;
    item->options->expires = 0;
    item->options->hidden = 0;
    item->options->priority = Standard;

    // summary
    if(!incidence->summary().isEmpty())
        item->subject = qStringToString(incidence->summary());

    // TODO: reinstate when we know that this isn't causing problems with recurrence
    //   if ( incidence->created().isValid() ) {
    //     item->created = qDateTimeToChar( incidence->created(), mTimezone );
    //   } else
    //     item->created = 0;

    //   if ( incidence->lastModified().isValid() )
    //     item->modified = qDateTimeToChar( incidence->lastModified(), mTimezone );

    setItemDescription(incidence, item);

    item->source = (ngwt__ItemSource *)soap_malloc(soap(), sizeof(ngwt__ItemSource));
#if 1
    if(incidence->attendeeCount() > 0)
    {
        setAttendees(incidence, item);
        *item->source = sent_;
    }
    else
        *item->source = personal_;
#endif

    setRecurrence(incidence, item);
    return true;
}
Ejemplo n.º 7
0
ngwt__Appointment *IncidenceConverter::convertToAppointment(KCal::Event *event)
{
    kdDebug() << "IncidenceConverter::convertToAppointment()" << endl;
    if(!event)
        return 0;

    ngwt__Appointment *appointment = soap_new_ngwt__Appointment(soap(), -1);
    appointment->startDate = 0;
    appointment->endDate = 0;
    appointment->startDay = 0;
    appointment->endDay = 0;
    appointment->acceptLevel = 0;
    appointment->alarm = 0;
    appointment->allDayEvent = 0;
    appointment->place = 0;
    appointment->timezone = 0;

    if(!convertToCalendarItem(event, appointment))
    {
        soap_dealloc(soap(), appointment);
        return 0;
    }

    if(event->doesFloat())
    {
        bool *allDayEvent = (bool *)soap_malloc(soap(), 1);
        (*allDayEvent) = true;
        appointment->allDayEvent = allDayEvent;

        if(event->dtStart().isValid())
        {
            /*      kdDebug() << " convertToAppointment() raw start date: " << event->dtStart().toString() << endl;*/
            QDateTime start = event->dtStart();
            start.setTime(QTime(0, 0, 0));
            appointment->startDate = qDateTimeToChar(start, mTimezone);
            //appointment->startDay = qDateToString( event->dtStart().date()/*.addDays( -1 )*/ );
            /*      kdDebug() << "   converted start date: " << appointment->startDate << endl;*/
        }
        else
            kdDebug() << "   event start date not valid " << endl;
        if(event->hasEndDate())
        {
            //       kdDebug() << " convertToAppointment() raw end date: " << event->dtEnd().toString() << endl;
            QDateTime end = event->dtEnd();
            end = end.addDays(1);
            end.setTime(QTime(0, 0, 0));
            appointment->endDate = qDateTimeToChar(end, mTimezone);
            //appointment->endDay = qDateToString( event->dtEnd().date() );
            //       kdDebug() << "   converted end date:" << appointment->endDate << endl;
        }
        else
            kdDebug() << "   event end date not valid " << endl;
    }
    else
    {
        appointment->allDayEvent = 0;

        if(event->dtStart().isValid())
            appointment->startDate = qDateTimeToChar(event->dtStart(), mTimezone);

        if(event->hasEndDate())
            appointment->endDate = qDateTimeToChar(event->dtEnd(), mTimezone);
    }

    enum ngwt__AcceptLevel *al = (enum ngwt__AcceptLevel *)soap_malloc(soap(), sizeof(enum ngwt__AcceptLevel));
    *al = Busy;
    appointment->acceptLevel = al;

    KCal::Alarm::List alarms = event->alarms();
    if(!alarms.isEmpty())
    {
        ngwt__Alarm *alarm = soap_new_ngwt__Alarm(soap(), -1);
        alarm->__item = alarms.first()->startOffset().asSeconds() * -1;
        bool *enabled = (bool *)soap_malloc(soap(), sizeof(bool));
        *enabled = alarms.first()->enabled();
        alarm->enabled = enabled;

        appointment->alarm = alarm;
    }
    else
        appointment->alarm = 0;

    if(!event->location().isEmpty())
    {
        std::string *location = qStringToString(event->location());

        appointment->place = location;
    }
    else
        appointment->place = 0;

    appointment->timezone = 0;

    return appointment;
}
Ejemplo n.º 8
0
std::string* GWConverter::qDateTimeToString( const QDateTime &dt )
{
  return qStringToString( dt.toString( "yyyyMMddThhmmZ" ) );
}
Ejemplo n.º 9
0
std::string* GWConverter::qDateToString( const QDate &date )
{
  return qStringToString( date.toString( "yyyyMMdd" ) );
}