From 07e1bf23744ac4305406c416e1361582948a1d3e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 7 Jan 2003 13:28:22 +0000 Subject: Architecture for translatable xml/xsl start page. 2003-01-07 Marco Pesenti Gritti * configure.in: * data/Makefile.am: * data/start_here.html: * data/starthere/Makefile.am: * data/starthere/index.xml.in: * data/starthere/section.xsl: * embed/mozilla/StartHereProtocolHandler.cpp: * lib/Makefile.am: * lib/widgets/ephy-autocompletion-window.c: (hack_tree_view_move_selection): * po/POTFILES.in: Architecture for translatable xml/xsl start page. --- embed/mozilla/StartHereProtocolHandler.cpp | 52 ++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'embed') diff --git a/embed/mozilla/StartHereProtocolHandler.cpp b/embed/mozilla/StartHereProtocolHandler.cpp index 47a1af310..4ea95294c 100644 --- a/embed/mozilla/StartHereProtocolHandler.cpp +++ b/embed/mozilla/StartHereProtocolHandler.cpp @@ -17,6 +17,7 @@ */ #include "ephy-file-helpers.h" +#include "ephy-start-here.h" #include "nsCOMPtr.h" #include "nsIFactory.h" @@ -26,6 +27,7 @@ #include "nsNetCID.h" #include "nsNetUtil.h" #include "nsXPComFactory.h" +#include "nsIStorageStream.h" static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); @@ -110,25 +112,47 @@ NS_IMETHODIMP GStartHereProtocolHandler::NewURI(const nsACString &aSpec, NS_IMETHODIMP GStartHereProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) { - nsresult rv; + nsresult rv; + EphyStartHere *sh; + char *buf; + PRUint32 bytesWritten; + + mURI = aURI; - nsCAutoString path; - rv = aURI->GetPath(path); - if (NS_FAILED(rv)) return rv; + nsCAutoString path; + rv = aURI->GetPath(path); + if (NS_FAILED(rv)) return rv; - char *httpSpec = g_strconcat ("file:///", - ephy_file ("start_here.html"), - NULL); - - if (!httpSpec) return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr sStream; + nsCOMPtr stream; + + rv = NS_NewStorageStream(16384, (PRUint32)-1, getter_AddRefs(sStream)); + if (NS_FAILED(rv)) return rv; - nsCOMPtr serv(do_GetIOService(&rv)); - if (NS_FAILED(rv)) return rv; + rv = sStream->GetOutputStream(0, getter_AddRefs(stream)); + if (NS_FAILED(rv)) return rv; - // now we have an HTTP url, give the user an HTTP channel - rv = serv->NewChannel(nsDependentCString(httpSpec), nsnull, nsnull, _retval); + sh = ephy_start_here_new (); + buf = ephy_start_here_get_page (sh, "index"); + rv = stream->Write (buf, strlen (buf), &bytesWritten); + g_free (buf); + + nsCOMPtr iStream; + PRUint32 size; - return rv; + rv = sStream->GetLength(&size); + if (NS_FAILED(rv)) return rv; + + rv = sStream->NewInputStream(0, getter_AddRefs(iStream)); + if (NS_FAILED(rv)) return rv; + + rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), mURI, + iStream, NS_LITERAL_CSTRING("text/xml"), + NS_LITERAL_CSTRING("utf-8"), size); + + NS_IF_ADDREF (*_retval = mChannel); + + return rv; } /* boolean allowPort (in long port, in string scheme); */ -- cgit v1.2.3