fix for #108264, problems with autosubscribe dialog on linux.

fix for #68303 and #109537. problems with auto-subscribe / auto-unsubscribe when newsgroup has non-ASCII chars in the name.

patches by hwaara.  r/sr=sspitzer,alecf
This commit is contained in:
sspitzer%netscape.com 2001-11-14 01:37:28 +00:00
Родитель 0dce65ed23
Коммит 8b50437f89
2 изменённых файлов: 49 добавлений и 25 удалений

Просмотреть файл

@ -1093,12 +1093,19 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsCOMPtr<nsIStringBundle> bundle;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
// to handle non-ASCII newsgroup names, we store them internally as escaped.
// decode and unescape the newsgroup name so we'll display a proper name.
nsXPIDLString unescapedName;
rv = NS_MsgDecodeUnescapeURLPath(group.get(), getter_Copies(unescapedName));
NS_ENSURE_SUCCESS(rv,rv);
bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
const PRUnichar *formatStrings[1] = { NS_ConvertUTF8toUCS2(group).get() };
const PRUnichar *formatStrings[1] = { unescapedName.get() };
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("autoSubscribeText").get(),
formatStrings, 1,
getter_Copies(confirmText));
NS_ENSURE_SUCCESS(rv,rv);
PRBool confirmResult = PR_FALSE;
rv = dialog->Confirm(nsnull, confirmText, &confirmResult);

Просмотреть файл

@ -1185,46 +1185,63 @@ nsNntpIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
{
nsresult rv = EnsureInner();
NS_ENSURE_SUCCESS(rv,rv);
return mInner->GetSubscribeListener(aListener);
return mInner->GetSubscribeListener(aListener);
}
NS_IMETHODIMP
nsNntpIncomingServer::Subscribe(const PRUnichar *aUnicharName)
{
return SubscribeToNewsgroup(NS_LossyConvertUCS2toASCII(aUnicharName).get());
return SubscribeToNewsgroup(NS_LossyConvertUCS2toASCII(aUnicharName).get());
}
NS_IMETHODIMP
nsNntpIncomingServer::Unsubscribe(const PRUnichar *aUnicharName)
{
nsresult rv;
nsCAutoString name;
name.AssignWithConversion(aUnicharName);
nsresult rv;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv)) return rv;
if (!rootFolder) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv))
return rv;
nsCOMPtr <nsIMsgFolder> serverFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!serverFolder) return NS_ERROR_FAILURE;
if (!rootFolder)
return NS_ERROR_FAILURE;
nsCOMPtr <nsIMsgFolder> serverFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr <nsIFolder> subFolder;
rv = serverFolder->FindSubFolder(name.get(), getter_AddRefs(subFolder));
if (NS_FAILED(rv)) return rv;
if (!serverFolder)
return NS_ERROR_FAILURE;
// to handle non-ASCII newsgroup names, we store them internally as escaped.
// so we need to escape and encode the name, in order to find it.
nsXPIDLCString escapedName;
rv = NS_MsgEscapeEncodeURLPath(aUnicharName, getter_Copies(escapedName));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgFolder> newsgroupFolder = do_QueryInterface(subFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!newsgroupFolder) return NS_ERROR_FAILURE;
nsCOMPtr <nsIFolder> subFolder;
rv = serverFolder->FindSubFolder(escapedName.get(), getter_AddRefs(subFolder));
if (NS_FAILED(rv))
return rv;
rv = serverFolder->PropagateDelete(newsgroupFolder, PR_TRUE /* delete storage */, nsnull);
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsIMsgFolder> newsgroupFolder = do_QueryInterface(subFolder, &rv);
if (NS_FAILED(rv))
return rv;
/* since we've unsubscribed to a newsgroup, the newsrc needs to be written out */
rv = SetNewsrcHasChanged(PR_TRUE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
if (!newsgroupFolder)
return NS_ERROR_FAILURE;
rv = serverFolder->PropagateDelete(newsgroupFolder, PR_TRUE /* delete storage */, nsnull);
if (NS_FAILED(rv))
return rv;
// since we've unsubscribed to a newsgroup, the newsrc needs to be written out
rv = SetNewsrcHasChanged(PR_TRUE);
if (NS_FAILED(rv))
return rv;
return NS_OK;
}
PRInt32