Bug 182933 - Updating more pref API users. r=timeless,sr=sspitzer

This commit is contained in:
caillon%returnzero.com 2003-01-21 06:55:31 +00:00
Родитель b5a2a88023
Коммит 261e5513ff
5 изменённых файлов: 55 добавлений и 60 удалений

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

@ -83,7 +83,6 @@
#include "nsMsgDBCID.h"
#include "nsIPref.h"
#include "nsINewsDownloadDialogArgs.h"
#include "nsXPCOM.h"
@ -300,9 +299,6 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow *aMsgWindow,
if (m_getOldMessages || !m_knownArts.set->IsMember(last_possible))
{
nsCOMPtr <nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
PRBool notifyMaxExceededOn = PR_TRUE;
rv = nntpServer->GetNotifyOn(&notifyMaxExceededOn);
if (NS_FAILED(rv)) notifyMaxExceededOn = PR_TRUE;

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

@ -105,7 +105,8 @@
#include "nsIStreamListener.h"
#include "nsNetCID.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIMsgWindow.h"
#include "nsIWindowWatcher.h"
@ -173,7 +174,6 @@ protected:
PRUint32 mLength;
};
static NS_DEFINE_CID(kPrefServiceCID,NS_PREF_CID);
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
typedef struct _cancelInfoEntry {
@ -4256,7 +4256,7 @@ PRInt32 nsNNTPProtocol::DoCancel()
cancelInfo.old_from = m_cancelFromHdr;
cancelInfo.from = nsnull;
nsCOMPtr <nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIPrompt> dialog;
@ -4328,18 +4328,17 @@ PRInt32 nsNNTPProtocol::DoCancel()
else {
NNTP_LOG_NOTE("CANCELCHK supported, don't do the us vs. them test");
}
// QA needs to be able to disable this confirm dialog, for the automated tests. see bug #31057
rv = prefs->GetBoolPref(PREF_NEWS_CANCEL_CONFIRM, &requireConfirmationForCancel);
if (NS_FAILED(rv) || requireConfirmationForCancel)
{
/* Last chance to cancel the cancel.*/
GetNewsStringByName("cancelConfirm", getter_Copies(confirmText));
rv = dialog->Confirm(nsnull, confirmText, &confirmCancelResult);
// XXX: todo, check rv?
}
rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_CONFIRM, &requireConfirmationForCancel);
if (NS_FAILED(rv) || requireConfirmationForCancel) {
/* Last chance to cancel the cancel.*/
GetNewsStringByName("cancelConfirm", getter_Copies(confirmText));
rv = dialog->Confirm(nsnull, confirmText, &confirmCancelResult);
// XXX: todo, check rv?
}
else {
confirmCancelResult = 1;
confirmCancelResult = 1;
}
if (confirmCancelResult != 1) {
@ -4393,29 +4392,29 @@ PRInt32 nsNNTPProtocol::DoCancel()
cancelInfo.from, newsgroups, subject, id,
other_random_headers, body);
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl)
status = SendData(mailnewsurl, data);
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl)
status = SendData(mailnewsurl, data);
PR_Free (data);
if (status < 0) {
nsCAutoString errorText;
errorText.AppendInt(status);
AlertError(MK_TCP_WRITE_ERROR, errorText.get());
failure = PR_TRUE;
goto FAIL;
}
nsCAutoString errorText;
errorText.AppendInt(status);
AlertError(MK_TCP_WRITE_ERROR, errorText.get());
failure = PR_TRUE;
goto FAIL;
}
SetFlag(NNTP_PAUSE_FOR_READ);
m_nextState = NNTP_RESPONSE;
m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
m_nextState = NNTP_RESPONSE;
m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
// QA needs to be able to turn this alert off, for the automate tests. see bug #31057
rv = prefs->GetBoolPref(PREF_NEWS_CANCEL_ALERT_ON_SUCCESS, &showAlertAfterCancel);
if (NS_FAILED(rv) || showAlertAfterCancel) {
GetNewsStringByName("messageCancelled", getter_Copies(alertText));
rv = dialog->Alert(nsnull, alertText);
// XXX: todo, check rv?
}
rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_ALERT_ON_SUCCESS, &showAlertAfterCancel);
if (NS_FAILED(rv) || showAlertAfterCancel) {
GetNewsStringByName("messageCancelled", getter_Copies(alertText));
rv = dialog->Alert(nsnull, alertText);
// XXX: todo, check rv?
}
if (!m_runningURL) return -1;

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

@ -38,7 +38,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "prlog.h"
#include "msgCore.h" // precompiled header...
@ -100,7 +101,6 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
// ###tw This really ought to be the most
// efficient file reading size for the current
@ -1826,10 +1826,10 @@ NS_IMETHODIMP nsMsgNewsFolder::GetPersistElided(PRBool *aPersistElided)
return NS_OK;
}
nsCOMPtr <nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = prefs->GetBoolPref("news.persist_server_open_state_in_folderpane", aPersistElided);
rv = prefBranch->GetBoolPref("news.persist_server_open_state_in_folderpane", aPersistElided);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}

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

