From 03101dff3364d93e18b7145ff4fcd164bff7eb60 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 30 Jan 2006 20:32:44 +0000 Subject: Special error text for localhost URIs. Bug #323261, patch by MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-01-30 Christian Persch * embed/mozilla/EphyAboutModule.cpp: Special error text for localhost URIs. Bug #323261, patch by Jean-François Rameau. --- embed/mozilla/EphyAboutModule.cpp | 57 +++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'embed/mozilla') diff --git a/embed/mozilla/EphyAboutModule.cpp b/embed/mozilla/EphyAboutModule.cpp index 350fa8569..9690c2c03 100644 --- a/embed/mozilla/EphyAboutModule.cpp +++ b/embed/mozilla/EphyAboutModule.cpp @@ -244,15 +244,62 @@ EphyAboutModule::GetErrorMessage(nsIURI *aURI, /* Translators: %s is the hostname, like "www.example.com" */ *aTitle = g_markup_printf_escaped - (_("“%s” Refused the Connection"), - host.get()); + (_("“%s” Refused the Connection"), + host.get()); /* Translators: %s is the hostname, like "www.example.com" */ *aPrimary = g_markup_printf_escaped (_("“%s” refused the connection."), host.get()); - *aSecondary = _("The server may be busy or you may have a " - "network connection problem. Try again later."); - *aLinkIntro = _("There may be an old version of the page you wanted:"); + + /* FIXME what about 127.0.0.* ? */ + if (strcmp (host.get(), "localhost") == 0) + { + const char *not_started_msg = _("some service isn't started, or"); + PRInt32 port; + aURI->GetPort (&port); + + *aSecondary = _("Likely causes of the problem are"); + + /* Try to get the service name attached to that port */ + if (port != -1) + { + struct servent *serv; + + if ((serv = getservbyport (htons (port), NULL)) != NULL) + { + *aTertiary = g_markup_printf_escaped ( + _("" + ""), + serv->s_name, port); + } + else + { + *aTertiary = g_markup_printf_escaped ( + _(""), + port); + } + } + else + { + *aTertiary = _(""); + } + } + else + { + *aSecondary = _("The server may be busy or you may have a " + "network connection problem. Try again later."); + *aLinkIntro = _("There may be an old version of the page you wanted:"); + } } else if (strcmp (aError, "netInterrupt") == 0) { -- cgit v1.2.3