From b5d72f7147fd65d229fe15cffd4e12e6f159d278 Mon Sep 17 00:00:00 2001 From: Bo Thorsen Date: Sat, 25 Oct 2003 22:16:21 +0000 Subject: [PATCH] Implement handing groupware replies over to KOrganizer svn path=/trunk/kdepim/; revision=261982 --- kmgroupware.cpp | 78 +++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 52 deletions(-) diff --git a/kmgroupware.cpp b/kmgroupware.cpp index 83e43bce2..4d5c8a74a 100644 --- a/kmgroupware.cpp +++ b/kmgroupware.cpp @@ -673,77 +673,48 @@ void KMGroupware::processVCalRequest( const QCString& receiver, //----------------------------------------------------------------------------- -void KMGroupware::processVCalReply( const QCString& sender, const QString& vCalIn, +void KMGroupware::processVCalReply( const QCString& sender, + const QString& vCal, const QString& choice ) { - VCalType type = getVCalType( vCalIn ); + VCalType type = getVCalType( vCal ); if( type == vCalUnknown ) { kdDebug(5006) << "processVCalReply called with something that is not a vCal\n"; return; } - if("enter" == choice ){ + if( choice == "enter" ) { // step 1: call Organizer - QString vCalOut; - ignore_GroupwareDataChangeSlots = true; - // emit signal... - emit signalIncidenceAnswer( sender, vCalIn, vCalOut ); -#if 0 - // This code will be taken care of by korganizer - - // Check for the user stopping this transaction or some error happening - if( vCalOut == "false" ) { - kdDebug(5006) << "Problem in processing the iCal reply\n"; - ignore_GroupwareDataChangeSlots = false; - return; - } - - // note: If we do not get a vCalOut back, we just store the vCalIn into mCalendar + QByteArray data, replyData; + QCString replyType; + QDataStream arg( data, IO_WriteOnly ); + arg << sender << vCal; + if( kapp->dcopClient()->call( "korganizer", "KOrganizerIface", + "eventReply(QCString,QString)", + data, replyType, replyData ) + && replyType == "bool" ) + { + bool rc; + QDataStream replyStream( replyData, IO_ReadOnly ); + replyStream >> rc; + kdDebug(5006) << "KOrganizer call succeeded, rc = " << rc << endl; - QString uid( "UID" ); - vPartMicroParser( vCalOut.isEmpty() ? vCalIn.utf8() : vCalOut.utf8(), uid ); - KMFolder* folder = type == vCalEvent ? mCalendar : mTasks; - KMMessage* msgNew = kmkernel->iCalIface().findMessageByUID( uid, folder ); - bool isNewMsg = ( msgNew == 0 ); - if( isNewMsg ) { - // Process a new event: - msgNew = new KMMessage(); // makes a "Content-Type=text/plain" message - msgNew->initHeader(); - msgNew->setType( DwMime::kTypeText ); - msgNew->setSubtype( DwMime::kSubtypeVCal ); - msgNew->setHeaderField("Content-Type", - "text/calendar; method=REPLY; charset=\"utf-8\""); - if( type == vCalEvent ) - msgNew->setSubject( "Meeting" ); - else if( type == vCalTodo ) - msgNew->setSubject( "Task" ); + if( rc ) + kdDebug(5006) << "KOrganizer call succeeded\n"; } else - // Strip the X-UID header so it will be uploaded to the IMAP server again - msgNew->removeHeaderField("X-UID"); - - // add missing headers/content: - msgNew->setTo( msgNew->from() ); - msgNew->setBodyEncoded( vCalOut.isEmpty() ? vCalIn.utf8() : vCalOut.utf8() ); - - if( isNewMsg ) { - // Mark the message as read and store it in a folder - msgNew->touch(); - folder->addMsg( msgNew ); - } + kdDebug(5006) << "KOrganizer call failed\n"; // step 2: inform user that Organizer was updated KMessageBox::information( mMainWin, (type == vCalEvent ? i18n("The answer was registered in your calendar.") : i18n("The answer was registered in your task list.")), QString::null, "groupwareBox"); - ignore_GroupwareDataChangeSlots = false; -#endif - } else if( "cancel" == choice ) { + } else if( choice == "cancel" ) { QString uid( "UID" ); QString descr("DESCRIPTION"); QString summary("SUMMARY"); - vPartMicroParser( vCalIn.utf8(), uid, descr, summary ); + vPartMicroParser( vCal.utf8(), uid, descr, summary ); if( type == vCalEvent ) { emit signalEventDeleted( uid ); KMessageBox::information( mMainWin, i18n("The event %1 was deleted from your calendar.") @@ -1449,9 +1420,12 @@ bool KMGroupware::handleLink( const KURL &aUrl, KMMessage* msg ) return false; if( gwType != "vCal" || gwData.isEmpty() - || ( "request" != gwAction && "reply" != gwAction && "cancel" != gwAction ) ) + || ( "request" != gwAction && "reply" != gwAction + && "cancel" != gwAction ) ) { // Then we can't handle it. But it is a groupware link, so we return true + kdDebug(5006) << "Unhandled groupware link\n"; return true; + } // Read the vCal QFile file( gwData );