MIMEGetRelativeCryptoNestLevel(MimeObject *obj)
int MIMEGetRelativeCryptoNestLevel(MimeObject *obj)
MIMEGetRelativeCryptoNestLevel(MimeObject *obj){  /*    the part id of any mimeobj is mime_part_address(obj)    our currently displayed crypto part is obj    the part shown as the toplevel object in the current window is        obj->options->part_to_load        possibly stored in the toplevel object only ???        but hopefully all nested mimeobject point to the same displayooptions    we need to find out the nesting level of our currently displayed crypto object    wrt the shown part in the toplevel window  */  // if we are showing the toplevel message, aTopMessageNestLevel == 0  int aTopMessageNestLevel = 0;  MimeObject *aTopShownObject = nsnull;  if (obj && obj->options->part_to_load) {    PRBool aAlreadyFoundTop = PR_FALSE;    for (MimeObject *walker = obj; walker; walker = walker->parent) {      if (aAlreadyFoundTop) {        if (!mime_typep(walker, (MimeObjectClass *) &mimeEncryptedClass)            && !mime_typep(walker, (MimeObjectClass *) &mimeMultipartSignedClass)) {          ++aTopMessageNestLevel;        }      }      if (!aAlreadyFoundTop && !strcmp(mime_part_address(walker), walker->options->part_to_load)) {        aAlreadyFoundTop = PR_TRUE;        aTopShownObject = walker;      }      if (!aAlreadyFoundTop && !walker->parent) {        aTopShownObject = walker;      }    }  }  PRBool CryptoObjectIsChildOfTopShownObject = PR_FALSE;  if (!aTopShownObject) {    // no sub part specified, top message is displayed, and    // our crypto object is definitively a child of it    CryptoObjectIsChildOfTopShownObject = PR_TRUE;  }  // if we are the child of the topmost message, aCryptoPartNestLevel == 1  int aCryptoPartNestLevel = 0;  if (obj) {    for (MimeObject *walker = obj; walker; walker = walker->parent) {      // Crypto mime objects are transparent wrt nesting.      if (!mime_typep(walker, (MimeObjectClass *) &mimeEncryptedClass)          && !mime_typep(walker, (MimeObjectClass *) &mimeMultipartSignedClass)) {        ++aCryptoPartNestLevel;      }      if (aTopShownObject && walker->parent == aTopShownObject) {        CryptoObjectIsChildOfTopShownObject = PR_TRUE;      }    }  }  if (!CryptoObjectIsChildOfTopShownObject) {    return -1;  }  return aCryptoPartNestLevel - aTopMessageNestLevel;}