From dc17bcb8fbcdd9106e9da27cedb8860ea8df235d Mon Sep 17 00:00:00 2001 From: "mark.lin%eng.sun.com" Date: Sat, 13 Nov 1999 00:37:48 +0000 Subject: [PATCH] Added support for Proxies in the MRJ Plugin via getProxyForURL. Reviewed by ed.burns@eng.sun.com and approved by drapeau@eng.sun.com. Fixes bug #18691. I can be contacted at mark.lin@eng.sun.com or phone: (408) 517-5365, (650) 627-8409. git-svn-id: svn://10.0.0.236/trunk@53385 18797224-902f-48f8-a5cc-f745e15eee43 --- .../oji/MRJ/plugin/Source/MRJContext.cp | 44 +++++++++++++++++++ .../plugin/oji/MRJ/plugin/Source/MRJContext.h | 3 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp index 3588527a047..033df821529 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp +++ b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.cp @@ -769,6 +769,38 @@ Boolean MRJContext::appletLoaded() return (mViewer != NULL); } +void MRJContext::setProxyInfoForURL(char * url, JMProxyType proxyType) +{ + /* + * We then call 'nsIPluginManager2::FindProxyForURL' which will return + * proxy information which we can parse and set via JMSetProxyInfo. + */ + + char * result = NULL; + + thePluginManager2->FindProxyForURL(url, &result); + if (result != NULL) { + JMProxyInfo proxyInfo; + + /* See if a proxy was specified */ + if (strcmp("DIRECT", result)) { + int index = 0; + int length = strlen(result); + + proxyInfo.useProxy = true; + result = strchr(result, ' '); + for (index = 0; *result != ':' && index < length; result++, index++) { + proxyInfo.proxyHost[index] = *result; + } + proxyInfo.proxyHost[index] = '\0'; + result++; + proxyInfo.proxyPort = atoi(result); + JMSetProxyInfo(mSessionRef, proxyType, &proxyInfo); + } + } +} + + Boolean MRJContext::loadApplet() { static JMAppletSecurity security = { @@ -787,6 +819,18 @@ Boolean MRJContext::loadApplet() }; OSStatus status; + /* Added by Mark: */ + /* + * Set proxy info + * It is only set if the new enhanced Plugin Manager exists. + */ + if (thePluginManager2 != NULL) { + /* Sample URL's to use for getting the HTTP proxy and FTP proxy */ + setProxyInfoForURL("http://www.mozilla.org", eHTTPProxy); + setProxyInfoForURL("ftp://ftp.mozilla.org", eFTPProxy); + } + /* End set proxy info code */ + status = ::JMNewAppletViewer(&mViewer, mContext, mLocator, 0, &security, &callbacks, this); if (status == noErr) { diff --git a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h index f59eb080637..0ffc5a59c20 100644 --- a/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h +++ b/mozilla/plugin/oji/MRJ/plugin/Source/MRJContext.h @@ -37,7 +37,7 @@ // Instance state information about the plugin. // // *Developers*: Use this struct to hold per-instance -// information that youšll need in the +// information that youźll need in the // various functions in this file. // @@ -58,6 +58,7 @@ public: Boolean createContext(); JMAWTContextRef getContextRef(); + void setProxyInfoForURL(char * url, JMProxyType proxyType); Boolean appletLoaded(); Boolean loadApplet(); Boolean isActive();