зеркало из https://github.com/mozilla/pjs.git
[OS/2] Bug 390075: real build break fix to exthandler OS/2 code, r=wuno, sr=mkaply
This commit is contained in:
Родитель
4a73275d4e
Коммит
c999c04d96
|
@ -40,6 +40,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMIMEInfoOS2.h"
|
||||
#include "nsOSHelperAppService.h"
|
||||
#include "nsExternalHelperAppService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -151,18 +152,15 @@ NS_IMETHODIMP nsMIMEInfoOS2::LaunchWithURI(nsIURI* aURI,
|
|||
return process->Run(PR_FALSE, &strPath, 1, &pid);
|
||||
}
|
||||
|
||||
nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI * aURL)
|
||||
nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI* aURL)
|
||||
{
|
||||
// XXX this is just a build break fix, functionality is broken, see bug 390075
|
||||
#warning nsMIMEInfoOS2::LoadUriInternal is dysfunctional!
|
||||
// LOG(("-- nsOSHelperAppService::LoadUriInternal\n"));
|
||||
nsCOMPtr<nsIPref> thePrefsService(do_GetService(NS_PREF_CONTRACTID));
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (!thePrefsService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* Convert SimpleURI to StandardURL */
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -177,20 +175,24 @@ nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI * aURL)
|
|||
|
||||
nsCAutoString prefName;
|
||||
prefName = NS_LITERAL_CSTRING("applications.") + uProtocol;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
|
||||
nsXPIDLCString prefString;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
|
||||
}
|
||||
|
||||
nsCAutoString applicationName;
|
||||
nsCAutoString parameters;
|
||||
|
||||
rv = thePrefsService->CopyCharPref(prefName.get(), getter_Copies(prefString));
|
||||
if (NS_FAILED(rv) || prefString.IsEmpty()) {
|
||||
char szAppFromINI[CCHMAXPATH];
|
||||
char szParamsFromINI[MAXINIPARAMLENGTH];
|
||||
/* did OS2.INI contain application? */
|
||||
// XXX this is just a build break fix, functionality is broken, see bug 390075
|
||||
// rv = GetApplicationAndParametersFromINI(uProtocol,
|
||||
// szAppFromINI, sizeof(szAppFromINI),
|
||||
// szParamsFromINI, sizeof(szParamsFromINI));
|
||||
rv = GetApplicationAndParametersFromINI(uProtocol,
|
||||
szAppFromINI, sizeof(szAppFromINI),
|
||||
szParamsFromINI, sizeof(szParamsFromINI));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
applicationName = szAppFromINI;
|
||||
parameters = szParamsFromINI;
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
|
||||
#include "nsMIMEInfoImpl.h"
|
||||
|
||||
#include "nsIPref.h" // XX Need to convert Handler code to new pref stuff
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
|
@ -49,11 +50,6 @@
|
|||
#define INCL_WINSHELLDATA
|
||||
#include <os2.h>
|
||||
|
||||
#define MAXINIPARAMLENGTH 1024 // max length of OS/2 INI key for application parameters
|
||||
|
||||
#define LOG(args) PR_LOG(mLog, PR_LOG_DEBUG, args)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(mLog, PR_LOG_DEBUG)
|
||||
|
||||
class nsMIMEInfoOS2 : public nsMIMEInfoImpl
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -50,8 +50,6 @@
|
|||
#include "nsILineInputStream.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIProcess.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsHashtable.h"
|
||||
|
@ -1126,105 +1124,6 @@ nsOSHelperAppService::GetHandlerAndDescriptionFromMailcapFile(const nsAString& a
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Check OS/2 INI for application and parameters for the protocol
|
||||
// return NS_OK, if application exists for protocol in INI and is not empty
|
||||
nsresult
|
||||
nsOSHelperAppService::GetApplicationAndParametersFromINI(const nsACString& aProtocol,
|
||||
char * app, ULONG appLength,
|
||||
char * param, ULONG paramLength)
|
||||
{
|
||||
/* initialize app to '\0' for later check */
|
||||
*app = '\0';
|
||||
|
||||
/* http or https */
|
||||
if ((aProtocol == NS_LITERAL_CSTRING("http")) ||
|
||||
(aProtocol == NS_LITERAL_CSTRING("https"))) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultBrowserExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* mailto: */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("mailto")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultMailExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultMailParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* ftp */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("ftp")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultFTPExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultFTPParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* news: or snews: */
|
||||
else if ((aProtocol == NS_LITERAL_CSTRING("news")) ||
|
||||
(aProtocol == NS_LITERAL_CSTRING("snews"))) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultNewsExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultNewsParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* irc: */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("irc")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultIRCExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultIRCParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
else {
|
||||
NS_WARNING("GetApplicationAndParametersFromINI(): unsupported protocol scheme");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* application string in INI was empty */
|
||||
if (app[0] == '\0')
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
|
||||
|
@ -1236,13 +1135,17 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch
|
|||
nsCAutoString prefName;
|
||||
prefName = NS_LITERAL_CSTRING("applications.") + nsDependentCString(aProtocolScheme);
|
||||
|
||||
nsCOMPtr<nsIPref> thePrefsService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (thePrefsService) {
|
||||
nsXPIDLCString prefString;
|
||||
rv = thePrefsService->CopyCharPref(prefName.get(), getter_Copies(prefString));
|
||||
*aHandlerExists = NS_SUCCEEDED(rv) && !prefString.IsEmpty();
|
||||
if (*aHandlerExists) {
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLCString prefString;
|
||||
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
|
||||
*aHandlerExists = NS_SUCCEEDED(rv) && !prefString.IsEmpty();
|
||||
if (*aHandlerExists) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check the OS/2 INI for the protocol */
|
||||
|
@ -1520,16 +1423,15 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
|
|||
NS_IMETHODIMP
|
||||
nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIPref> thePrefsService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (!thePrefsService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> thePrefsService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCAutoString prefName = NS_LITERAL_CSTRING("applications.") + aScheme;
|
||||
nsXPIDLCString prefString;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCAutoString applicationName;
|
||||
|
||||
nsresult rv = thePrefsService->CopyCharPref(prefName.get(), getter_Copies(prefString));
|
||||
if (NS_FAILED(rv) || prefString.IsEmpty()) {
|
||||
rv = thePrefsService->GetBranch(prefName.get(), getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv)) {
|
||||
char szAppFromINI[CCHMAXPATH];
|
||||
char szParamsFromINI[MAXINIPARAMLENGTH];
|
||||
/* did OS2.INI contain application? */
|
||||
|
@ -1542,7 +1444,11 @@ nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsASt
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
} else {
|
||||
applicationName.Append(prefString);
|
||||
nsXPIDLCString prefString;
|
||||
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(prefString));
|
||||
if (NS_SUCCEEDED(rv) && !prefString.IsEmpty()) {
|
||||
applicationName.Append(prefString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1568,3 +1474,100 @@ nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsASt
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check OS/2 INI for application and parameters for the protocol
|
||||
// return NS_OK, if application exists for protocol in INI and is not empty
|
||||
nsresult GetApplicationAndParametersFromINI(const nsACString& aProtocol,
|
||||
char* app, ULONG appLength,
|
||||
char* param, ULONG paramLength)
|
||||
{
|
||||
/* initialize app to '\0' for later check */
|
||||
*app = '\0';
|
||||
|
||||
/* http or https */
|
||||
if ((aProtocol == NS_LITERAL_CSTRING("http")) ||
|
||||
(aProtocol == NS_LITERAL_CSTRING("https"))) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultBrowserExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* mailto: */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("mailto")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultMailExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultMailParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* ftp */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("ftp")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultFTPExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultFTPParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* news: or snews: */
|
||||
else if ((aProtocol == NS_LITERAL_CSTRING("news")) ||
|
||||
(aProtocol == NS_LITERAL_CSTRING("snews"))) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultNewsExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultNewsParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
/* irc: */
|
||||
else if (aProtocol == NS_LITERAL_CSTRING("irc")) {
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultIRCExe",
|
||||
"",
|
||||
app,
|
||||
appLength);
|
||||
PrfQueryProfileString(HINI_USER,
|
||||
"WPURLDEFAULTSETTINGS",
|
||||
"DefaultIRCParameters",
|
||||
"",
|
||||
param,
|
||||
paramLength);
|
||||
}
|
||||
else {
|
||||
NS_WARNING("GetApplicationAndParametersFromINI(): unsupported protocol scheme");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* application string in INI was empty */
|
||||
if (app[0] == '\0')
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define LOG(args) PR_LOG(mLog, PR_LOG_DEBUG, args)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(mLog, PR_LOG_DEBUG)
|
||||
|
||||
class nsHashtable;
|
||||
class nsILineInputStream;
|
||||
class nsMIMEInfoOS2;
|
||||
|
@ -69,14 +72,12 @@ public:
|
|||
NS_IMETHODIMP GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
|
||||
protected:
|
||||
already_AddRefed<nsMIMEInfoOS2> GetFromType(const nsCString& aMimeType);
|
||||
already_AddRefed<nsMIMEInfoOS2> GetFromExtension(const nsCString& aFileExt);
|
||||
|
||||
private:
|
||||
nsresult GetApplicationAndParametersFromINI(const nsACString& aProtocol,
|
||||
char * app, unsigned long appLength,
|
||||
char * param, unsigned long paramLength);
|
||||
// Helper methods which have to access static members
|
||||
static nsresult UnescapeCommand(const nsAString& aEscapedCommand,
|
||||
const nsAString& aMajorType,
|
||||
|
@ -147,4 +148,11 @@ private:
|
|||
nsAString& aMozillaFlags);
|
||||
};
|
||||
|
||||
#define MAXINIPARAMLENGTH 1024 // max length of OS/2 INI key for application parameters
|
||||
|
||||
// helper function for access to OS2.INI
|
||||
nsresult GetApplicationAndParametersFromINI(const nsACString& aProtocol,
|
||||
char* app, unsigned long appLength,
|
||||
char* param, unsigned long paramLength);
|
||||
|
||||
#endif // nsOSHelperAppService_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче