GetImapServerKey(),
hostName, userName,
nsImapProtocol::DiscoverMailboxSpec(nsImapMailboxSpec * adoptedBoxSpec)  {  // IMAP_LoadTrashFolderName(); **** needs to work on localization issues  nsIMAPNamespace *ns = nsnull;    NS_ASSERTION (m_hostSessionList, "fatal null host session list");    if (!m_hostSessionList) return;    m_hostSessionList->GetDefaultNamespaceOfTypeForHost(        GetImapServerKey(), kPersonalNamespace, ns);  const char *nsPrefix = ns ? ns->GetPrefix() : 0;  nsCString canonicalSubDir;  if (nsPrefix)  {        PRUnichar slash = '/';    canonicalSubDir = nsPrefix;    if (canonicalSubDir.Length() && canonicalSubDir.Last() == slash)        canonicalSubDir.SetLength((PRUint32) canonicalSubDir.Length()-1);  }        switch (m_hierarchyNameState)  {  case kNoOperationInProgress:  case kDiscoverTrashFolderInProgress:  case kListingForInfoAndDiscovery:    {            if (canonicalSubDir.Length() &&                PL_strstr(adoptedBoxSpec->allocatedPathName,                          canonicalSubDir.GetBuffer()))                m_onlineBaseFolderExists = PR_TRUE;            if (ns && nsPrefix) // if no personal namespace, there can be no Trash folder      {                PRBool onlineTrashFolderExists = PR_FALSE;                if (m_hostSessionList)                    m_hostSessionList->GetOnlineTrashFolderExistsForHost(                        GetImapServerKey(), onlineTrashFolderExists);        if (GetDeleteIsMoveToTrash() && // don't set the Trash flag if not using the Trash model          !onlineTrashFolderExists &&                     PL_strstr(adoptedBoxSpec->allocatedPathName,                               kImapTrashFolderName))        {          PRBool trashExists = PR_FALSE;                    nsCString trashMatch;                    trashMatch = nsPrefix;                    trashMatch += kImapTrashFolderName;          {            char *serverTrashName = nsnull;                        m_runningUrl->AllocateCanonicalPath(                            trashMatch.GetBuffer(),                            ns->GetDelimiter(), &serverTrashName);             if (serverTrashName)            {              if (!PL_strcasecmp(nsPrefix, "INBOX.")) // need to special-case this because it should be case-insensitive              {#ifdef DEBUG                NS_ASSERTION (PL_strlen(serverTrashName) > 6,                                              "Oops.. less that 6");#endif                trashExists = ((PL_strlen(serverTrashName) > 6 /* nsCRT::strlen("INBOX.") */) &&                  (PL_strlen(adoptedBoxSpec->allocatedPathName) > 6 /* nsCRT::strlen("INBOX.") */) &&                  !PL_strncasecmp(adoptedBoxSpec->allocatedPathName, serverTrashName, 6) && /* "INBOX." */                  !PL_strcmp(adoptedBoxSpec->allocatedPathName + 6, serverTrashName + 6));              }              else              {                trashExists = (PL_strcmp(serverTrashName, adoptedBoxSpec->allocatedPathName) == 0);              }                            if (m_hostSessionList)              m_hostSessionList->                                SetOnlineTrashFolderExistsForHost(                                    GetImapServerKey(), trashExists);              PR_Free(serverTrashName);            }          }                    if (trashExists)                    adoptedBoxSpec->box_flags |= kImapTrash;        }      }      // Discover the folder (shuttle over to libmsg, yay)      // Do this only if the folder name is not empty (i.e. the root)      if (adoptedBoxSpec->allocatedPathName &&                *adoptedBoxSpec->allocatedPathName)      {                nsCString boxNameCopy;                         boxNameCopy = adoptedBoxSpec->allocatedPathName;                if (m_imapServerSink)                {                    m_imapServerSink->PossibleImapMailbox(boxNameCopy, 									adoptedBoxSpec->hierarchySeparator,                                    adoptedBoxSpec->box_flags);                                    PRBool useSubscription = PR_FALSE;                    if (m_hostSessionList)                        m_hostSessionList->GetHostIsUsingSubscription(                            GetImapServerKey(),                            useSubscription);          if ((GetMailboxDiscoveryStatus() != eContinue) &&             (GetMailboxDiscoveryStatus() != eContinueNew) &&            (GetMailboxDiscoveryStatus() != eListMyChildren))          {                      SetConnectionStatus(-1);          }          else if (boxNameCopy.Length() &&                              (GetMailboxDiscoveryStatus() ==                               eListMyChildren) &&                             (!useSubscription || GetSubscribingNow()))          {            NS_ASSERTION (PR_FALSE,                                       "we should never get here anymore");                      SetMailboxDiscoveryStatus(eContinue);          }          else if (GetMailboxDiscoveryStatus() == eContinueNew)          {            if (m_hierarchyNameState ==                            kListingForInfoAndDiscovery &&                            boxNameCopy.Length() &&                             !(adoptedBoxSpec->box_flags & kNameSpace))            {              // remember the info here also              nsIMAPMailboxInfo *mb = new                                nsIMAPMailboxInfo(boxNameCopy.GetBuffer(),                                    adoptedBoxSpec->hierarchySeparator);                             m_listedMailboxList.AppendElement((void*) mb);            }            SetMailboxDiscoveryStatus(eContinue);          }        }      }        }        NS_IF_RELEASE( adoptedBoxSpec);        break;    case kDiscoverBaseFolderInProgress:        {            if (canonicalSubDir.Length() &&                PL_strstr(adoptedBoxSpec->allocatedPathName,                          canonicalSubDir.GetBuffer()))                m_onlineBaseFolderExists = PR_TRUE;        }        break;    case kDeleteSubFoldersInProgress:        {            NS_ASSERTION(m_deletableChildren,                          "Oops .. null m_deletableChildren\n");            m_deletableChildren->AppendElement((void*)                nsCRT::strdup(adoptedBoxSpec->allocatedPathName));            PR_FREEIF(adoptedBoxSpec->hostName);            NS_IF_RELEASE( adoptedBoxSpec);        }        break;  case kListingForInfoOnly:    {      //UpdateProgressWindowForUpgrade(adoptedBoxSpec->allocatedPathName);      ProgressEventFunctionUsingIdWithString(IMAP_DISCOVERING_MAILBOX,                adoptedBoxSpec->allocatedPathName);      nsIMAPMailboxInfo *mb = new                nsIMAPMailboxInfo(adoptedBoxSpec->allocatedPathName,                                  adoptedBoxSpec->hierarchySeparator);      m_listedMailboxList.AppendElement((void*) mb);            PR_FREEIF(adoptedBoxSpec->allocatedPathName);            NS_IF_RELEASE(adoptedBoxSpec);    }    break;  case kDiscoveringNamespacesOnly:    {            PR_FREEIF(adoptedBoxSpec->allocatedPathName);            NS_IF_RELEASE(adoptedBoxSpec);    }    break;    default:        NS_ASSERTION (PR_FALSE, "we aren't supposed to be here");        break;  }}