X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=null_prompt_service.cpp;fp=null_prompt_service.cpp;h=c1d24be55a6ef3da5880c49ad6f7e1e14c6a9ca3;hb=80da930b8321600a81d3d9ae39ff4b27def501c3;hp=0000000000000000000000000000000000000000;hpb=be757cb101de2c2abd8131533c40f740da9e3eca;p=videolink.git diff --git a/null_prompt_service.cpp b/null_prompt_service.cpp new file mode 100644 index 0000000..c1d24be --- /dev/null +++ b/null_prompt_service.cpp @@ -0,0 +1,144 @@ +// Copyright 2006 Ben Hutchings . +// See the file "COPYING" for licence details. + +#include +#include +#include + +#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 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 +}