bool GroupDavGlobals::interpretAddressBookDownloadItemsJob( KABC::AddressBookAdaptor *adaptor, KIO::Job *job, const QString &jobData) { kdDebug(5800) << "GroupDavGlobals::interpretAddressBookDownloadItemsJob, vCard=" << endl; kdDebug(5800) << jobData << endl; if(!adaptor || !job) return false; KABC::VCardConverter conv; KABC::Addressee::List addrs(conv.parseVCards(jobData)); if(addrs.count() != 1) { kdError() << "Parsed vCard does not contain exactly one addressee." << endl; return false; } KABC::Addressee a = addrs.first(); KIO::SimpleJob *sjob = dynamic_cast<KIO::SimpleJob *>(job); KURL remoteId; if(sjob) remoteId = sjob->url(); QString fingerprint = extractFingerprint(job, jobData); adaptor->addressbookItemDownloaded(a, a.uid(), remoteId, fingerprint, remoteId.prettyURL()); return true; }
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; }