qtmobility/src/messaging/qmessagecontentcontainer_maemo.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
--- a/qtmobility/src/messaging/qmessagecontentcontainer_maemo.cpp	Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/src/messaging/qmessagecontentcontainer_maemo.cpp	Wed Jun 23 19:08:38 2010 +0300
@@ -312,22 +312,32 @@
 
 QString QMessageContentContainer::textContent() const
 {
-    if (d_ptr->_textContent.isEmpty() && d_ptr->_attachmentId != 0) {
-        ModestEngine *engine = ModestEngine::instance();
-        d_ptr->_textContent = engine->getMimePart(QMessageId(d_ptr->_containingMessageId),
+    QString retString;
+
+    if (!d_ptr->_textContent.isEmpty()) {
+        retString = d_ptr->_textContent;
+    } else {
+        if (d_ptr->_content.isEmpty() && d_ptr->_attachmentId != 0) {
+            ModestEngine *engine = ModestEngine::instance();
+            d_ptr->_content = engine->getMimePart(QMessageId(d_ptr->_containingMessageId),
                                                   d_ptr->_attachmentId);
-        d_ptr->_size = d_ptr->_textContent.size();
-    }
-    if (!d_ptr->_textContent.isEmpty()) {
-        return d_ptr->_textContent;
+            d_ptr->_size = d_ptr->_content.size();
+        }
+
+        if (!d_ptr->_content.isEmpty()) {
+            if (d_ptr->_subType.toLower() == "html") {
+                QTextCodec *codec = QTextCodec::codecForName(d_ptr->_charset.data());
+                if (codec) {
+                    retString = codec->toUnicode(d_ptr->_content);
+                }
+            } else {
+                // Modest plugin automatically decodes plain text content to UTF-8 format
+                retString = QString::fromUtf8(d_ptr->_content);
+            }
+        }
     }
 
-    QTextCodec *codec = QTextCodec::codecForName(d_ptr->_charset.data());
-    if (codec) {
-        return codec->toUnicode(d_ptr->_content);
-    } else {
-        return QString::fromLatin1(d_ptr->_content);
-    }
+    return retString;
 }
 
 QByteArray QMessageContentContainer::content() const