summaryrefslogtreecommitdiffstats
path: root/kmail/urlhandlermanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/urlhandlermanager.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/urlhandlermanager.cpp')
-rw-r--r--kmail/urlhandlermanager.cpp207
1 files changed, 187 insertions, 20 deletions
diff --git a/kmail/urlhandlermanager.cpp b/kmail/urlhandlermanager.cpp
index 100009faa..8ab2a25fc 100644
--- a/kmail/urlhandlermanager.cpp
+++ b/kmail/urlhandlermanager.cpp
@@ -2,7 +2,7 @@
urlhandlermanager.cpp
This file is part of KMail, the KDE mail client.
- Copyright (c) 2002-2003 Klar�vdalens Datakonsult AB
+ Copyright (c) 2002-2003 Klar�lvdalens Datakonsult AB
Copyright (c) 2003 Marc Mutz <mutz@kde.org>
KMail is free software; you can redistribute it and/or modify it
@@ -43,9 +43,11 @@
#include "kmreaderwin.h"
#include "kmkernel.h"
#include "callback.h"
+#include "stl_util.h"
+#include <kstandarddirs.h>
+#include <kurldrag.h>
#include <kimproxy.h>
-#include "stl_util.h"
#include <kurl.h>
#include <algorithm>
@@ -123,8 +125,14 @@ namespace {
~AttachmentURLHandler() {}
bool handleClick( const KURL &, KMReaderWin * ) const;
+ bool handleShiftClick( const KURL &url, KMReaderWin *window ) const;
+ bool handleDrag( const KURL &url, const TQString& imagePath, KMReaderWin *window ) const;
+ bool willHandleDrag( const KURL &url, const TQString& imagePath, KMReaderWin *window ) const;
bool handleContextMenuRequest( const KURL &, const TQPoint &, KMReaderWin * ) const;
TQString statusBarMessage( const KURL &, KMReaderWin * ) const;
+ private:
+ partNode* partNodeForUrl( const KURL &url, KMReaderWin *w ) const;
+ bool attachmentIsInHeader( const KURL &url ) const;
};
class ShowAuditLogURLHandler : public KMail::URLHandler {
@@ -137,6 +145,24 @@ namespace {
TQString statusBarMessage( const KURL &, KMReaderWin * ) const;
};
+ // Handler that prevents dragging of internal images added by KMail, such as the envelope image
+ // in the enterprise header
+ class InternalImageURLHandler : public KMail::URLHandler {
+ public:
+ InternalImageURLHandler() : KMail::URLHandler()
+ {}
+ ~InternalImageURLHandler()
+ {}
+ bool handleDrag( const KURL &url, const TQString& imagePath, KMReaderWin *window ) const;
+ bool willHandleDrag( const KURL &url, const TQString& imagePath, KMReaderWin *window ) const;
+ bool handleClick( const KURL &, KMReaderWin * ) const
+ { return false; }
+ bool handleContextMenuRequest( const KURL &, const TQPoint &, KMReaderWin * ) const
+ { return false; }
+ TQString statusBarMessage( const KURL &, KMReaderWin * ) const
+ { return TQString(); }
+ };
+
class FallBackURLHandler : public KMail::URLHandler {
public:
FallBackURLHandler() : KMail::URLHandler() {}
@@ -212,7 +238,7 @@ static partNode * partNodeFromXKMailUrl( const KURL & url, KMReaderWin * w, TQSt
const int part_id = urlParts[1].toInt( &ok );
if ( !ok )
return 0;
- *path = KURL::decode_string( urlParts[2], 106 );
+ *path = KURL::decode_string( urlParts[2] );
return w->partNodeForId( part_id );
}
@@ -274,6 +300,7 @@ KMail::URLHandlerManager::URLHandlerManager() {
registerHandler( new AttachmentURLHandler() );
registerHandler( mBodyPartURLHandlerManager = new BodyPartURLHandlerManager() );
registerHandler( new ShowAuditLogURLHandler() );
+ registerHandler( new InternalImageURLHandler );
registerHandler( new FallBackURLHandler() );
}
@@ -311,6 +338,32 @@ bool KMail::URLHandlerManager::handleClick( const KURL & url, KMReaderWin * w )
return false;
}
+bool KMail::URLHandlerManager::handleShiftClick( const KURL &url, KMReaderWin *window ) const
+{
+ for ( HandlerList::const_iterator it = mHandlers.begin() ; it != mHandlers.end() ; ++it )
+ if ( (*it)->handleShiftClick( url, window ) )
+ return true;
+ return false;
+}
+
+bool KMail::URLHandlerManager::willHandleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+{
+ for ( HandlerList::const_iterator it = mHandlers.begin() ; it != mHandlers.end() ; ++it )
+ if ( (*it)->willHandleDrag( url, imagePath, window ) )
+ return true;
+ return false;
+}
+
+bool KMail::URLHandlerManager::handleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+{
+ for ( HandlerList::const_iterator it = mHandlers.begin() ; it != mHandlers.end() ; ++it )
+ if ( (*it)->handleDrag( url, imagePath, window ) )
+ return true;
+ return false;
+}
+
bool KMail::URLHandlerManager::handleContextMenuRequest( const KURL & url, const TQPoint & p, KMReaderWin * w ) const {
for ( HandlerList::const_iterator it = mHandlers.begin() ; it != mHandlers.end() ; ++it )
if ( (*it)->handleContextMenuRequest( url, p, w ) )
@@ -405,6 +458,13 @@ namespace {
return true;
}
+ if ( url.path() == "showRawToltecMail" ) {
+ w->saveRelativePosition();
+ w->setShowRawToltecMail( true );
+ w->update( true );
+ return true;
+ }
+
// if ( url.path() == "startIMApp" )
// {
// kmkernel->imProxy()->startPreferredApp();
@@ -430,6 +490,10 @@ namespace {
return i18n("Show signature details.");
if ( url.path() == "hideSignatureDetails" )
return i18n("Hide signature details.");
+ if ( url.path() == "hideAttachmentQuicklist" )
+ return i18n( "Hide attachment list" );
+ if ( url.path() == "showAttachmentQuicklist" )
+ return i18n( "Show attachment list" );
}
return TQString::null ;
}
@@ -459,11 +523,14 @@ namespace {
if ( url.protocol() == "kmail" && url.path() == "levelquote" )
{
TQString query= url.query();
- if ( query.length()>=2 )
- if ( query[ 1 ] =='-' )
+ if ( query.length()>=2 ) {
+ if ( query[ 1 ] =='-' ) {
return i18n("Expand all quoted text.");
- else
+ }
+ else {
return i18n("Collapse quoted text.");
+ }
+ }
}
return TQString::null ;
}
@@ -517,32 +584,106 @@ namespace {
}
namespace {
- bool AttachmentURLHandler::handleClick( const KURL & url, KMReaderWin * w ) const {
+
+ partNode* AttachmentURLHandler::partNodeForUrl( const KURL &url, KMReaderWin *w ) const
+ {
if ( !w || !w->message() )
+ return 0;
+ if ( url.protocol() != "attachment" )
+ return 0;
+
+ bool ok;
+ int nodeId = url.path().toInt( &ok );
+ if ( !ok )
+ return 0;
+
+ partNode * node = w->partNodeForId( nodeId );
+ return node;
+ }
+
+ bool AttachmentURLHandler::attachmentIsInHeader( const KURL &url ) const
+ {
+ bool inHeader = false;
+ const TQString place = url.queryItem( "place" ).lower();
+ if ( place != TQString::null ) {
+ inHeader = ( place == "header" );
+ }
+ return inHeader;
+ }
+
+ bool AttachmentURLHandler::handleClick( const KURL & url, KMReaderWin * w ) const
+ {
+ partNode * node = partNodeForUrl( url, w );
+ if ( !node )
+ return false;
+
+ const bool inHeader = attachmentIsInHeader( url );
+ const bool shouldShowDialog = !node->isDisplayedEmbedded() || !inHeader;
+ if ( inHeader )
+ w->scrollToAttachment( node );
+ if ( shouldShowDialog )
+ w->openAttachment( node->nodeId(), w->tempFileUrlFromPartNode( node ).path() );
+ return true;
+ }
+
+ bool AttachmentURLHandler::handleShiftClick( const KURL &url, KMReaderWin *window ) const
+ {
+ partNode * node = partNodeForUrl( url, window );
+ if ( !node )
return false;
- const int id = KMReaderWin::msgPartFromUrl( url );
- if ( id <= 0 )
+ if ( !window )
return false;
- w->openAttachment( id, url.path() );
+ window->saveAttachment( window->tempFileUrlFromPartNode( node ) );
return true;
}
- bool AttachmentURLHandler::handleContextMenuRequest( const KURL & url, const TQPoint & p, KMReaderWin * w ) const {
- if ( !w || !w->message() )
+ bool AttachmentURLHandler::willHandleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+ {
+ Q_UNUSED( imagePath );
+ return partNodeForUrl( url, window ) != 0;
+ }
+
+ bool AttachmentURLHandler::handleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+ {
+ Q_UNUSED( imagePath );
+ const partNode * node = partNodeForUrl( url, window );
+ if ( !node )
return false;
- const int id = KMReaderWin::msgPartFromUrl( url );
- if ( id <= 0 )
+
+ KURL file = window->tempFileUrlFromPartNode( node ).path();
+ if ( !file.isEmpty() ) {
+ TQString icon = node->msgPart().iconName( KIcon::Small );
+ KURLDrag* urlDrag = new KURLDrag( file, window );
+ if ( !icon.isEmpty() ) {
+ TQPixmap iconMap( icon );
+ urlDrag->setPixmap( iconMap );
+ }
+ urlDrag->drag();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ bool AttachmentURLHandler::handleContextMenuRequest( const KURL & url, const TQPoint & p, KMReaderWin * w ) const
+ {
+ partNode * node = partNodeForUrl( url, w );
+ if ( !node )
return false;
- w->showAttachmentPopup( id, url.path(), p );
+
+ w->showAttachmentPopup( node->nodeId(), w->tempFileUrlFromPartNode( node ).path(), p );
return true;
}
- TQString AttachmentURLHandler::statusBarMessage( const KURL & url, KMReaderWin * w ) const {
- if ( !w || !w->message() )
- return TQString::null;
- const partNode * node = w->partNodeFromUrl( url );
+ TQString AttachmentURLHandler::statusBarMessage( const KURL & url, KMReaderWin * w ) const
+ {
+ partNode * node = partNodeForUrl( url, w );
if ( !node )
return TQString::null;
+
const KMMessagePart & msgPart = node->msgPart();
TQString name = msgPart.fileName();
if ( name.isEmpty() )
@@ -569,7 +710,9 @@ namespace {
return true;
}
- bool ShowAuditLogURLHandler::handleContextMenuRequest( const KURL & url, const TQPoint &, KMReaderWin * w ) const {
+ bool ShowAuditLogURLHandler::handleContextMenuRequest( const KURL & url, const TQPoint &, KMReaderWin * w ) const
+ {
+ Q_UNUSED( w );
// disable RMB for my own links:
return !extractAuditLog( url ).isEmpty();
}
@@ -583,6 +726,30 @@ namespace {
}
namespace {
+ bool InternalImageURLHandler::handleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+ {
+ Q_UNUSED( window );
+ Q_UNUSED( url );
+ const TQString kmailImagePath = locate( "data", "kmail/pics/" );
+ if ( imagePath.contains( kmailImagePath ) ) {
+ // Do nothing, don't start a drag
+ return true;
+ }
+ return false;
+ }
+
+ bool InternalImageURLHandler::willHandleDrag( const KURL &url, const TQString& imagePath,
+ KMReaderWin *window ) const
+ {
+ Q_UNUSED( window );
+ Q_UNUSED( url );
+ const TQString kmailImagePath = locate( "data", "kmail/pics/" );
+ return imagePath.contains( kmailImagePath );
+ }
+}
+
+namespace {
bool FallBackURLHandler::handleClick( const KURL & url, KMReaderWin * w ) const {
if ( w )
w->emitUrlClicked( url, Qt::LeftButton );