Re: Acceesing History and Profile in Mozilla through Jrex

Jean-Philippe Leboeuf <[email protected]> Tue, 08 Aug 2006 20:59:22 +0200
Newsgroups gmane.comp.mozilla.jrex
Message-ID <[email protected]>
Hello,

did you mean "History" or "Bookmarks"?

1) For history,

* You have to create a listener for window events, associated with the 
window manager:

JRexWindowManager winManager = (JRexWindowManager) 
JRexFactory.getInstance().getImplInstance(JRexFactory.WINDOW_MANAGER);

        class OdysseusWindowListener implements 
org.mozilla.jrex.event.window.WindowListener {
          JRexWindowManager winManager;
          public OdysseusWindowListener(JRexWindowManager winManager) {
            this.winManager = winManager;
          }
          public void windowCreated(int jrexPeerID) {
              logger.debug("windowCreated (jrexPeerID <" + jrexPeerID + 
">)");
              JRexCanvas browser = winManager.getBrowser(jrexPeerID);
              browser.addHistoryListener(new 
OdysseusHistory(browser.getNavigator()));
          }
          public void windowDisposing(int jrexPeerID) {
              logger.debug("windowDisposing (jrexPeerID <" + jrexPeerID 
+ ">)");
          }
        }

winManager.addJRexWindowListener(new OdysseusWindowListener(winManager));

* And here is an example of history listener:

/*
 * Created on 14 sept. 2005
 */
package org.wittycube.projects.odysseus;

import java.util.HashMap;
import java.net.URI;
import org.apache.log4j.Logger;
import org.mozilla.jrex.event.history.HistoryEvent;
import org.mozilla.jrex.event.history.HistoryListener;
import org.mozilla.jrex.exception.JRexException;
import org.mozilla.jrex.navigation.WebNavigation;

/**
 * @author jpleboeuf
 */
public class OdysseusHistory implements HistoryListener {
 
  private static Logger logger = Odysseus.logger;
 
  private WebNavigation navigator = null;
 
  public OdysseusHistory(WebNavigation navigator) {
    this.navigator = navigator;
  }
 
  public void addEntry(HistoryEvent event) {
//      logger.debug("URL: " + event.getEventParam().toString().trim());
    try {
      URI refURI = navigator.getReferringURI();
      URI curURI = navigator.getCurrentURI();
//      logger.debug("RefURI: " + refURI);
//      logger.debug("CurURI: " + curURI);
    } catch (JRexException jrexe) {
      logger.error(jrexe);
    }
  }
 
  public boolean reload(HistoryEvent event) {
    return true;
  }
  public boolean goBack(HistoryEvent event) {
    return true;
  }
  public boolean goForward(HistoryEvent event) {
    return true;
  }
  public boolean goToIndex(HistoryEvent event) {
    return true;
  } 
  public boolean purge(HistoryEvent event) {
    return true;
  }
 
}

2) I am interested in the problem of creating a temporary profile too.
(JDIC, has the same kind of problems: without profile BUT Mozilla 
installed, JDIC crashes...)

++jpl

jeet kulkarni wrote:

>I am developing an application where i need to access the History of Mozilla.
>I tried using the Histoty class of Jrex and its associated methods ,but
>found that the History wasnt getting populated. Alslo i need a way to handle
>profiles in Mozilla. I would like to create a profile at run- time and load
>the appropriate if possible. Is there an API to achieve this?
>
>Thanks in Advance.
>
>- Jeet Kulkarni
>Tel No: 631 512 0286.
>  
>