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/exchangecalendaradaptor.cpp | 183 +++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 kresources/newexchange/exchangecalendaradaptor.cpp (limited to 'kresources/newexchange/exchangecalendaradaptor.cpp') diff --git a/kresources/newexchange/exchangecalendaradaptor.cpp b/kresources/newexchange/exchangecalendaradaptor.cpp new file mode 100644 index 000000000..254eb4da1 --- /dev/null +++ b/kresources/newexchange/exchangecalendaradaptor.cpp @@ -0,0 +1,183 @@ +/* + This file is part of kdepim. + + Copyright (C) 2004 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 "exchangecalendaradaptor.h" +#include "exchangeglobals.h" +#include "exchangeconvertercalendar.h" +#include +#include +#include +#include +#include +#include +#include "davcalendaradaptor.h" + +using namespace KCal; + +ExchangeCalendarUploadItem::ExchangeCalendarUploadItem( CalendarAdaptor *adaptor, KCal::Incidence *incidence, KPIM::GroupwareUploadItem::UploadType type ) + : GroupwareUploadItem( type ) +{ + if ( incidence && adaptor ) { + if ( incidence->type() == "Event" ) mItemType = KPIM::FolderLister::Event; + else if ( incidence->type() == "Todo" ) mItemType = KPIM::FolderLister::Todo; + else if ( incidence->type() == "Journal" ) mItemType = KPIM::FolderLister::Journal; +kdDebug()<<"mItemType=="<customProperty( adaptor->identifier(), "storagelocation" ) ); + setUid( incidence->uid() ); + + ExchangeConverterCalendar format; + format.setTimeZone( adaptor->resource()->timeZoneId() ); + mDavData = format.createWebDAV( incidence ); + } +} + +KIO::TransferJob *ExchangeCalendarUploadItem::createUploadJob( KPIM::GroupwareDataAdaptor *adaptor, const KURL &baseUrl ) +{ +kdDebug()<<"ExchangeCalendarUploadItem::createUploadJob, adaptor="<calendarURL(), "DAV:", "sql", query, false ); + job->setWindow( mWindow ); + connect(job, SIGNAL(result( KIO::Job * )), this, SLOT(slotFindUidResult(KIO::Job *))); +} + +*/ + + +QString ExchangeCalendarAdaptor::defaultNewItemName( KPIM::GroupwareUploadItem *item ) { + if ( item ) return item->uid()+".EML"; + else return QString::null; +} + +KPIM::GroupwareUploadItem *ExchangeCalendarAdaptor::newUploadItem( KCal::Incidence*it, + KPIM::GroupwareUploadItem::UploadType type ) +{ + return new ExchangeCalendarUploadItem( this, it, type ); +} + +bool ExchangeCalendarAdaptor::interpretUploadJob( KIO::Job *job, const QString &/*jobData*/ ) +{ + kdDebug(7000) << "ExchangeCalendarAdaptor::interpretUploadJob " << endl; + KIO::DavJob *davjob = dynamic_cast(job); + bool error = job->error(); + const QString err = job->errorString(); + + if ( davjob ) { + if ( error ) { + emit itemUploadError( davjob->url(), err ); + return false; + } else { + QDomDocument doc( davjob->response() ); + // TODO: extract the href and the items that got a 404. If there's + // something important among them, issue the "usual" not-all-settings-uploaded + // warning to the user. + + // We don't know the local id here (and we don't want to extract it from + // the idMapper, that's the task of the receiver + emit itemUploaded( uidFromJob( job ), davjob->url() ); + } + return true; + } else { + return false; + } +} + +bool ExchangeCalendarAdaptor::interpretUploadNewJob( KIO::Job *job, const QString &/*jobData*/ ) +{ +// TODO: How does the incidence mapper know the old/new ids??? + kdDebug(7000) << "ExchangeCalendarAdaptor::interpretUploadNewJob " << endl; + KIO::DavJob *davjob = dynamic_cast(job); + bool error = job->error(); + const QString err = job->errorString(); + + if ( davjob ) { + if ( error ) { + emit itemUploadNewError( idMapper()->localId( davjob->url().path() ), err ); + return false; + } else { + QDomDocument doc( davjob->response() ); + // TODO: extract the href and the items that got a 404. If there's + // something important among them, issue the "usual" not-all-settings-uploaded + // warning to the user. + + // We don't know the local id here (and we don't want to extract it from + // the idMapper, that's the task of the receiver + emit itemUploadedNew( uidFromJob( job ), davjob->url() ); + } + return true; + } else { + return false; + } +} + -- cgit v1.2.1