From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kresources/newexchange/exchangeglobals.cpp | 286 +++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 kresources/newexchange/exchangeglobals.cpp (limited to 'kresources/newexchange/exchangeglobals.cpp') diff --git a/kresources/newexchange/exchangeglobals.cpp b/kresources/newexchange/exchangeglobals.cpp new file mode 100644 index 000000000..7cca837df --- /dev/null +++ b/kresources/newexchange/exchangeglobals.cpp @@ -0,0 +1,286 @@ +/* + This file is part of kdepim. + + 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 QDomElement &prop ) +{ + const QString &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 ) +{ + QStringList 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 QString &/*jobData*/ ) +{ +kdDebug()<<"ExchangeGlobals::interpretListItemsJob"<(job); + + if ( !davjob ) { + return false; + } + QDomDocument doc = davjob->response(); + + kdDebug(7000) << " Doc: " << doc.toString() << endl; + kdDebug(7000) << " IdMapper: " << adaptor->idMapper()->asString() << endl; + + QDomElement docElem = doc.documentElement(); + QDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + QDomElement 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() ); + QDomElement propstat = e.namedItem("propstat").toElement(); + if ( propstat.isNull() ) + continue; + QDomElement prop = propstat.namedItem( "prop" ).toElement(); + if ( prop.isNull() ) + continue; + QDomElement elem = prop.namedItem("getetag").toElement(); + const QString &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 QString &/*jobData*/ ) +{ + KIO::DavJob *davjob = dynamic_cast(job); + if ( !davjob || !adaptor ) return false; + +kdDebug() << "ExchangeGlobals::interpretCalendarDownloadItemsJob(): QDomDocument=" + << 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 ) { + QString 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 QString &/*jobData*/ ) +{ + KIO::DavJob *davjob = dynamic_cast(job); + if ( !davjob || !adaptor ) return false; + +kdDebug() << "ExchangeGlobals::interpretAddressBookDownloadItemsJob(): QDomDocument=" + << 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 ) { + QString 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; +} + + + -- cgit v1.2.1