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 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 (NS_FAILED(rv)) aServer->SetServerBusy(PR_FALSE); } } else { nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(aUrlToRun); if (url) AlertServerBusy(url); rv = NS_ERROR_FAILURE; } } // if server return rv; }
NS_IMETHODIMP nsPop3Service::NewChannel(nsIURI *aURI, nsIChannel **_retval) { NS_ENSURE_ARG_POINTER(aURI); nsresult rv = NS_OK; nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(aURI, &rv); nsXPIDLCString realUserName; if (NS_SUCCEEDED(rv) && url) { nsCOMPtr <nsIMsgIncomingServer> server; url->GetServer(getter_AddRefs(server)); if (server) { // find out if the server is busy or not...if the server is busy, we are // *NOT* going to run the url. The error code isn't quite right... // We might want to put up an error right here. PRBool serverBusy = PR_FALSE; rv = server->GetServerBusy(&serverBusy); if (serverBusy) { AlertServerBusy(url); return NS_MSG_FOLDER_BUSY; } server->GetRealUsername(getter_Copies(realUserName)); } } nsPop3Protocol * protocol = new nsPop3Protocol(aURI); if (protocol) { rv = protocol->Initialize(aURI); if (NS_FAILED(rv)) { delete protocol; return rv; } protocol->SetUsername(realUserName.get()); rv = protocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval); } else rv = NS_ERROR_NULL_POINTER; return rv; }
nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer *aServer, nsIURI *aUrlToRun) { NS_ENSURE_ARG_POINTER(aServer); NS_ENSURE_ARG_POINTER(aUrlToRun); nsCString userName; // load up required server information // we store the username unescaped in the server // so there is no need to unescape it nsresult rv = aServer->GetRealUsername(userName); // find out if the server is busy or not...if the server is busy, we are // *NOT* going to run the url bool serverBusy = false; rv = aServer->GetServerBusy(&serverBusy); if (!serverBusy) { nsRefPtr<nsPop3Protocol> protocol = new nsPop3Protocol(aUrlToRun); if (protocol) { // the protocol stores the unescaped username, so there is no need to escape it. protocol->SetUsername(userName.get()); rv = protocol->LoadUrl(aUrlToRun); if (NS_FAILED(rv)) aServer->SetServerBusy(false); } } else { nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(aUrlToRun); if (url) AlertServerBusy(url); rv = NS_ERROR_FAILURE; } return rv; }
NS_IMETHODIMP nsPop3Service::NewChannel(nsIURI *aURI, nsIChannel **_retval) { NS_ENSURE_ARG_POINTER(aURI); nsresult rv; nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(aURI, &rv); nsCString realUserName; if (NS_SUCCEEDED(rv) && url) { nsCOMPtr<nsIMsgIncomingServer> server; url->GetServer(getter_AddRefs(server)); if (server) { // find out if the server is busy or not...if the server is busy, we are // *NOT* going to run the url. The error code isn't quite right... // We might want to put up an error right here. bool serverBusy = false; rv = server->GetServerBusy(&serverBusy); if (serverBusy) { AlertServerBusy(url); return NS_MSG_FOLDER_BUSY; } server->GetRealUsername(realUserName); } } nsRefPtr<nsPop3Protocol> protocol = new nsPop3Protocol(aURI); NS_ENSURE_TRUE(protocol, NS_ERROR_OUT_OF_MEMORY); rv = protocol->Initialize(aURI); NS_ENSURE_SUCCESS(rv, rv); protocol->SetUsername(realUserName.get()); return CallQueryInterface(protocol, _retval); }