libkpimexchange Library API Documentation

exchangedelete.cpp

00001 /* 00002 This file is part of libkpimexchange 00003 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #include <qstring.h> 00022 #include <qregexp.h> 00023 00024 #include <kurl.h> 00025 #include <kdebug.h> 00026 #include <krfcdate.h> 00027 #include <kio/job.h> 00028 #include <kio/jobclasses.h> 00029 00030 #include <kio/slave.h> 00031 #include <kio/scheduler.h> 00032 #include <kio/slavebase.h> 00033 #include <kio/davjob.h> 00034 #include <kio/http.h> 00035 00036 #include "exchangeclient.h" 00037 #include "exchangeprogress.h" 00038 #include "exchangedelete.h" 00039 #include "exchangeaccount.h" 00040 #include "utils.h" 00041 00042 using namespace KPIM; 00043 00044 // Delete: 00045 // - Find URL for uid 00046 // - Delete URL 00047 // - Can there be multipe URLs, for instance when dealing with 00048 // recurrent appointments? Maybe, so we just look for Master or Single 00049 // instancetypes 00050 00051 ExchangeDelete::ExchangeDelete( KCal::Event* event, ExchangeAccount* account, QWidget* window ) : 00052 mWindow( window ) 00053 { 00054 kdDebug() << "Created ExchangeDelete" << endl; 00055 00056 mAccount = account; 00057 00058 findUidSingleMaster( event->uid() ); 00059 } 00060 00061 ExchangeDelete::~ExchangeDelete() 00062 { 00063 kdDebug() << "ExchangeDelete destructor" << endl; 00064 } 00065 00066 void ExchangeDelete::findUidSingleMaster( QString const& uid ) 00067 { 00068 QString query = 00069 "SELECT \"DAV:href\", \"urn:schemas:calendar:uid\"\r\n" 00070 "FROM Scope('shallow traversal of \"\"')\r\n" 00071 "WHERE \"urn:schemas:calendar:uid\" = '" + uid + "'\r\n" 00072 " AND (\"urn:schemas:calendar:instancetype\" = 0\r\n" 00073 " OR \"urn:schemas:calendar:instancetype\" = 1)\r\n"; 00074 00075 KIO::DavJob* job = KIO::davSearch( mAccount->calendarURL(), "DAV:", "sql", query, false ); 00076 job->setWindow( mWindow ); 00077 connect(job, SIGNAL(result( KIO::Job * )), this, SLOT(slotFindUidResult(KIO::Job *))); 00078 } 00079 00080 void ExchangeDelete::slotFindUidResult( KIO::Job * job ) 00081 { 00082 if ( job->error() ) { 00083 job->showErrorDialog( 0L ); 00084 emit finished( this, ExchangeClient::CommunicationError, "IO Error: " + QString::number(job->error()) + ":" + job->errorString() ); 00085 return; 00086 } 00087 QDomDocument& response = static_cast<KIO::DavJob *>( job )->response(); 00088 00089 QDomElement item = response.documentElement().firstChild().toElement(); 00090 QDomElement hrefElement = item.namedItem( "href" ).toElement(); 00091 if ( item.isNull() || hrefElement.isNull() ) { 00092 // Not found 00093 emit finished( this, ExchangeClient::DeleteUnknownEventError, "UID of event to be deleted not found on server\n"+response.toString() ); 00094 return; 00095 } 00096 // Found the appointment's URL 00097 QString href = hrefElement.text(); 00098 KURL url(href); 00099 00100 startDelete( toDAV( url ) ); 00101 } 00102 00103 void ExchangeDelete::startDelete( const KURL& url ) 00104 { 00105 KIO::SimpleJob* job = KIO::file_delete( url, false ); // no GUI 00106 job->setWindow( mWindow ); 00107 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotDeleteResult( KIO::Job * ) ) ); 00108 } 00109 00110 void ExchangeDelete::slotDeleteResult( KIO::Job* job ) 00111 { 00112 kdDebug() << "Finished Delete" << endl; 00113 if ( job->error() ) { 00114 job->showErrorDialog( 0L ); 00115 emit finished( this, ExchangeClient::CommunicationError, "IO Error: " + QString::number(job->error()) + ":" + job->errorString() ); 00116 return; 00117 } 00118 emit finished( this, ExchangeClient::ResultOK, QString::null ); 00119 } 00120 00121 #include "exchangedelete.moc"
KDE Logo
This file is part of the documentation for libkpimexchange Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:51:24 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003