NC: the Net Context

The protocol handler code at times requires resources that may vary from connection to connection. For example, access to a password-protected ftp site may require the ftp protocol module to prompt for a password; most protocol modules will notify observers of significant events; and so on.

These can be seen as a set of callbacks that the caller must provide to the URL Connection. We have grouped these callbacks together as methods in an interface, called the Net Context. This interface provides the per-connection context required for the netlib to work.

We imagine that there will be several types that implement this interface: one for each front-end, perhaps one for each front-end for mail/news windows, a ``null'' context used internally (by, e.g., the image library), and one or more used in server situations. I would guess that there would be one instance per window, but the details of this are up to the callers.

Note that there is no such thing as a Net Context Group. Never was, never will be.


This interface is defined in java, and is compiled with JMC. The C syntax is included in each method description, and is summarised below.

import netscape.jmc.*;
import netscape.types.*;
import netscape.url.URL;

public abstract interface NC {
  // popups
  public abstract boolean confirm(TextMessage m) throws Exception;
  public abstract String prompt(TextMessage m, String d) throws Exception;
  public abstract String getPassword(TextMessage m) throws Exception;

  // registerCallback is needed for multithreading
  // public abstract void registerCallback(PREventQueue queue, Callback callback, Object arg) throws Exception;

  // Instructions to the front end to go do something.  Legacy.
  public abstract void doRemoteHost(int url_type, String host, String port, String username) throws Exception;
  public abstract void setRefreshURLTimer(int seconds, URL url) throws Exception;

  // Dynamic observation points
  public abstract void observe(String name, Observer proc, Object addArg) throws Exception;
  public abstract void notify(String name, int message, Object notifyArg) throws Exception;

Interface Methods

Inherited Methods

Although this interface does not inherit anything, note that all objects implementing this interface will inherit the usual JMC base methods.

C interface

#include "NC.h"

jbool NC_confirm(NC *self, struct TextMessage a, JMCException **e);
const char *NC_prompt(NC *self, struct TextMessage a, const char *b, JMCException **e);
const char *NC_getPassword(NC *self, struct TextMessage a, JMCException **e);
void NC_doRemoteHost(NC *self, jint url_type, const char *host, const char *port, const char *username, JMCException **e);
void NC_setRefreshURLTimer(NC *self, jint seconds, URL *url, JMCException **e);
void NC_observe(NC *self, const char *name, XP_ObserverProc proc, void *addArg, JMCException **e);
void NC_notify(NC *self, const char *name, jint message, void *notifyArg, JMCException **e);

/* methods inherited from base JMC object interface */
void *NC_getInterface(NC *self, JMCInterfaceID id, JMCException **e);
void NC_addRef(NC *self, JMCException **e);
void NC_release(NC *self, JMCException **e);
jint NC_hashCode(NC *self, JMCException **e);
void *NC_clone(NC *self, JMCException **e);
const char *NC_toString(NC *self, JMCException **e);
void NC_finalize(NC *self, JMCException **e);

Written by Frederick at 18:32 17.03.1997.