Re: save a web page
"krithika" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <1173448308.192603.172570__34918.1116828278$1173448995$gmane$org@30g2000cwc.googlegroups.com> |
On Jan 26, 10:58 pm, Javier Pedemonte <[email protected]> wrote: > For the answer to both questions, do a search on LXR for > ENCODE_FLAGS_ABSOLUTE_LINKS:http://lxr.mozilla.org/mozilla/search?string=ENCODE_FLAGS_ABSOLUTE_LINKS. > (The LXR page is athttp://lxr.mozilla.org, and the trunk code can be > searched athttp://lxr.mozilla.org/mozilla). > > Just take a look at how this is used in existing code... > > javier > > [email protected] wrote: > > Hi > > > I have successfully embeddedgeckoin my java application using > > xulrunner and the package org.eclipse.swt.browser. Thanks to the people > > that make those available to the comunity. (I hope you can understand > > my english). > > > I'm trying to load a web page from a url and once it's loaded I want to > > save it to the filesystem. I want that the filesystem version > > represents trustworthily the web version the more it cans, and without > > remote references. I'm kind of confused about the encodingFlags > > arguments of method nsIWebBrowserPersist.saveDocument(). > > > Question 1 - It is ok to bitwise-or the flags like > > "nsIWebBrowserPersist.ENCODE_FLAGS_ABSOLUTE_LINKS | > > nsIWebBrowserPersist.ENCODE_FLAGS_PREFORMATTED" ? > > > Question 2 - What would be the best flags for the filesystem version's > > optimal representation of the web version? > > > I get incomplete information in > >http://www.xulplanet.com/references/xpcomref/ifaces/nsIWebBrowserPers.... > > Is there an other xpcom reference? > > > thanks in advance, and thanks to the authors of MozillaBrowserswt > > class and xulrunner. Hi, I tried using swt from eclipse.My xulrunner version is 1.8.1.2.but the below code crashes after loaduri , progress listerner says it is loading and after sometime it crashes.This is on linux.Do you see any issues in my usage. public TestGTK(Composite parent, int style) { super(parent,style); } public static void main(String[] args) { System.out.println("user.dir "+System.getProperty("user.dir")); //Browser brow = new Browser(); Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(300, 300, 300, 300); shell.setText("Main Window"); TestGTK gtk = new TestGTK(shell,SWT.EMBEDDED); gtk.initDisplay(shell); shell.open(); gtk.test(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } void initDisplay(Composite parent) { Display display = parent.getDisplay(); display.setData(NO_INPUT_METHOD, null); } public void test() { GREVersionRange[] range = new GREVersionRange[1]; range[0] = new GREVersionRange("1.8.0", true, "1.9", false); try { grePath = Mozilla.getGREPathWithProperties(range, null); System.out.println("File grePath = "+grePath); if (null == grePath) { grePath = new File(FALLBACK_GRE_PATH); } locProvider = new LocationProvider(grePath); }catch (FileNotFoundException e) { System.out.println("Renderer: FileNotFoundException "+grePath); } Mozilla mozilla = Mozilla.getInstance(); mozilla.initialize(grePath); try { mozilla.initEmbedding(grePath, grePath, locProvider); }catch (XPCOMException e) { System.out.println("Fehler: XPCOMException"); } componentManager =mozilla.getComponentManager(); System.out.println("Step0: componentManager "+componentManager); nsIAppShell AppShell = (nsIAppShell) componentManager.createInstance( NS_APPSHELL_CID, null, nsIAppShell.NS_IAPPSHELL_IID); AppShell.create(null, null); AppShell.spinup(); serviceManager = mozilla.getServiceManager(); System.out.println("Step1: serviceManager "+serviceManager); proxy = (nsIProxyObjectManager)componentManager.createInstanceByContractID("@mozilla.org/ xpcomproxy;1",null,nsIProxyObjectManager.NS_IPROXYOBJECTMANAGER_IID); appStartup =(nsIAppStartup)serviceManager.getServiceByContractID("@mozilla.org/ toolkit/app-startup;1",nsIAppStartup.NS_IAPPSTARTUP_IID); System.out.println("Step2: nsIAppStartup appStartup = "+appStartup); nsIWindowCreator windowCreator =(nsIWindowCreator)appStartup.queryInterface(nsIWindowCreator.NS_IWINDOWCREATOR_IID); System.out.println("Step3: nsIWindowCreator windowCreator ="+windowCreator); windowWatcher = (nsIWindowWatcher)serviceManager.getServiceByContractID("@mozilla.org/ embedcomp/window-watcher;1", nsIWindowWatcher.NS_IWINDOWWATCHER_IID); System.out.println("Step4: nsIWindowWatcher windowWatcher ="+windowWatcher); windowWatcher.setWindowCreator(windowCreator); System.out.println("Step5: setWindowCreator(windowCreator)"); browser = (nsIWebBrowser)componentManager.createInstanceByContractID("@mozilla.org/ embedding/browser/nsWebBrowser; 1",null,nsIWebBrowser.NS_IWEBBROWSER_IID); System.out.println("Step6: nsIWebBrowser "+browser); int hwnd = createWindowHandle(); System.out.println("createWindowHandle "+hwnd); nsIBaseWindow baseWindow = (nsIBaseWindow) browser.queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID); baseWindow.initWindow(hwnd, 0, 0, 0, 1024, 768); baseWindow.create(); baseWindow.setVisibility(true); webNavigation = (nsIWebNavigation) browser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID); System.out.println("Step8: nsIWebNavigation "+webNavigation); webNavigation.loadURI(urlToLoad,nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); System.out.println("Step9: nsIWebNavigation url "+urlToLoad); listener=new WebProgressListener(); progress= (nsIWebProgress)serviceManager.getServiceByContractID("@mozilla.org/ docloaderservice;1", nsIWebProgress.NS_IWEBPROGRESS_IID); System.out.println("Step7: nsIWebProgress "+progress); progress.addProgressListener((nsIWebProgressListener)listener,nsIWebProgress.NOTIFY_ALL); System.out.println("Step7: nsIWebProgressListener added "); //nsIInterfaceRequestor ir = (nsIInterfaceRequestor) browser.queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID); //print = (nsIWebBrowserPrint) ir.getInterface(nsIWebBrowserPrint.NS_IWEBBROWSERPRINT_IID); DocumentProcessor processor = new DocumentProcessor(this); //appStartup.run(); } int createWindowHandle() { String osname=System.getProperty("os.name"); System.out.println("osname "+osname); int embed_handle = OS.gtk_hbox_new (false, 0); OS.gtk_container_add (this.handle, embed_handle); OS.gtk_widget_show (embed_handle); return embed_handle; } regards, Krith