Load/save encryption/signature state (bug #1003 (or was that #1006?))

svn path=/trunk/kdenetwork/kmail/; revision=151452
wilder-work
Kalle Dalheimer 24 years ago
parent ea1241628e
commit 3d3d22c76b
  1. 5
      kmacctlocal.cpp
  2. 3
      kmacctmaildir.cpp
  3. 65
      kmheaders.cpp
  4. 2
      kmheaders.h
  5. 41
      kmmessage.cpp
  6. 42
      kmmsgbase.cpp
  7. 26
      kmmsgbase.h
  8. 2
      pics/Makefile.am

@ -187,6 +187,9 @@ void KMAcctLocal::processNewMail(bool)
{
msg->setStatus(msg->headerField("Status").latin1(),
msg->headerField("X-Status").latin1());
msg->setEncryptionState( msg->headerField( "X-KMail-EncryptionState" ).latin1() );
msg->setSignatureState( msg->headerField( "X-KMail-SignatureState" ).latin1() );
addedOk = processNewMsg(msg);
if (addedOk)
@ -209,7 +212,7 @@ void KMAcctLocal::processNewMail(bool)
if (rc)
KMessageBox::information( 0, i18n("Cannot remove mail from\nmailbox `%1':\n%2").arg(mailFolder.location()).arg(strerror(rc)));
QString statusMsg;
if ( num )
if ( num )
statusMsg = i18n("Transmission completed, %n new message.",
"Transmission completed, %n new messages.", num);
else

@ -172,6 +172,9 @@ void KMAcctMaildir::processNewMail(bool)
{
msg->setStatus(msg->headerField("Status").latin1(),
msg->headerField("X-Status").latin1());
msg->setEncryptionState( msg->headerField( "X-KMail-EncryptionState" ).latin1() );
msg->setSignatureState( msg->headerField( "X-KMail-SignatureState" ).latin1() );
addedOk = processNewMsg(msg);
if (addedOk)
hasNewMail = true;

@ -72,6 +72,7 @@ QPixmap* KMHeaders::pixPartiallySigned = 0;
QPixmap* KMHeaders::pixFullyEncrypted = 0;
QPixmap* KMHeaders::pixPartiallyEncrypted = 0;
QPixmap* KMHeaders::pixFiller = 0;
QPixmap* KMHeaders::pixUndefined = 0;
QIconSet* KMHeaders::up = 0;
QIconSet* KMHeaders::down = 0;
bool KMHeaders::mTrue = true;
@ -86,7 +87,7 @@ KMHeaderToFolderDrag::KMHeaderToFolderDrag( QWidget * parent,
{
dragPix = new QPixmap( DesktopIcon("message",
KIcon::SizeMedium ) );
setPixmap( *dragPix );
}
@ -193,7 +194,7 @@ public:
} else if(col == headers->paintInfo()->senderCol) {
if (qstricmp(headers->folder()->whoField(), "To")==0)
tmp = mMsgBase->toStrip();
else
else
tmp = mMsgBase->fromStrip();
if (tmp.isEmpty())
tmp = i18n("Unknown");
@ -246,7 +247,7 @@ public:
int width = 0;
int height = 0;
for ( PixmapList::ConstIterator it = pixmaps.begin();
it != pixmaps.end(); ++it ) {
it != pixmaps.end(); ++it ) {
width += (*it).width();
height = QMAX( height, (*it).height() );
}
@ -310,6 +311,8 @@ public:
pixmaps << *KMHeaders::pixFullyEncrypted;
else if( mMsgBase->encryptionState() == KMMsgPartiallyEncrypted )
pixmaps << *KMHeaders::pixPartiallyEncrypted;
else if( mMsgBase->encryptionState() == KMMsgEncryptionStateUnknown )
pixmaps << *KMHeaders::pixUndefined;
else
pixmaps << *KMHeaders::pixFiller;
@ -317,11 +320,14 @@ public:
pixmaps << *KMHeaders::pixFullySigned;
else if( mMsgBase->signatureState() == KMMsgPartiallySigned )
pixmaps << *KMHeaders::pixPartiallySigned;
else if( mMsgBase->signatureState() == KMMsgSignatureStateUnknown )
pixmaps << *KMHeaders::pixUndefined;
else
pixmaps << *KMHeaders::pixFiller;
static QPixmap mergedpix;
mergedpix = pixmapMerge( pixmaps );
qDebug( "pixmapMerge returned a pixmap with size %dx%d", mergedpix.width(), mergedpix.height() );
return &mergedpix;
}
return NULL;
@ -433,7 +439,7 @@ public:
return ((KMHeaderItem *)this)->mKey =
generate_key(mMsgId, headers, headers->folder()->getMsgBase( mMsgId ),
headers->paintInfo(), sortOrder);
}
}
return mKey;
}
@ -551,6 +557,7 @@ KMHeaders::KMHeaders(KMMainWin *aOwner, QWidget *parent,
pixFullyEncrypted = new QPixmap( UserIcon( "kmmsgfullyencrypted" ) );
pixPartiallyEncrypted = new QPixmap( UserIcon( "kmmsgpartiallyencrypted" ) );
pixFiller = new QPixmap( UserIcon( "kmmsgfiller" ) );
pixUndefined = new QPixmap( UserIcon( "kmundefined" ) );
up = new QIconSet( UserIcon("abup" ), QIconSet::Small );
down = new QIconSet( UserIcon("abdown" ), QIconSet::Small );
}
@ -658,8 +665,8 @@ void KMHeaders::readConfig (void)
{ // area for config group "General"
KConfigGroupSaver saver(config, "General");
mPaintInfo.showSize = config->readBoolEntry("showMessageSize");
KMime::DateFormatter::FormatType t =
KMime::DateFormatter::FormatType t =
(KMime::DateFormatter::FormatType) config->readNumEntry("dateFormat", KMime::DateFormatter::Fancy ) ;
mDate.setCustomFormat( config->readEntry("customDateFormat", QString::null ) );
mDate.setFormat( t );
@ -940,7 +947,7 @@ void KMHeaders::setFolder (KMFolder *aFolder, bool jumpToFirst)
addColumn(colText, x);
else
addColumn(colText);
setColumnAlignment( mPaintInfo.sizeCol, AlignRight );
#ifdef SCORING
mPaintInfo.scoreCol++;
@ -1127,12 +1134,12 @@ void KMHeaders::setMsgStatus (KMMsgStatus status, int /*msgId*/)
KMHeaderItem *item = static_cast<KMHeaderItem*>(qitem);
if (mFolder->protocol() == "imap")
ids.append(item->msgId());
else
else
mFolder->setStatus(item->msgId(), status);
}
if ( !ids.empty() )
mFolder->setStatus(ids, status);
if ( !ids.empty() )
mFolder->setStatus(ids, status);
}
@ -1188,8 +1195,8 @@ int KMHeaders::slotFilterMsg(KMMessage *msg)
// if ( p != msg->parent() ) {
// kdDebug() << p << " != " << msg->parent() << " for message "
// << msg->subject() << ", " << msg->fromStrip() << endl;
//
// }
//
// }
assert( p == msg->parent() ); assert( idx >= 0 );
p->unGetMsg( idx );
}
@ -1330,7 +1337,7 @@ void KMHeaders::deleteMsg (int msgId)
if (mFolder != trash)
{
folder = trash;
}
}
} else {
@ -1339,11 +1346,11 @@ void KMHeaders::deleteMsg (int msgId)
// move to trash folder
folder = kernel->trashFolder();
}
}
}
// move messages
moveMsgToFolder(folder, msgId);
mSortInfo.dirty = TRUE;
mOwner->statusMsg("");
// triggerUpdate();
@ -1513,12 +1520,12 @@ void KMHeaders::forwardMsg ()
fwdMsg->setAutomaticFields(true);
fwdMsg->setCharset("utf-8");
fwdMsg->setBody(msgText);
for (KMMsgBase *mb = linklist.first(); mb; mb = linklist.next()) {
KMMessage *thisMsg = static_cast<KMMessage *>(mb);
fwdMsg->link(thisMsg, KMMsgStatusForwarded);
}
kernel->kbp()->busy();
win = new KMComposeWin(&mOwner->mCryptPlugList, fwdMsg, id);
win->setCharset("");
@ -1892,9 +1899,9 @@ void KMHeaders::copyMsgToFolder (KMFolder* destFolder, int msgId)
rc = destFolder->addMsg(newMsg, &index);
if (rc == 0 && index != -1)
destFolder->unGetMsg( destFolder->count() - 1 );
}
}
}
if (!isMessage && list.isEmpty())
{
assert(idx != -1);
@ -2588,7 +2595,7 @@ void KMHeaders::slotRMB()
QPopupMenu *msgCopyMenu = new QPopupMenu(menu);
mOwner->folderToPopupMenu( NULL, FALSE, this, &mMenuToFolder, msgCopyMenu );
bool out_folder = kernel->folderIsDraftOrOutbox(mFolder);
bool out_folder = kernel->folderIsDraftOrOutbox(mFolder);
if ( out_folder )
mOwner->editAction->plug(menu);
else {
@ -2810,7 +2817,7 @@ bool KMHeaders::writeSortOrder()
fwrite(&appended, sizeof(appended), 1, sortStream);
fwrite(&discovered_count, sizeof(discovered_count), 1, sortStream);
fwrite(&sorted_count, sizeof(sorted_count), 1, sortStream);
QPtrStack<KMHeaderItem> items;
{
QPtrStack<QListViewItem> s;
@ -2975,7 +2982,7 @@ public:
};
void KMSortCacheItem::updateSortFile(FILE *sortStream, bool waiting_for_parent)
{
{
if(mSortOffset == -1) {
fseek(sortStream, 0, SEEK_END);
mSortOffset = ftell(sortStream);
@ -3051,7 +3058,7 @@ bool KMHeaders::readSortOrder(bool set_selection)
fread(&appended, sizeof(appended), 1, sortStream);
fread(&discovered_count, sizeof(discovered_count), 1, sortStream);
fread(&sorted_count, sizeof(sorted_count), 1, sortStream);
if (sorted_count + discovered_count > mFolder->count()) { //sanity check
kdDebug(5006) << "Whoa.0! " << __FILE__ << ":" << __LINE__ << endl;
fclose(sortStream);
@ -3214,7 +3221,7 @@ bool KMHeaders::readSortOrder(bool set_selection)
msgs.insert(md5, sortCache[x]);
}
for(QPtrListIterator<KMSortCacheItem> it(unparented); it.current(); ++it) {
replyToIdMD5 = mFolder->getMsgBase((*it)->id())->replyToIdMD5();
replyToIdMD5 = mFolder->getMsgBase((*it)->id())->replyToIdMD5();
if(!replyToIdMD5.isEmpty() && (i = msgs[replyToIdMD5])) {
i->addUnsortedChild((*it));
if(sortStream)
@ -3245,11 +3252,11 @@ bool KMHeaders::readSortOrder(bool set_selection)
compare_KMSortCacheItem);
//merge two sorted lists of siblings
for(QPtrListIterator<KMSortCacheItem> it(*sorted);
(unsorted && unsorted_off < unsorted_count) || it.current(); ) {
(unsorted && unsorted_off < unsorted_count) || it.current(); ) {
if(it.current() &&
(!unsorted || unsorted_off >= unsorted_count ||
(ascending && (*it)->key() >= unsorted[unsorted_off]->key()) ||
(!ascending && (*it)->key() < unsorted[unsorted_off]->key()))) {
(!ascending && (*it)->key() < unsorted[unsorted_off]->key()))) {
new_kci = (*it);
++it;
} else {
@ -3302,12 +3309,12 @@ bool KMHeaders::readSortOrder(bool set_selection)
item = static_cast<KMHeaderItem*>(item->itemBelow());
}
}
if(first_unread == -1 ) {
setMsgRead(mCurrentItem);
setTopItemByIndex(mTopItem);
setCurrentItemByIndex((mCurrentItem >= 0) ? mCurrentItem : 0);
} else {
} else {
setMsgRead(first_unread);
setCurrentItemByIndex(first_unread);
makeHeaderVisible();

@ -251,7 +251,7 @@ protected:
*pixQueued, *pixFwd, *pixFlag,
*pixFullySigned, *pixPartiallySigned,
*pixFullyEncrypted, *pixPartiallyEncrypted,
*pixFiller;
*pixFiller, *pixUndefined;
/** Look for color changes */
virtual bool event(QEvent *e);

@ -222,6 +222,8 @@ QCString KMMessage::asSendableString()
msg.fromString(asString());
msg.removeHeaderField("Status");
msg.removeHeaderField("X-Status");
msg.removeHeaderField("X-KMail-EncryptionState");
msg.removeHeaderField("X-KMail-SignatureState");
msg.removeHeaderField("X-KMail-Transport");
msg.removeHeaderField("X-KMail-Identity");
msg.removeHeaderField("X-KMail-Fcc");
@ -239,10 +241,18 @@ void KMMessage::setStatusFields(void)
str[0] = (char)status();
str[1] = '\0';
setHeaderField("Status", status()==KMMsgStatusNew ? "R " : "RO");
setHeaderField("X-Status", str);
}
str[0] = (char)encryptionState();
str[1] = '\0';
setHeaderField("X-KMail-EncryptionState", str);
str[0] = (char)signatureState();
str[1] = '\0';
setHeaderField("X-KMail-SignatureState", str);
}
//----------------------------------------------------------------------------
@ -294,9 +304,12 @@ void KMMessage::fromString(const QCString& aStr, bool aSetStatus)
mMsg->FromString((const char*)result);
mMsg->Parse();
if (aSetStatus)
if (aSetStatus) {
setStatus(headerField("Status").latin1(), headerField("X-Status").latin1());
setEncryptionState(headerField("X-KMail-EncryptionState").latin1());
setSignatureState(headerField("X-KMail-SignatureState").latin1());
}
mNeedsAssembly = FALSE;
mDate = date();
@ -347,7 +360,7 @@ QString KMMessage::formatString(const QString& aStr) const
to have a long form of the date used? I don't
like this change to a short XX/XX/YY date format.
At least not for the default. -sanders */
result += KMime::DateFormatter::formatDate( KMime::DateFormatter::Localized,
result += KMime::DateFormatter::formatDate( KMime::DateFormatter::Localized,
date(), sReplyLanguage, false );
break;
case 'e':
@ -904,7 +917,7 @@ KMMessage* KMMessage::createReply(bool replyToAll, bool replyToList,
} else { // valid rx
QString subj = subject();
if ( rx.search( subj ) == 0 ) { // matches
recognized = true;
if ( sReplaceSubjPrefix )
msg->setSubject( subj.replace( 0, rx.matchedLength(), "Re: " ) );
@ -996,7 +1009,7 @@ KMMessage* KMMessage::createRedirect(void)
msg->setSubject(subject());
msg->setFrom(from());
msg->cleanupHeader();
// setStatus(KMMsgStatusForwarded);
msg->link(this, KMMsgStatusForwarded);
@ -1104,7 +1117,7 @@ QCString KMMessage::createForwardBody(void)
str = asQuotedString(s, "", QString::null, false, false);
str += "\n-------------------------------------------------------\n";
}
return str;
}
@ -1117,7 +1130,7 @@ KMMessage* KMMessage::createForward(void)
int i;
msg->initFromMessage(this);
QString st = QString::fromUtf8(createForwardBody());
QCString encoding = autoDetectCharset(charset(), sPrefCharsets, st);
if (encoding.isEmpty()) encoding = "utf-8";
@ -1319,8 +1332,8 @@ QString KMMessage::dateStr(void) const
if (!header.HasDate()) return "";
unixTime = header.Date().AsUnixTime();
return KMime::DateFormatter::formatDate( static_cast<KMime::DateFormatter::FormatType>(general.readNumEntry( "dateFormat", KMime::DateFormatter::Fancy )),
return KMime::DateFormatter::formatDate( static_cast<KMime::DateFormatter::FormatType>(general.readNumEntry( "dateFormat", KMime::DateFormatter::Fancy )),
unixTime, general.readEntry( "customDateFormat" ) );
}
@ -2435,7 +2448,7 @@ QString KMMessage::generateMessageId( const QString& addr )
QString msgIdSuffix;
KConfigGroup general( kapp->config(), "General" );
if( general.readBoolEntry( "useCustomMessageIdSuffix", false ) )
msgIdSuffix = general.readEntry( "myMessageIdSuffix", "" );
@ -2861,13 +2874,13 @@ void KMMessage::link(const KMMessage *aMsg, KMMsgStatus aStatus)
QString type = headerField("X-KMail-Link-Type");
if (!type.isEmpty())
type += ",";
message += QString::number(aMsg->getMsgSerNum());
if (aStatus == KMMsgStatusReplied)
type += "reply";
else if (aStatus == KMMsgStatusForwarded)
type += "forward";
setHeaderField("X-KMail-Link-Message", message);
setHeaderField("X-KMail-Link-Type", type);
}

@ -30,7 +30,7 @@
/* Swap bytes in 16 bit value. */
#ifdef bswap_16
#define kmail_swap_16(x) bswap_16(x)
#else
#else
#define kmail_swap_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
#endif
@ -161,6 +161,36 @@ void KMMsgBase::setStatus(const char* aStatusStr, const char* aXStatusStr)
}
void KMMsgBase::setEncryptionState( const char* status )
{
if( status[0] == (char)KMMsgEncryptionStateUnknown )
setEncryptionState( KMMsgEncryptionStateUnknown );
else if( status[0] == (char)KMMsgNotEncrypted )
setEncryptionState( KMMsgNotEncrypted );
else if( status[0] == (char)KMMsgPartiallyEncrypted )
setEncryptionState( KMMsgPartiallyEncrypted );
else if( status[0] == (char)KMMsgFullyEncrypted )
setEncryptionState( KMMsgFullyEncrypted );
else
setEncryptionState( KMMsgEncryptionStateUnknown );
}
void KMMsgBase::setSignatureState( const char* status )
{
if( status[0] == (char)KMMsgSignatureStateUnknown )
setSignatureState( KMMsgSignatureStateUnknown );
else if( status[0] == (char)KMMsgNotSigned )
setSignatureState( KMMsgNotSigned );
else if( status[0] == (char)KMMsgPartiallySigned )
setSignatureState( KMMsgPartiallySigned );
else if( status[0] == (char)KMMsgFullySigned )
setSignatureState( KMMsgFullySigned );
else
setSignatureState( KMMsgSignatureStateUnknown );
}
//-----------------------------------------------------------------------------
bool KMMsgBase::isUnread(void) const
{
@ -244,7 +274,7 @@ const QCString KMMsgBase::toUsAscii(const QString& _str, bool *ok)
QString result = _str;
int len = result.length();
for (int i = 0; i < len; i++)
if (result.at(i).unicode() >= 128) {
if (result.at(i).unicode() >= 128) {
result.at(i) = '?';
all_ok = false;
}
@ -628,7 +658,7 @@ QCString KMMsgBase::autoDetectCharset(const QCString &_encoding, const QStringLi
if (ok)
return encoding;
}
else
else
{
QTextCodec *codec = KMMsgBase::codecForName(encoding);
if (!codec) {
@ -914,7 +944,7 @@ unsigned long KMMsgBase::getLongPart(MsgPartType t) const
// We swap the result to host order.
ret = kmail_swap_32(ret);
}
}
break;
}
@ -950,7 +980,7 @@ const uchar *KMMsgBase::asIndexString(int &length) const
#ifndef WORDS_BIGENDIAN
// #warning Byte order is little endian (call swapEndian)
#define SWAP_TO_NETWORK_ORDER(x) swapEndian(x)
#else
#else
// #warning Byte order is big endian
#define SWAP_TO_NETWORK_ORDER(x)
#endif
@ -1007,4 +1037,4 @@ bool KMMsgBase::syncIndexString() const
}
return FALSE;
}

@ -34,19 +34,19 @@ typedef enum
/** Flags for the encryption state. */
typedef enum
{
KMMsgEncryptionStateUnknown=0,
KMMsgNotEncrypted=1,
KMMsgPartiallyEncrypted=2,
KMMsgFullyEncrypted=3
KMMsgEncryptionStateUnknown=' ',
KMMsgNotEncrypted='N',
KMMsgPartiallyEncrypted='P',
KMMsgFullyEncrypted='F'
} KMMsgEncryptionState;
/** Flags for the signature state. */
typedef enum
{
KMMsgSignatureStateUnknown=0,
KMMsgNotSigned=1,
KMMsgPartiallySigned=2,
KMMsgFullySigned=3
KMMsgSignatureStateUnknown=' ',
KMMsgNotSigned='N',
KMMsgPartiallySigned='P',
KMMsgFullySigned='F'
} KMMsgSignatureState;
@ -92,10 +92,12 @@ public:
/** Set encryption status of the message. */
virtual void setEncryptionState(const KMMsgEncryptionState status) { mEncryptionState = status; }
virtual void setEncryptionState( const char* status );
/** Set signature status of the message. */
virtual void setSignatureState(const KMMsgSignatureState status) { mSignatureState = status; }
virtual void setSignatureState( const char* status );
/** Important header fields of the message that are also kept in the index. */
virtual QString subject(void) const = 0;
@ -155,7 +157,7 @@ public:
* This function is a bit more tolerant, than QTextCodec::codecForName */
static QTextCodec* codecForName(const QCString& _str);
/** Convert all non-ascii characters to question marks
/** Convert all non-ascii characters to question marks
* If ok is non-null, *ok will be set to true if all characters
* where ascii, *ok will be set to false otherwise */
static const QCString toUsAscii(const QString& _str, bool *ok=0);
@ -235,7 +237,7 @@ public:
MsgFilePart = 11
};
/** access to long msgparts */
unsigned long getLongPart(MsgPartType) const;
unsigned long getLongPart(MsgPartType) const;
/** access to string msgparts */
QString getStringPart(MsgPartType) const;
/** sync'ing just one KMMsgBase */

@ -8,7 +8,7 @@ data_DATA = green-bullet.png kmfldin.png kmfldout.png kmfolder.png \
feather_white.png pub_key_red.png pgp-keys.png \
kmfolderfull.png abup.png abdown.png kmmsgpartiallyencrypted.png \
kmmsgpartiallysigned.png kmmsgfiller.png kmmsgfullyencrypted.png \
kmmsgfullysigned.png
kmmsgfullysigned.png kmundefined.png
datadir = $(kde_datadir)/kmail/pics

Loading…
Cancel
Save