On Sat, Jul 05, 2008 at 05:46:32PM +0200, Stefan wrote:
> Package: galeon
> Version: 2.0.5-1
> Severity: important
> 
> Since update to new galeon version (this one) I am not possible to
> connect to pages with htaccess authorization. Galeon doesen't prompt
> for a password and only shows the error page 401 from the server.
(...)

This was a known issue when the package was uploaded ;)

Anyways, here is a patch to make that work.

Note for galeon maintainers:
strictly speaking, HAVE_NSIPROMPTSERVICE2_H and
HAVE_NSINONBLOCKINGALERTSERVICE_H shouldn't be mutually exclusive. But the
fact is HAVE_NSINONBLOCKINGALERTSERVICE_H is not even set in
configure/config.h, so I didn't want to bother more than that.
Also note that the messages shown in the prompt dialog are provided by
xulrunner, and thus may not be localized in the same language as the
galeon UI. I think it's not actually worse than before xulrunner 1.9,
though. You can modify MakeDialogText to use your own strings if you
prefer.

Mike
diff -u galeon-2.0.5/debian/patches/90_autotools.patch 
galeon-2.0.5/debian/patches/90_autotools.patch
--- galeon-2.0.5/debian/patches/90_autotools.patch
+++ galeon-2.0.5/debian/patches/90_autotools.patch
@@ -635,7 +635,17 @@
 diff -Nur galeon-2.0.5/config.h.in galeon-2.0.5.new/config.h.in
 --- galeon-2.0.5/config.h.in   2008-02-10 18:44:07.000000000 +0100
 +++ galeon-2.0.5.new/config.h.in       2008-07-03 15:34:51.000000000 +0200
-@@ -282,5 +282,11 @@
+@@ -168,6 +168,9 @@
+ /* Define if nsIPrintOptions::AvailablePrinters exists */
+ #undef HAVE_NSIPRINTOPTIONS_AVAILABLEPRINTERS
+ 
++/* Define if nsIPromptService2.h exists */
++#undef HAVE_NSIPROMPTSERVICE2_H
++
+ /* Define if nsIScriptContext is MOZILLA_INTERNAL_API */
+ #undef HAVE_NSISCRIPTCONTEXT_INTERNAL_API
+ 
+@@ -282,5 +285,11 @@
  /* Define to the location of the g++ string header. */
  #undef STRING_HEADER
  
@@ -2681,7 +2691,42 @@
  
  TEST_MOZILLA_INCLUDE_DIRS="widget mimetype docshell history dom necko string 
layout gfx content js exthandler pipnss uriloader caps xpconnect nkcache 
fastfind gtkembedmoz chrome"
  for i in $TEST_MOZILLA_INCLUDE_DIRS ; do
-@@ -27221,7 +27769,7 @@
+@@ -27188,6 +27188,34 @@
+ fi
+ 
+ 
++as_ac_File=`echo "ac_cv_file_$MOZILLA_INCLUDE_ROOT/nsIPromptService2.h" | 
$as_tr_sh`
++{ echo "$as_me:$LINENO: checking for 
$MOZILLA_INCLUDE_ROOT/nsIPromptService2.h" >&5
++echo $ECHO_N "checking for $MOZILLA_INCLUDE_ROOT/nsIPromptService2.h... 
$ECHO_C" >&6; }
++if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  test "$cross_compiling" = yes &&
++  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross 
compiling" >&5
++echo "$as_me: error: cannot check for file existence when cross compiling" 
>&2;}
++   { (exit 1); exit 1; }; }
++if test -r "$MOZILLA_INCLUDE_ROOT/nsIPromptService2.h"; then
++  eval "$as_ac_File=yes"
++else
++  eval "$as_ac_File=no"
++fi
++fi
++ac_res=`eval echo '${'$as_ac_File'}'`
++             { echo "$as_me:$LINENO: result: $ac_res" >&5
++echo "${ECHO_T}$ac_res" >&6; }
++if test `eval echo '${'$as_ac_File'}'` = yes; then
++
++cat >>confdefs.h <<\_ACEOF
++#define HAVE_NSIPROMPTSERVICE2_H 1
++_ACEOF
++
++fi
++
++
+ CXXFLAGS="$_SAVE_CXXFLAGS $MOZ_DEBUG_FLAGS"
+ CPPFLAGS=$_SAVE_CPPFLAGS
+ LDFLAGS=$_SAVE_LDFLAGS
+@@ -27221,7 +27797,7 @@
  
      fi
    fi
