mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
fix #23372, remove hard coded string from account manager and account wizard
js. fix #23313, don't allow user to delete "local folders" account. fix #23413, implement delete account. further divorce "none" from "pop3" (which will be useful once we get to movemail and other incoming mail server types) r=alecf
This commit is contained in:
parent
f08e81815b
commit
da6aaee871
@ -42,9 +42,10 @@
|
||||
|
||||
|
||||
var accountArray;
|
||||
|
||||
var accounttree;
|
||||
var lastServerId;
|
||||
var lastPageId;
|
||||
var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
|
||||
|
||||
// services used
|
||||
var RDF;
|
||||
@ -67,13 +68,7 @@ function onLoad() {
|
||||
|
||||
smtpService =
|
||||
Components.classes["component://netscape/messengercompose/smtp"].getService(Components.interfaces.nsISmtpService);
|
||||
var tree = document.getElementById("accounttree");
|
||||
var items = tree.getElementsByTagName("treeitem");
|
||||
|
||||
if (items && items.length>0) {
|
||||
// skip the template?
|
||||
tree.selectItem(items[1]);
|
||||
}
|
||||
accounttree = document.getElementById("accounttree");
|
||||
|
||||
doSetOKCancel(onOk, 0);
|
||||
|
||||
@ -82,6 +77,21 @@ function onLoad() {
|
||||
deleteButton = document.getElementById("deleteButton");
|
||||
setDefaultButton = document.getElementById("setDefaultButton");
|
||||
|
||||
selectFirstAccount()
|
||||
}
|
||||
|
||||
function selectFirstAccount()
|
||||
{
|
||||
//dump("selectFirstAccount\n");
|
||||
var items = accounttree.getElementsByTagName("treeitem");
|
||||
if (items && items.length>0) {
|
||||
// skip the template?
|
||||
accounttree.selectItem(items[1]);
|
||||
var result = getServerIdAndPageIdFromTree(accounttree);
|
||||
if (result) {
|
||||
updateButtons(accounttree,result.serverId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onOk() {
|
||||
@ -114,21 +124,88 @@ function onNewAccount() {
|
||||
window.openDialog("chrome://messenger/content/AccountWizard.xul", "wizard", "chrome,modal", result);
|
||||
if (result.refresh) {
|
||||
refreshAccounts();
|
||||
|
||||
// propagate refresh if it's not already on
|
||||
// i.e. we'll never turn off refresh once it's on.
|
||||
window.arguments[0].refresh = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onDuplicateAccount() {
|
||||
//dump("onDuplicateAccount\n");
|
||||
|
||||
if (duplicateButton.getAttribute("disabled") == "true") return;
|
||||
|
||||
var result = getServerIdAndPageIdFromTree(accounttree);
|
||||
if (result) {
|
||||
var canDuplicate = true;
|
||||
var account = getAccountFromServerId(result.serverId);
|
||||
if (account) {
|
||||
var server = account.incomingServer;
|
||||
var type = server.type;
|
||||
|
||||
var protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
|
||||
canDuplicate = protocolinfo.canDuplicate;
|
||||
}
|
||||
else {
|
||||
canDuplicate = false;
|
||||
}
|
||||
|
||||
if (canDuplicate) {
|
||||
try {
|
||||
accountManager.duplicateAccount(account);
|
||||
refreshAccounts();
|
||||
}
|
||||
catch (ex) {
|
||||
var alertText = Bundle.GetStringFromName("failedDuplicateAccount");
|
||||
window.alert(alertText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onDeleteAccount() {
|
||||
//dump("onDeleteAccount\n");
|
||||
|
||||
if (deleteButton.getAttribute("disabled") == "true") return;
|
||||
|
||||
var result = getServerIdAndPageIdFromTree(accounttree);
|
||||
if (result) {
|
||||
var canDelete = true;
|
||||
var account = getAccountFromServerId(result.serverId);
|
||||
if (account) {
|
||||
var server = account.incomingServer;
|
||||
var type = server.type;
|
||||
|
||||
var protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
|
||||
canDelete = protocolinfo.canDelete;
|
||||
}
|
||||
else {
|
||||
canDelete = false;
|
||||
}
|
||||
|
||||
if (canDelete) {
|
||||
try {
|
||||
accountManager.removeAccount(account);
|
||||
refreshAccounts();
|
||||
selectFirstAccount();
|
||||
}
|
||||
catch (ex) {
|
||||
var alertText = Bundle.GetStringFromName("failedDeleteAccount");
|
||||
window.alert(alertText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// another temporary hack until the account manager
|
||||
// can refresh the account list itself.
|
||||
function refreshAccounts()
|
||||
{
|
||||
var tree = document.getElementById("accounttree");
|
||||
tree.clearItemSelection();
|
||||
tree.setAttribute('ref', tree.getAttribute('ref'));
|
||||
//dump("refreshAccounts\n");
|
||||
accounttree.clearItemSelection();
|
||||
accounttree.setAttribute('ref', accounttree.getAttribute('ref'));
|
||||
|
||||
// propagate refresh if it's not already on
|
||||
// i.e. we'll never turn off refresh once it's on.
|
||||
window.arguments[0].refresh = true;
|
||||
}
|
||||
|
||||
function saveAccount(accountValues, account)
|
||||
@ -190,12 +267,49 @@ function onPageLoad(event, name) {
|
||||
}
|
||||
|
||||
|
||||
function updateButtons(tree) {
|
||||
if (tree.selectedItems.length > 0) {
|
||||
if (duplicateButton) duplicateButton.removeAttribute("disabled");
|
||||
if (setDefaultButton) setDefaultButton.removeAttribute("disabled");
|
||||
if (deleteButton) deleteButton.removeAttribute("disabled");
|
||||
function updateButtons(tree,serverId) {
|
||||
var canDuplicate = true;
|
||||
var canDelete = true;
|
||||
|
||||
//dump("updateButtons\n");
|
||||
//dump("serverId = " + serverId + "\n");
|
||||
var account = getAccountFromServerId(serverId);
|
||||
//dump("account = " + account + "\n");
|
||||
|
||||
if (account) {
|
||||
var server = account.incomingServer;
|
||||
var type = server.type;
|
||||
|
||||
//dump("servertype = " + type + "\n");
|
||||
|
||||
var protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
|
||||
canDuplicate = protocolinfo.canDuplicate;
|
||||
canDelete = protocolinfo.canDelete;
|
||||
}
|
||||
else {
|
||||
// HACK
|
||||
// if account is null, we have either selected a SMTP server, or there is a problem
|
||||
// either way, we don't want the user to be able to delete it or duplicate it
|
||||
canDelete = false;
|
||||
canDuplicate = false;
|
||||
}
|
||||
|
||||
if (tree.selectedItems.length > 0) {
|
||||
if (canDuplicate) {
|
||||
if (duplicateButton) duplicateButton.removeAttribute("disabled");
|
||||
}
|
||||
else {
|
||||
if (duplicateButton) duplicateButton.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
if (setDefaultButton) setDefaultButton.removeAttribute("disabled");
|
||||
|
||||
if (canDelete) {
|
||||
if (deleteButton) deleteButton.removeAttribute("disabled");
|
||||
}
|
||||
else {
|
||||
if (deleteButton) deleteButton.setAttribute("disabled", "true");
|
||||
}
|
||||
} else {
|
||||
if (duplicateButton) duplicateButton.setAttribute("disabled", "true");
|
||||
if (setDefaultButton) setDefaultButton.setAttribute("disabled", "true");
|
||||
@ -208,31 +322,14 @@ function updateButtons(tree) {
|
||||
// figure out context by what they clicked on
|
||||
//
|
||||
function onAccountClick(tree) {
|
||||
|
||||
if (tree.selectedItems.length < 1) return;
|
||||
var node = tree.selectedItems[0];
|
||||
//dump("onAccountClick\n");
|
||||
var result = getServerIdAndPageIdFromTree(tree);
|
||||
|
||||
updateButtons(tree);
|
||||
|
||||
// get the page to load
|
||||
// (stored in the PageTag attribute of this node)
|
||||
var pageId = node.getAttribute('PageTag');
|
||||
|
||||
|
||||
// get the server's ID
|
||||
// (stored in the ID attribute of the server node)
|
||||
var servernode = node.parentNode.parentNode;
|
||||
|
||||
// for toplevel treeitems, we just use the current treeitem
|
||||
// dump("servernode is " + servernode + "\n");
|
||||
if (servernode.tagName != "treeitem") {
|
||||
servernode = node;
|
||||
if (result) {
|
||||
// dump("before showPage(" + result.serverId + "," + result.pageId + ");\n");
|
||||
showPage(result.serverId, result.pageId);
|
||||
updateButtons(tree,result.serverId);
|
||||
}
|
||||
var serverid = servernode.getAttribute('id');
|
||||
|
||||
//dump("before showPage(" + serverid + "," + pageId + ");\n");
|
||||
showPage(serverid, pageId);
|
||||
|
||||
}
|
||||
|
||||
// show the page for the given server:
|
||||
@ -469,7 +566,7 @@ function getAccountFromServerId(serverId) {
|
||||
var serverFolder =
|
||||
serverResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
} catch (ex) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
var incomingServer = serverFolder.server;
|
||||
|
||||
@ -506,3 +603,27 @@ function getValueArrayFor(serverId) {
|
||||
return accountArray[serverId];
|
||||
}
|
||||
|
||||
function getServerIdAndPageIdFromTree(tree)
|
||||
{
|
||||
var serverId = null;
|
||||
|
||||
if (tree.selectedItems.length < 1) return null;
|
||||
var node = tree.selectedItems[0];
|
||||
|
||||
// get the page to load
|
||||
// (stored in the PageTag attribute of this node)
|
||||
var pageId = node.getAttribute('PageTag');
|
||||
|
||||
// get the server's Id
|
||||
// (stored in the Id attribute of the server node)
|
||||
var servernode = node.parentNode.parentNode;
|
||||
|
||||
// for toplevel treeitems, we just use the current treeitem
|
||||
// dump("servernode is " + servernode + "\n");
|
||||
if (servernode.tagName != "treeitem") {
|
||||
servernode = node;
|
||||
}
|
||||
serverId = servernode.getAttribute('id');
|
||||
|
||||
return {"serverId": serverId, "pageId": pageId }
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
class="dialog"
|
||||
onload="onLoad(event);">
|
||||
|
||||
<html:script src="chrome://messenger/content/AccountManager.js"/>
|
||||
<html:script language="JavaScript" src="chrome://global/content/strres.js"/>
|
||||
<html:script src="chrome://messenger/content/AccountManager.js"/>
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
||||
@ -65,8 +66,8 @@
|
||||
<titledbutton class="dialog push" value="&newAccountButton.label;" onclick="onNewAccount();" id="newAccountButton"/>
|
||||
<titledbutton class="dialog push" value="&setDefaultButton.label;" disabled="true" id="setDefaultButton"/>
|
||||
<box align="horizontal">
|
||||
<titledbutton class="dialog push" disabled="true" value="&duplicateButton.label;" id="duplicateButton" flex="50%"/>
|
||||
<titledbutton class="dialog push" disabled="true" value="&deleteButton.label;" id="deleteButton" flex="50%"/>
|
||||
<titledbutton class="dialog push" disabled="true" value="&duplicateButton.label;" id="duplicateButton" onclick="onDuplicateAccount();" flex="50%"/>
|
||||
<titledbutton class="dialog push" disabled="true" value="&deleteButton.label;" onclick="onDeleteAccount();" id="deleteButton" flex="50%"/>
|
||||
</box>
|
||||
</box>
|
||||
<box flex="75%">
|
||||
|
@ -19,15 +19,19 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
|
||||
|
||||
function validate(data)
|
||||
{
|
||||
var email = document.getElementById("identity.email").value;
|
||||
var name = document.getElementById("identity.fullName").value;
|
||||
|
||||
if (! name || name=="") {
|
||||
window.alert("Please enter your name.");
|
||||
var alertText = Bundle.GetStringFromName("enterName");
|
||||
window.alert(alertText);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -35,7 +39,8 @@ function validate(data)
|
||||
if (emailArray.length != 2 ||
|
||||
emailArray[0] == "" ||
|
||||
emailArray[1] == "") {
|
||||
window.alert("Please enter a valid email address.");
|
||||
var alertText = Bundle.GetStringFromName("enterValidEmail");
|
||||
window.alert(alertText);
|
||||
return false;
|
||||
}
|
||||
dump("emailArray[0] = '" + emailArray[0] + "'\n");
|
||||
|
@ -28,7 +28,9 @@ Rights Reserved.
|
||||
align="vertical"
|
||||
class="dialog"
|
||||
onload="parent.wizardPageLoaded('identity');">
|
||||
<html:script src="aw-identity.js"/>
|
||||
|
||||
<html:script language="JavaScript" src="chrome://global/content/strres.js"/>
|
||||
<html:script language="JavaScript" src="chrome://messenger/content/aw-identity.js"/>
|
||||
|
||||
<box class="title" align="horizontal">
|
||||
<html:div class="title">&identityTitle.label;</html:div>
|
||||
|
@ -19,14 +19,18 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
|
||||
|
||||
function validate() {
|
||||
var servername = document.getElementById("server.hostName").value;
|
||||
var smtpserver = document.getElementById("smtp.hostname").value;
|
||||
|
||||
if (!servername || !smtpserver || servername == "" || smtpserver=="") {
|
||||
window.alert("Please enter a valid hostname");
|
||||
var alertText = Bundle.GetStringFromName("enterValidHostname");
|
||||
window.alert(alertText);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -28,7 +28,9 @@ Rights Reserved.
|
||||
align="vertical"
|
||||
class="dialog"
|
||||
onload="parent.wizardPageLoaded('server');">
|
||||
<html:script src="aw-server.js"/>
|
||||
|
||||
<html:script language="JavaScript" src="chrome://global/content/strres.js"/>
|
||||
<html:script language="JavaScript" src="chrome://messenger/content/aw-server.js"/>
|
||||
|
||||
<box class="title" align="horizontal">
|
||||
<html:div class="title">&serverTitle.label;</html:div>
|
||||
|
@ -24,3 +24,8 @@
|
||||
#
|
||||
enterAccountName=Please enter a name for this account.
|
||||
enterUserName=Please enter a username.
|
||||
enterName=Please enter your name.
|
||||
enterValidEmail=Please enter a valid email address.
|
||||
enterValidHostname=Please enter a valid hostname.
|
||||
failedDeleteAccount=Failed to delete this account.
|
||||
failedDuplicateAccount=Failed to duplicate this account.
|
||||
|
@ -35,7 +35,8 @@ interface nsIMsgAccountManager : nsISupports {
|
||||
nsIMsgAccount createAccount();
|
||||
nsIMsgAccount getAccount(in string key);
|
||||
|
||||
void RemoveAccount(in nsIMsgAccount account);
|
||||
void removeAccount(in nsIMsgAccount account);
|
||||
void duplicateAccount(in nsIMsgAccount account);
|
||||
|
||||
/*
|
||||
* creates a new identity and assigns it a new, unique "key"
|
||||
|
@ -36,5 +36,7 @@ interface nsIMsgProtocolInfo : nsISupports
|
||||
readonly attribute nsIIDPtr serverIID;
|
||||
readonly attribute boolean requiresUsername;
|
||||
readonly attribute boolean preflightPrettyNameWithEmailAddress;
|
||||
readonly attribute boolean canDelete;
|
||||
readonly attribute boolean canDuplicate;
|
||||
};
|
||||
|
||||
|
@ -694,10 +694,17 @@ nsMsgAccountManager::createKeyedServer(const char* key,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManager::DuplicateAccount(nsIMsgAccount *aAccount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccount);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManager::RemoveAccount(nsIMsgAccount *aAccount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccount);
|
||||
nsresult rv;
|
||||
rv = LoadAccounts();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2387,3 +2387,19 @@ nsImapService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNa
|
||||
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapService::GetCanDelete(PRBool *aCanDelete)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDelete);
|
||||
*aCanDelete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapService::GetCanDuplicate(PRBool *aCanDuplicate)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDuplicate);
|
||||
*aCanDuplicate = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -122,6 +122,7 @@
|
||||
//
|
||||
// nsPop3Service
|
||||
//
|
||||
|
||||
#define NS_POP3SERVICE_PROGID1 \
|
||||
"component://netscape/messenger/popservice"
|
||||
|
||||
@ -131,13 +132,25 @@
|
||||
#define NS_POP3PROTOCOLINFO_PROGID \
|
||||
NS_MSGPROTOCOLINFO_PROGID_PREFIX "pop3"
|
||||
|
||||
#define NS_POP3SERVICE_CID \
|
||||
{ /* 3BB459E3-D746-11d2-806A-006008128C4E */ \
|
||||
0x3bb459e3, 0xd746, 0x11d2, \
|
||||
{ 0x80, 0x6a, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e }}
|
||||
|
||||
//
|
||||
// nsNoneService
|
||||
//
|
||||
|
||||
#define NS_NONESERVICE_PROGID \
|
||||
"component://netscape/messenger/noneservice"
|
||||
|
||||
#define NS_NONEPROTOCOLINFO_PROGID \
|
||||
NS_MSGPROTOCOLINFO_PROGID_PREFIX "none"
|
||||
|
||||
#define NS_POP3SERVICE_CID \
|
||||
{ /* 3BB459E3-D746-11d2-806A-006008128C4E} */ \
|
||||
0x3bb459e3, 0xd746, 0x11d2, \
|
||||
{ 0x80, 0x6a, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e }}
|
||||
#define NS_NONESERVICE_CID \
|
||||
{ /* 75b63b46-1dd2-11b2-9873-bb375e1550fa */ \
|
||||
0x75b63b46, 0x1dd2, 0x11b2, \
|
||||
{ 0x98, 0x73, 0xbb, 0x37, 0x5e, 0x15, 0x50, 0xfa }}
|
||||
|
||||
//
|
||||
// nsParseMailMsgState
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "nsLocalMailFolder.h"
|
||||
#include "nsParseMailbox.h"
|
||||
#include "nsPop3Service.h"
|
||||
#include "nsNoneService.h"
|
||||
#include "nsPop3IncomingServer.h"
|
||||
#include "nsNoIncomingServer.h"
|
||||
#include "nsLocalMessage.h"
|
||||
@ -43,6 +44,7 @@ static NS_DEFINE_CID(kMailboxServiceCID, NS_MAILBOXSERVICE_CID);
|
||||
static NS_DEFINE_CID(kLocalMailFolderResourceCID, NS_LOCALMAILFOLDERRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kMailboxMessageResourceCID, NS_MAILBOXMESSAGERESOURCE_CID);
|
||||
static NS_DEFINE_CID(kPop3ServiceCID, NS_POP3SERVICE_CID);
|
||||
static NS_DEFINE_CID(kNoneServiceCID, NS_NONESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
|
||||
static NS_DEFINE_CID(kPop3IncomingServerCID, NS_POP3INCOMINGSERVER_CID);
|
||||
static NS_DEFINE_CID(kNoIncomingServerCID, NS_NOINCOMINGSERVER_CID);
|
||||
@ -55,6 +57,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPop3URL)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgMailboxParser)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailboxService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPop3Service)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoneService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgLocalMailFolder)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLocalMessage)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParseMailMessageState)
|
||||
@ -83,6 +86,7 @@ protected:
|
||||
nsCOMPtr<nsIGenericFactory> mMailboxParserFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mMailboxServiceFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mPop3ServiceFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mNoneServiceFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mLocalMailFolderFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mLocalMessageFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mParseMailMsgStateFactory;
|
||||
@ -123,6 +127,7 @@ void nsMsgLocalModule::Shutdown()
|
||||
mMailboxParserFactory = null_nsCOMPtr();
|
||||
mMailboxServiceFactory = null_nsCOMPtr();
|
||||
mPop3ServiceFactory = null_nsCOMPtr();
|
||||
mNoneServiceFactory = null_nsCOMPtr();
|
||||
mLocalMailFolderFactory = null_nsCOMPtr();
|
||||
mLocalMessageFactory = null_nsCOMPtr();
|
||||
mParseMailMsgStateFactory = null_nsCOMPtr();
|
||||
@ -186,6 +191,12 @@ NS_IMETHODIMP nsMsgLocalModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mPop3ServiceFactory), &nsPop3ServiceConstructor);
|
||||
fact = mPop3ServiceFactory;
|
||||
}
|
||||
else if (aClass.Equals(kNoneServiceCID))
|
||||
{
|
||||
if (!mNoneServiceFactory)
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mNoneServiceFactory), &nsNoneServiceConstructor);
|
||||
fact = mNoneServiceFactory;
|
||||
}
|
||||
else if (aClass.Equals(kLocalMailFolderResourceCID))
|
||||
{
|
||||
if (!mLocalMailFolderFactory)
|
||||
@ -251,9 +262,11 @@ static Components gComponents[] = {
|
||||
NS_POP3SERVICE_PROGID1 },
|
||||
{ "POP Protocol Handler", &kPop3ServiceCID,
|
||||
NS_POP3SERVICE_PROGID2 },
|
||||
{ "None Service", &kNoneServiceCID,
|
||||
NS_NONESERVICE_PROGID },
|
||||
{ "pop3 Protocol Information", &kPop3ServiceCID,
|
||||
NS_POP3PROTOCOLINFO_PROGID },
|
||||
{ "none Protocol Information", &kPop3ServiceCID,
|
||||
{ "none Protocol Information", &kNoneServiceCID,
|
||||
NS_NONEPROTOCOLINFO_PROGID },
|
||||
{ "Local Mail Folder Resource Factory", &kLocalMailFolderResourceCID,
|
||||
NS_LOCALMAILFOLDERRESOURCE_PROGID },
|
||||
|
@ -24,6 +24,5 @@
|
||||
#[installed by xpidl] nsIMailboxService.h
|
||||
#[installed by xpidl] nsIPop3Service.h
|
||||
#[installed by xpidl] nsIPop3IncomingServer.h
|
||||
|
||||
#[installed by xpidl] nsIMailboxUrl.h
|
||||
#[installed by xpidl] nsIMsgParseMailMsgState.h
|
||||
|
@ -37,6 +37,7 @@ XPIDLSRCS = \
|
||||
nsIMailboxUrl.idl \
|
||||
nsIMsgParseMailMsgState.idl \
|
||||
nsINoIncomingServer.idl \
|
||||
nsINoneService.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -34,6 +34,7 @@ XPIDLSRCS = \
|
||||
.\nsIMailboxUrl.idl \
|
||||
.\nsIMsgParseMailMsgState.idl \
|
||||
.\nsINoIncomingServer.idl \
|
||||
.\nsINoneService.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
29
mailnews/local/public/nsINoneService.idl
Normal file
29
mailnews/local/public/nsINoneService.idl
Normal file
@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(14714890-1dd2-11b2-87de-d265839520d6)]
|
||||
interface nsINoneService : nsISupports {
|
||||
/* nothing yet, but soon. */
|
||||
};
|
@ -31,5 +31,5 @@ nsPop3Service.h
|
||||
nsPop3IncomingServer.h
|
||||
nsLocalMessage.h
|
||||
nsLocalStringBundle.h
|
||||
nsNoneService.h
|
||||
nsNoIncomingServer.h
|
||||
|
||||
|
@ -45,6 +45,7 @@ CPPSRCS = \
|
||||
nsLocalUndoTxn.cpp \
|
||||
nsLocalStringBundle.cpp \
|
||||
nsNoIncomingServer.cpp \
|
||||
nsNoneService.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
@ -60,6 +61,7 @@ EXPORTS = \
|
||||
nsPop3IncomingServer.h \
|
||||
nsLocalMessage.h \
|
||||
nsLocalStringBundle.h \
|
||||
nsNoneService.h \
|
||||
nsNoIncomingServer.h \
|
||||
$(NULL)
|
||||
|
||||
|
@ -41,6 +41,7 @@ EXPORTS= \
|
||||
nsLocalMailFolder.h \
|
||||
nsLocalUtils.h \
|
||||
nsLocalStringBundle.h \
|
||||
nsNoneService.h \
|
||||
nsNoIncomingServer.h \
|
||||
$(NULL)
|
||||
|
||||
@ -58,6 +59,7 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsMailboxProtocol.obj \
|
||||
.\$(OBJDIR)\nsMailboxService.obj \
|
||||
.\$(OBJDIR)\nsPop3Service.obj \
|
||||
.\$(OBJDIR)\nsNoneService.obj \
|
||||
.\$(OBJDIR)\nsLocalMailFolder.obj \
|
||||
.\$(OBJDIR)\nsPop3IncomingServer.obj \
|
||||
.\$(OBJDIR)\nsLocalMessage.obj \
|
||||
|
128
mailnews/local/src/nsNoneService.cpp
Normal file
128
mailnews/local/src/nsNoneService.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
#include "msgCore.h" // precompiled header...
|
||||
|
||||
#include "nsNoneService.h"
|
||||
#include "nsINoIncomingServer.h"
|
||||
#include "nsINoneService.h"
|
||||
#include "nsIMsgProtocolInfo.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsFileLocations.h"
|
||||
|
||||
#define PREF_MAIL_ROOT_NONE "mail.root.none"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
|
||||
nsNoneService::nsNoneService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsNoneService::~nsNoneService()
|
||||
{}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsNoneService, nsINoneService, nsIMsgProtocolInfo);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::SetDefaultLocalPath(nsIFileSpec *aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = prefs->SetFilePref(PREF_MAIL_ROOT_NONE, aPath, PR_FALSE /* set default */);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = prefs->GetFilePref(PREF_MAIL_ROOT_NONE, aResult);
|
||||
if (NS_SUCCEEDED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_MailDirectory50, aResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetDefaultLocalPath(*aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetServerIID(nsIID* *aServerIID)
|
||||
{
|
||||
*aServerIID = new nsIID(NS_GET_IID(nsINoIncomingServer));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetRequiresUsername(PRBool *aRequiresUsername)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequiresUsername);
|
||||
*aRequiresUsername = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNameWithEmailAddress)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPreflightPrettyNameWithEmailAddress);
|
||||
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetCanDelete(PRBool *aCanDelete)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDelete);
|
||||
*aCanDelete = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNoneService::GetCanDuplicate(PRBool *aCanDuplicate)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDuplicate);
|
||||
*aCanDuplicate = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
46
mailnews/local/src/nsNoneService.h
Normal file
46
mailnews/local/src/nsNoneService.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsNoneService_h___
|
||||
#define nsNoneService_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIMsgProtocolInfo.h"
|
||||
#include "nsINoneService.h"
|
||||
|
||||
class nsNoneService : public nsIMsgProtocolInfo, public nsINoneService
|
||||
{
|
||||
public:
|
||||
|
||||
nsNoneService();
|
||||
virtual ~nsNoneService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGPROTOCOLINFO
|
||||
NS_DECL_NSINONESERVICE
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsNoneService_h___ */
|
@ -44,7 +44,6 @@
|
||||
#define POP3_PORT 110 // The IANA port for Pop3
|
||||
|
||||
#define PREF_MAIL_ROOT_POP3 "mail.root.pop3"
|
||||
#define PREF_MAIL_ROOT_NONE "mail.root.none"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
|
||||
@ -290,18 +289,7 @@ nsPop3Service::SetDefaultLocalPath(nsIFileSpec *aPath)
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/*
|
||||
there is no nsNoService, so in the MsgLocalFactory, we
|
||||
registered the nsPop3Service with both
|
||||
"component://netscape/messenger/protocol/info;type=none"
|
||||
"component://netscape/messenger/protocol/info;type=pop3"
|
||||
on disk, both roots (mail.root.none and mail.root.pop3) should point to <profile>/Mail or "mail.directory"
|
||||
so we set both here to the same value
|
||||
*/
|
||||
rv = prefs->SetFilePref(PREF_MAIL_ROOT_POP3, aPath, PR_FALSE /* set default */);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = prefs->SetFilePref(PREF_MAIL_ROOT_NONE, aPath, PR_FALSE /* set default */);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -348,3 +336,19 @@ nsPop3Service::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNa
|
||||
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPop3Service::GetCanDelete(PRBool *aCanDelete)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDelete);
|
||||
*aCanDelete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPop3Service::GetCanDuplicate(PRBool *aCanDuplicate)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDuplicate);
|
||||
*aCanDuplicate = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1093,3 +1093,19 @@ nsNntpService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNa
|
||||
*aPreflightPrettyNameWithEmailAddress = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetCanDelete(PRBool *aCanDelete)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDelete);
|
||||
*aCanDelete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetCanDuplicate(PRBool *aCanDuplicate)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanDuplicate);
|
||||
*aCanDuplicate = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user