diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp
index a5245f442..3960e77d8 100644
--- a/kmreaderwin.cpp
+++ b/kmreaderwin.cpp
@@ -461,6 +461,7 @@ void KMReaderWin::parseMsg(KMMessage* aMsg)
QString type, subtype, str, contDisp;
bool asIcon = false;
inlineImage = false;
+ VCard *vc;
assert(aMsg!=NULL);
type = aMsg->typeStr();
@@ -468,15 +469,24 @@ void KMReaderWin::parseMsg(KMMessage* aMsg)
// Hrm we have to iterate this twice with the current design. This
// should really be fixed. (FIXME)
+ int vcnum = -1;
for (int j = 0; j < aMsg->numBodyParts(); j++) {
aMsg->bodyPart(j, &msgPart);
if (!stricmp(msgPart.typeStr(), "text")
&& !stricmp(msgPart.subtypeStr(), "x-vcard")) {
- debug("FOUND A VCARD");
+ int vcerr;
+ vc = VCard::parseVCard(msgPart.body(), &vcerr);
+
+ if (vc) {
+ delete vc;
+ debug("FOUND A VALID VCARD");
+ vcnum = j;
+ break;
+ }
}
}
- writeMsgHeader();
+ writeMsgHeader(vcnum);
if (numParts > 0)
{
@@ -591,9 +601,30 @@ void KMReaderWin::parseMsg(KMMessage* aMsg)
//-----------------------------------------------------------------------------
-void KMReaderWin::writeMsgHeader(void)
+void KMReaderWin::writeMsgHeader(int vcpartnum)
{
QString str;
+ QString vcname;
+ KMMessagePart aMsgPart;
+ QString vcFileName;
+
+ if (vcpartnum >= 0) {
+ mMsg->bodyPart(vcpartnum, &aMsgPart);
+ vcFileName = aMsgPart.fileName();
+ if (vcFileName.isEmpty()) {
+ vcFileName = "/unnamed";
+ } else {
+ // remove quotes from the filename so that the shell does not get confused
+ int c = 0;
+ while ((c = vcFileName.find('"', c)) >= 0)
+ vcFileName.remove(c, 1);
+
+ c = 0;
+ while ((c = vcFileName.find('\'', c)) >= 0)
+ vcFileName.remove(c, 1);
+ }
+ vcname = QString("%1part%2/%3").arg(mAttachDir).arg(vcpartnum+1).arg(vcFileName);
+ }
switch (mHeaderStyle)
{
@@ -604,14 +635,22 @@ void KMReaderWin::writeMsgHeader(void)
if (!mMsg->cc().isEmpty())
mViewer->write(i18n("Cc: ")+
KMMessage::emailAddrAsAnchor(mMsg->cc(),TRUE) + ", ");
- mViewer->write(strToHtml(mMsg->dateShortStr()) + ")
\n");
+ mViewer->write(" "+strToHtml(mMsg->dateShortStr()) + ")");
+ if (vcpartnum >= 0) {
+ mViewer->write(" "+i18n("[vCard]")+"");
+ }
+ mViewer->write("
\n");
break;
case HdrStandard:
mViewer->write("" +
strToHtml(mMsg->subject()) + "
\n");
mViewer->write(i18n("From: ") +
- KMMessage::emailAddrAsAnchor(mMsg->from(),FALSE) + "
\n");
+ KMMessage::emailAddrAsAnchor(mMsg->from(),FALSE));
+ if (vcpartnum >= 0) {
+ mViewer->write(" "+i18n("[vCard]")+"");
+ }
+ mViewer->write("
\n");
mViewer->write(i18n("To: ") +
KMMessage::emailAddrAsAnchor(mMsg->to(),FALSE) + "
\n");
if (!mMsg->cc().isEmpty())
@@ -631,7 +670,11 @@ void KMReaderWin::writeMsgHeader(void)
">