2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-06 22:34:19 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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/
|
1999-04-06 22:34:19 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1999-04-06 22:34:19 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-06 03:18:27 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-04-06 22:34:19 +00:00
|
|
|
|
|
|
|
#include "nsMsgIncomingServer.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsCom.h"
|
|
|
|
#include "plstr.h"
|
|
|
|
#include "prmem.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
#include "nsIServiceManager.h"
|
1999-07-17 03:26:24 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2000-03-28 04:58:05 +00:00
|
|
|
#include "nsXPIDLString.h"
|
2001-09-29 08:28:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsEscape.h"
|
2000-03-28 04:58:05 +00:00
|
|
|
|
|
|
|
#include "nsMsgBaseCID.h"
|
2001-01-01 22:00:17 +00:00
|
|
|
#include "nsMsgDBCID.h"
|
1999-07-17 03:26:24 +00:00
|
|
|
#include "nsIMsgFolder.h"
|
|
|
|
#include "nsIMsgFolderCache.h"
|
|
|
|
#include "nsIMsgFolderCacheElement.h"
|
2000-01-29 15:53:14 +00:00
|
|
|
#include "nsIMsgWindow.h"
|
2000-03-28 04:58:05 +00:00
|
|
|
#include "nsIMsgFilterService.h"
|
|
|
|
#include "nsIMsgProtocolInfo.h"
|
|
|
|
|
|
|
|
#include "nsIPref.h"
|
2000-05-12 20:41:19 +00:00
|
|
|
#include "nsIDocShell.h"
|
2000-01-29 15:53:14 +00:00
|
|
|
#include "nsIWebShell.h"
|
|
|
|
#include "nsIWebShellWindow.h"
|
2001-04-10 18:30:25 +00:00
|
|
|
#include "nsIAuthPrompt.h"
|
2002-01-26 00:44:18 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsNetUtil.h"
|
2001-04-07 03:33:56 +00:00
|
|
|
#include "nsIWindowWatcher.h"
|
2001-01-13 15:31:30 +00:00
|
|
|
#include "nsIStringBundle.h"
|
2000-03-28 04:58:05 +00:00
|
|
|
|
1999-08-30 22:12:20 +00:00
|
|
|
#include "nsIRDFService.h"
|
|
|
|
#include "nsRDFCID.h"
|
2000-05-16 05:35:23 +00:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
1999-04-10 20:55:30 +00:00
|
|
|
|
2001-10-09 19:20:31 +00:00
|
|
|
#include "nsIMsgAccountManager.h"
|
|
|
|
|
2000-03-15 07:12:59 +00:00
|
|
|
#ifdef DEBUG_sspitzer
|
|
|
|
#define DEBUG_MSGINCOMING_SERVER
|
|
|
|
#endif /* DEBUG_sspitzer */
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
1999-08-30 22:12:20 +00:00
|
|
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
2000-03-28 04:58:05 +00:00
|
|
|
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
2001-02-03 17:43:24 +00:00
|
|
|
#define OFFLINE_STATUS_CHANGED_TOPIC "network:offline-status-changed"
|
|
|
|
|
2000-05-31 08:00:13 +00:00
|
|
|
#define PORT_NOT_SET -1
|
|
|
|
|
2001-01-27 23:31:15 +00:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer)
|
1999-10-06 20:32:25 +00:00
|
|
|
|
1999-04-06 22:34:19 +00:00
|
|
|
nsMsgIncomingServer::nsMsgIncomingServer():
|
2001-12-04 15:34:00 +00:00
|
|
|
m_rootFolder(0),
|
1999-04-10 20:55:30 +00:00
|
|
|
m_prefs(0),
|
2001-12-04 15:34:00 +00:00
|
|
|
m_biffState(nsIMsgFolder::nsMsgBiffState_NoMail),
|
2000-12-22 23:32:32 +00:00
|
|
|
m_serverBusy(PR_FALSE),
|
2001-03-14 02:32:04 +00:00
|
|
|
m_canHaveFilters(PR_FALSE),
|
2002-02-05 01:35:32 +00:00
|
|
|
m_displayStartupPage(PR_TRUE),
|
|
|
|
mPerformingBiff(PR_FALSE)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMsgIncomingServer::~nsMsgIncomingServer()
|
|
|
|
{
|
1999-04-10 20:55:30 +00:00
|
|
|
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
|
|
|
|
m_prefs,
|
|
|
|
nsnull);
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
2001-02-03 17:43:24 +00:00
|
|
|
|
2000-03-05 21:26:01 +00:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsMsgIncomingServer);
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsMsgIncomingServer);
|
2000-01-26 00:54:15 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsMsgIncomingServer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMsgIncomingServer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgIncomingServer)
|
2000-03-05 21:26:01 +00:00
|
|
|
NS_INTERFACE_MAP_END_THREADSAFE
|
1999-04-06 22:34:19 +00:00
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
NS_IMPL_GETSET(nsMsgIncomingServer, ServerBusy, PRBool, m_serverBusy)
|
2001-10-29 09:27:57 +00:00
|
|
|
NS_IMPL_GETTER_STR(nsMsgIncomingServer::GetKey, m_serverKey.get())
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-19 23:46:35 +00:00
|
|
|
nsMsgIncomingServer::SetKey(const char * serverKey)
|
1999-04-10 20:55:30 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// in order to actually make use of the key, we need the prefs
|
|
|
|
if (!m_prefs)
|
|
|
|
rv = nsServiceManager::GetService(kPrefServiceCID,
|
2000-02-06 03:18:27 +00:00
|
|
|
NS_GET_IID(nsIPref),
|
1999-04-10 20:55:30 +00:00
|
|
|
(nsISupports**)&m_prefs);
|
|
|
|
|
2001-08-10 21:54:54 +00:00
|
|
|
m_serverKey.Assign(serverKey);
|
1999-04-10 20:55:30 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-05-26 23:56:21 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetRootFolder(nsIFolder * aRootFolder)
|
|
|
|
{
|
|
|
|
m_rootFolder = aRootFolder;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetRootFolder(nsIFolder * *aRootFolder)
|
|
|
|
{
|
|
|
|
if (!aRootFolder)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-06-06 18:46:03 +00:00
|
|
|
if (m_rootFolder) {
|
|
|
|
*aRootFolder = m_rootFolder;
|
|
|
|
NS_ADDREF(*aRootFolder);
|
|
|
|
} else {
|
1999-09-09 04:11:38 +00:00
|
|
|
nsresult rv = CreateRootFolder();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
*aRootFolder = m_rootFolder;
|
1999-08-30 22:12:20 +00:00
|
|
|
NS_IF_ADDREF(*aRootFolder);
|
1999-06-06 18:46:03 +00:00
|
|
|
}
|
1999-05-26 23:56:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-03 02:06:57 +00:00
|
|
|
|
2002-01-14 22:59:02 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRootMsgFolder);
|
|
|
|
nsCOMPtr <nsIFolder> rootFolder;
|
|
|
|
nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
|
|
|
|
if (NS_SUCCEEDED(rv) && rootFolder)
|
|
|
|
rv = rootFolder->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aRootMsgFolder);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-04-03 02:06:57 +00:00
|
|
|
NS_IMETHODIMP
|
2000-04-21 22:55:18 +00:00
|
|
|
nsMsgIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow)
|
2000-04-03 02:06:57 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_sspitzer
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("PerformExpand()\n");
|
2000-04-03 02:06:57 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-11 22:10:42 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::PerformBiff()
|
|
|
|
{
|
|
|
|
//This had to be implemented in the derived class, but in case someone doesn't implement it
|
|
|
|
//just return not implemented.
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-02-05 01:35:32 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetPerformingBiff(PRBool *aPerformingBiff)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPerformingBiff);
|
|
|
|
*aPerformingBiff = mPerformingBiff;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetPerformingBiff(PRBool aPerformingBiff)
|
|
|
|
{
|
|
|
|
mPerformingBiff = aPerformingBiff;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-04 15:34:00 +00:00
|
|
|
NS_IMPL_GETSET(nsMsgIncomingServer, BiffState, PRUint32, m_biffState);
|
|
|
|
|
1999-07-17 03:26:24 +00:00
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::WriteToFolderCache(nsIMsgFolderCache *folderCache)
|
|
|
|
{
|
1999-07-17 20:33:15 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-07-17 03:26:24 +00:00
|
|
|
if (m_rootFolder)
|
|
|
|
{
|
1999-07-17 20:33:15 +00:00
|
|
|
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(m_rootFolder, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv) && msgFolder)
|
2000-07-26 21:22:54 +00:00
|
|
|
rv = msgFolder->WriteToFolderCache(folderCache, PR_TRUE /* deep */);
|
1999-07-17 03:26:24 +00:00
|
|
|
}
|
1999-07-17 20:33:15 +00:00
|
|
|
return rv;
|
1999-07-17 03:26:24 +00:00
|
|
|
}
|
|
|
|
|
1999-09-30 01:44:30 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::CloseCachedConnections()
|
|
|
|
{
|
|
|
|
// derived class should override if they cache connections.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetDownloadMessagesAtStartup(PRBool *getMessagesAtStartup)
|
|
|
|
{
|
|
|
|
// derived class should override if they need to do this.
|
|
|
|
*getMessagesAtStartup = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-01 07:26:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetCanHaveFilters(PRBool *canHaveFilters)
|
|
|
|
{
|
|
|
|
// derived class should override if they need to do this.
|
|
|
|
*canHaveFilters = m_canHaveFilters;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetCanHaveFilters(PRBool canHaveFilters)
|
|
|
|
{
|
|
|
|
// derived class should override if they need to do this.
|
|
|
|
m_canHaveFilters = canHaveFilters;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:42:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetCanBeDefaultServer(PRBool *canBeDefaultServer)
|
|
|
|
{
|
|
|
|
// derived class should override if they need to do this.
|
|
|
|
*canBeDefaultServer = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-14 02:32:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetCanSearchMessages(PRBool *canSearchMessages)
|
|
|
|
{
|
|
|
|
// derived class should override if they need to do this.
|
|
|
|
NS_ENSURE_ARG_POINTER(canSearchMessages);
|
|
|
|
*canSearchMessages = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-28 20:22:06 +00:00
|
|
|
// construct <localStoreType>://[<username>@]<hostname
|
1999-09-09 04:11:38 +00:00
|
|
|
NS_IMETHODIMP
|
2000-05-16 21:17:55 +00:00
|
|
|
nsMsgIncomingServer::GetServerURI(char* *aResult)
|
1999-09-09 04:11:38 +00:00
|
|
|
{
|
1999-11-03 07:16:59 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
1999-10-28 20:22:06 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCAutoString uri;
|
|
|
|
|
|
|
|
nsXPIDLCString localStoreType;
|
|
|
|
rv = GetLocalStoreType(getter_Copies(localStoreType));
|
1999-11-03 07:16:59 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-03-26 12:14:14 +00:00
|
|
|
uri.Append(localStoreType);
|
1999-10-28 20:22:06 +00:00
|
|
|
uri += "://";
|
|
|
|
|
|
|
|
nsXPIDLCString username;
|
|
|
|
rv = GetUsername(getter_Copies(username));
|
|
|
|
|
1999-11-03 07:16:59 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && ((const char*)username) && username[0]) {
|
|
|
|
nsXPIDLCString escapedUsername;
|
|
|
|
*((char **)getter_Copies(escapedUsername)) =
|
2000-02-05 01:19:38 +00:00
|
|
|
nsEscape(username, url_XAlphas);
|
|
|
|
// nsEscape(username, url_Path);
|
2000-01-12 03:03:30 +00:00
|
|
|
// not all servers have a username
|
2000-03-26 12:14:14 +00:00
|
|
|
uri.Append(escapedUsername);
|
1999-11-03 07:16:59 +00:00
|
|
|
uri += '@';
|
|
|
|
}
|
1999-10-28 20:22:06 +00:00
|
|
|
|
|
|
|
nsXPIDLCString hostname;
|
|
|
|
rv = GetHostName(getter_Copies(hostname));
|
|
|
|
|
1999-11-03 07:16:59 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && ((const char*)hostname) && hostname[0]) {
|
|
|
|
nsXPIDLCString escapedHostname;
|
|
|
|
*((char **)getter_Copies(escapedHostname)) =
|
|
|
|
nsEscape(hostname, url_Path);
|
2000-01-12 03:03:30 +00:00
|
|
|
// not all servers have a hostname
|
2000-03-26 12:14:14 +00:00
|
|
|
uri.Append(escapedHostname);
|
1999-11-03 07:16:59 +00:00
|
|
|
}
|
|
|
|
|
2001-09-29 08:28:41 +00:00
|
|
|
*aResult = ToNewCString(uri);
|
1999-10-28 20:22:06 +00:00
|
|
|
return NS_OK;
|
1999-09-09 04:11:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::CreateRootFolder()
|
1999-08-30 22:12:20 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
// get the URI from the incoming server
|
|
|
|
nsXPIDLCString serverUri;
|
2000-05-16 21:17:55 +00:00
|
|
|
rv = GetServerURI(getter_Copies(serverUri));
|
1999-09-09 04:11:38 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-30 22:12:20 +00:00
|
|
|
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
|
1999-08-30 22:12:20 +00:00
|
|
|
|
|
|
|
// get the corresponding RDF resource
|
|
|
|
// RDF will create the server resource if it doesn't already exist
|
|
|
|
nsCOMPtr<nsIRDFResource> serverResource;
|
|
|
|
rv = rdf->GetResource(serverUri, getter_AddRefs(serverResource));
|
1999-09-09 04:11:38 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-30 22:12:20 +00:00
|
|
|
|
|
|
|
// make incoming server know about its root server folder so we
|
|
|
|
// can find sub-folders given an incoming server.
|
1999-09-09 04:11:38 +00:00
|
|
|
m_rootFolder = do_QueryInterface(serverResource, &rv);
|
|
|
|
return rv;
|
1999-08-30 22:12:20 +00:00
|
|
|
}
|
|
|
|
|
2000-01-26 00:54:15 +00:00
|
|
|
void
|
1999-04-06 22:34:19 +00:00
|
|
|
nsMsgIncomingServer::getPrefName(const char *serverKey,
|
2000-01-26 00:54:15 +00:00
|
|
|
const char *prefName,
|
|
|
|
nsCString& fullPrefName)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
// mail.server.<key>.<pref>
|
|
|
|
fullPrefName = "mail.server.";
|
|
|
|
fullPrefName.Append(serverKey);
|
|
|
|
fullPrefName.Append('.');
|
|
|
|
fullPrefName.Append(prefName);
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
// this will be slightly faster than the above, and allows
|
|
|
|
// the "default" server preference root to be set in one place
|
2000-01-26 00:54:15 +00:00
|
|
|
void
|
|
|
|
nsMsgIncomingServer::getDefaultPrefName(const char *prefName,
|
|
|
|
nsCString& fullPrefName)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
// mail.server.default.<pref>
|
|
|
|
fullPrefName = "mail.server.default.";
|
|
|
|
fullPrefName.Append(prefName);
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::GetBoolValue(const char *prefname,
|
1999-04-10 20:55:30 +00:00
|
|
|
PRBool *val)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
|
|
|
nsresult rv = m_prefs->GetBoolPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = getDefaultBoolPref(prefname, val);
|
|
|
|
|
|
|
|
return rv;
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::getDefaultBoolPref(const char *prefname,
|
|
|
|
PRBool *val) {
|
|
|
|
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
|
|
|
getDefaultPrefName(prefname, fullPrefName);
|
2001-10-29 09:27:57 +00:00
|
|
|
nsresult rv = m_prefs->GetBoolPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
1999-06-06 18:46:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
*val = PR_FALSE;
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
1999-04-10 20:55:30 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::SetBoolValue(const char *prefname,
|
1999-04-10 20:55:30 +00:00
|
|
|
PRBool val)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult rv;
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
PRBool defaultValue;
|
|
|
|
rv = getDefaultBoolPref(prefname, &defaultValue);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) &&
|
|
|
|
val == defaultValue)
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-04-10 20:55:30 +00:00
|
|
|
else
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetBoolPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
return rv;
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::GetIntValue(const char *prefname,
|
1999-04-10 20:55:30 +00:00
|
|
|
PRInt32 *val)
|
1999-04-06 22:34:19 +00:00
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
|
|
|
nsresult rv = m_prefs->GetIntPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = getDefaultIntPref(prefname, val);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::GetFileValue(const char* prefname,
|
|
|
|
nsIFileSpec **spec)
|
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
2000-08-21 23:43:48 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> prefLocal;
|
|
|
|
nsCOMPtr<nsIFileSpec> outSpec;
|
|
|
|
nsXPIDLCString pathBuf;
|
|
|
|
|
2001-10-29 09:27:57 +00:00
|
|
|
nsresult rv = m_prefs->GetFileXPref(fullPrefName.get(), getter_AddRefs(prefLocal));
|
2000-08-21 23:43:48 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = prefLocal->GetPath(getter_Copies(pathBuf));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = outSpec->SetNativePath((const char *)pathBuf);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
*spec = outSpec;
|
|
|
|
NS_ADDREF(*spec);
|
1999-09-09 04:11:38 +00:00
|
|
|
|
2000-08-21 23:43:48 +00:00
|
|
|
return NS_OK;
|
1999-09-09 04:11:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::SetFileValue(const char* prefname,
|
|
|
|
nsIFileSpec *spec)
|
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
2000-08-21 23:43:48 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsFileSpec tempSpec;
|
|
|
|
nsCOMPtr<nsILocalFile> prefLocal;
|
|
|
|
|
|
|
|
rv = spec->GetFileSpec(&tempSpec);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = NS_FileSpecToIFile(&tempSpec, getter_AddRefs(prefLocal));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetFileXPref(fullPrefName.get(), prefLocal);
|
2000-08-21 23:43:48 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-09 04:11:38 +00:00
|
|
|
|
2000-08-21 23:43:48 +00:00
|
|
|
return NS_OK;
|
1999-09-09 04:11:38 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::getDefaultIntPref(const char *prefname,
|
|
|
|
PRInt32 *val) {
|
|
|
|
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
|
|
|
getDefaultPrefName(prefname, fullPrefName);
|
2001-10-29 09:27:57 +00:00
|
|
|
nsresult rv = m_prefs->GetIntPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
1999-06-06 18:46:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
*val = 0;
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::SetIntValue(const char *prefname,
|
1999-04-10 20:55:30 +00:00
|
|
|
PRInt32 val)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
PRInt32 defaultVal;
|
|
|
|
rv = getDefaultIntPref(prefname, &defaultVal);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && defaultVal == val)
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-04-10 20:55:30 +00:00
|
|
|
else
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetIntPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
return rv;
|
1999-04-06 22:34:19 +00:00
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::GetCharValue(const char *prefname,
|
1999-04-10 20:55:30 +00:00
|
|
|
char **val)
|
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
|
|
|
nsresult rv = m_prefs->CopyCharPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = getDefaultCharPref(prefname, val);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-03 00:10:00 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::GetUnicharValue(const char *prefname,
|
|
|
|
PRUnichar **val)
|
|
|
|
{
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
|
|
|
nsresult rv = m_prefs->CopyUnicharPref(fullPrefName.get(), val);
|
1999-12-03 00:10:00 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
rv = getDefaultUnicharPref(prefname, val);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-10 21:58:09 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::getDefaultCharPref(const char *prefname,
|
|
|
|
char **val) {
|
|
|
|
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
|
|
|
getDefaultPrefName(prefname, fullPrefName);
|
2001-10-29 09:27:57 +00:00
|
|
|
nsresult rv = m_prefs->CopyCharPref(fullPrefName.get(), val);
|
1999-04-10 21:58:09 +00:00
|
|
|
|
1999-06-06 18:46:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1999-06-14 22:53:09 +00:00
|
|
|
*val = nsnull; // null is ok to return here
|
1999-06-06 18:46:03 +00:00
|
|
|
rv = NS_OK;
|
|
|
|
}
|
1999-04-10 21:58:09 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-03 00:10:00 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::getDefaultUnicharPref(const char *prefname,
|
|
|
|
PRUnichar **val) {
|
|
|
|
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
|
|
|
getDefaultPrefName(prefname, fullPrefName);
|
2001-10-29 09:27:57 +00:00
|
|
|
nsresult rv = m_prefs->CopyUnicharPref(fullPrefName.get(), val);
|
1999-12-03 00:10:00 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
*val = nsnull; // null is ok to return here
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
nsresult
|
1999-09-09 04:11:38 +00:00
|
|
|
nsMsgIncomingServer::SetCharValue(const char *prefname,
|
1999-08-10 04:39:22 +00:00
|
|
|
const char * val)
|
1999-04-10 20:55:30 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
if (!val) {
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-09-09 04:11:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
char *defaultVal=nsnull;
|
|
|
|
rv = getDefaultCharPref(prefname, &defaultVal);
|
1999-09-09 04:11:38 +00:00
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
if (NS_SUCCEEDED(rv) &&
|
|
|
|
PL_strcmp(defaultVal, val) == 0)
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-04-10 20:55:30 +00:00
|
|
|
else
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetCharPref(fullPrefName.get(), val);
|
1999-04-10 20:55:30 +00:00
|
|
|
|
|
|
|
PR_FREEIF(defaultVal);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-03 00:10:00 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::SetUnicharValue(const char *prefname,
|
|
|
|
const PRUnichar * val)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-26 00:54:15 +00:00
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
1999-12-03 00:10:00 +00:00
|
|
|
|
|
|
|
if (!val) {
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-12-03 00:10:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUnichar *defaultVal=nsnull;
|
|
|
|
rv = getDefaultUnicharPref(prefname, &defaultVal);
|
1999-12-07 08:48:52 +00:00
|
|
|
if (defaultVal && NS_SUCCEEDED(rv) &&
|
1999-12-03 00:10:00 +00:00
|
|
|
nsCRT::strcmp(defaultVal, val) == 0)
|
2001-10-29 09:27:57 +00:00
|
|
|
m_prefs->ClearUserPref(fullPrefName.get());
|
1999-12-03 00:10:00 +00:00
|
|
|
else
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetUnicharPref(fullPrefName.get(), val);
|
1999-12-03 00:10:00 +00:00
|
|
|
|
|
|
|
PR_FREEIF(defaultVal);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-06-14 22:53:09 +00:00
|
|
|
// pretty name is the display name to show to the user
|
|
|
|
NS_IMETHODIMP
|
1999-08-10 04:39:22 +00:00
|
|
|
nsMsgIncomingServer::GetPrettyName(PRUnichar **retval) {
|
1999-06-14 22:53:09 +00:00
|
|
|
|
1999-12-03 00:10:00 +00:00
|
|
|
nsXPIDLString val;
|
|
|
|
nsresult rv = GetUnicharValue("name", getter_Copies(val));
|
1999-06-14 22:53:09 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-08-10 04:39:22 +00:00
|
|
|
// if there's no name, then just return the hostname
|
2000-08-19 20:52:31 +00:00
|
|
|
if (nsCRT::strlen(val) == 0)
|
|
|
|
return GetConstructedPrettyName(retval);
|
|
|
|
else
|
|
|
|
*retval = nsCRT::strdup(val);
|
1999-06-14 22:53:09 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-14 09:01:39 +00:00
|
|
|
nsMsgIncomingServer::SetPrettyName(const PRUnichar *value)
|
|
|
|
{
|
|
|
|
SetUnicharValue("name", value);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFolder> rootFolder;
|
|
|
|
GetRootFolder(getter_AddRefs(rootFolder));
|
|
|
|
|
|
|
|
if (rootFolder)
|
|
|
|
rootFolder->SetPrettyName(value);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-09 04:11:38 +00:00
|
|
|
}
|
|
|
|
|
2000-08-19 20:52:31 +00:00
|
|
|
|
|
|
|
// construct the pretty name to show to the user if they haven't
|
|
|
|
// specified one. This should be overridden for news and mail.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetConstructedPrettyName(PRUnichar **retval)
|
|
|
|
{
|
|
|
|
|
|
|
|
nsXPIDLCString username;
|
|
|
|
nsAutoString prettyName;
|
|
|
|
nsresult rv = GetUsername(getter_Copies(username));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if ((const char*)username &&
|
|
|
|
PL_strcmp((const char*)username, "")!=0) {
|
|
|
|
prettyName.AssignWithConversion(username);
|
2001-12-16 11:58:03 +00:00
|
|
|
prettyName.Append(NS_LITERAL_STRING(" on "));
|
2000-08-19 20:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXPIDLCString hostname;
|
|
|
|
rv = GetHostName(getter_Copies(hostname));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
|
|
|
|
prettyName.AppendWithConversion(hostname);
|
|
|
|
|
2001-09-29 08:28:41 +00:00
|
|
|
*retval = ToNewUnicode(prettyName);
|
2000-08-19 20:52:31 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::ToString(PRUnichar** aResult) {
|
2001-10-29 09:27:57 +00:00
|
|
|
*aResult = ToNewUnicode(NS_LITERAL_STRING("[nsIMsgIncomingServer: ") +
|
|
|
|
NS_ConvertASCIItoUCS2(m_serverKey) +
|
|
|
|
NS_LITERAL_STRING("]"));
|
1999-09-09 04:11:38 +00:00
|
|
|
NS_ASSERTION(*aResult, "no server name!");
|
|
|
|
return NS_OK;
|
1999-06-14 22:53:09 +00:00
|
|
|
}
|
1999-09-09 04:11:38 +00:00
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
|
1999-08-31 04:39:43 +00:00
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetPassword(const char * aPassword)
|
|
|
|
{
|
|
|
|
m_password = aPassword;
|
2000-03-24 08:26:32 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
PRBool rememberPassword = PR_FALSE;
|
|
|
|
|
|
|
|
rv = GetRememberPassword(&rememberPassword);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (rememberPassword) {
|
|
|
|
rv = StorePassword();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
1999-08-31 04:39:43 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-22 02:21:18 +00:00
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetPassword(char ** aPassword)
|
1999-08-31 04:39:43 +00:00
|
|
|
{
|
2000-02-01 07:14:54 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aPassword);
|
|
|
|
|
2001-09-29 08:28:41 +00:00
|
|
|
*aPassword = ToNewCString(m_password);
|
2000-02-01 07:14:54 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-22 02:21:18 +00:00
|
|
|
}
|
1999-08-31 04:39:43 +00:00
|
|
|
|
2000-04-13 02:59:01 +00:00
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetServerRequiresPasswordForBiff(PRBool *_retval)
|
|
|
|
{
|
|
|
|
if (!_retval) return NS_ERROR_NULL_POINTER;
|
|
|
|
*_retval = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-22 02:21:18 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-29 15:53:14 +00:00
|
|
|
nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
|
|
|
PRUnichar *aPromptTitle,
|
|
|
|
nsIMsgWindow* aMsgWindow,
|
2000-04-26 22:31:59 +00:00
|
|
|
PRBool *okayValue,
|
2000-01-29 15:53:14 +00:00
|
|
|
char **aPassword)
|
1999-09-22 06:02:46 +00:00
|
|
|
{
|
2000-02-01 07:14:54 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-08-31 04:39:43 +00:00
|
|
|
|
2000-02-01 07:14:54 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aPassword);
|
2000-04-26 22:31:59 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(okayValue);
|
1999-09-22 02:21:18 +00:00
|
|
|
|
|
|
|
if (m_password.IsEmpty()) {
|
2001-04-10 18:30:25 +00:00
|
|
|
nsCOMPtr<nsIAuthPrompt> dialog;
|
2000-02-12 00:52:53 +00:00
|
|
|
// aMsgWindow is required if we need to prompt
|
2000-02-29 21:01:53 +00:00
|
|
|
if (aMsgWindow)
|
|
|
|
{
|
|
|
|
// prompt the user for the password
|
2000-05-12 20:41:19 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-05-16 05:35:23 +00:00
|
|
|
|
2000-05-12 20:41:19 +00:00
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell, &rv));
|
2000-02-29 21:01:53 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-05-16 05:35:23 +00:00
|
|
|
dialog = do_GetInterface(webShell, &rv);
|
2000-05-31 04:48:31 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-02-29 21:01:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-07 03:33:56 +00:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
|
|
|
if (wwatch)
|
2001-04-10 18:30:25 +00:00
|
|
|
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
|
2001-04-07 03:33:56 +00:00
|
|
|
if (!dialog) return NS_ERROR_FAILURE;
|
2000-02-29 21:01:53 +00:00
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && dialog)
|
1999-08-31 04:39:43 +00:00
|
|
|
{
|
2000-02-01 07:14:54 +00:00
|
|
|
nsXPIDLString uniPassword;
|
2000-01-29 15:53:14 +00:00
|
|
|
nsXPIDLCString serverUri;
|
2000-05-16 21:17:55 +00:00
|
|
|
rv = GetServerURI(getter_Copies(serverUri));
|
2000-01-29 15:53:14 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-05-16 05:35:23 +00:00
|
|
|
rv = dialog->PromptPassword(aPromptTitle, aPromptMessage,
|
2001-04-10 18:30:25 +00:00
|
|
|
NS_ConvertASCIItoUCS2(serverUri).get(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
2000-05-16 05:35:23 +00:00
|
|
|
getter_Copies(uniPassword), okayValue);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-31 04:39:43 +00:00
|
|
|
|
2000-04-26 22:31:59 +00:00
|
|
|
if (!*okayValue) // if the user pressed cancel, just return NULL;
|
1999-08-31 04:39:43 +00:00
|
|
|
{
|
|
|
|
*aPassword = nsnull;
|
2001-11-21 21:55:36 +00:00
|
|
|
return NS_MSG_PASSWORD_PROMPT_CANCELLED;
|
1999-08-31 04:39:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// we got a password back...so remember it
|
2000-04-22 08:43:34 +00:00
|
|
|
nsCString aCStr; aCStr.AssignWithConversion(uniPassword);
|
1999-08-31 04:39:43 +00:00
|
|
|
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = SetPassword(aCStr.get());
|
2000-02-01 07:14:54 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-31 04:39:43 +00:00
|
|
|
} // if we got a prompt dialog
|
|
|
|
} // if the password is empty
|
|
|
|
|
2000-02-01 07:14:54 +00:00
|
|
|
rv = GetPassword(aPassword);
|
1999-08-31 04:39:43 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-24 08:26:32 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::StorePassword()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsXPIDLCString pwd;
|
|
|
|
rv = GetPassword(getter_Copies(pwd));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
2000-03-24 08:26:32 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsXPIDLCString serverSpec;
|
|
|
|
rv = GetServerURI(getter_Copies(serverSpec));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2002-01-26 00:44:18 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_NewURI(getter_AddRefs(uri), serverSpec);
|
2000-03-24 08:26:32 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
rv = observerService->NotifyObservers(uri, "login-succeeded", NS_ConvertUTF8toUCS2(pwd).get());
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
2000-03-24 08:26:32 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-02-03 05:01:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::ForgetPassword()
|
|
|
|
{
|
2002-01-26 02:37:56 +00:00
|
|
|
nsresult rv;
|
2000-02-03 05:01:42 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
2002-01-26 00:44:18 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsXPIDLCString serverSpec;
|
|
|
|
rv = GetServerURI(getter_Copies(serverSpec));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2002-01-26 00:44:18 +00:00
|
|
|
|
2002-01-26 02:37:56 +00:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_NewURI(getter_AddRefs(uri), serverSpec);
|
|
|
|
|
|
|
|
rv = observerService->NotifyObservers(uri, "login-failed", nsnull);
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
2000-02-03 05:01:42 +00:00
|
|
|
|
|
|
|
rv = SetPassword("");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-09-21 05:04:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::ForgetSessionPassword()
|
|
|
|
{
|
|
|
|
m_password.Truncate(0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-14 09:03:40 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetDefaultLocalPath(nsIFileSpec *aDefaultLocalPath)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-05-31 08:00:13 +00:00
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo;
|
|
|
|
rv = getProtocolInfo(getter_AddRefs(protocolInfo));
|
1999-09-14 09:03:40 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = protocolInfo->SetDefaultLocalPath(aDefaultLocalPath);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetLocalPath(nsIFileSpec **aLocalPath)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-09-15 00:04:47 +00:00
|
|
|
|
|
|
|
// if the local path has already been set, use it
|
1999-09-09 04:11:38 +00:00
|
|
|
rv = GetFileValue("directory", aLocalPath);
|
|
|
|
if (NS_SUCCEEDED(rv) && *aLocalPath) return rv;
|
|
|
|
|
2000-05-31 08:00:13 +00:00
|
|
|
// otherwise, create the path using the protocol info.
|
|
|
|
// note we are using the
|
2000-04-01 09:37:24 +00:00
|
|
|
// hostname, unless that directory exists.
|
|
|
|
// this should prevent all collisions.
|
2000-05-31 08:00:13 +00:00
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo;
|
|
|
|
rv = getProtocolInfo(getter_AddRefs(protocolInfo));
|
1999-09-14 00:36:37 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-09 04:11:38 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIFileSpec> path;
|
1999-09-14 00:36:37 +00:00
|
|
|
rv = protocolInfo->GetDefaultLocalPath(getter_AddRefs(path));
|
1999-09-09 04:11:38 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
path->CreateDir();
|
|
|
|
|
2000-04-01 09:37:24 +00:00
|
|
|
// set the leaf name to "dummy", and then call MakeUnique with a suggested leaf name
|
|
|
|
rv = path->AppendRelativeUnixPath("dummy");
|
1999-09-15 00:04:47 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-04-01 09:37:24 +00:00
|
|
|
nsXPIDLCString hostname;
|
|
|
|
rv = GetHostName(getter_Copies(hostname));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = path->MakeUniqueWithSuggestedName((const char *)hostname);
|
1999-09-15 00:04:47 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-04-01 09:37:24 +00:00
|
|
|
|
1999-09-15 00:04:47 +00:00
|
|
|
rv = SetLocalPath(path);
|
1999-09-09 04:11:38 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-09 21:17:32 +00:00
|
|
|
|
1999-09-09 04:11:38 +00:00
|
|
|
*aLocalPath = path;
|
|
|
|
NS_ADDREF(*aLocalPath);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetLocalPath(nsIFileSpec *spec)
|
|
|
|
{
|
|
|
|
if (spec) {
|
|
|
|
spec->CreateDir();
|
|
|
|
return SetFileValue("directory", spec);
|
|
|
|
}
|
1999-09-09 21:17:32 +00:00
|
|
|
else {
|
1999-09-14 09:03:40 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-09-09 21:17:32 +00:00
|
|
|
}
|
1999-09-09 04:11:38 +00:00
|
|
|
}
|
|
|
|
|
1999-09-22 02:21:18 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetRememberPassword(PRBool value)
|
|
|
|
{
|
2000-03-24 08:26:32 +00:00
|
|
|
if (!value) {
|
2000-02-12 00:52:53 +00:00
|
|
|
ForgetPassword();
|
2000-03-24 08:26:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-12-22 23:32:32 +00:00
|
|
|
StorePassword();
|
2000-03-24 08:26:32 +00:00
|
|
|
}
|
2000-02-16 07:43:18 +00:00
|
|
|
return SetBoolValue("remember_password", value);
|
1999-09-22 02:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetRememberPassword(PRBool* value)
|
|
|
|
{
|
2000-02-12 00:52:53 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(value);
|
|
|
|
|
2000-02-16 07:43:18 +00:00
|
|
|
return GetBoolValue("remember_password", value);
|
1999-09-22 02:21:18 +00:00
|
|
|
}
|
|
|
|
|
1999-10-28 20:22:06 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetLocalStoreType(char **aResult)
|
|
|
|
{
|
|
|
|
NS_NOTYETIMPLEMENTED("nsMsgIncomingServer superclass not implementing GetLocalStoreType!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2000-01-26 04:11:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::Equals(nsIMsgIncomingServer *server, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(server);
|
|
|
|
NS_ENSURE_ARG_POINTER(_retval);
|
|
|
|
|
|
|
|
nsXPIDLCString key1;
|
|
|
|
nsXPIDLCString key2;
|
|
|
|
|
|
|
|
rv = GetKey(getter_Copies(key1));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = server->GetKey(getter_Copies(key2));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// compare the server keys
|
|
|
|
if (PL_strcmp((const char *)key1,(const char *)key2)) {
|
2000-03-15 07:12:59 +00:00
|
|
|
#ifdef DEBUG_MSGINCOMING_SERVER
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s and %s are different, servers are not the same\n",(const char *)key1,(const char *)key2);
|
2000-03-15 07:12:59 +00:00
|
|
|
#endif /* DEBUG_MSGINCOMING_SERVER */
|
2000-01-26 04:11:14 +00:00
|
|
|
*_retval = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
2000-03-15 07:12:59 +00:00
|
|
|
#ifdef DEBUG_MSGINCOMING_SERVER
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s and %s are equal, servers are the same\n",(const char *)key1,(const char *)key2);
|
2000-03-15 07:12:59 +00:00
|
|
|
#endif /* DEBUG_MSGINCOMING_SERVER */
|
2000-01-26 04:11:14 +00:00
|
|
|
*_retval = PR_TRUE;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-02-11 00:55:54 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::ClearAllValues()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCAutoString rootPref("mail.server.");
|
|
|
|
rootPref += m_serverKey;
|
|
|
|
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->EnumerateChildren(rootPref.get(), clearPrefEnum, (void *)m_prefs);
|
2000-02-11 00:55:54 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-15 07:12:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::RemoveFiles()
|
|
|
|
{
|
2001-04-26 05:46:43 +00:00
|
|
|
// IMPORTANT, see bug #77652
|
|
|
|
// don't turn this code on yet. we don't inform the user that
|
|
|
|
// we are going to be deleting the directory, and they might have
|
|
|
|
// tweaked their localPath pref for this server to point to
|
|
|
|
// somewhere they didn't want deleted.
|
|
|
|
// until we tell them, we shouldn't do the delete.
|
2000-03-15 07:12:59 +00:00
|
|
|
#if 0
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr <nsIFileSpec> localPath;
|
|
|
|
rv = GetLocalPath(getter_AddRefs(localPath));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (!localPath) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRBool exists = PR_FALSE;
|
|
|
|
rv = localPath->Exists(&exists);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// if it doesn't exist, that's ok.
|
|
|
|
if (!exists) return NS_OK;
|
|
|
|
|
|
|
|
rv = localPath->Delete(PR_TRUE /* recursive */);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// now check if it really gone
|
|
|
|
rv = localPath->Exists(&exists);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// if it still exists, something failed.
|
|
|
|
if (exists) return NS_ERROR_FAILURE;
|
|
|
|
#endif /* 0 */
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-11 00:55:54 +00:00
|
|
|
void
|
|
|
|
nsMsgIncomingServer::clearPrefEnum(const char *aPref, void *aClosure)
|
|
|
|
{
|
|
|
|
nsIPref *prefs = (nsIPref *)aClosure;
|
|
|
|
prefs->ClearUserPref(aPref);
|
|
|
|
}
|
|
|
|
|
2000-03-28 04:58:05 +00:00
|
|
|
nsresult
|
2002-01-31 22:08:48 +00:00
|
|
|
nsMsgIncomingServer::GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aResult)
|
2000-03-28 04:58:05 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (!mFilterList) {
|
2002-01-14 22:59:02 +00:00
|
|
|
nsCOMPtr<nsIMsgFolder> msgFolder;
|
|
|
|
rv = GetRootMsgFolder(getter_AddRefs(msgFolder));
|
2000-03-28 04:58:05 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFileSpec> thisFolder;
|
|
|
|
rv = msgFolder->GetPath(getter_AddRefs(thisFolder));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-06-01 23:35:38 +00:00
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
mFilterFile = do_CreateInstance(NS_FILESPEC_CONTRACTID, &rv);
|
2000-03-28 04:58:05 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-06-01 23:35:38 +00:00
|
|
|
|
|
|
|
rv = mFilterFile->FromFileSpec(thisFolder);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mFilterFile->AppendRelativeUnixPath("rules.dat");
|
2000-03-28 04:58:05 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgFilterService> filterService =
|
|
|
|
do_GetService(kMsgFilterServiceCID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2002-01-31 22:08:48 +00:00
|
|
|
rv = filterService->OpenFilterList(mFilterFile, msgFolder, aMsgWindow, getter_AddRefs(mFilterList));
|
2000-03-28 04:58:05 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = mFilterList;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
2000-03-30 02:49:10 +00:00
|
|
|
return NS_OK;
|
2000-03-28 04:58:05 +00:00
|
|
|
|
2001-08-10 21:54:54 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 19:20:31 +00:00
|
|
|
// If the hostname contains ':' (like hostname:1431)
|
|
|
|
// then parse and set the port number.
|
2000-05-03 21:42:31 +00:00
|
|
|
nsresult
|
2001-10-09 19:20:31 +00:00
|
|
|
nsMsgIncomingServer::InternalSetHostName(const char *aHostname, const char *prefName)
|
2000-05-03 21:42:31 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2001-10-09 19:20:31 +00:00
|
|
|
if (PL_strchr(aHostname, ':'))
|
|
|
|
{
|
2000-05-03 21:42:31 +00:00
|
|
|
nsCAutoString newHostname(aHostname);
|
|
|
|
PRInt32 colonPos = newHostname.FindChar(':');
|
|
|
|
|
|
|
|
nsCAutoString portString;
|
|
|
|
newHostname.Right(portString, newHostname.Length() - colonPos);
|
|
|
|
|
|
|
|
newHostname.Truncate(colonPos);
|
|
|
|
|
|
|
|
PRInt32 err;
|
|
|
|
PRInt32 port = portString.ToInteger(&err);
|
|
|
|
if (!err) SetPort(port);
|
|
|
|
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = SetCharValue(prefName, newHostname.get());
|
2000-05-03 21:42:31 +00:00
|
|
|
}
|
2001-10-09 19:20:31 +00:00
|
|
|
else
|
|
|
|
rv = SetCharValue(prefName, aHostname);
|
2000-05-03 21:42:31 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-10-09 19:20:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::OnUserOrHostNameChanged(const char *oldName, const char *newName)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// 1. Reset password so that users are prompted for new password for the new user/host.
|
|
|
|
ForgetPassword();
|
|
|
|
|
|
|
|
// 2. Let the derived class close all cached connection to the old host.
|
|
|
|
CloseCachedConnections();
|
|
|
|
|
|
|
|
// 3. Notify any listeners for account server changes.
|
|
|
|
nsCOMPtr<nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = accountManager->NotifyServerChanged(this);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// 4. Lastly, replace all occurrences of old name in the acct name with the new one.
|
|
|
|
nsXPIDLString acctName;
|
|
|
|
rv = GetPrettyName(getter_Copies(acctName));
|
|
|
|
if (NS_SUCCEEDED(rv) && acctName)
|
|
|
|
{
|
|
|
|
nsAutoString newAcctName, oldVal, newVal;
|
|
|
|
oldVal.AssignWithConversion(oldName);
|
|
|
|
newVal.AssignWithConversion(newName);
|
|
|
|
newAcctName.Assign(acctName);
|
|
|
|
newAcctName.ReplaceSubstring(oldVal, newVal);
|
|
|
|
SetPrettyName(newAcctName.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::SetHostName(const char *aHostname)
|
|
|
|
{
|
|
|
|
return (InternalSetHostName(aHostname, "hostname"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRealHostName() is called only when the server name is changed from the
|
|
|
|
// UI (Account Settings page). No one should call it in any circumstances.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetRealHostName(const char *aHostname)
|
|
|
|
{
|
|
|
|
nsXPIDLCString oldName;
|
|
|
|
nsresult rv = GetRealHostName(getter_Copies(oldName));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = InternalSetHostName(aHostname, "realhostname");
|
|
|
|
|
|
|
|
// A few things to take care of if we're changing the hostname.
|
|
|
|
if (nsCRT::strcasecmp(aHostname, oldName.get()))
|
|
|
|
rv = OnUserOrHostNameChanged(oldName.get(), aHostname);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-05-03 21:42:31 +00:00
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::GetHostName(char **aResult)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
rv = GetCharValue("hostname", aResult);
|
|
|
|
if (PL_strchr(*aResult, ':')) {
|
|
|
|
// gack, we need to reformat the hostname - SetHostName will do that
|
|
|
|
SetHostName(*aResult);
|
|
|
|
rv = GetCharValue("hostname", aResult);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2000-02-11 00:55:54 +00:00
|
|
|
|
2001-10-09 19:20:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetRealHostName(char **aResult)
|
|
|
|
{
|
|
|
|
// If 'realhostname' is set (was changed) then use it, otherwise use 'hostname'
|
|
|
|
nsresult rv;
|
|
|
|
rv = GetCharValue("realhostname", aResult);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!*aResult || (nsCRT::strlen(*aResult) == 0))
|
|
|
|
return(GetHostName(aResult));
|
|
|
|
|
|
|
|
if (PL_strchr(*aResult, ':'))
|
|
|
|
{
|
|
|
|
SetRealHostName(*aResult);
|
|
|
|
rv = GetCharValue("realhostname", aResult);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetRealUsername(char **aResult)
|
|
|
|
{
|
|
|
|
// If 'realuserName' is set (was changed) then use it, otherwise use 'userName'
|
|
|
|
nsresult rv;
|
|
|
|
rv = GetCharValue("realuserName", aResult);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!*aResult || (nsCRT::strlen(*aResult) == 0))
|
|
|
|
return(GetUsername(aResult));
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetRealUsername(const char *aUsername)
|
|
|
|
{
|
|
|
|
// Need to take care of few things if we're changing the username.
|
|
|
|
nsXPIDLCString oldName;
|
|
|
|
nsresult rv = GetRealUsername(getter_Copies(oldName));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = SetCharValue("realuserName", aUsername);
|
|
|
|
if (nsCRT::strcasecmp(aUsername, oldName.get()))
|
|
|
|
rv = OnUserOrHostNameChanged(oldName.get(), aUsername);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-01-31 20:25:33 +00:00
|
|
|
#define BIFF_PREF_NAME "check_new_mail"
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetDoBiff(PRBool *aDoBiff)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDoBiff);
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), BIFF_PREF_NAME, fullPrefName);
|
|
|
|
rv = m_prefs->GetBoolPref(fullPrefName.get(), aDoBiff);
|
2001-01-31 20:25:33 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) return rv;
|
|
|
|
|
|
|
|
// if the pref isn't set, use the default
|
|
|
|
// value based on the protocol
|
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo;
|
|
|
|
|
|
|
|
rv = getProtocolInfo(getter_AddRefs(protocolInfo));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = protocolInfo->GetDefaultDoBiff(aDoBiff);
|
|
|
|
// note, don't call SetDoBiff()
|
|
|
|
// since we keep changing our minds on
|
|
|
|
// if biff should be on or off, let's keep the ability
|
|
|
|
// to change the default in future builds.
|
|
|
|
// if we call SetDoBiff() here, it will be in the users prefs.
|
|
|
|
// and we can't do anything after that.
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetDoBiff(PRBool aDoBiff)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCAutoString fullPrefName;
|
2001-10-29 09:27:57 +00:00
|
|
|
getPrefName(m_serverKey.get(), BIFF_PREF_NAME, fullPrefName);
|
2001-01-31 20:25:33 +00:00
|
|
|
|
2001-10-29 09:27:57 +00:00
|
|
|
rv = m_prefs->SetBoolPref(fullPrefName.get(), aDoBiff);
|
2001-01-31 20:25:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 08:00:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetPort(PRInt32 *aPort)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPort);
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetIntValue("port", aPort);
|
|
|
|
if (*aPort != PORT_NOT_SET) return rv;
|
|
|
|
|
|
|
|
// if the port isn't set, use the default
|
|
|
|
// port based on the protocol
|
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo;
|
|
|
|
|
|
|
|
rv = getProtocolInfo(getter_AddRefs(protocolInfo));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2001-03-02 02:18:15 +00:00
|
|
|
PRBool isSecure = PR_FALSE;
|
|
|
|
// Try this, and if it fails, fall back to the non-secure port
|
|
|
|
GetIsSecure(&isSecure);
|
|
|
|
return protocolInfo->GetDefaultServerPort(isSecure, aPort);
|
2000-05-31 08:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetPort(PRInt32 aPort)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2001-09-26 01:01:49 +00:00
|
|
|
|
2000-05-31 08:00:13 +00:00
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo;
|
|
|
|
rv = getProtocolInfo(getter_AddRefs(protocolInfo));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRInt32 defaultPort;
|
2000-12-09 03:03:58 +00:00
|
|
|
// First param is set to FALSE so that the non-secure
|
|
|
|
// default port is returned
|
|
|
|
rv = protocolInfo->GetDefaultServerPort(PR_FALSE, &defaultPort);
|
2000-05-31 08:00:13 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && aPort == defaultPort)
|
|
|
|
// clear it out by setting it to the default
|
|
|
|
rv = SetIntValue("port", PORT_NOT_SET);
|
|
|
|
else
|
|
|
|
rv = SetIntValue("port", aPort);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMsgIncomingServer::getProtocolInfo(nsIMsgProtocolInfo **aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsXPIDLCString type;
|
|
|
|
rv = GetType(getter_Copies(type));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCAutoString contractid(NS_MSGPROTOCOLINFO_CONTRACTID_PREFIX);
|
|
|
|
contractid.Append(type);
|
2000-05-31 08:00:13 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgProtocolInfo> protocolInfo =
|
2001-10-29 09:27:57 +00:00
|
|
|
do_GetService(contractid.get(), &rv);
|
2000-05-31 08:00:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aResult = protocolInfo;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-01 22:00:17 +00:00
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetRetentionSettings(nsIMsgRetentionSettings **settings)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(settings);
|
2001-01-05 04:40:27 +00:00
|
|
|
nsMsgRetainByPreference retainByPreference;
|
|
|
|
PRInt32 daysToKeepHdrs = 0;
|
|
|
|
PRInt32 numHeadersToKeep = 0;
|
|
|
|
PRBool keepUnreadMessagesOnly = PR_FALSE;
|
|
|
|
PRInt32 daysToKeepBodies = 0;
|
2001-03-22 14:40:35 +00:00
|
|
|
PRBool cleanupBodiesByDays = PR_FALSE;
|
2001-01-05 04:40:27 +00:00
|
|
|
nsresult rv = NS_OK;
|
2001-01-01 22:00:17 +00:00
|
|
|
if (!m_retentionSettings)
|
|
|
|
{
|
|
|
|
m_retentionSettings = do_CreateInstance(NS_MSG_RETENTIONSETTINGS_CONTRACTID);
|
2001-01-05 04:40:27 +00:00
|
|
|
if (m_retentionSettings)
|
|
|
|
{
|
|
|
|
rv = GetBoolValue("keepUnreadOnly", &keepUnreadMessagesOnly);
|
|
|
|
rv = GetIntValue("retainBy", (PRInt32*) &retainByPreference);
|
|
|
|
rv = GetIntValue("numHdrsToKeep", &numHeadersToKeep);
|
|
|
|
rv = GetIntValue("daysToKeepHdrs", &daysToKeepHdrs);
|
|
|
|
rv = GetIntValue("daysToKeepBodies", &daysToKeepBodies);
|
2001-03-22 14:40:35 +00:00
|
|
|
rv = GetBoolValue("cleanupBodies", &cleanupBodiesByDays);
|
2001-01-05 04:40:27 +00:00
|
|
|
m_retentionSettings->SetRetainByPreference(retainByPreference);
|
|
|
|
m_retentionSettings->SetNumHeadersToKeep((PRUint32) numHeadersToKeep);
|
|
|
|
m_retentionSettings->SetKeepUnreadMessagesOnly(keepUnreadMessagesOnly);
|
|
|
|
m_retentionSettings->SetDaysToKeepBodies(daysToKeepBodies);
|
|
|
|
m_retentionSettings->SetDaysToKeepHdrs(daysToKeepHdrs);
|
2001-03-22 14:40:35 +00:00
|
|
|
m_retentionSettings->SetCleanupBodiesByDays(cleanupBodiesByDays);
|
2001-01-05 04:40:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2001-01-01 22:00:17 +00:00
|
|
|
// Create an empty retention settings object,
|
|
|
|
// get the settings from the server prefs, and init the object from the prefs.
|
|
|
|
}
|
|
|
|
*settings = m_retentionSettings;
|
2001-01-05 04:40:27 +00:00
|
|
|
NS_IF_ADDREF(*settings); return rv;
|
2001-01-01 22:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetRetentionSettings(nsIMsgRetentionSettings *settings)
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
nsMsgRetainByPreference retainByPreference;
|
|
|
|
PRUint32 daysToKeepHdrs = 0;
|
|
|
|
PRUint32 numHeadersToKeep = 0;
|
|
|
|
PRBool keepUnreadMessagesOnly = PR_FALSE;
|
|
|
|
PRUint32 daysToKeepBodies = 0;
|
2001-03-22 14:40:35 +00:00
|
|
|
PRBool cleanupBodiesByDays = PR_FALSE;
|
2001-01-01 22:00:17 +00:00
|
|
|
m_retentionSettings = settings;
|
2001-03-17 01:59:34 +00:00
|
|
|
m_retentionSettings->GetRetainByPreference(&retainByPreference);
|
|
|
|
m_retentionSettings->GetNumHeadersToKeep(&numHeadersToKeep);
|
|
|
|
m_retentionSettings->GetKeepUnreadMessagesOnly(&keepUnreadMessagesOnly);
|
|
|
|
m_retentionSettings->GetDaysToKeepBodies(&daysToKeepBodies);
|
|
|
|
m_retentionSettings->GetDaysToKeepHdrs(&daysToKeepHdrs);
|
2001-03-22 14:40:35 +00:00
|
|
|
m_retentionSettings->GetCleanupBodiesByDays(&cleanupBodiesByDays);
|
2001-03-17 01:59:34 +00:00
|
|
|
nsresult rv = SetBoolValue("keepUnreadOnly", keepUnreadMessagesOnly);
|
|
|
|
rv = SetIntValue("retainBy", retainByPreference);
|
|
|
|
rv = SetIntValue("numHdrsToKeep", numHeadersToKeep);
|
|
|
|
rv = SetIntValue("daysToKeepHdrs", daysToKeepHdrs);
|
|
|
|
rv = SetIntValue("daysToKeepBodies", daysToKeepBodies);
|
2001-03-22 14:40:35 +00:00
|
|
|
rv = SetBoolValue("cleanupBodies", cleanupBodiesByDays);
|
2001-03-17 01:59:34 +00:00
|
|
|
return rv;
|
2001-01-01 22:00:17 +00:00
|
|
|
}
|
2001-03-14 02:32:04 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetDisplayStartupPage(PRBool *displayStartupPage)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(displayStartupPage);
|
|
|
|
*displayStartupPage = m_displayStartupPage;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetDisplayStartupPage(PRBool displayStartupPage)
|
|
|
|
{
|
|
|
|
m_displayStartupPage = displayStartupPage;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-01-01 22:00:17 +00:00
|
|
|
|
2001-03-17 01:59:34 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetDownloadSettings(nsIMsgDownloadSettings **settings)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(settings);
|
|
|
|
PRBool downloadUnreadOnly = PR_FALSE;
|
|
|
|
PRBool downloadByDate = PR_FALSE;
|
|
|
|
PRUint32 ageLimitOfMsgsToDownload = 0;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (!m_downloadSettings)
|
|
|
|
{
|
|
|
|
m_downloadSettings = do_CreateInstance(NS_MSG_DOWNLOADSETTINGS_CONTRACTID);
|
|
|
|
if (m_downloadSettings)
|
|
|
|
{
|
|
|
|
rv = GetBoolValue("downloadUnreadOnly", &downloadUnreadOnly);
|
|
|
|
rv = GetBoolValue("downloadByDate", &downloadByDate);
|
|
|
|
rv = GetIntValue("ageLimit", (PRInt32 *) &ageLimitOfMsgsToDownload);
|
|
|
|
m_downloadSettings->SetDownloadUnreadOnly(downloadUnreadOnly);
|
|
|
|
m_downloadSettings->SetDownloadByDate(downloadByDate);
|
|
|
|
m_downloadSettings->SetAgeLimitOfMsgsToDownload(ageLimitOfMsgsToDownload);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
// Create an empty download settings object,
|
|
|
|
// get the settings from the server prefs, and init the object from the prefs.
|
|
|
|
}
|
|
|
|
*settings = m_downloadSettings;
|
|
|
|
NS_IF_ADDREF(*settings); return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetDownloadSettings(nsIMsgDownloadSettings *settings)
|
|
|
|
{
|
|
|
|
m_downloadSettings = settings;
|
|
|
|
PRBool downloadUnreadOnly = PR_FALSE;
|
|
|
|
PRBool downloadByDate = PR_FALSE;
|
|
|
|
PRUint32 ageLimitOfMsgsToDownload = 0;
|
|
|
|
m_downloadSettings->GetDownloadUnreadOnly(&downloadUnreadOnly);
|
|
|
|
m_downloadSettings->GetDownloadByDate(&downloadByDate);
|
|
|
|
m_downloadSettings->GetAgeLimitOfMsgsToDownload(&ageLimitOfMsgsToDownload);
|
|
|
|
nsresult rv = SetBoolValue("downloadUnreadOnly", downloadUnreadOnly);
|
|
|
|
rv = SetBoolValue("downloadByDate", downloadByDate);
|
|
|
|
rv = SetIntValue("ageLimit", ageLimitOfMsgsToDownload);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-06-16 07:20:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetSupportsDiskSpace(PRBool *aSupportsDiskSpace)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSupportsDiskSpace);
|
|
|
|
*aSupportsDiskSpace = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-19 01:38:51 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSupportLevel);
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetIntValue("offline_support_level", aSupportLevel);
|
|
|
|
if (*aSupportLevel != OFFLINE_SUPPORT_LEVEL_UNDEFINED) return rv;
|
|
|
|
|
|
|
|
// set default value
|
|
|
|
*aSupportLevel = OFFLINE_SUPPORT_LEVEL_NONE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::SetOfflineSupportLevel(PRInt32 aSupportLevel)
|
|
|
|
{
|
|
|
|
SetIntValue("offline_support_level", aSupportLevel);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-01-13 15:31:30 +00:00
|
|
|
#define BASE_MSGS_URL "chrome://messenger/locale/messenger.properties"
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::DisplayOfflineMsg(nsIMsgWindow *aMsgWindow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
2001-04-27 21:30:24 +00:00
|
|
|
rv = bundleService->CreateBundle(BASE_MSGS_URL, getter_AddRefs(bundle));
|
2001-01-13 15:31:30 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (bundle)
|
|
|
|
{
|
|
|
|
nsXPIDLString errorMsgTitle;
|
|
|
|
nsXPIDLString errorMsgBody;
|
|
|
|
|
2001-03-08 08:05:05 +00:00
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodybody").get(), getter_Copies(errorMsgBody));
|
|
|
|
bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodytitle").get(), getter_Copies(errorMsgTitle));
|
2001-01-13 15:31:30 +00:00
|
|
|
if (aMsgWindow)
|
|
|
|
return aMsgWindow->DisplayHTMLInMessagePane(errorMsgTitle, errorMsgBody);
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2001-01-01 22:00:17 +00:00
|
|
|
|
2001-06-20 06:13:27 +00:00
|
|
|
// Called only during the migration process. A unique name is generated for the
|
|
|
|
// migrated account.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GeneratePrettyNameForMigration(PRUnichar **aPrettyName)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 4.x had provisions for multiple imap servers to be maintained under
|
|
|
|
* single identity. So, when migrated each of those server accounts need
|
|
|
|
* to be represented by unique account name. nsImapIncomingServer will
|
|
|
|
* override the implementation for this to do the right thing.
|
|
|
|
*/
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2001-07-06 21:16:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetFilterScope(nsMsgSearchScopeValue *filterScope)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(filterScope);
|
|
|
|
|
|
|
|
*filterScope = nsMsgSearchScope::offlineMail;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgIncomingServer::GetSearchScope(nsMsgSearchScopeValue *searchScope)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(searchScope);
|
|
|
|
|
|
|
|
*searchScope = nsMsgSearchScope::offlineMail;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-10 20:55:30 +00:00
|
|
|
// use the convenience macros to implement the accessors
|
1999-05-27 05:36:10 +00:00
|
|
|
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Username, "userName");
|
1999-08-31 04:39:43 +00:00
|
|
|
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, PrefPassword, "password");
|
2000-01-19 01:16:35 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, IsSecure, "isSecure");
|
1999-04-10 20:55:30 +00:00
|
|
|
NS_IMPL_SERVERPREF_INT(nsMsgIncomingServer, BiffMinutes, "check_time");
|
1999-07-13 19:23:40 +00:00
|
|
|
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Type, "type");
|
2000-01-11 20:03:51 +00:00
|
|
|
// in 4.x, this was "mail.pop3_gets_new_mail" for pop and
|
|
|
|
// "mail.imap.new_mail_get_headers" for imap (it was global)
|
|
|
|
// in 5.0, this will be per server, and it will be "download_on_biff"
|
1999-04-16 00:36:52 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, DownloadOnBiff, "download_on_biff");
|
2000-01-15 03:06:39 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, Valid, "valid");
|
2000-02-15 06:57:45 +00:00
|
|
|
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, RedirectorType, "redirector_type");
|
2000-05-15 14:55:22 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, EmptyTrashOnExit,
|
|
|
|
"empty_trash_on_exit");
|
2000-12-22 23:32:32 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, CanDelete, "canDelete");
|
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, LoginAtStartUp, "login_at_startup");
|
2001-06-23 21:11:52 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer,
|
|
|
|
DefaultCopiesAndFoldersPrefsToServer,
|
|
|
|
"allows_specialfolders_usage");
|
2001-02-03 17:43:24 +00:00
|
|
|
|
2001-06-29 07:04:38 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer,
|
|
|
|
CanCreateFoldersOnServer,
|
|
|
|
"canCreateFolders");
|
|
|
|
|
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer,
|
|
|
|
CanFileMessagesOnServer,
|
|
|
|
"canFileMessages");
|
|
|
|
|
2001-03-25 18:48:27 +00:00
|
|
|
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer,
|
|
|
|
LimitOfflineMessageSize,
|
|
|
|
"limit_offline_message_size")
|
|
|
|
|
2001-02-03 17:43:24 +00:00
|
|
|
NS_IMPL_SERVERPREF_INT(nsMsgIncomingServer, MaxMessageSize, "max_size")
|
2001-10-31 03:45:24 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetUnicharAttribute(const char *aName, const PRUnichar *val)
|
|
|
|
{
|
|
|
|
return SetUnicharValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetUnicharAttribute(const char *aName, PRUnichar **val)
|
|
|
|
{
|
|
|
|
return GetUnicharValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetCharAttribute(const char *aName, const char *val)
|
|
|
|
{
|
|
|
|
return SetCharValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetCharAttribute(const char *aName, char **val)
|
|
|
|
{
|
|
|
|
return GetCharValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetBoolAttribute(const char *aName, PRBool val)
|
|
|
|
{
|
|
|
|
return SetBoolValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetBoolAttribute(const char *aName, PRBool *val)
|
|
|
|
{
|
|
|
|
return GetBoolValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::SetIntAttribute(const char *aName, PRInt32 val)
|
|
|
|
{
|
|
|
|
return SetIntValue(aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgIncomingServer::GetIntAttribute(const char *aName, PRInt32 *val)
|
|
|
|
{
|
|
|
|
return GetIntValue(aName, val);
|
|
|
|
}
|