bool GroupDavGlobals::interpretCalendarDownloadItemsJob( KCal::CalendarAdaptor *adaptor, KIO::Job *job, const QString &jobData ) { kdDebug(5800) << "GroupDavGlobals::interpretCalendarDownloadItemsJob, iCalendar=" << endl; kdDebug(5800) << jobData << endl; if ( !adaptor || !job ) return false; KCal::CalendarLocal calendar( QString::fromLatin1("UTC") ); KCal::ICalFormat ical; calendar.setTimeZoneId( adaptor->resource()->timeZoneId() ); KCal::Incidence::List incidences; if ( ical.fromString( &calendar, jobData ) ) { KCal::Incidence::List raw = calendar.rawIncidences(); KCal::Incidence::List::Iterator it = raw.begin(); if ( raw.count() != 1 ) { kdError() << "Parsed iCalendar does not contain exactly one event." << endl; return false; } KCal::Incidence *inc = (raw.front())->clone(); if ( !inc ) return false; KIO::SimpleJob *sjob = dynamic_cast<KIO::SimpleJob *>(job); KURL remoteId; if ( sjob ) remoteId = sjob->url(); QString fingerprint = extractFingerprint( job, jobData ); adaptor->calendarItemDownloaded( inc, inc->uid(), remoteId, fingerprint, remoteId.prettyURL() ); return true; } else { kdError() << "Unable to parse iCalendar" << endl; } return false; }
void KOrganizerPlugin::processDropEvent( QDropEvent *event ) { const QMimeData *md = event->mimeData(); if ( KPIM::KVCardDrag::canDecode( md ) ) { KABC::Addressee::List contacts; KPIM::KVCardDrag::fromMimeData( md, contacts ); KABC::Addressee::List::Iterator it; QStringList attendees; for ( it = contacts.begin(); it != contacts.end(); ++it ) { QString email = (*it).fullEmail(); if ( email.isEmpty() ) { attendees.append( (*it).realName() + "<>" ); } else { attendees.append( email ); } } interface()->openEventEditor( i18nc( "@item", "Meeting" ), QString(), QStringList(), attendees ); return; } if ( KCal::ICalDrag::canDecode( event->mimeData() ) ) { KCal::CalendarLocal cal( KSystemTimeZones::local() ); if ( KCal::ICalDrag::fromMimeData( event->mimeData(), &cal ) ) { KCal::Incidence::List incidences = cal.incidences(); Q_ASSERT( incidences.count() ); if ( !incidences.isEmpty() ) { event->accept(); KCal::Incidence *i = incidences.first(); QString summary; if ( dynamic_cast<KCal::Journal*>( i ) ) { summary = i18nc( "@item", "Note: %1", i->summary() ); } else { summary = i->summary(); } interface()->openEventEditor( summary, i->description(), QStringList() ); return; } // else fall through to text decoding } } if ( md->hasText() ) { QString text = md->text(); kDebug() << "DROP:" << text; interface()->openEventEditor( text ); return; } if ( KPIM::MailList::canDecode( md ) ) { KPIM::MailList mails = KPIM::MailList::fromMimeData( md ); event->accept(); if ( mails.count() != 1 ) { KMessageBox::sorry( core(), i18nc( "@info", "Dropping multiple mails is not supported." ) ); } else { KPIM::MailSummary mail = mails.first(); QString txt = i18nc( "@item", "From: %1\nTo: %2\nSubject: %3", mail.from(), mail.to(), mail.subject() ); KTemporaryFile tf; tf.setAutoRemove( true ); tf.open(); QString uri = KDEPIMPROTOCOL_EMAIL + QString::number( mail.serialNumber() ); tf.write( event->encodedData( "message/rfc822" ) ); interface()->openEventEditor( i18nc( "@item", "Mail: %1", mail.subject() ), txt, uri, tf.fileName(), QStringList(), "message/rfc822" ); tf.close(); } return; } kWarning() << QString( "Cannot handle drop events of type '%1'." ).arg( event->format() ); }