From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * 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 --- kmail/attachmentstrategy.cpp | 87 +++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 21 deletions(-) (limited to 'kmail/attachmentstrategy.cpp') diff --git a/kmail/attachmentstrategy.cpp b/kmail/attachmentstrategy.cpp index 8d1e59a90..6e147b946 100644 --- a/kmail/attachmentstrategy.cpp +++ b/kmail/attachmentstrategy.cpp @@ -45,6 +45,21 @@ namespace KMail { +static AttachmentStrategy::Display smartDisplay( const partNode *node ) +{ + if ( node->hasContentDispositionInline() ) + // explict "inline" disposition: + return AttachmentStrategy::Inline; + if ( node->isAttachment() ) + // explicit "attachment" disposition: + return AttachmentStrategy::AsIcon; + if ( node->type() == DwMime::kTypeText && + node->msgPart().fileName().stripWhiteSpace().isEmpty() && + node->msgPart().name().stripWhiteSpace().isEmpty() ) + // text/* w/o filename parameter: + return AttachmentStrategy::Inline; + return AttachmentStrategy::AsIcon; +} // // IconicAttachmentStrategy: @@ -60,7 +75,7 @@ namespace KMail { public: const char * name() const { return "iconic"; } const AttachmentStrategy * next() const { return smart(); } - const AttachmentStrategy * prev() const { return hidden(); } + const AttachmentStrategy * prev() const { return headerOnly(); } bool inlineNestedMessages() const { return false; } Display defaultDisplay( const partNode * ) const { return AsIcon; } @@ -86,18 +101,7 @@ namespace KMail { bool inlineNestedMessages() const { return true; } Display defaultDisplay( const partNode * node ) const { - if ( node->hasContentDispositionInline() ) - // explict "inline" disposition: - return Inline; - if ( node->isAttachment() ) - // explicit "attachment" disposition: - return AsIcon; - if ( node->type() == DwMime::kTypeText && - node->msgPart().fileName().stripWhiteSpace().isEmpty() && - node->msgPart().name().stripWhiteSpace().isEmpty() ) - // text/* w/o filename parameter: - return Inline; - return AsIcon; + return smartDisplay( node ); } }; @@ -134,13 +138,45 @@ namespace KMail { public: const char * name() const { return "hidden"; } - const AttachmentStrategy * next() const { return iconic(); } + const AttachmentStrategy * next() const { return headerOnly(); } const AttachmentStrategy * prev() const { return inlined(); } bool inlineNestedMessages() const { return false; } Display defaultDisplay( const partNode * ) const { return None; } }; + class HeaderOnlyAttachmentStrategy : public AttachmentStrategy { + friend class ::KMail::AttachmentStrategy; + protected: + HeaderOnlyAttachmentStrategy() : AttachmentStrategy() {} + virtual ~HeaderOnlyAttachmentStrategy() {} + + public: + const char * name() const { return "headerOnly"; } + const AttachmentStrategy * next() const { return iconic(); } + const AttachmentStrategy * prev() const { return hidden(); } + + bool inlineNestedMessages() const { + return true; + } + + Display defaultDisplay( const partNode *node ) const { + if ( node->isInEncapsulatedMessage() ) { + return smartDisplay( node ); + } + + partNode::AttachmentDisplayInfo info = node->attachmentDisplayInfo(); + if ( info.displayInHeader ) { + // The entire point about this attachment strategy: Hide attachments in the body that are + // already displayed in the attachment quick list + return None; + } else { + return smartDisplay( node ); + } + } + }; + + // // AttachmentStrategy abstract base: @@ -156,10 +192,11 @@ namespace KMail { const AttachmentStrategy * AttachmentStrategy::create( Type type ) { switch ( type ) { - case Iconic: return iconic(); - case Smart: return smart(); - case Inlined: return inlined(); - case Hidden: return hidden(); + case Iconic: return iconic(); + case Smart: return smart(); + case Inlined: return inlined(); + case Hidden: return hidden(); + case HeaderOnly: return headerOnly(); } kdFatal( 5006 ) << "AttachmentStrategy::create(): Unknown attachment startegy ( type == " << (int)type << " ) requested!" << endl; @@ -168,10 +205,11 @@ namespace KMail { const AttachmentStrategy * AttachmentStrategy::create( const TQString & type ) { TQString lowerType = type.lower(); - if ( lowerType == "iconic" ) return iconic(); + if ( lowerType == "iconic" ) return iconic(); //if ( lowerType == "smart" ) return smart(); // not needed, see below - if ( lowerType == "inlined" ) return inlined(); - if ( lowerType == "hidden" ) return hidden(); + if ( lowerType == "inlined" ) return inlined(); + if ( lowerType == "hidden" ) return hidden(); + if ( lowerType == "headeronly" ) return headerOnly(); // don't kdFatal here, b/c the strings are user-provided // (KConfig), so fail gracefully to the default: return smart(); @@ -181,6 +219,7 @@ namespace KMail { static const AttachmentStrategy * smartStrategy = 0; static const AttachmentStrategy * inlinedStrategy = 0; static const AttachmentStrategy * hiddenStrategy = 0; + static const AttachmentStrategy * headerOnlyStrategy = 0; const AttachmentStrategy * AttachmentStrategy::iconic() { if ( !iconicStrategy ) @@ -206,4 +245,10 @@ namespace KMail { return hiddenStrategy; } + const AttachmentStrategy * AttachmentStrategy::headerOnly() { + if ( !headerOnlyStrategy ) + headerOnlyStrategy = new HeaderOnlyAttachmentStrategy(); + return headerOnlyStrategy; + } + } // namespace KMail -- cgit v1.2.1