if (!addFlags && (flags & userFlags) && !(flags & settableFlags)) return;
if (!(flags & userFlags) && !(flags & settableFlags)) return;
void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,                                                 PRBool idsAreUids,                                                 imapMessageFlagsType flags,                                                 PRBool addFlags){  nsCString flagString;  uint16 userFlags = GetServerStateParser().SupportsUserFlags();  uint16 settableFlags = GetServerStateParser().SettablePermanentFlags();  if (!addFlags && (flags & userFlags) && !(flags & settableFlags))    return;         // if cannot set any of the flags bail out      if (addFlags)      flagString = "+Flags (";  else      flagString = "-Flags (";      if (flags & kImapMsgSeenFlag && kImapMsgSeenFlag & settableFlags)      flagString .Append("\\Seen ");  if (flags & kImapMsgAnsweredFlag && kImapMsgAnsweredFlag & settableFlags)      flagString .Append("\\Answered ");  if (flags & kImapMsgFlaggedFlag && kImapMsgFlaggedFlag & settableFlags)      flagString .Append("\\Flagged ");  if (flags & kImapMsgDeletedFlag && kImapMsgDeletedFlag & settableFlags)      flagString .Append("\\Deleted ");  if (flags & kImapMsgDraftFlag && kImapMsgDraftFlag & settableFlags)      flagString .Append("\\Draft ");  if (flags & kImapMsgForwardedFlag && kImapMsgSupportForwardedFlag & userFlags)        flagString .Append("$Forwarded ");  // if supported  if (flags & kImapMsgMDNSentFlag && kImapMsgSupportMDNSentFlag & userFlags)        flagString .Append("$MDNSent ");  // if supported  // all this label stuff is predicated on us using the flags to get and set  // labels, which limits us to 5 labels. If we ever want more labels, we'll  // need to rip this label stuff out of here, and write a new method to  // get and set labels, and we'll need a new way of communicating label  // values back to the core mail/news code.  if (userFlags & kImapMsgSupportUserFlag)  {    if ((flags & kImapMsgLabelFlags))    {      // turn into a number from 1-5      PRUint32 labelValue = (flags & kImapMsgLabelFlags) >> 9;      flagString.Append("$Label");      flagString.AppendInt(labelValue);      flagString.Append(" ");    }    // only turn off all labels if the caller has said to turn off flags    // and passed in 0 as the flag value. There is at least one situation    // where client code attempts to add flags of 0    else if (!flags && !addFlags)// we must be turning off labels, so subtract them all       flagString.Append("$Label1 $Label2 $Label3 $Label4 $Label5 ");  }  if (flagString.Length() > 8) // if more than "+Flags ("  {  // replace the final space with ')'    flagString.SetCharAt(')',flagString.Length() - 1);      Store(messageIdsString, flagString.get(), idsAreUids);    // looks like we're going to have to turn off any potential labels on these msgs.    if (addFlags && (userFlags & kImapMsgSupportUserFlag) && (flags & kImapMsgLabelFlags))    {      flagString = "-Flags (";      PRUint32 labelValue = (flags & kImapMsgLabelFlags) >> 9;      for (PRUint32 i = 1; i <= 5; i++)      {         if (labelValue != i)         {            flagString.Append("$Label");            flagString.AppendInt(i);            flagString.Append(" ");         }       }      flagString.SetCharAt(')',flagString.Length() - 1);        Store(messageIdsString, flagString.get(), idsAreUids);    }  }}