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
Родитель a685d8fad3
Коммит 7906d6d342
5 изменённых файлов: 55 добавлений и 60 удалений

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

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

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

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

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

@ -38,7 +38,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsIPref.h" #include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "prlog.h" #include "prlog.h"
#include "msgCore.h" // precompiled header... #include "msgCore.h" // precompiled header...
@ -100,7 +101,6 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_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 // ###tw This really ought to be the most
// efficient file reading size for the current // efficient file reading size for the current
@ -1826,10 +1826,10 @@ NS_IMETHODIMP nsMsgNewsFolder::GetPersistElided(PRBool *aPersistElided)
return NS_OK; 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); 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); NS_ENSURE_SUCCESS(rv,rv);
return rv; return rv;
} }

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

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

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

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