Summary: | Try getting MIME type from filename for better attachment display | ||
---|---|---|---|
Product: | [Applications] kmail | Reporter: | Jonathan Marten <jjm> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | kollix |
Priority: | NOR | ||
Version: | 1.3 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Other | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
Patch to try harder for attachment type
Email message demonstrating problems |
Description
Jonathan Marten
2001-12-06 10:08:14 UTC
Just noticed that the original patch doesn't display the correct icon for attachments whose MIME type is unknown and where using the attachment name doesn't yield a known MIME type either - it shows as a folder. This new patch only uses the file name to generate an icon if it actually corresponds to a known type. The additional modification to kmreaderwin.cpp makes another cosmetic change to suppress the attachment 'comment' if it is the same as the 'label' (often happens with attachments from CDE's dtmail). Otherwise the same text is pointlessly shown twice (one clickable the other not). ---------------------------------------------------------------------- --- kdenetwork-2.2/kmail/kmmsgpart.cpp.origWed Dec 5 15:34:29 2001 +++ kdenetwork-2.2/kmail/kmmsgpart.cppWed Dec 12 13:55:49 2001 @@ -2184 +21822 @@ QString fileName = KMimeType::mimeType(mimeType.isEmpty() ? (mType + "/" + mSubtype).lower() : mimeType.lower())->icon(QString()FALSE); + + if (fileName.isEmpty()) + { + fileName = this->fileName(); + if (fileName.isEmpty()) fileName = this->name(); + if (!fileName.isEmpty()) + { + kdDebug(5006) << "KMMessagePart::iconName: unknown mimetype " << + (mType + "/" + mSubtype) << " using filename " << fileName << endl; + fileName = KMimeType::iconForURL("file:/tmp/"+fileName0); + } + else + { + kdDebug(5006) << "KMMessagePart::iconName: unknown mimetype " << + (mType + "/" + mSubtype) << endl; + } + } + fileName = KGlobal::instance()->iconLoader()->iconPath( fileName KIcon::Desktop ); --- kdenetwork-2.2/kmail/kmreaderwin.cpp.origTue Nov 6 14:15:47 2001 +++ kdenetwork-2.2/kmail/kmreaderwin.cppWed Dec 12 14:01:43 2001 @@ -10614 +10616 @@ if (fileName.isEmpty()) fileName = aMsgPart->name(); label = fileName; + if (label==comment) comment = ""; + /* HTMLize label */ label.replace(QRegExp("\"") """); @@ -11114 +11135 @@ else iconName = aMsgPart->iconName(); + if (iconName.right(14)=="mime_empty.png") { @@ -11164 +11195 @@ iconName = aMsgPart->iconName(); } + mViewer->write("<table><tr><td><a href=\"" + href + "\"><img src=\"" + iconName + "\" border=\"0\">" + label + ---------------------------------------------------------------------- -- Jonathan Marten SCM Team Engineer VSP Bracknell UK jonathan.marten@uk.sun.com Sun Microsystems Closed as fixed, but the problem is still present in KDE 3.4 (KMail 1.8). Updated patch against KDE 3.4 sources attached, along with a test case message that demonstrates both problems. Created attachment 10799 [details]
Patch to try harder for attachment type
Created attachment 10800 [details]
Email message demonstrating problems
Can confirm with KDE-3.5.5; it's also duplicate with 77898 *** Bug 77898 has been marked as a duplicate of this bug. *** SVN commit 603223 by marten: Get attachment icon from file name if not available from Content-Type BUG: 35836 M +9 -0 branches/work/kdepim-3.5.5+/kmail/kmmsgpart.cpp M +1 -0 branches/work/kdepim-3.5.5+/kmail/objecttreeparser.cpp --- branches/work/kdepim-3.5.5+/kmail/kmmsgpart.cpp #603222:603223 @@ -386,8 +386,17 @@ { QCString mimeType( mType + "/" + mSubtype ); KPIM::kAsciiToLower( mimeType.data() ); + QString fileName = KMimeType::mimeType( mimeType )->icon( QString::null, false ); + if ( fileName.isEmpty() ) + { + fileName = this->fileName(); + if ( fileName.isEmpty() ) fileName = this->name(); + if ( !fileName.isEmpty() ) + fileName = KMimeType::findByURL( "file:/tmp/"+fileName, 0, true, true )->icon( QString::null, true ); + } + fileName = KGlobal::instance()->iconLoader()->iconPath( fileName, KIcon::Desktop ); return fileName; --- branches/work/kdepim-3.5.5+/kmail/objecttreeparser.cpp #603222:603223 @@ -1734,6 +1734,7 @@ QString comment = msgPart->contentDescription(); comment = KMMessage::quoteHtmlChars( comment, true ); + if ( label == comment ) comment = QString::null; QString fileName = mReader->writeMessagePartToTempFile( msgPart, partNum ); SVN commit 603260 by marten: Correct encoding of file name before lookup, using a KURL (Correction from Martin Koller) CCBUG: 35836 M +6 -2 branches/work/kdepim-3.5.5+/kmail/kmmsgpart.cpp --- branches/work/kdepim-3.5.5+/kmail/kmmsgpart.cpp #603259:603260 @@ -393,8 +393,12 @@ { fileName = this->fileName(); if ( fileName.isEmpty() ) fileName = this->name(); - if ( !fileName.isEmpty() ) - fileName = KMimeType::findByURL( "file:/tmp/"+fileName, 0, true, true )->icon( QString::null, true ); + if ( !fileName.isEmpty() ) + { + KURL u( "file:///tmp/" ); + u.addPath( fileName ); + fileName = KMimeType::findByURL( u, 0, true, true )->icon( QString::null, true ); + } } fileName = SVN commit 608103 by marten: Merge commits 603223+603260 from branches/work/kdepim-3.5.5+: Get attachment icon from file name if not available from Content-Type (Using KMimeType::findByPath as suggested by David Faure) CCBUG: 35836 M +11 -0 kmmsgpart.cpp M +1 -0 objecttreeparser.cpp --- branches/KDE/3.5/kdepim/kmail/kmmsgpart.cpp #608102:608103 @@ -386,8 +386,19 @@ { QCString mimeType( mType + "/" + mSubtype ); KPIM::kAsciiToLower( mimeType.data() ); + QString fileName = KMimeType::mimeType( mimeType )->icon( QString::null, false ); + if ( fileName.isEmpty() ) + { + fileName = this->fileName(); + if ( fileName.isEmpty() ) fileName = this->name(); + if ( !fileName.isEmpty() ) + { + fileName = KMimeType::findByPath( "/tmp/"+fileName, 0, true )->icon( QString::null, true ); + } + } + fileName = KGlobal::instance()->iconLoader()->iconPath( fileName, KIcon::Desktop ); return fileName; --- branches/KDE/3.5/kdepim/kmail/objecttreeparser.cpp #608102:608103 @@ -1734,6 +1734,7 @@ QString comment = msgPart->contentDescription(); comment = KMMessage::quoteHtmlChars( comment, true ); + if ( label == comment ) comment = QString::null; QString fileName = mReader->writeMessagePartToTempFile( msgPart, partNum ); SVN commit 608814 by marten: Forward port 603223+603260 from branches/work/kdepim-3.5.5+: Get attachment icon from file name if not available from Content-Type CCBUG: 35836 M +12 -1 kmmsgpart.cpp M +1 -0 objecttreeparser.cpp --- trunk/KDE/kdepim/kmail/kmmsgpart.cpp #608813:608814 @@ -388,7 +388,18 @@ Q3CString mimeType( mType + '/' + mSubtype ); kAsciiToLower( mimeType.data() ); QString fileName = - KMimeType::mimeType( mimeType )->iconName( QString() ); + KMimeType::mimeType( mimeType )->iconName(); + + if ( fileName.isEmpty() ) + { + fileName = this->fileName(); + if ( fileName.isEmpty() ) fileName = this->name(); + if ( !fileName.isEmpty() ) + { + fileName = KMimeType::findByPath( "/tmp/"+fileName, 0, true )->iconName(); + } + } + fileName = KGlobal::instance()->iconLoader()->iconPath( fileName, K3Icon::Desktop ); return fileName; --- trunk/KDE/kdepim/kmail/objecttreeparser.cpp #608813:608814 @@ -1744,6 +1744,7 @@ QString comment = msgPart->contentDescription(); comment = KMMessage::quoteHtmlChars( comment, true ); + if ( label == comment ) comment = QString::null; QString fileName = mReader->writeMessagePartToTempFile( msgPart, partNum ); |