//----------------------------------------------------------------------------- KMMessage* KMFolder::take(int idx) { KMMsgBase* mb; KMMessage* msg; assert(mStream!=NULL); assert(idx>=0 && idx<=mMsgList.high()); mb = mMsgList[idx]; if (!mb) return NULL; if (!mb->isMessage()) readMsg(idx); msg = (KMMessage*)mMsgList.take(idx); if (msg->status()==KMMsgStatusUnread || msg->status()==KMMsgStatusNew) { --unreadMsgs; emit numUnreadMsgsChanged( this ); } msg->setParent(NULL); mDirty = TRUE; needsCompact=true; // message is taken from here - needs to be compacted if (!mQuiet) emit msgRemoved(idx); return msg; }
int KMFilterMgr::process(Q_UINT32 serNum, const KMFilter *filter) { bool stopIt = false; int result = 1; if(!filter) return 1; if(isMatching(serNum, filter)) { KMFolder *folder = 0; int idx = -1; // get the message with the serNum KMMsgDict::instance()->getLocation(serNum, &folder, &idx); if(!folder || (idx == -1) || (idx >= folder->count())) { return 1; } KMFolderOpener openFolder(folder, "filtermgr"); KMMsgBase *msgBase = folder->getMsgBase(idx); bool unGet = !msgBase->isMessage(); KMMessage *msg = folder->getMsg(idx); // do the actual filtering stuff if(!msg || !beginFiltering(msg)) { if(unGet) folder->unGetMsg(idx); return 1; } if(filter->execActions(msg, stopIt) == KMFilter::CriticalError) { if(unGet) folder->unGetMsg(idx); return 2; } KMFolder *targetFolder = MessageProperty::filterFolder(msg); endFiltering(msg); if(targetFolder) { tempOpenFolder(targetFolder); msg->setTransferInProgress(false); result = targetFolder->moveMsg(msg); msg->setTransferInProgress(true); } if(unGet) folder->unGetMsg(idx); } else { result = 1; } return result; }
//----------------------------------------------------------------------------- KMMessage* KMFolder::getMsg(int idx) { KMMsgBase* mb; // assert(idx>=0 && idx<=mMsgList.high()); if(!(idx >= 0 && idx <= mMsgList.high())) return 0L; mb = mMsgList[idx]; if (!mb) return NULL; if (mb->isMessage()) return ((KMMessage*)mb); return readMsg(idx); }