only in patch2:
unchanged:
--- galeon-2.0.5.orig/debian/patches/80_http_auth.patch
+++ galeon-2.0.5/debian/patches/80_http_auth.patch
@@ -0,0 +1,238 @@
+--- galeon-2.0.5.orig/mozilla/EphyPromptService.cpp
++++ galeon-2.0.5/mozilla/EphyPromptService.cpp
+@@ -38,6 +38,24 @@
+ #include "AutoEventQueue.h"
+ #endif
+ 
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++#include <nsIAuthInformation.h>
++#include <nsIStringBundle.h>
++#include <nsServiceManagerUtils.h>
++/* That is ugly but I didn't find another way, except including
++ * NS_GetAuthHostPort */
++#define kNotFound -1
++NS_COM void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest );
++#include <nsStringAPI.h>
++#include <nsIProxiedChannel.h>
++#include <nsIProxyInfo.h>
++#include <nsIIDNService.h>
++#include <nsNetCID.h>
++#include <nsIURI.h>
++#include <nsNetUtil.h>
++#include <nsPromptUtils.h>
++#endif
++
+ #include "GaleonUtils.h"
+ 
+ #include <glib.h>
+@@ -629,7 +647,11 @@
+ }
+ 
+ /* FIXME: needs THREADSAFE? */
+-#if HAVE_NSINONBLOCKINGALERTSERVICE_H
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++NS_IMPL_ISUPPORTS2 (EphyPromptService,
++                  nsIPromptService,
++                  nsIPromptService2)
++#elif HAVE_NSINONBLOCKINGALERTSERVICE_H
+ NS_IMPL_ISUPPORTS2 (EphyPromptService,
+                   nsIPromptService,
+                   nsINonBlockingAlertService)
+@@ -873,3 +895,146 @@
+ }
+ 
+ #endif /* HAVE_NSINONBLOCKINGALERTSERVICE_H */
++
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++static nsresult
++MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
++               nsString& message)
++{
++  nsresult rv;
++  nsCOMPtr<nsIStringBundleService> bundleSvc =
++    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
++  NS_ENSURE_SUCCESS(rv, rv);
++
++  nsCOMPtr<nsIStringBundle> bundle;
++  rv = bundleSvc->CreateBundle("chrome://global/locale/prompts.properties",
++                               getter_AddRefs(bundle));
++  NS_ENSURE_SUCCESS(rv, rv);
++
++  // figure out what message to display...
++  nsCAutoString host;
++  PRInt32 port;
++  NS_GetAuthHostPort(aChannel, aAuthInfo, PR_FALSE, host, &port);
++
++  nsAutoString displayHost;
++  CopyUTF8toUTF16(host, displayHost);
++
++  nsCOMPtr<nsIURI> uri;
++  aChannel->GetURI(getter_AddRefs(uri));
++
++  nsCAutoString scheme;
++  uri->GetScheme(scheme);
++
++  nsAutoString username;
++  aAuthInfo->GetUsername(username);
++
++  PRUint32 flags;
++  aAuthInfo->GetFlags(&flags);
++  PRBool proxyAuth = (flags & nsIAuthInformation::AUTH_PROXY) != 0;
++
++  nsAutoString realm;
++  aAuthInfo->GetRealm(realm);
++
++  // Append the port if it was specified
++  if (port != -1) {
++    displayHost.Append(PRUnichar(':'));
++    displayHost.AppendInt(port);
++  }
++
++  NS_NAMED_LITERAL_STRING(proxyText, "EnterLoginForProxy");
++  NS_NAMED_LITERAL_STRING(originText, "EnterLoginForRealm");
++  NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
++  NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");
++
++  const PRUnichar *text;
++  if (proxyAuth) {
++    text = proxyText.get();
++  } else {
++    text = originText.get();
++
++    // prepend "scheme://"
++    nsAutoString schemeU;
++    CopyASCIItoUTF16(scheme, schemeU);
++    schemeU.AppendLiteral("://");
++    displayHost.Insert(schemeU, 0);
++  }
++
++  const PRUnichar *strings[] = { realm.get(), displayHost.get() };
++  PRUint32 count = NS_ARRAY_LENGTH(strings);
++
++  if (flags & nsIAuthInformation::ONLY_PASSWORD) {
++    text = passwordText.get();
++    strings[0] = username.get();
++  } else if (!proxyAuth && realm.IsEmpty()) {
++    text = noRealmText.get();
++    count--;
++    strings[0] = strings[1];
++  }
++
++  rv = bundle->FormatStringFromName(text, strings, count, 
getter_Copies(message));
++  return rv;
++}
++
++NS_METHOD
++EphyPromptService::PromptAuth(nsIDOMWindow *aParent,
++                              nsIChannel *aChannel,
++                              PRUint32 level,
++                              nsIAuthInformation *authInfo,
++                              const PRUnichar *checkboxLabel,
++                              PRBool *checkValue,
++                              PRBool *retval)
++{
++      NS_ENSURE_ARG_POINTER (retval);
++      NS_ENSURE_ARG_POINTER (authInfo);
++
++  nsString message;
++  MakeDialogText(aChannel, authInfo, message);
++
++  nsAutoString defaultUser, defaultDomain, defaultPass;
++  authInfo->GetUsername(defaultUser);
++  authInfo->GetDomain(defaultDomain);
++  authInfo->GetPassword(defaultPass);
++
++  PRUint32 flags;
++  authInfo->GetFlags(&flags);
++
++  if ((flags & nsIAuthInformation::NEED_DOMAIN) && !defaultDomain.IsEmpty()) {
++    defaultDomain.Append(PRUnichar('\\'));
++    defaultUser.Insert(defaultDomain, 0);
++  }
++
++  // NOTE: Allocation failure is not fatal here (just default to empty string
++  // if allocation fails)
++  PRUnichar *user = ToNewUnicode(defaultUser),
++    *pass = ToNewUnicode(defaultPass);
++  nsresult rv;
++  if (flags & nsIAuthInformation::ONLY_PASSWORD)
++    rv = PromptPassword(aParent, nsnull, message.get(),
++                                  &pass, checkboxLabel,
++                                  checkValue, retval);
++  else
++    rv = PromptUsernameAndPassword(aParent, nsnull, message.get(),
++                                             &user, &pass, checkboxLabel,
++                                             checkValue, retval);
++
++  nsString userStr(user);
++  nsString passStr(pass);
++  authInfo->SetUsername(userStr);
++  authInfo->SetPassword(passStr);
++
++  return rv;
++}
++
++NS_METHOD EphyPromptService::AsyncPromptAuth(nsIDOMWindow *aParent,
++                                             nsIChannel *aChannel,
++                                             nsIAuthPromptCallback *aCallback,
++                                             nsISupports *aContext,
++                                             PRUint32 level,
++                                             nsIAuthInformation *authInfo,
++                                             const PRUnichar *checkboxLabel,
++                                             PRBool *checkValue,
++                                             nsICancelable **retval)
++{
++  return NS_ERROR_NOT_IMPLEMENTED;
++}
++#endif
+--- galeon-2.0.5.orig/mozilla/EphyPromptService.h
++++ galeon-2.0.5/mozilla/EphyPromptService.h
+@@ -20,7 +20,11 @@
+ #ifndef EPHY_PROMPT_SERVICE_H
+ #define EPHY_PROMPT_SERVICE_H
+ 
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++#include <nsIPromptService2.h>
++#else
+ #include <nsIPromptService.h>
++#endif
+ 
+ #if HAVE_NSINONBLOCKINGALERTSERVICE_H
+ #include <nsINonBlockingAlertService.h>
+@@ -33,7 +37,12 @@
+ 
+ #define EPHY_PROMPT_SERVICE_CLASSNAME "Epiphany Prompt Service"
+ 
+-class EphyPromptService : public nsIPromptService
++class EphyPromptService :
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++                      public nsIPromptService2
++#else
++                      public nsIPromptService
++#endif
+ #if HAVE_NSINONBLOCKINGALERTSERVICE_H
+                       , public nsINonBlockingAlertService
+ #endif
+@@ -41,6 +50,9 @@
+ public:
+       NS_DECL_ISUPPORTS
+       NS_DECL_NSIPROMPTSERVICE
++#ifdef HAVE_NSIPROMPTSERVICE2_H
++      NS_DECL_NSIPROMPTSERVICE2
++#endif
+ #if HAVE_NSINONBLOCKINGALERTSERVICE_H
+       NS_DECL_NSINONBLOCKINGALERTSERVICE
+ #endif
+--- galeon-2.0.5.orig/configure.in
++++ galeon-2.0.5/configure.in
+@@ -1159,6 +1159,10 @@
+       [AC_DEFINE([HAVE_NSIPASSWORD_H],[1],
+       [Define if nsIPassword.h exists])])
+ 
++AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/nsIPromptService2.h],
++      [AC_DEFINE([HAVE_NSIPROMPTSERVICE2_H],[1],
++      [Define if nsIPromptService2.h exists])])
++
+ dnl restore flags
+ CXXFLAGS="$_SAVE_CXXFLAGS $MOZ_DEBUG_FLAGS"
+ CPPFLAGS=$_SAVE_CPPFLAGS

Reply via email to