]> git.decadent.org.uk Git - videolink.git/commitdiff
Disabled prompts in batch processing mode.
authorBen Hutchings <ben@decadent.org.uk>
Sat, 11 Mar 2006 01:28:27 +0000 (01:28 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 2 Nov 2008 23:39:57 +0000 (23:39 +0000)
Makefile
null_prompt_service.cpp [new file with mode: 0644]
null_prompt_service.hpp [new file with mode: 0644]
webdvd.cpp

index 13830561967fad9ecaf609c77c1457cbe5809835..7f091327843f70e96456d533f5d8e29cb0452c7b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -32,8 +32,9 @@ endif
 
 cxxsources := \
     auto_proc.cpp browser_widget.cpp child_iterator.cpp generate_dvd.cpp   \
-    link_iterator.cpp pixbufs.cpp style_sheets.cpp temp_file.cpp video.cpp \
-    vob_list.cpp webdvd.cpp x_frame_buffer.cpp xml_utils.cpp xpcom_support.cpp
+    link_iterator.cpp null_prompt_service.cpp pixbufs.cpp style_sheets.cpp \
+    temp_file.cpp video.cpp vob_list.cpp webdvd.cpp x_frame_buffer.cpp     \
+    xml_utils.cpp xpcom_support.cpp
 csources := jquant2.c
 
 webdvd : $(cxxsources:.cpp=.o) $(csources:.c=.o)
@@ -63,8 +64,8 @@ webdvd.% \
 browser_widget.% generate_dvd.% pixbufs.% temp_file.% vob_list.% webdvd.% \
     : CPPFLAGS += $(shell pkg-config --cflags gtkmm-2.0)
 
-browser_widget.% child_iterator.o link_iterator.% style_sheets.% webdvd.% \
-xpcom_support.%                                                           \
+browser_widget.% child_iterator.o link_iterator.% null_prompt_service.% \
+style_sheets.% webdvd.% xpcom_support.%                                 \
     : CPPFLAGS += $(shell pkg-config --cflags mozilla-gtkmozembed)
 
 # These dig a bit deeper into Mozilla
diff --git a/null_prompt_service.cpp b/null_prompt_service.cpp
new file mode 100644 (file)
index 0000000..c1d24be
--- /dev/null
@@ -0,0 +1,144 @@
+// Copyright 2006 Ben Hutchings <ben@decadentplace.org.uk>.
+// See the file "COPYING" for licence details.
+
+#include <nsCOMPtr.h>
+#include <nsIComponentManager.h>
+#include <nsIFactory.h>
+
+#include "null_prompt_service.hpp"
+#include "xpcom_support.hpp"
+
+using xpcom_support::check;
+
+namespace
+{
+    NS_DEFINE_IID(prompt_service_iid, NS_IPROMPTSERVICE_IID);
+
+    class null_prompt_service_factory : public nsIFactory
+    {
+       NS_DECL_ISUPPORTS
+       NS_DECL_NSIFACTORY
+    };
+
+    NS_IMPL_ISUPPORTS1(null_prompt_service_factory, nsIFactory)
+
+    NS_IMETHODIMP null_prompt_service_factory::CreateInstance(
+       nsISupports *, const nsIID & iid, void ** result)
+    {
+       if (!iid.Equals(prompt_service_iid))
+           return NS_ERROR_NO_INTERFACE;
+
+       try
+       {
+           *result = new null_prompt_service;
+           return NS_OK;
+       }
+       catch (std::bad_alloc &)
+       {
+           return NS_ERROR_OUT_OF_MEMORY;
+       }
+    }
+
+    NS_IMETHODIMP null_prompt_service_factory::LockFactory(PRBool lock)
+    {
+       return NS_ERROR_NOT_IMPLEMENTED;
+    }
+}
+
+NS_IMPL_ISUPPORTS1(null_prompt_service, nsIPromptService)
+
+NS_IMETHODIMP null_prompt_service::Alert(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *)
+{
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::AlertCheck(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *, const PRUnichar *,
+    PRBool *)
+{
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::Confirm(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::ConfirmCheck(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *,
+    const PRUnichar *, PRBool *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::ConfirmEx(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *,
+    PRUint32 flags, const PRUnichar *, const PRUnichar *, const PRUnichar *,
+    const PRUnichar *, PRBool *, PRInt32 * result)
+{
+    // Accept the default
+    if (flags & BUTTON_POS_1_DEFAULT)
+       *result = 1;
+    else if (flags & BUTTON_POS_2_DEFAULT)
+       *result = 2;
+    else
+       *result = 0;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::Prompt(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *, PRUnichar **,
+    const PRUnichar *, PRBool *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::PromptUsernameAndPassword(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *,
+    PRUnichar **, PRUnichar **, const PRUnichar *, PRBool *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::PromptPassword(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *, PRUnichar **,
+    const PRUnichar *, PRBool *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+NS_IMETHODIMP null_prompt_service::Select(
+    nsIDOMWindow *, const PRUnichar *, const PRUnichar *, PRUint32,
+    const PRUnichar **, PRInt32 *, PRBool * result)
+{
+    // Cancel
+    *result = false;
+    return NS_OK;
+}
+
+void null_prompt_service::install()
+{
+    static const nsCID prompt_service_cid = {
+       0xa2112d6a, 0x0e28, 0x421f,
+       {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}
+    };
+    nsCOMPtr<nsIFactory> prompt_factory(new null_prompt_service_factory);
+    check(nsComponentManager::RegisterFactory(
+             prompt_service_cid,
+             "Prompt Service",
+             "@mozilla.org/embedcomp/prompt-service;1",
+             prompt_factory,
+             PR_TRUE)); // replace existing
+}
diff --git a/null_prompt_service.hpp b/null_prompt_service.hpp
new file mode 100644 (file)
index 0000000..c3b6951
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef INC_NULL_PROMPT_SERVICE_HPP
+#define INC_NULL_PROMPT_SERVICE_HPP
+
+#include <nsIPromptService.h>
+
+class null_prompt_service : public nsIPromptService
+{
+public:
+    static void install();
+
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIPROMPTSERVICE
+};
+
+#endif // !INC_NULL_PROMPT_SERVICE_HPP
index 43f54c7021a703b8be936cb8280548239dfee6f0..c4cf8a95f662d35d7ab67c3e14f1a4c50b70b8f1 100644 (file)
@@ -55,6 +55,7 @@
 #include "dvd.hpp"
 #include "generate_dvd.hpp"
 #include "link_iterator.hpp"
+#include "null_prompt_service.hpp"
 #include "pixbufs.hpp"
 #include "style_sheets.hpp"
 #include "temp_file.hpp"
@@ -936,6 +937,8 @@ int main(int argc, char ** argv)
        // Initialise Mozilla
        browser_widget::initialiser browser_init;
        set_browser_preferences();
+       if (!preview_mode)
+           null_prompt_service::install();
 
        // Run the browser/converter
        webdvd_window window(frame_params, menu_url, output_dir);