@ -41,7 +41,8 @@
#include "nsNntpIncomingServer.h"
#include "nsXPIDLString.h"
#include "nsEscape.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIMsgNewsFolder.h"
#include "nsIFolder.h"
#include "nsIFileSpec.h"
@ -82,7 +83,6 @@
// operating system.
#define HOSTINFO_FILE_BUFFER_SIZE 1024
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kSubscribableServerCID, NS_SUBSCRIBABLESERVER_CID);
NS_IMPL_ADDREF_INHERITED(nsNntpIncomingServer, nsMsgIncomingServer)
@ -232,14 +232,13 @@ nsNntpIncomingServer::SetNewsrcRootPath(nsIFileSpec *aNewsrcRootPath)
{
nsresult rv;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &rv));
if (NS_SUCCEEDED(rv) && prefs) {
rv = prefs->SetFilePref(PREF_MAIL_NEWSRC_ROOT,aNewsrcRootPath, PR_FALSE /* set default */);
return rv;
}
else {
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && prefBranch) {
return prefBranch->SetComplexValue(PREF_MAIL_NEWSRC_ROOT, NS_GET_IID(nsIFileSpec),
aNewsrcRootPath);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -249,13 +248,14 @@ nsNntpIncomingServer::GetNewsrcRootPath(nsIFileSpec **aNewsrcRootPath)
*aNewsrcRootPath = nsnull;
nsresult rv;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &rv));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
PRBool havePref = PR_FALSE;
nsCOMPtr<nsIFile> localFile;
nsCOMPtr<nsILocalFile> prefLocal;
rv = prefs->GetFileXPref(PREF_MAIL_NEWSRC_ROOT, getter_AddRefs(prefLocal));
rv = prefBranch->GetComplexValue(PREF_MAIL_NEWSRC_ROOT, NS_GET_IID(nsILocalFile),
getter_AddRefs(prefLocal));
if (NS_SUCCEEDED(rv)) {
localFile = prefLocal;
havePref = PR_TRUE;
@ -265,7 +265,7 @@ nsNntpIncomingServer::GetNewsrcRootPath(nsIFileSpec **aNewsrcRootPath)
if (NS_FAILED(rv)) return rv;
havePref = PR_FALSE;
}
PRBool exists;
rv = localFile->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)

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

@ -54,7 +54,8 @@
#include "nsNewsDatabase.h"
#include "nsMsgDBCID.h"
#include "nsMsgBaseCID.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsCRT.h" // for nsCRT::strtok
#include "nsNntpService.h"
#include "nsIChannel.h"
@ -91,7 +92,6 @@
#define PREF_MAIL_ROOT_NNTP "mail.root.nntp"
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
static NS_DEFINE_CID(kCPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kMessengerMigratorCID, NS_MESSENGERMIGRATOR_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
@ -1433,11 +1433,10 @@ NS_IMETHODIMP
nsNntpService::SetDefaultLocalPath(nsIFileSpec *aPath)
{
nsresult rv;
nsCOMPtr<nsIPref> prefs(do_GetService(kCPrefServiceCID, &rv));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = prefs->SetFilePref(PREF_MAIL_ROOT_NNTP, aPath, PR_FALSE /* set default */);
return rv;
return prefBranch->SetComplexValue(PREF_MAIL_ROOT_NNTP, NS_GET_IID(nsIFileSpec), aPath);
}
NS_IMETHODIMP
@ -1447,13 +1446,14 @@ nsNntpService::GetDefaultLocalPath(nsIFileSpec ** aResult)
*aResult = nsnull;
nsresult rv;
nsCOMPtr<nsIPref> prefs(do_GetService(kCPrefServiceCID, &rv));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
PRBool havePref = PR_FALSE;
nsCOMPtr<nsIFile> localFile;
nsCOMPtr<nsILocalFile> prefLocal;
rv = prefs->GetFileXPref(PREF_MAIL_ROOT_NNTP, getter_AddRefs(prefLocal));
rv = prefBranch->GetComplexValue(PREF_MAIL_ROOT_NNTP, NS_GET_IID(nsILocalFile),
getter_AddRefs(prefLocal));
if (NS_SUCCEEDED(rv)) {
localFile = prefLocal;
havePref = PR_TRUE;
@ -1463,7 +1463,7 @@ nsNntpService::GetDefaultLocalPath(nsIFileSpec ** aResult)
if (NS_FAILED(rv)) return rv;
havePref = PR_FALSE;
}
PRBool exists;
rv = localFile->Exists(&exists);
if (NS_FAILED(rv)) return rv;
@ -1710,11 +1710,11 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask)
{
if (!aChromeUrlForTask) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIPref> prefService(do_GetService(kCPrefServiceCID, &rv));
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
PRInt32 layout;
rv = prefService->GetIntPref("mail.pane_config", &layout);
rv = prefBranch->GetIntPref("mail.pane_config", &layout);
if(NS_SUCCEEDED(rv))
{
if(layout == 0)