[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    [RFC] mail stati -or- make "mark read" not treat on "mark replied"'s
From:       Marc Mutz <Marc.Mutz () uni-bielefeld ! de>
Date:       2001-05-29 17:47:59
[Download RAW message or body]

Hi!

This issue has come up once in a while in bug and wishlist reports, as 
well as on this ml.

How can KMail maintain the state of a message?

Currently, the state is simply a number (a char, in fact), making it 
impossible to have a certain combination of states, e.g. "replied and 
read". What's worse: There are states that are logical opposites of 
each other (new <-> old, read <-> unread) and states that have no 
logical opposites, but define the real state by their existence or 
non-existence (replied, forwarded, deleted, flagged). This is obviously 
very unsatisfying.

Therefore, I've made an analysis of the currently supported states and 
re-arranged them into disjoint logical groups. It became evident that 
most of them are in fact boolean, but there are two states that are 
different:

query           is true iff                     resulting header
is/set...       X-KMail-Status matches  on set...(true) on set...(false)
-------------------------------------------------------------------------------- 
(specials:)
Unknown         /^[^ADFGNOQRSU]*$/      = ' '           = 'N' ?
(bools:)
New             /N/                     - 'O' + 'N'     - 'O' - 'N'
Read            /R/                     - 'U' + 'R'     - 'U' - 'R'
Replied         /A/                     + 'A'           - 'A'
Forwarded       /F/                     + 'F'           - 'F'
Deleted         /D/                     + 'D'           - 'D'
Flagged         /G/                     + 'G'           - 'G'
(tristates:)
Sent,           /S/ && !/Q/             - 'Q' + 'S'     - 'Q' - 'S'
Queued          !/S/ && /Q/             + 'Q' - 'S'     - 'Q' - 'S'

ad Unknown:
A Message's status is unknown if the combination of states is invalid. 
Thus, the above regexp for Unknown is incomplete. It also has to test 
for e.g. 'UR' and 'ON'.
It's not clear whether there should be an explicit setUnknown(FALSE), 
because the opposite of the Unknown (pseudo-)state is not well-defined.

ad bools:
They are quite straightforward. They are defined by existence and 
absence of their corresponding char and can be represented with a 
single bit.

ad Sent/Queued:
They are not so straightforward, but nonetheless quite easy: A message 
is in one of the states "not-send-and-not-queued", "sent" or "queued", 
where all of them are mutually exclusive. This "substate" therefore has 
to be represented by a tupel of bits, where the first means "queued" 
and the second means "sent", but the combination (11) is forbidden.

Conclusion:
---------

The state of an mail should be represented in two ways:
1. As X-KMail-Status: header which contains a certain set of chars, 
each of which defines a particular substate.
2. As a bitfield.
depending on whether we talk about on-disk or in-memory format.

In C++, this would look like:

struct KMMsgStatus {
  bool unknown:1,  /* convenience, may be omitted */
  bool: new:1,
  bool: read:1,
  bool: replied:1,
  bool: forwarded:1,
  bool: deleted:1,
  bool: flagged:1,   /* should be retitled 'importance'
                   and get different levels */
// uint importance:2 // e.g.
  uint sent:2
};

#define SENT 0x2
#define QUEUED 0x1

Marc

-- 
Marc Mutz <Marc@Mutz.com>
http://marc.mutz.com/
http://www.mathematik.uni-bielefeld.de/~mmutz/
http://EncryptionHOWTO.sourceforge.net/
_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic