cleanup dead/unused pop3/local code, r/sr=sspitzer 181805

This commit is contained in:
bienvenu%netscape.com 2002-11-25 23:28:01 +00:00
parent 0fd0d8b99b
commit b364539585
6 changed files with 574 additions and 651 deletions

View File

@ -68,15 +68,4 @@ interface nsIMailboxService : nsISupports {
in nsIStreamListener aMailboxParser,
in nsIUrlListener aUrlListener);
/*
* This is more of a convience function for testing purposes. We want
* to able to say: display message number 'n' in this mailbox without
* having to go out and get the key for message number 'n'. this
* function simply makes that possible.
*/
nsIURI DisplayMessageNumber(in string url,
in unsigned long aMessageNumber,
in nsISupports aDisplayConsumer,
in nsIUrlListener aUrlListener);
};

View File

@ -319,17 +319,6 @@ NS_IMETHODIMP nsMailboxService::GetUrlForUri(const char *aMessageURI, nsIURI **a
return rv;
}
nsresult nsMailboxService::DisplayMessageNumber(const char *url,
PRUint32 aMessageNumber,
nsISupports * aDisplayConsumer,
nsIUrlListener * aUrlListener,
nsIURI ** aURL)
{
// mscott - this function is no longer supported...
NS_ASSERTION(0, "deprecated method");
return NS_OK;
}
// Takes a mailbox url, this method creates a protocol instance and loads the url
// into the protocol instance.
nsresult nsMailboxService::RunMailboxUrl(nsIURI * aMailboxUrl, nsISupports * aDisplayConsumer)
@ -359,65 +348,65 @@ nsresult nsMailboxService::RunMailboxUrl(nsIURI * aMailboxUrl, nsISupports * aDi
// listener if appropriate. AND it can take in a mailbox action and set that field
// on the returned url as well.
nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsIUrlListener * aUrlListener,
nsMailboxAction aMailboxAction, nsIMailboxUrl ** aMailboxUrl,
nsIMsgWindow *msgWindow)
nsMailboxAction aMailboxAction, nsIMailboxUrl ** aMailboxUrl,
nsIMsgWindow *msgWindow)
{
nsresult rv = NS_OK;
rv = nsComponentManager::CreateInstance(kCMailboxUrl,
nsnull,
NS_GET_IID(nsIMailboxUrl),
(void **) aMailboxUrl);
if (NS_SUCCEEDED(rv) && aMailboxUrl && *aMailboxUrl)
{
// okay now generate the url string
char * urlSpec;
nsCAutoString folderURI;
nsFileSpec folderPath;
nsMsgKey msgKey;
nsresult rv = NS_OK;
rv = nsComponentManager::CreateInstance(kCMailboxUrl,
nsnull,
NS_GET_IID(nsIMailboxUrl),
(void **) aMailboxUrl);
if (NS_SUCCEEDED(rv) && aMailboxUrl && *aMailboxUrl)
{
// okay now generate the url string
char * urlSpec;
nsCAutoString folderURI;
nsFileSpec folderPath;
nsMsgKey msgKey;
const char *part = PL_strstr(aSrcMsgMailboxURI, "part=");
rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
NS_ENSURE_SUCCESS(rv,rv);
rv = nsLocalURI2Path(kMailboxRootURI, folderURI.get(), folderPath);
if (NS_SUCCEEDED(rv))
{
// set up the url spec and initialize the url with it.
nsFilePath filePath(folderPath); // convert to file url representation...
nsXPIDLCString escapedFilePath;
*((char**)getter_Copies(escapedFilePath)) =
nsEscape(filePath, url_Path);
rv = nsLocalURI2Path(kMailboxRootURI, folderURI.get(), folderPath);
if (NS_SUCCEEDED(rv))
{
// set up the url spec and initialize the url with it.
nsFilePath filePath(folderPath); // convert to file url representation...
nsXPIDLCString escapedFilePath;
*((char**)getter_Copies(escapedFilePath)) =
nsEscape(filePath, url_Path);
// we're not using the escapedFilePath at this point because it doesn't work.
if (mPrintingOperation)
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) filePath, msgKey);
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) filePath, msgKey);
else if (part)
urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", (const char *)
filePath, msgKey, part);
urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", (const char *)
filePath, msgKey, part);
else
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) filePath, msgKey);
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
url->SetSpec(nsDependentCString(urlSpec));
PR_FREEIF(urlSpec);
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) filePath, msgKey);
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
url->SetSpec(nsDependentCString(urlSpec));
PR_Free(urlSpec);
(*aMailboxUrl)->SetMailboxAction(aMailboxAction);
// set up the url listener
if (aUrlListener)
rv = url->RegisterListener(aUrlListener);
url->SetMsgWindow(msgWindow);
// set up the url listener
if (aUrlListener)
rv = url->RegisterListener(aUrlListener);
url->SetMsgWindow(msgWindow);
nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(url);
if (msgUrl)
{
msgUrl->SetOriginalSpec(aSrcMsgMailboxURI);
msgUrl->SetUri(aSrcMsgMailboxURI);
}
} // if we got a url
} // if we got a url
return rv;
} // if we got a url
} // if we got a url
return rv;
}
NS_IMETHODIMP nsMailboxService::GetScheme(nsACString &aScheme)

View File

@ -255,13 +255,12 @@ NS_IMETHODIMP nsPop3IncomingServer::CreateDefaultMailboxes(nsIFileSpec *path)
NS_IMETHODIMP nsPop3IncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener, nsIMsgFolder *inbox, nsIURI **aResult)
{
nsresult rv;
nsresult rv;
nsCOMPtr<nsIPop3Service> pop3Service = do_GetService(kCPop3ServiceCID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIPop3Service> pop3Service = do_GetService(kCPop3ServiceCID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = pop3Service->GetNewMail(aMsgWindow, aUrlListener, inbox, this, aResult);
return rv;
return pop3Service->GetNewMail(aMsgWindow, aUrlListener, inbox, this, aResult);
}
NS_IMETHODIMP

File diff suppressed because it is too large Load Diff

View File

@ -85,125 +85,80 @@ NS_IMPL_ISUPPORTS3(nsPop3Service,
nsIMsgProtocolInfo)
NS_IMETHODIMP nsPop3Service::CheckForNewMail(nsIMsgWindow* aMsgWindow,
nsIUrlListener * aUrlListener,
nsIMsgFolder *inbox,
nsIPop3IncomingServer *popServer,
nsIURI ** aURL)
nsIUrlListener * aUrlListener,
nsIMsgFolder *aInbox,
nsIPop3IncomingServer *aPopServer,
nsIURI ** aURL)
{
nsresult rv = NS_OK;
nsXPIDLCString popHost;
nsXPIDLCString popUser;
PRInt32 popPort = -1;
nsCOMPtr<nsIMsgIncomingServer> server;
nsCOMPtr<nsIURI> url;
server = do_QueryInterface(popServer);
if (!server) return NS_MSG_INVALID_OR_MISSING_SERVER;
rv = server->GetHostName(getter_Copies(popHost));
if (NS_FAILED(rv)) return rv;
if (!((const char *)popHost)) return NS_MSG_INVALID_OR_MISSING_SERVER;
rv = server->GetPort(&popPort);
if (NS_FAILED(rv)) return rv;
rv = server->GetUsername(getter_Copies(popUser));
if (NS_FAILED(rv)) return rv;
if (!((const char *)popUser)) return NS_MSG_SERVER_USERNAME_MISSING;
nsXPIDLCString escapedUsername;
*((char**)getter_Copies(escapedUsername)) =
nsEscape(popUser, url_XAlphas);
if (NS_SUCCEEDED(rv) && popServer)
{
// now construct a pop3 url...
// we need to escape the username because it may contain
// characters like / % or @
char * urlSpec = PR_smprintf("pop3://%s@%s:%d/?check", (const char *)escapedUsername, (const char *)popHost, popPort);
rv = BuildPop3Url(urlSpec, inbox, popServer, aUrlListener, getter_AddRefs(url), aMsgWindow);
PR_Free(urlSpec);
}
if (NS_SUCCEEDED(rv) && url)
rv = RunPopUrl(server, url);
if (aURL && url) // we already have a ref count on pop3url...
{
*aURL = url; // transfer ref count to the caller...
NS_IF_ADDREF(*aURL);
}
return rv;
return GetMail(PR_FALSE /* don't download, just check */, aMsgWindow, aUrlListener, aInbox, aPopServer, aURL);
}
nsresult nsPop3Service::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlListener * aUrlListener,
nsIMsgFolder *aInbox,
nsIPop3IncomingServer *popServer,
nsIMsgFolder *aInbox,
nsIPop3IncomingServer *aPopServer,
nsIURI ** aURL)
{
nsresult rv = NS_OK;
nsXPIDLCString popHost;
nsXPIDLCString popUser;
PRInt32 popPort;
nsCOMPtr<nsIURI> url;
return GetMail(PR_TRUE /* download */, aMsgWindow, aUrlListener, aInbox, aPopServer, aURL);
}
nsCOMPtr<nsIMsgIncomingServer> server;
server = do_QueryInterface(popServer);
nsresult nsPop3Service::GetMail(PRBool downloadNewMail,
nsIMsgWindow* aMsgWindow,
nsIUrlListener * aUrlListener,
nsIMsgFolder *aInbox,
nsIPop3IncomingServer *aPopServer,
nsIURI ** aURL)
{
if (!server) return NS_MSG_INVALID_OR_MISSING_SERVER;
rv = server->GetHostName(getter_Copies(popHost));
if (NS_FAILED(rv)) return rv;
if (!((const char *)popHost)) return NS_MSG_INVALID_OR_MISSING_SERVER;
rv = server->GetPort(&popPort);
if (NS_FAILED(rv)) return rv;
rv = server->GetUsername(getter_Copies(popUser));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString escapedUsername;
*((char **)getter_Copies(escapedUsername)) =
nsEscape(popUser, url_XAlphas);
if (NS_FAILED(rv)) return rv;
if (!((const char *)popUser)) return NS_MSG_SERVER_USERNAME_MISSING;
if (NS_SUCCEEDED(rv) && popServer )
{
// now construct a pop3 url...
// we need to escape the username because it may contain
// characters like / % or @
char * urlSpec = PR_smprintf("pop3://%s@%s:%d", (const char *)escapedUsername, (const char *)popHost, popPort);
if (aInbox)
{
rv = BuildPop3Url(urlSpec, aInbox, popServer, aUrlListener, getter_AddRefs(url), aMsgWindow);
}
PR_Free(urlSpec);
}
if (NS_SUCCEEDED(rv) && url)
{
nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(url);
if (mailNewsUrl)
mailNewsUrl->SetMsgWindow(aMsgWindow);
rv = RunPopUrl(server, url);
}
if (aURL && url) // we already have a ref count on pop3url...
{
*aURL = url; // transfer ref count to the caller...
NS_IF_ADDREF(*aURL);
}
return rv;
NS_ENSURE_ARG_POINTER(aInbox);
nsXPIDLCString popHost;
nsXPIDLCString popUser;
PRInt32 popPort = -1;
nsCOMPtr<nsIMsgIncomingServer> server;
nsCOMPtr<nsIURI> url;
server = do_QueryInterface(aPopServer);
if (!server)
return NS_MSG_INVALID_OR_MISSING_SERVER;
nsresult rv = server->GetHostName(getter_Copies(popHost));
NS_ENSURE_SUCCESS(rv, rv);
if (!((const char *)popHost))
return NS_MSG_INVALID_OR_MISSING_SERVER;
rv = server->GetPort(&popPort);
NS_ENSURE_SUCCESS(rv, rv);
rv = server->GetUsername(getter_Copies(popUser));
NS_ENSURE_SUCCESS(rv, rv);
if (!((const char *)popUser))
return NS_MSG_SERVER_USERNAME_MISSING;
nsXPIDLCString escapedUsername;
*((char**)getter_Copies(escapedUsername)) = nsEscape(popUser, url_XAlphas);
if (NS_SUCCEEDED(rv) && aPopServer)
{
// now construct a pop3 url...
// we need to escape the username because it may contain
// characters like / % or @
char * urlSpec = (downloadNewMail)
? PR_smprintf("pop3://%s@%s:%d", (const char *)escapedUsername, (const char *)popHost, popPort)
: PR_smprintf("pop3://%s@%s:%d/?check", (const char *)escapedUsername, (const char *)popHost, popPort);
rv = BuildPop3Url(urlSpec, aInbox, aPopServer, aUrlListener, getter_AddRefs(url), aMsgWindow);
PR_Free(urlSpec);
}
if (NS_SUCCEEDED(rv) && url)
rv = RunPopUrl(server, url);
if (aURL && url) // we already have a ref count on pop3url...
NS_IF_ADDREF(*aURL = url);
return rv;
}
nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
@ -247,56 +202,56 @@ nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer * aServer, nsIURI * aUrlToRun)
{
nsresult rv = NS_OK;
if (aServer && aUrlToRun)
{
nsXPIDLCString userName;
// load up required server information
// we store the username unescaped in the server
// so there is no need to unescape it
nsresult rv = NS_OK;
if (aServer && aUrlToRun)
{
nsXPIDLCString userName;
// load up required server information
// we store the username unescaped in the server
// so there is no need to unescape it
rv = aServer->GetRealUsername(getter_Copies(userName));
// find out if the server is busy or not...if the server is busy, we are
// *NOT* going to run the url
PRBool serverBusy = PR_FALSE;
rv = aServer->GetServerBusy(&serverBusy);
if (!serverBusy)
{
nsPop3Protocol * protocol = new nsPop3Protocol(aUrlToRun);
if (protocol)
{
NS_ADDREF(protocol);
rv = protocol->Initialize(aUrlToRun);
if(NS_FAILED(rv))
{
delete protocol;
return rv;
}
// the protocol stores the unescaped username, so there is no need to escape it.
protocol->SetUsername(userName);
rv = protocol->LoadUrl(aUrlToRun);
NS_RELEASE(protocol);
}
}
} // if server
return rv;
// find out if the server is busy or not...if the server is busy, we are
// *NOT* going to run the url
PRBool serverBusy = PR_FALSE;
rv = aServer->GetServerBusy(&serverBusy);
if (!serverBusy)
{
nsPop3Protocol * protocol = new nsPop3Protocol(aUrlToRun);
if (protocol)
{
NS_ADDREF(protocol);
rv = protocol->Initialize(aUrlToRun);
if(NS_FAILED(rv))
{
delete protocol;
return rv;
}
// the protocol stores the unescaped username, so there is no need to escape it.
protocol->SetUsername(userName);
rv = protocol->LoadUrl(aUrlToRun);
NS_RELEASE(protocol);
}
}
} // if server
return rv;
}
NS_IMETHODIMP nsPop3Service::GetScheme(nsACString &aScheme)
{
aScheme = "pop3";
return NS_OK;
aScheme = "pop3";
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::GetDefaultPort(PRInt32 *aDefaultPort)
{
NS_ENSURE_ARG_POINTER(aDefaultPort);
*aDefaultPort = POP3_PORT;
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
@ -333,7 +288,7 @@ NS_IMETHODIMP nsPop3Service::NewURI(const nsACString &aSpec,
if (offset != -1)
folderUri.Truncate(offset);
nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
rv = rdfService->GetResource(folderUri.get(),
getter_AddRefs(resource));
@ -405,35 +360,35 @@ NS_IMETHODIMP nsPop3Service::NewURI(const nsACString &aSpec,
NS_IMETHODIMP nsPop3Service::NewChannel(nsIURI *aURI, nsIChannel **_retval)
{
nsresult rv = NS_OK;
nsPop3Protocol * protocol = new nsPop3Protocol(aURI);
if (protocol)
{
rv = protocol->Initialize(aURI);
if (NS_FAILED(rv))
{
delete protocol;
return rv;
}
nsCAutoString username;
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(aURI, &rv);
if (NS_SUCCEEDED(rv) && url)
{
// GetUsername() returns an escaped username, and the protocol
// stores the username unescaped, so we must unescape the username.
// XXX this is of course very risky since the unescaped string may
// contain embedded nulls as well as characters from some unknown
// charset!!
url->GetUsername(username);
NS_UnescapeURL(username);
protocol->SetUsername(username.get());
}
rv = protocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
nsresult rv = NS_OK;
nsPop3Protocol * protocol = new nsPop3Protocol(aURI);
if (protocol)
{
rv = protocol->Initialize(aURI);
if (NS_FAILED(rv))
{
delete protocol;
return rv;
}
nsCAutoString username;
nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(aURI, &rv);
if (NS_SUCCEEDED(rv) && url)
{
// GetUsername() returns an escaped username, and the protocol
// stores the username unescaped, so we must unescape the username.
// XXX this is of course very risky since the unescaped string may
// contain embedded nulls as well as characters from some unknown
// charset!!
url->GetUsername(username);
NS_UnescapeURL(username);
protocol->SetUsername(username.get());
}
rv = protocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
}
else
rv = NS_ERROR_NULL_POINTER;
return rv;
}

View File

@ -64,6 +64,12 @@ public:
NS_DECL_NSIMSGPROTOCOLINFO
protected:
nsresult GetMail(PRBool downloadNewMail,
nsIMsgWindow* aMsgWindow,
nsIUrlListener * aUrlListener,
nsIMsgFolder *inbox,
nsIPop3IncomingServer *popServer,
nsIURI ** aURL);
// convience function to make constructing of the pop3 url easier...
nsresult BuildPop3Url(const char * urlSpec, nsIMsgFolder *inbox,
nsIPop3IncomingServer *, nsIUrlListener * aUrlListener,