aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-07 21:28:22 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-07 21:28:22 +0800
commit07e1bf23744ac4305406c416e1361582948a1d3e (patch)
treed24a68d5e11adb2cc0df438f8f8e78fe47f4339b /embed
parent5d3540a4c4e9606adef1575b92c0142f65f1ee86 (diff)
downloadgsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar.gz
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar.bz2
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar.lz
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar.xz
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.tar.zst
gsoc2013-epiphany-07e1bf23744ac4305406c416e1361582948a1d3e.zip
Architecture for translatable xml/xsl start page.
2003-01-07 Marco Pesenti Gritti <marco@it.gnome.org> * 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.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/StartHereProtocolHandler.cpp52
1 files changed, 38 insertions, 14 deletions
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<nsIStorageStream> sStream;
+ nsCOMPtr<nsIOutputStream> stream;
+
+ rv = NS_NewStorageStream(16384, (PRUint32)-1, getter_AddRefs(sStream));
+ if (NS_FAILED(rv)) return rv;
- nsCOMPtr<nsIIOService> 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<nsIInputStream> 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); */