rem: bool res; int idx = -1; KMFolder *folder = 0; kmkernel->msgDict()->getLocation(serNum, &folder, &idx); if (!folder || (idx == -1) || (idx >= folder->count())) { return false;
add: QString msgContents;   bool logContents = true;  if( field() == "<message>" ) { msgContents = msg->asString(); logContents = false; } else if ( field() == "<body>" ) { msgContents = msg->bodyToUnicode(); logContents = false; } else if ( field() == "<any header>" ) { msgContents = msg->headerAsString(); logContents = false; } else if ( field() == "<recipients>" ) {    if ( function() == FuncEquals || function() == FuncNotEqual )   return matchesInternal( msg->headerField("To") ) || matchesInternal( msg->headerField("Cc") ) || matchesInternal( msg->headerField("Bcc") )  || matchesInternal( msg->cc() );  msgContents = msg->headerField("To"); if ( !msg->headerField("Cc").compare( msg->cc() ) ) msgContents += ", " + msg->headerField("Cc"); else msgContents += ", " + msg->cc(); msgContents += ", " + msg->headerField("Bcc"); }  else {   msgContents = msg->headerFields( field() ).join( " " );
context: bool KMSearchPattern::matches( Q_UINT32 serNum ) const{  if ( isEmpty() )    return true;  bool res;  int idx = -1;  KMFolder *folder = 0;  kmkernel->msgDict()->getLocation(serNum, &folder, &idx);  if (!folder || (idx == -1) || (idx >= folder->count())) {    return false;  }  bool opened = folder->isOpened();  if ( !opened )    folder->open();  KMMsgBase *msgBase = folder->getMsgBase(idx);  if (requiresBody()) {    bool unGet = !msgBase->isMessage();    KMMessage *msg = folder->getMsg(idx);    res = matches( msg );    if (unGet)      folder->unGetMsg(idx);  } else {    res = matches( folder->getDwString(idx) );  }  if ( !opened )    folder->close();  return res;}