exchangedelete.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00045
00046
00047
00048
00049
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
00093 emit finished( this, ExchangeClient::DeleteUnknownEventError, "UID of event to be deleted not found on server\n"+response.toString() );
00094 return;
00095 }
00096
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 );
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"
This file is part of the documentation for libkpimexchange Library Version 3.2.2.