diff --git a/mailnews/base/prefs/resources/content/AccountManager.js b/mailnews/base/prefs/resources/content/AccountManager.js index 685e04c0cd81..8c774370eccb 100644 --- a/mailnews/base/prefs/resources/content/AccountManager.js +++ b/mailnews/base/prefs/resources/content/AccountManager.js @@ -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 } +} diff --git a/mailnews/base/prefs/resources/content/AccountManager.xul b/mailnews/base/prefs/resources/content/AccountManager.xul index e9edaf29d0bf..2d3555b2b7dd 100644 --- a/mailnews/base/prefs/resources/content/AccountManager.xul +++ b/mailnews/base/prefs/resources/content/AccountManager.xul @@ -12,7 +12,8 @@ class="dialog" onload="onLoad(event);"> - + + @@ -65,8 +66,8 @@ - - + + diff --git a/mailnews/base/prefs/resources/content/aw-identity.js b/mailnews/base/prefs/resources/content/aw-identity.js index 7ba03f1e8722..696451ba7d47 100644 --- a/mailnews/base/prefs/resources/content/aw-identity.js +++ b/mailnews/base/prefs/resources/content/aw-identity.js @@ -19,15 +19,19 @@ * * Contributor(s): * Alec Flett + * Seth Spitzer */ +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"); diff --git a/mailnews/base/prefs/resources/content/aw-identity.xul b/mailnews/base/prefs/resources/content/aw-identity.xul index 7ace7b9775a5..5c399c7b60dd 100644 --- a/mailnews/base/prefs/resources/content/aw-identity.xul +++ b/mailnews/base/prefs/resources/content/aw-identity.xul @@ -28,7 +28,9 @@ Rights Reserved. align="vertical" class="dialog" onload="parent.wizardPageLoaded('identity');"> - + + + &identityTitle.label; diff --git a/mailnews/base/prefs/resources/content/aw-server.js b/mailnews/base/prefs/resources/content/aw-server.js index 80ba7b0fa1bb..1453bd9b1f54 100644 --- a/mailnews/base/prefs/resources/content/aw-server.js +++ b/mailnews/base/prefs/resources/content/aw-server.js @@ -19,14 +19,18 @@ * * Contributor(s): * Alec Flett + * Seth Spitzer */ +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; diff --git a/mailnews/base/prefs/resources/content/aw-server.xul b/mailnews/base/prefs/resources/content/aw-server.xul index 9a5c7f290c88..c03e1a2cd97a 100644 --- a/mailnews/base/prefs/resources/content/aw-server.xul +++ b/mailnews/base/prefs/resources/content/aw-server.xul @@ -28,7 +28,9 @@ Rights Reserved. align="vertical" class="dialog" onload="parent.wizardPageLoaded('server');"> - + + + &serverTitle.label; diff --git a/mailnews/base/prefs/resources/locale/en-US/prefs.properties b/mailnews/base/prefs/resources/locale/en-US/prefs.properties index 409964cb0ce9..32bf6e6411ff 100644 --- a/mailnews/base/prefs/resources/locale/en-US/prefs.properties +++ b/mailnews/base/prefs/resources/locale/en-US/prefs.properties @@ -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. diff --git a/mailnews/base/public/nsIMsgAccountManager.idl b/mailnews/base/public/nsIMsgAccountManager.idl index b6f415f43001..5398936eea80 100644 --- a/mailnews/base/public/nsIMsgAccountManager.idl +++ b/mailnews/base/public/nsIMsgAccountManager.idl @@ -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" diff --git a/mailnews/base/public/nsIMsgProtocolInfo.idl b/mailnews/base/public/nsIMsgProtocolInfo.idl index a93bb3641874..d5d04ef01bec 100644 --- a/mailnews/base/public/nsIMsgProtocolInfo.idl +++ b/mailnews/base/public/nsIMsgProtocolInfo.idl @@ -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; }; diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 51e41115dd89..adc924dfd2b5 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -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; diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index de6bb26c2840..42810cd683ce 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -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; +} diff --git a/mailnews/local/build/nsMsgLocalCID.h b/mailnews/local/build/nsMsgLocalCID.h index 0cbfb89867ef..24cfb0aadf2a 100644 --- a/mailnews/local/build/nsMsgLocalCID.h +++ b/mailnews/local/build/nsMsgLocalCID.h @@ -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 diff --git a/mailnews/local/build/nsMsgLocalFactory.cpp b/mailnews/local/build/nsMsgLocalFactory.cpp index 72918b5e7b0c..a0582366b4d1 100644 --- a/mailnews/local/build/nsMsgLocalFactory.cpp +++ b/mailnews/local/build/nsMsgLocalFactory.cpp @@ -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 mMailboxParserFactory; nsCOMPtr mMailboxServiceFactory; nsCOMPtr mPop3ServiceFactory; + nsCOMPtr mNoneServiceFactory; nsCOMPtr mLocalMailFolderFactory; nsCOMPtr mLocalMessageFactory; nsCOMPtr 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 }, diff --git a/mailnews/local/public/MANIFEST b/mailnews/local/public/MANIFEST index b2dfcbc8d31b..50392742a748 100644 --- a/mailnews/local/public/MANIFEST +++ b/mailnews/local/public/MANIFEST @@ -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 diff --git a/mailnews/local/public/Makefile.in b/mailnews/local/public/Makefile.in index fcc1df45d1a0..7bdbc683d9ce 100644 --- a/mailnews/local/public/Makefile.in +++ b/mailnews/local/public/Makefile.in @@ -37,6 +37,7 @@ XPIDLSRCS = \ nsIMailboxUrl.idl \ nsIMsgParseMailMsgState.idl \ nsINoIncomingServer.idl \ + nsINoneService.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mailnews/local/public/makefile.win b/mailnews/local/public/makefile.win index ca5c0edbe1d3..36893714ab17 100644 --- a/mailnews/local/public/makefile.win +++ b/mailnews/local/public/makefile.win @@ -34,6 +34,7 @@ XPIDLSRCS = \ .\nsIMailboxUrl.idl \ .\nsIMsgParseMailMsgState.idl \ .\nsINoIncomingServer.idl \ + .\nsINoneService.idl \ $(NULL) EXPORTS = \ diff --git a/mailnews/local/public/nsINoneService.idl b/mailnews/local/public/nsINoneService.idl new file mode 100644 index 000000000000..975076a637f5 --- /dev/null +++ b/mailnews/local/public/nsINoneService.idl @@ -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 + */ + +#include "nsISupports.idl" + +[scriptable, uuid(14714890-1dd2-11b2-87de-d265839520d6)] +interface nsINoneService : nsISupports { + /* nothing yet, but soon. */ +}; diff --git a/mailnews/local/src/MANIFEST b/mailnews/local/src/MANIFEST index 528e8f260ac8..22b02db07af1 100644 --- a/mailnews/local/src/MANIFEST +++ b/mailnews/local/src/MANIFEST @@ -31,5 +31,5 @@ nsPop3Service.h nsPop3IncomingServer.h nsLocalMessage.h nsLocalStringBundle.h +nsNoneService.h nsNoIncomingServer.h - diff --git a/mailnews/local/src/Makefile.in b/mailnews/local/src/Makefile.in index fdf55cec2525..479aad1cbb6e 100644 --- a/mailnews/local/src/Makefile.in +++ b/mailnews/local/src/Makefile.in @@ -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) diff --git a/mailnews/local/src/makefile.win b/mailnews/local/src/makefile.win index aabb7e715e2b..c3f4b9b3c7c6 100644 --- a/mailnews/local/src/makefile.win +++ b/mailnews/local/src/makefile.win @@ -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 \ diff --git a/mailnews/local/src/nsNoneService.cpp b/mailnews/local/src/nsNoneService.cpp new file mode 100644 index 000000000000..d82f5add8f31 --- /dev/null +++ b/mailnews/local/src/nsNoneService.cpp @@ -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 + */ + +#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; +} diff --git a/mailnews/local/src/nsNoneService.h b/mailnews/local/src/nsNoneService.h new file mode 100644 index 000000000000..3aecff077006 --- /dev/null +++ b/mailnews/local/src/nsNoneService.h @@ -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 + */ + +#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___ */ diff --git a/mailnews/local/src/nsPop3Service.cpp b/mailnews/local/src/nsPop3Service.cpp index 3d74dc98e3c9..dbf84f5f7269 100644 --- a/mailnews/local/src/nsPop3Service.cpp +++ b/mailnews/local/src/nsPop3Service.cpp @@ -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 /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; +} diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index 3945f4abed7b..90c69ba7f70c 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -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; +}