Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv3271/src/mail
Modified Files:
VFolder.cpp
Log Message:
handle UID properly in MFVirt
Index: VFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/VFolder.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -u -2 -r1.5 -r1.6
--- VFolder.cpp 17 Jul 2002 19:22:52 -0000 1.5
+++ VFolder.cpp 17 Jul 2002 21:34:33 -0000 1.6
@@ -84,4 +84,7 @@
{
m_folder->IncRef();
+
+ // no messages so far
+ m_uidLast = 0;
}
@@ -234,5 +237,5 @@
{
// for compatibility reasons we return profile not IncRef()'d so
- // compensate for one done by MFolder::GetProfile()
+ // compensate for IncRef() done by MFolder::GetProfile()
profile->DecRef();
}
@@ -255,4 +258,20 @@
}
+MailFolderVirt::Msg *MailFolderVirt::GetMsgFromUID(UIdType uid) const
+{
+ MsgCookie cookie;
+ for ( Msg *msg = GetFirstMsg(cookie); msg; msg = GetNextMsg(cookie) )
+ {
+ if ( msg->uidVirt == uid )
+ {
+ return msg;
+ }
+ }
+
+ FAIL_MSG( "no message with such UID in the virtual folder" );
+
+ return NULL;
+}
+
void MailFolderVirt::AddMsg(MailFolderVirt::Msg *msg)
{
@@ -357,5 +376,5 @@
HeaderInfo * const hiDst = headers[count++];
- const HeaderInfo * const hiSrc = hil->GetEntryUId(msg->uid);
+ const HeaderInfo * const hiSrc = hil->GetEntryUId(msg->uidPhys);
if ( !hiSrc )
{
@@ -368,8 +387,6 @@
// override some fields:
- // UID must refer to this folder, not the other one (notice that count
- // is already incremented, as it should be -- UIDs == msgnos start
- // from 1, not 0)
- hiDst->m_UId = count;
+ // UID must refer to this folder, not the other one
+ hiDst->m_UId = msg->uidVirt;
// and we maintain our own, independent flags
@@ -476,6 +493,15 @@
MsgnoType MailFolderVirt::GetMsgnoFromUID(UIdType uid) const
{
- // UIDs are the same as msgnos for us for now...
- return uid;
+ MsgnoType n = 1;
+ MsgCookie cookie;
+ for ( Msg *msg = GetFirstMsg(cookie); msg; msg = GetNextMsg(cookie), n++ )
+ {
+ if ( msg->uidVirt == uid )
+ {
+ return n;
+ }
+ }
+
+ return MSGNO_ILLEGAL;
}
@@ -501,5 +527,5 @@
return NULL;
- Message *message = msg->mf->GetMessage(msg->uid);
+ Message *message = msg->mf->GetMessage(msg->uidPhys);
if ( !message )
return NULL;
@@ -511,5 +537,5 @@
MailFolderVirt::SetMessageFlag(unsigned long uid, int flag, bool set)
{
- if ( !DoSetMessageFlag(uid, flag, set) )
+ if ( !DoSetMessageFlag(SEQ_UID, uid, flag, set) )
return false;
@@ -520,7 +546,10 @@
bool
-MailFolderVirt::DoSetMessageFlag(unsigned long uid, int flag, bool set)
+MailFolderVirt::DoSetMessageFlag(SequenceKind kind,
+ unsigned long uid,
+ int flag,
+ bool set)
{
- Msg *msg = GetMsgFromUID(uid);
+ Msg *msg = kind == SEQ_MSGNO ? GetMsgFromMsgno(uid) : GetMsgFromUID(uid);
if ( !msg )
@@ -535,5 +564,6 @@
}
- const MsgnoType msgno = uid; // UID == msgno here
+ const MsgnoType msgno = kind == SEQ_MSGNO ? uid : GetMsgnoFromUID(uid);
+ CHECK( msgno != MSGNO_ILLEGAL, false, "SetMessageFlag: invalid UID" );
HeaderInfoList_obj headers = GetHeaders();
@@ -567,5 +597,4 @@
bool rc = true;
- // we ignore sequence kind here because msgnos == UIDs for us
size_t cookie;
for ( UIdType n = seq.GetFirst(cookie);
@@ -573,5 +602,5 @@
n = seq.GetNext(n, cookie) )
{
- if ( !SetMessageFlag(n, flag, set) )
+ if ( !DoSetMessageFlag(kind, n, flag, set) )
rc = false;
}
@@ -592,10 +621,11 @@
return false;
- UIdType uid = msg.GetUId();
- const HeaderInfo *hi = hil->GetEntryUId(uid);
+ UIdType uidPhys = msg.GetUId();
+ const HeaderInfo *hi = hil->GetEntryUId(uidPhys);
if ( !hi )
return false;
- AddMsg(new Msg(mf, uid, hi->GetStatus()));
+ // use the new UID for the new message
+ AddMsg(new Msg(mf, uidPhys, ++m_uidLast, hi->GetStatus()));
return true;
@@ -652,7 +682,5 @@
if ( !(msg->flags & MSG_STAT_DELETED) || !(flags & SEARCH_UNDELETED) )
{
- // we don't care whether we're searching for UIDs or msgnos as they
- // are one and the same for us
- results->Add(n);
+ results->Add(flags & SEARCH_UID ? msg->uidVirt : n);
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates