a=phil. Fixes for 29184 and 29104 (r=alecf and bienvenu) Can now access and copy to a local

subfolder.  Fix for 7844 (r=nhotta and bienvenu) Can now view Japanese local folders.
This commit is contained in:
putterman%netscape.com 2000-02-26 20:46:39 +00:00
parent de9519f19a
commit 7abb41369e
5 changed files with 55 additions and 61 deletions

View File

@ -575,43 +575,7 @@ nsMsgFolder::parseURI(PRBool needServer)
// to be appended onto the server's path
nsCAutoString newPath("");
nsCAutoString oldPath(result);
nsCAutoString pathPiece;
PRInt32 startSlashPos = oldPath.FindChar('/');
PRInt32 endSlashPos = (startSlashPos >= 0)
? oldPath.FindChar('/', PR_FALSE, startSlashPos + 1) : oldPath.Length() - 1;
if (endSlashPos == -1)
endSlashPos = oldPath.Length();
// trick to make sure we only add the path to the first n-1 folders
PRBool haveFirst=PR_FALSE;
while (startSlashPos != -1) {
oldPath.Mid(pathPiece, startSlashPos + 1, endSlashPos - startSlashPos);
// skip leading '/' (and other // style things)
if (pathPiece.Length() > 0) {
// add .sbd onto the previous path
if (haveFirst) {
newPath+=".sbd";
newPath += "/";
}
NS_MsgHashIfNecessary(pathPiece);
newPath += pathPiece;
haveFirst=PR_TRUE;
}
// look for the next slash
startSlashPos = endSlashPos;
endSlashPos = (startSlashPos >= 0)
? oldPath.FindChar('/', PR_FALSE, startSlashPos + 1) : oldPath.Length() - 1;
if (endSlashPos == -1)
endSlashPos = oldPath.Length();
if (startSlashPos == endSlashPos)
break;
}
NS_MsgCreatePathStringFromFolderURI(result, newPath);
// now append munged path onto server path
nsCOMPtr<nsIFileSpec> serverPath;

View File

@ -328,3 +328,45 @@ nsresult NS_MsgHashIfNecessary(nsCAutoString &name)
return NS_OK;
}
nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& pathString)
{
nsCAutoString oldPath(folderURI);
nsCAutoString pathPiece;
PRInt32 startSlashPos = oldPath.FindChar('/');
PRInt32 endSlashPos = (startSlashPos >= 0)
? oldPath.FindChar('/', PR_FALSE, startSlashPos + 1) - 1 : oldPath.Length() - 1;
if (endSlashPos == -1)
endSlashPos = oldPath.Length();
// trick to make sure we only add the path to the first n-1 folders
PRBool haveFirst=PR_FALSE;
while (startSlashPos != -1) {
oldPath.Mid(pathPiece, startSlashPos + 1, endSlashPos - startSlashPos);
// skip leading '/' (and other // style things)
if (pathPiece.Length() > 0) {
// add .sbd onto the previous path
if (haveFirst) {
pathString+=".sbd";
pathString += "/";
}
NS_MsgHashIfNecessary(pathPiece);
pathString += pathPiece;
haveFirst=PR_TRUE;
}
// look for the next slash
startSlashPos = endSlashPos + 1;
endSlashPos = (startSlashPos >= 0)
? oldPath.FindChar('/', PR_FALSE, startSlashPos + 1) - 1: oldPath.Length() - 1;
if (endSlashPos == -1)
endSlashPos = oldPath.Length();
if (startSlashPos == endSlashPos)
break;
}
return NS_OK;
}

View File

@ -67,5 +67,7 @@ NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriority p, nsStrin
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);
NS_MSG_BASE nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& pathString);
#endif

View File

@ -70,6 +70,7 @@
#include "nsIMessenger.h"
#include "nsIMsgMailSession.h"
#include "nsMsgBaseCID.h"
#include "nsMsgI18N.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -216,6 +217,8 @@ nsMsgLocalMailFolder::CreateSubFolders(nsFileSpec &path)
{
nsresult rv = NS_OK;
nsAutoString currentFolderNameStr;
nsAutoString convertedFolderNameStr;
const nsString fileCharset = msgCompFileSystemCharset();
nsCOMPtr<nsIMsgFolder> child;
char *folderName;
for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) {
@ -230,6 +233,8 @@ nsMsgLocalMailFolder::CreateSubFolders(nsFileSpec &path)
}
AddSubfolder(&currentFolderNameStr, getter_AddRefs(child));
ConvertToUnicode(fileCharset, folderName, convertedFolderNameStr);
child->SetName(convertedFolderNameStr.GetUnicode());
PL_strfree(folderName);
}
return rv;

View File

@ -186,35 +186,16 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr,
// advance past hostname
while ((*curPos)=='/') curPos++;
while (*curPos && (*curPos)!='/') curPos++;
while ((*curPos)=='/') curPos++;
// get the seperator
nsAutoString sbdSep;
rv = nsGetMailFolderSeparator(sbdSep);
// for each token in between the /'s, put a .sbd on the end and
// append to the path
char *newStr=nsnull;
char *temp = PL_strdup(curPos);
char *token = nsCRT::strtok(temp, "/", &newStr);
while (token) {
nsCAutoString dir(token);
// look for next token
token = nsCRT::strtok(newStr, "/", &newStr);
// check if we're the last entry
if (token) {
NS_MsgHashIfNecessary(dir);
dir += sbdSep; // no, we're not, so append .sbd
pathResult += (const char *) dir;
}
else {
NS_MsgHashIfNecessary(dir);
pathResult += (const char *) dir;
}
}
PL_strfree(temp);
nsCAutoString newPath("");
NS_MsgCreatePathStringFromFolderURI(curPos, newPath);
pathResult+=newPath.GetBuffer();
}
return NS_OK;
}