]> git.decadent.org.uk Git - videolink.git/blobdiff - null_prompt_service.cpp
Release versions 1.2.11 and 1.2.11-1
[videolink.git] / null_prompt_service.cpp
index dca78103dbdb020e6cdaca48b2142e18b1395849..68d6d9010a287cb6189cd93137afb4d54273afe7 100644 (file)
@@ -1,19 +1,23 @@
-// Copyright 2006 Ben Hutchings <ben@decadentplace.org.uk>.
+// Copyright 2006 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
+#include <new>
 #include <string>
 
 #include <langinfo.h>
 
+#include "wchar_t_short.h"
 #include <nsCOMPtr.h>
 #include <nsICharsetConverterManager.h>
 #include <nsIComponentManager.h>
 #include <nsIFactory.h>
-#include <nsIServiceManagerUtils.h>
+#include <nsIComponentRegistrar.h>
+#include <nsServiceManagerUtils.h>
 #include <nsIUnicodeEncoder.h>
+#include "wchar_t_default.h"
 
 #include "null_prompt_service.hpp"
-#include "webdvd.hpp"
+#include "videolink.hpp"
 #include "xpcom_support.hpp"
 
 using xpcom_support::check;
@@ -36,18 +40,20 @@ namespace
        if (!iid.Equals(prompt_service_iid))
            return NS_ERROR_NO_INTERFACE;
 
-       try
+       if (null_prompt_service * service =
+               new (std::nothrow) null_prompt_service)
        {
-           *result = new null_prompt_service;
+           service->AddRef();
+           *result = service;
            return NS_OK;
        }
-       catch (std::bad_alloc &)
+       else
        {
            return NS_ERROR_OUT_OF_MEMORY;
        }
     }
 
-    NS_IMETHODIMP null_prompt_service_factory::LockFactory(PRBool lock)
+    NS_IMETHODIMP null_prompt_service_factory::LockFactory(PRBool /*lock*/)
     {
        return NS_ERROR_NOT_IMPLEMENTED;
     }
@@ -190,10 +196,11 @@ void null_prompt_service::install()
        {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}
     };
     nsCOMPtr<nsIFactory> prompt_factory(new null_prompt_service_factory);
-    check(nsComponentManager::RegisterFactory(
+    nsCOMPtr<nsIComponentRegistrar> comp_registrar;
+    check(NS_GetComponentRegistrar(getter_AddRefs(comp_registrar)));
+    check(comp_registrar->RegisterFactory(
              prompt_service_cid,
              "Prompt Service",
              "@mozilla.org/embedcomp/prompt-service;1",
-             prompt_factory,
-             PR_TRUE)); // replace existing
+             prompt_factory));   
 }