- improved importing of mail messages and index creation. Annother step

towards mail folder sharing with pine :-)
- fixed a small bug in decoding of quoted-printable header lines

svn path=/trunk/kdenetwork/kmail/; revision=3535
wilder-work
Stefan Taferner 29 years ago
parent ba9cfa5ae4
commit 2449b226f7
  1. 26
      kmfolder.cpp
  2. 13
      kmmessage.cpp
  3. 4
      kmmessage.h
  4. 30
      kmmsgbase.cpp
  5. 2
      kmmsgbase.h

@ -276,7 +276,7 @@ bool KMFolder::isIndexOutdated(void)
int KMFolder::createIndexFromContents(void)
{
char line[MAX_LINE];
char status[8];
char status[8], xstatus[8];
QString subjStr, dateStr, fromStr;
unsigned long offs, size, pos;
bool atEof = FALSE;
@ -284,6 +284,7 @@ int KMFolder::createIndexFromContents(void)
QString msgStr(256);
QRegExp regexp(MSG_SEPERATOR_REGEX);
int i, num;
short needStatus;
assert(mStream != NULL);
rewind(mStream);
@ -296,7 +297,9 @@ int KMFolder::createIndexFromContents(void)
dateStr = "";
fromStr = "";
subjStr = "";
strcpy(status, "RO");
*status = '\0';
*xstatus = '\0';
needStatus = 3;
while (!atEof)
{
@ -323,10 +326,14 @@ int KMFolder::createIndexFromContents(void)
{
mi = new KMMsgInfo(this);
mi->init(subjStr, fromStr, 0, KMMsgStatusNew, offs, size);
mi->setStatus(status,xstatus);
mi->setDate(dateStr);
mi->setDirty(FALSE);
mMsgList.append(mi);
strcpy(status, "RO");
*status = '\0';
*xstatus = '\0';
needStatus = 3;
dateStr = "";
fromStr = "";
subjStr = "";
@ -337,11 +344,19 @@ int KMFolder::createIndexFromContents(void)
offs = ftell(mStream);
num++;
}
else if (strncmp(line, "Status: ", 8) == 0)
else if ((needStatus & 1) && strncmp(line, "Status: ", 8) == 0)
{
for(i=0; i<8 && line[i+8] > ' '; i++)
for(i=0; i<4 && line[i+8] > ' '; i++)
status[i] = line[i+8];
status[i] = '\0';
needStatus &= ~1;
}
else if ((needStatus & 2) && strncmp(line, "X-Status: ", 10) == 0)
{
for(i=0; i<4 && line[i+10] > ' '; i++)
xstatus[i] = line[i+10];
xstatus[i] = '\0';
needStatus &= ~2;
}
else if (strncmp(line, "Date: ", 6) == 0)
dateStr = QString(line+6).copy();
@ -593,6 +608,7 @@ int KMFolder::addMsg(KMMessage* aMsg, int* aIndex_ret)
if (idx >= 0) msgParent->take(idx);
}
aMsg->setStatusFields();
msgText = aMsg->asString();
len = msgText.length();

@ -66,6 +66,7 @@ const QString KMMessage::followup(void) const
else return "";
}
}
//-----------------------------------------------------------------------------
void KMMessage::setFollowup(const QString aStr)
{
@ -197,6 +198,18 @@ const QString KMMessage::asString(void)
return resultStr;
}
//-----------------------------------------------------------------------------
void KMMessage::setStatusFields(void)
{
char str[3];
str[0] = (char)status();
str[1] = '\0';
setHeaderField("Status", status()==KMMsgStatusNew ? "R " : "RO");
setHeaderField("X-Status", str);
}
//----------------------------------------------------------------------------
const QString KMMessage::headerAsString(void)
{

@ -211,6 +211,10 @@ public:
/** Open a window containing the complete, unparsed, message. */
virtual void viewSource(const QString windowCaption) const;
/** Set "Status" and "X-Status" fields of the message from the
* internal message status. */
virtual void setStatusFields(void);
/** Strip email address from string. Examples:
* "Stefan Taferner <taferner@kde.org>" returns "Stefan Taferner"
* "joe@nowhere.com" returns "joe@nowhere.com" */

@ -76,14 +76,31 @@ void KMMsgBase::setStatus(KMMsgStatus aStatus)
//-----------------------------------------------------------------------------
void KMMsgBase::setStatus(const char* aStatusStr)
void KMMsgBase::setStatus(const char* aStatusStr, const char* aXStatusStr)
{
int i;
for (i=0; i<NUM_STATUSLIST-1; i++)
if (strchr(aStatusStr, (char)sStatusList[i])) break;
mStatus = KMMsgStatusUnknown;
// first try to find status from "X-Status" field if given
if (aXStatusStr) for (i=0; i<NUM_STATUSLIST-1; i++)
{
if (strchr(aXStatusStr, (char)sStatusList[i]))
{
mStatus = sStatusList[i];
break;
}
}
// if not successful then use the "Status" field
if (mStatus == KMMsgStatusUnknown)
{
if (aStatusStr[0]=='R' && aStatusStr[1]=='O') mStatus=KMMsgStatusOld;
else if (aStatusStr[0]=='R') mStatus=KMMsgStatusUnread;
else if (aStatusStr[0]=='D') mStatus=KMMsgStatusDeleted;
else mStatus=KMMsgStatusNew;
}
mStatus = sStatusList[i];
mDirty = TRUE;
#ifndef KRN
if (mParent) mParent->headerOfMsgChanged(this);
@ -274,7 +291,7 @@ const QString KMMsgBase::decodeQuotedPrintableString(const QString aStr)
if (beg > start) result += aStr.mid(start, beg-start);
mid = aStr.find("?Q?", beg+2);
end = aStr.find("?=", beg+2);
if (mid>beg) end = aStr.find("?=", mid+3);
if (mid < 0 || end < 0)
{
// no quoted printable part -- skip it
@ -289,7 +306,8 @@ const QString KMMsgBase::decodeQuotedPrintableString(const QString aStr)
}
else if (aStr[mid+3]==' ') mid++;
result += decodeQuotedPrintable(aStr.mid(mid+3, end-mid-3).data());
if (end-mid-3 > 0)
result += decodeQuotedPrintable(aStr.mid(mid+3, end-mid-3).data());
start = end+2;
}
return result;

@ -46,7 +46,7 @@ public:
/** Set status and mark dirty. */
virtual void setStatus(const KMMsgStatus status);
virtual void setStatus(const char* statusStr);
virtual void setStatus(const char* statusField, const char* xstatusField=0);
/** Important header fields of the message that are also kept in the index. */
virtual const QString subject(void) const = 0;

Loading…
Cancel
Save