/* This file is part of tdepim. Copyright (c) 2005 Reinhold Kainhofer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "exchangeglobals.h" #include #include #include "exchangeconvertercalendar.h" #include "exchangeconvertercontact.h" #include #include #include #include #include #include #include KPIM::FolderLister::ContentType ExchangeGlobals::getContentType( const TQDomElement &prop ) { const TQString &contentclass = prop.namedItem("contentclass").toElement().text(); kdDebug()<<"contentclass: "<addMetaData("customHTTPHeader", "Translate: f"); job->addMetaData("cache", "reload");*/ return job; } KIO::Job *ExchangeGlobals::createRemoveJob( const KURL &uploadurl, const KPIM::GroupwareUploadItem::List &deletedItems ) { TQStringList urls; KPIM::GroupwareUploadItem::List::const_iterator it; kdDebug() << " ExchangeGlobals::createRemoveJob: , URL="<url().url() << endl; KURL url( uploadurl ); url.setPath( (*it)->url().path() ); if ( !url.isEmpty() ) urls << url.url(); kdDebug() << "Delete (Mod) : " << url.url() << endl; } return KIO::del( urls, false, false ); } // FIXME: This is exactly the same code as in the OGo resource, except that // it calls getContentType of the ExchangeGlobals class, instead of the one // from OGoGlobals!!!! bool ExchangeGlobals::interpretListItemsJob( KPIM::GroupwareDataAdaptor *adaptor, KIO::Job *job, const TQString &/*jobData*/ ) { kdDebug()<<"ExchangeGlobals::interpretListItemsJob"<(job); if ( !davjob ) { return false; } TQDomDocument doc = davjob->response(); kdDebug(7000) << " Doc: " << doc.toString() << endl; kdDebug(7000) << " IdMapper: " << adaptor->idMapper()->asString() << endl; TQDomElement docElem = doc.documentElement(); TQDomNode n = docElem.firstChild(); while( !n.isNull() ) { TQDomElement e = n.toElement(); // try to convert the node to an element. n = n.nextSibling(); if ( e.isNull() ) continue; const KURL &entry( e.namedItem("href").toElement().text() ); TQDomElement propstat = e.namedItem("propstat").toElement(); if ( propstat.isNull() ) continue; TQDomElement prop = propstat.namedItem( "prop" ).toElement(); if ( prop.isNull() ) continue; TQDomElement elem = prop.namedItem("getetag").toElement(); const TQString &newFingerprint = elem.text(); if ( elem.isNull() || newFingerprint.isEmpty() ) continue; KPIM::FolderLister::ContentType type = getContentType( prop ); if (type != KPIM::FolderLister::Unknown) { // Don't queue bad entries adaptor->processDownloadListItem( entry, newFingerprint, type ); } } return true; } bool ExchangeGlobals::interpretCalendarDownloadItemsJob( KCal::CalendarAdaptor *adaptor, KIO::Job *job, const TQString &/*jobData*/ ) { KIO::DavJob *davjob = dynamic_cast(job); if ( !davjob || !adaptor ) return false; kdDebug() << "ExchangeGlobals::interpretCalendarDownloadItemsJob(): TQDomDocument=" << endl << davjob->response().toString() << endl; KCal::ExchangeConverterCalendar conv; conv.setTimeZone( adaptor->resource()->timeZoneId() ); KCal::Incidence::List incidences = conv.parseWebDAV( davjob->response() ); bool res = false; KCal::Incidence::List::Iterator it = incidences.begin(); for ( ; it != incidences.end(); ++it ) { TQString fpr = (*it)->customProperty( "KDEPIM-Exchange-Resource", "fingerprint" ); KURL href( (*it)->customProperty( "KDEPIM-Exchange-Resource", "href" ) ); adaptor->calendarItemDownloaded( (*it), (*it)->uid(), href, fpr, href.prettyURL() ); res = true; } return res; } bool ExchangeGlobals::interpretAddressBookDownloadItemsJob( KABC::AddressBookAdaptor *adaptor, KIO::Job *job, const TQString &/*jobData*/ ) { KIO::DavJob *davjob = dynamic_cast(job); if ( !davjob || !adaptor ) return false; kdDebug() << "ExchangeGlobals::interpretAddressBookDownloadItemsJob(): TQDomDocument=" << endl << davjob->response().toString() << endl; KABC::ExchangeConverterContact conv; KABC::Addressee::List addressees = conv.parseWebDAV( davjob->response() ); bool res = false; KABC::Addressee::List::Iterator it = addressees.begin(); for ( ; it != addressees.end(); ++it ) { TQString fpr = (*it).custom( "KDEPIM-Exchange-Resource", "fingerprint" ); KURL href( (*it).custom( "KDEPIM-Exchange-Resource", "href" ) ); adaptor->addressbookItemDownloaded( (*it), (*it).uid(), href, fpr, href.prettyURL() ); res = true; } return res; }