[OS/2] Bug 390075: preliminary OS/2 build break fix for exthandler code, real solution will follow
authormozilla@weilbacher.org
Fri, 03 Aug 2007 12:06:33 -0700
changeset 4248 2ba232928626f640ea01240cb4eaa55b24e8b93b
parent 4247 8b0ccb3e44f1f79ed884f40f617a10b99b4331ed
child 4249 9b3bd1c5542770fb88697255596a9b699f55a87d
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs390075
milestone1.9a8pre
[OS/2] Bug 390075: preliminary OS/2 build break fix for exthandler code, real solution will follow
uriloader/exthandler/os2/nsMIMEInfoOS2.cpp
uriloader/exthandler/os2/nsMIMEInfoOS2.h
uriloader/exthandler/os2/nsOSHelperAppService.cpp
uriloader/exthandler/os2/nsOSHelperAppService.h
--- a/uriloader/exthandler/os2/nsMIMEInfoOS2.cpp
+++ b/uriloader/exthandler/os2/nsMIMEInfoOS2.cpp
@@ -34,20 +34,16 @@
  * use your version of this file under the terms of the MPL, 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 MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-
-#define INCL_DOS
-#include <os2.h>
-
 #include "nsMIMEInfoOS2.h"
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsReadableUtils.h"
 #include "nsIProcess.h"
 #include <stdlib.h>
 
 #define SALT_SIZE 8
@@ -151,17 +147,19 @@ NS_IMETHODIMP nsMIMEInfoOS2::LaunchWithU
   if (NS_FAILED(rv = process->Init(application)))
     return rv;
   PRUint32 pid;
   return process->Run(PR_FALSE, &strPath, 1, &pid);
 }
 
 nsresult nsMIMEInfoOS2::LoadUriInternal(nsIURI * aURL)
 {
-  LOG(("-- nsOSHelperAppService::LoadUriInternal\n"));
+// 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));
   if (!thePrefsService) {
     return NS_ERROR_FAILURE;
   }
 
   /* Convert SimpleURI to StandardURL */
   nsresult rv;
   nsCOMPtr<nsIURI> uri = do_CreateInstance(kStandardURLCID, &rv);
@@ -183,19 +181,20 @@ nsresult nsMIMEInfoOS2::LoadUriInternal(
   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? */
-    rv = GetApplicationAndParametersFromINI(uProtocol,
-                                            szAppFromINI, sizeof(szAppFromINI),
-                                            szParamsFromINI, sizeof(szParamsFromINI));
+// XXX this is just a build break fix, functionality is broken, see bug 390075
+//    rv = GetApplicationAndParametersFromINI(uProtocol,
+//                                            szAppFromINI, sizeof(szAppFromINI),
+//                                            szParamsFromINI, sizeof(szParamsFromINI));
     if (NS_SUCCEEDED(rv)) {
       applicationName = szAppFromINI;
       parameters = szParamsFromINI;
     } else {
       return NS_ERROR_FAILURE;
     }
   }
 
--- a/uriloader/exthandler/os2/nsMIMEInfoOS2.h
+++ b/uriloader/exthandler/os2/nsMIMEInfoOS2.h
@@ -34,16 +34,32 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsMIMEInfoOS2_h_
 #define nsMIMEInfoOS2_h_
 
 #include "nsMIMEInfoImpl.h"
 
+#include "nsIPref.h" // XX Need to convert Handler code to new pref stuff
+#include "nsNetCID.h"
+#include "nsEscape.h"
+static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); // XXX need to convert to contract id
+
+#define INCL_DOS
+#define INCL_DOSMISC
+#define INCL_DOSERRORS
+#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:
     nsMIMEInfoOS2(const char* aType = "") : nsMIMEInfoImpl(aType) {}
     nsMIMEInfoOS2(const nsACString& aMIMEType) : nsMIMEInfoImpl(aMIMEType) {}
     nsMIMEInfoOS2(const nsACString& aType, HandlerClass aClass) :
       nsMIMEInfoImpl(aType, aClass) {}
     virtual ~nsMIMEInfoOS2();
--- a/uriloader/exthandler/os2/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/os2/nsOSHelperAppService.cpp
@@ -41,45 +41,30 @@
 
 #include "nsOSHelperAppService.h"
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsXPIDLString.h"
 #include "nsIURL.h"
-#include "nsNetCID.h"
 #include "nsIFileStreams.h"
 #include "nsILineInputStream.h"
 #include "nsILocalFile.h"
-#include "nsEscape.h"
 #include "nsIProcess.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsHashtable.h"
 #include "nsCRT.h"
 #include "prenv.h"      // for PR_GetEnv()
 #include "nsMIMEInfoOS2.h"
 #include "nsAutoPtr.h"
-#include <stdlib.h>		// for system()
-
-#include "nsIPref.h" // XX Need to convert Handler code to new pref stuff
-static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); // XXX need to convert to contract id
-
-#define INCL_DOSMISC
-#define INCL_DOSERRORS
-#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)
+#include <stdlib.h>     // for system()
 
 static nsresult
 FindSemicolon(nsAString::const_iterator& aSemicolon_iter,
               const nsAString::const_iterator& aEnd_iter);
 static nsresult
 ParseMIMEType(const nsAString::const_iterator& aStart_iter,
               nsAString::const_iterator& aMajorTypeStart,
               nsAString::const_iterator& aMajorTypeEnd,
@@ -1498,29 +1483,37 @@ nsOSHelperAppService::GetMIMEInfoFromOS(
     retval->CopyBasicDataTo(miByExt);
 
     miByExt.swap(retval);
   }
   return retval;
 }
 
 already_AddRefed<nsIHandlerInfo>
-nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
+nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
+                                            PRBool *found)
 {
   NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
 
-  PRBool exists;
   nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
-                                        &exists);
-  NS_ENSURE_SUCCESS(rv, nsnull);
+                                        found);
+  if (NS_FAILED(rv))
+    return nsnull;
 
-  nsMIMEInfoOS2 *handlerInfo = new nsMIMEInfoOS2();
+  nsMIMEInfoOS2 *handlerInfo =
+    new nsMIMEInfoOS2(aScheme, nsMIMEInfoBase::eProtocolInfo);
   NS_ENSURE_TRUE(handlerInfo, nsnull);
   NS_ADDREF(handlerInfo);
 
+  if (!*found) {
+    // Code that calls this requires an object regardless if the OS has
+    // something for us, so we return the empty object.
+    return handlerInfo;
+  }
+
   nsAutoString desc;
   GetApplicationDescription(aScheme, desc);
   handlerInfo->SetDefaultDescription(desc);
 
   return handlerInfo;
 }
 
 
--- a/uriloader/exthandler/os2/nsOSHelperAppService.h
+++ b/uriloader/exthandler/os2/nsOSHelperAppService.h
@@ -57,17 +57,18 @@ class nsOSHelperAppService : public nsEx
 public:
   nsOSHelperAppService();
   virtual ~nsOSHelperAppService();
 
   // method overrides for mime.types and mime.info look up steps
   already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
                                                   const nsACString& aFileExt,
                                                   PRBool     *aFound);
-  already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
+  already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
+                                                         PRBool *found);
 
   // override nsIExternalProtocolService methods
   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);