Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-03-18 01:56:57 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-03-18 01:56:57 (GMT)
commit3fd29884f952ea96fcc003b9611c83612759a64b (patch)
tree3fe828a457c5e6ec4b35ed7ed6ca5fe9ae68ea38 /lib
parent57b617ef256e9aa2c4094d26342a0ff60c30ed26 (diff)
Pass the post data to the Persist
Diffstat (limited to 'lib')
-rw-r--r--lib/src/Makefile.am1
-rw-r--r--lib/src/sugar-browser.cpp42
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am
index bdf5dcc..8494971 100644
--- a/lib/src/Makefile.am
+++ b/lib/src/Makefile.am
@@ -11,6 +11,7 @@ libsugarprivate_la_CPPFLAGS = \
-I$(MOZILLA_INCLUDE_DIR)/mimetype \
-I$(MOZILLA_INCLUDE_DIR)/necko \
-I$(MOZILLA_INCLUDE_DIR)/pref \
+ -I$(MOZILLA_INCLUDE_DIR)/shistory \
-I$(MOZILLA_INCLUDE_DIR)/uriloader \
-I$(MOZILLA_INCLUDE_DIR)/webbrwsr \
-I$(MOZILLA_INCLUDE_DIR)/webbrowserpersist \
diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp
index 8385e1d..2f3c0b5 100644
--- a/lib/src/sugar-browser.cpp
+++ b/lib/src/sugar-browser.cpp
@@ -51,6 +51,10 @@
#include <nsISupportsPrimitives.h>
#include <nsIInterfaceRequestorUtils.h>
#include <nsIMIMEHeaderParam.h>
+#include <nsISHistory.h>
+#include <nsIHistoryEntry.h>
+#include <nsISHEntry.h>
+#include <nsIInputStream.h>
enum {
PROP_0,
@@ -673,6 +677,39 @@ sugar_browser_grab_focus(SugarBrowser *browser)
}
}
+
+static nsresult
+GetPostData(SugarBrowser *browser, nsIInputStream **postData)
+{
+#ifdef HAVE_NS_WEB_BROWSER
+ nsCOMPtr<nsIWebBrowser> webBrowser;
+ gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(browser),
+ getter_AddRefs(webBrowser));
+ NS_ENSURE_TRUE(webBrowser, NS_ERROR_FAILURE);
+
+ nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(webBrowser));
+ NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
+
+ PRInt32 sindex;
+
+ nsCOMPtr<nsISHistory> sessionHistory;
+ webNav->GetSessionHistory(getter_AddRefs(sessionHistory));
+ NS_ENSURE_TRUE(sessionHistory, NS_ERROR_FAILURE);
+
+ nsCOMPtr<nsIHistoryEntry> entry;
+ sessionHistory->GetIndex(&sindex);
+ sessionHistory->GetEntryAtIndex(sindex, PR_FALSE, getter_AddRefs(entry));
+
+ nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(entry));
+ if (shEntry) {
+ shEntry->GetPostData(postData);
+ }
+
+ return NS_OK;
+#endif
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
gboolean
sugar_browser_save_uri(SugarBrowser *browser,
const char *uri,
@@ -698,7 +735,10 @@ sugar_browser_save_uri(SugarBrowser *browser,
nsCOMPtr<nsIWebBrowserPersist> webPersist = do_QueryInterface (webBrowser);
NS_ENSURE_TRUE(webPersist, FALSE);
- rv = webPersist->SaveURI(sourceURI, nsnull, nsnull, nsnull, nsnull, destFile);
+ nsCOMPtr<nsIInputStream> postData;
+ GetPostData(browser, getter_AddRefs(postData));
+
+ rv = webPersist->SaveURI(sourceURI, nsnull, nsnull, postData, nsnull, destFile);
NS_ENSURE_SUCCESS(rv, FALSE);
return TRUE;