зеркало из https://github.com/mozilla/pjs.git
Bug #5781 --> fix nsImapUri2Path where we were appending the host name twice if there wasn't a folder attached to the URI.part of mailnews audit --> conversion to NS_WITH_SERVICE
a=chofmann
This commit is contained in:
Родитель
7ad289c41b
Коммит
c7f58ac247
|
@ -62,69 +62,69 @@ nsGetImapRoot(const char* hostname, nsFileSpec &result)
|
||||||
nsresult
|
nsresult
|
||||||
nsImapURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)
|
nsImapURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsAutoString sep;
|
nsAutoString sep;
|
||||||
|
|
||||||
sep += PR_GetDirectorySeparator();
|
sep += PR_GetDirectorySeparator();
|
||||||
|
|
||||||
nsAutoString sbdSep;
|
nsAutoString sbdSep;
|
||||||
/* sspitzer: is this ok for mail and news? */
|
/* sspitzer: is this ok for mail and news? */
|
||||||
rv = nsGetMailFolderSeparator(sbdSep);
|
rv = nsGetMailFolderSeparator(sbdSep);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsAutoString uri = uriStr;
|
nsAutoString uri = uriStr;
|
||||||
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
|
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if ((strcmp(rootURI, kImapRootURI) != 0) &&
|
if ((PL_strcmp(rootURI, kImapRootURI) != 0) &&
|
||||||
(strcmp(rootURI, kImapMessageRootURI) != 0)) {
|
(PL_strcmp(rootURI, kImapMessageRootURI) != 0))
|
||||||
pathResult = nsnull;
|
{
|
||||||
rv = NS_ERROR_FAILURE;
|
pathResult = nsnull;
|
||||||
}
|
rv = NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// the server name is the first component of the path, so extract it out
|
// the server name is the first component of the path, so extract it out
|
||||||
PRInt32 hostStart;
|
PRInt32 hostStart;
|
||||||
|
|
||||||
hostStart = uri.Find('/');
|
hostStart = uri.Find('/');
|
||||||
if (hostStart <= 0) return NS_ERROR_FAILURE;
|
if (hostStart <= 0) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// skip past all //
|
// skip past all //
|
||||||
while (uri[hostStart]=='/') hostStart++;
|
while (uri[hostStart]=='/') hostStart++;
|
||||||
|
|
||||||
// cut mailbox://hostname/folder -> hostname/folder
|
// cut imap://hostname/folder -> hostname/folder
|
||||||
nsAutoString hostname;
|
nsAutoString hostname;
|
||||||
uri.Right(hostname, uri.Length() - hostStart);
|
uri.Right(hostname, uri.Length() - hostStart);
|
||||||
|
|
||||||
PRInt32 hostEnd = hostname.Find('/');
|
PRInt32 hostEnd = hostname.Find('/');
|
||||||
|
|
||||||
// folder comes after the hostname, after the '/'
|
nsAutoString folder;
|
||||||
nsAutoString folder;
|
// folder comes after the hostname, after the '/'
|
||||||
hostname.Right(folder, hostname.Length() - hostEnd - 1);
|
|
||||||
|
|
||||||
// cut off first '/' and everything following it
|
// cut off first '/' and everything following it
|
||||||
// hostname/folder -> hostname
|
// hostname/folder -> hostname
|
||||||
if (hostEnd >0) {
|
if (hostEnd > 0)
|
||||||
hostname.Truncate(hostEnd);
|
{
|
||||||
}
|
hostname.Right(folder, hostname.Length() - hostEnd - 1);
|
||||||
|
hostname.Truncate(hostEnd);
|
||||||
|
}
|
||||||
|
char *hostchar = hostname.ToNewCString();
|
||||||
|
|
||||||
// local mail case
|
rv = nsGetImapRoot(hostchar, pathResult);
|
||||||
// should return a list of all local mail folders? or maybe nothing
|
|
||||||
// at all?
|
|
||||||
char *hostchar = hostname.ToNewCString();
|
|
||||||
|
|
||||||
rv = nsGetImapRoot(hostchar, pathResult);
|
delete[] hostchar;
|
||||||
|
|
||||||
delete[] hostchar;
|
if (NS_FAILED(rv))
|
||||||
|
{
|
||||||
|
pathResult = nsnull;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (folder != "")
|
||||||
pathResult = nsnull;
|
pathResult += folder;
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folder != "")
|
return NS_OK;
|
||||||
pathResult += folder;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
Загрузка…
Ссылка в новой задаче