Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
mozLineTerm Class Reference

#include <mozLineTerm.h>

Inheritance diagram for mozLineTerm:
Inheritance graph
[legend]
Collaboration diagram for mozLineTerm:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mozLineTerm ()
virtual ~mozLineTerm ()
void openAux (in wstring command, in wstring initInput, in wstring promptRegexp, in PRInt32 options, in PRInt32 processType, in PRInt32 nRows, in PRInt32 nCols, in PRInt32 xPixels, in PRInt32 yPixels, in nsIDOMDocument domDoc, in nsIObserver anObserver, in nsNativeStringRef aCookie)
 Opens LineTerm, a line-oriented terminal interface (without graphics)
void suspendAux (in boolean suspend)
 Suspend/restores LineTerm operation.
void closeAux ()
 Closes LineTerm.
void closeAllAux ()
 Close all LineTerms, not just this one.
void resizeAux (in long nRows, in long nCols)
 Resizes XMLterm to match a resized window.
void readAux (out long opcodes, out long opvals, out long buf_row, out long buf_col, out wstring retval, out wstring retstyle)
 Read output data and style strings and parameters from LineTerm.
void getCookie (in nsNativeStringRef aCookie)
void Open (in wstring command, in wstring initInput, in wstring promptRegexp, in PRInt32 options, in PRInt32 processType, in nsIDOMDocument domDoc)
 Opens LineTerm, a line-oriented terminal interface (without graphics)
void Close (in wstring aCookie)
 Closes LineTerm.
void Write (in wstring buf, in wstring aCookie)
 Writes string to LineTerm as if the user had typed it (command input)
wstring Read (out PRInt32 opcodes, out PRInt32 opvals, out PRInt32 buf_row, out PRInt32 buf_col, in wstring aCookie)
 Read output data string and parameters from LineTerm (command output)

Static Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_MOZILINETERM static
NS_DECL_MOZILINETERMAUX
NS_METHOD 
Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)
static void Callback (gpointer data, gint source, GdkInputCondition condition)
 GTK event callback function.

Public Attributes

attribute long cursorRow
attribute long cursorColumn
attribute boolean echoFlag

Protected Member Functions

NS_IMETHOD ArePrefsSecure (PRBool *_retval)
 Checks if Mozilla preference settings are secure.
NS_IMETHOD GetSecurePrincipal (nsIDOMDocument *domDoc, char **aPrincipalStr)
 Checks if document principal is secure and returns principal string.

Protected Attributes

int mLTerm
 lineterm descriptor index returned by lterm_new (>= 0)
int mCursorRow
 current cursor row position
int mCursorColumn
 current cursor column position
PRBool mSuspended
 flag controlling whether is LineTerm is suspended
PRBool mEchoFlag
 flag controlling input echo in LineTerm
nsIObservermObserver
 non-owning reference to Observer to be notified when data is available for reading from LineTerm
nsString mCookie
 cookie string used for authentication (stored in document.cookie)
PRTime mLastTime
 record of last time when timestamp was displayed in user input log

Static Protected Attributes

static PRBool mLoggingEnabled
 Flag controlling logging of user input to STDERR.
static PRBool mLoggingInitialized

Detailed Description

Definition at line 59 of file mozLineTerm.h.


Constructor & Destructor Documentation

Definition at line 118 of file mozLineTerm.cpp.

Here is the call graph for this function:

Definition at line 131 of file mozLineTerm.cpp.

Here is the call graph for this function:


Member Function Documentation

NS_IMETHODIMP mozLineTerm::ArePrefsSecure ( PRBool _retval) [protected]

Checks if Mozilla preference settings are secure.

Checks if preference settings are secure for LineTerm creation and use.

Parameters:
_retval(output) PR_TRUE if settings are secure

Definition at line 140 of file mozLineTerm.cpp.

{
  nsresult result;

  XMLT_LOG(mozLineTerm::ArePrefsSecure,30,("\n"));

  if (!_retval)
    return NS_ERROR_FAILURE;

  *_retval = PR_FALSE;

  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
  if (!prefBranch)
    return NS_ERROR_FAILURE;

  // Check if Components JS object is secure
  PRBool checkXPC;
  result = prefBranch->GetBoolPref("security.checkxpconnect", &checkXPC);
  if (NS_FAILED(result))
    return NS_ERROR_FAILURE;

  if (!checkXPC) {
    XMLT_ERROR("mozLineTerm::ArePrefsSecure: Error - Please add the line\n"
    "  pref(\"security.checkxpcconnect\",true);\n"
    "to your preferences file (.mozilla/prefs.js)\n");
    *_retval = PR_FALSE;
#if 0  // Temporarily comented out
    return NS_OK;
#endif
  }

  nsCAutoString secString ("security.policy.");
  /* Get global policy name. */
  nsXPIDLCString policyStr;

  result = prefBranch->GetCharPref("javascript.security_policy",
                                   getter_Copies(policyStr));
  if (NS_SUCCEEDED(result) && !policyStr.IsEmpty()) {
    secString.Append(policyStr);
  } else {
    secString.Append("default");
  }

  secString.Append(".htmldocument.cookie");

  XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", secString.get()));

  nsXPIDLCString secLevelString;
  result = prefBranch->GetCharPref(secString.get(), getter_Copies(secLevelString));

  if (NS_FAILED(result))
    return NS_ERROR_FAILURE;

  XMLT_LOG(mozLineTerm::ArePrefsSecure,32,
           ("secLevelString=%s\n", secLevelString.get()));

  *_retval = secLevelString.EqualsLiteral("sameOrigin");

  if (!(*_retval)) {
    XMLT_ERROR("mozLineTerm::ArePrefsSecure: Error - Please add the line\n"
    "  pref(\"security.policy.default.htmldocument.cookie\",\"sameOrigin\");\n"
    "to your preferences file (.mozilla/prefs.js)\n");
  }

  return NS_OK;
}

Here is the call graph for this function:

void mozLineTerm::Callback ( gpointer  data,
gint  source,
GdkInputCondition  condition 
) [static]

GTK event callback function.

GTK-style callback funtion for mozLineTerm object.

Definition at line 405 of file mozLineTerm.cpp.

{
  mozLineTerm* lineTerm = (mozLineTerm*) data;

  //XMLT_LOG(mozLineTerm::Callback,50,("\n"));

  PR_ASSERT(lineTerm != nsnull);
  PR_ASSERT(lineTerm->mObserver != nsnull);

  lineTerm->mObserver->Observe((nsISupports*) lineTerm, nsnull, nsnull);
  return;
}
void mozILineTerm::Close ( in wstring  aCookie) [inherited]

Closes LineTerm.

Parameters:
aCookiedocument.cookie string for authentication

Close all LineTerms, not just this one.

Closes LineTerm.

NS_METHOD mozLineTerm::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 83 of file mozLineTerm.cpp.

{
  if (!mLoggingInitialized) {
    // Initialize all LINETERM operations
    // (This initialization needs to be done at factory creation time;
    //  trying to do it earlier, i.e., at registration time,
    //  does not work ... something to do with loading of static global
    //  variables.)

    int messageLevel = 0;
    char* debugStr = (char*) PR_GetEnv("LTERM_DEBUG");

    if (debugStr && (strlen(debugStr) == 1)) {
      messageLevel = 98;
      debugStr = nsnull;
    }

    int result = lterm_init(0);
    if (result == 0) {
      tlog_set_level(LTERM_TLOG_MODULE, messageLevel, debugStr);
    }
    mLoggingInitialized = PR_TRUE;

    char* logStr = (char*) PR_GetEnv("LTERM_LOG");
    if (logStr && *logStr) {
      // Enable LineTerm logging
      mozLineTerm::mLoggingEnabled = PR_TRUE;
    }
  }

  return mozLineTermConstructor( aOuter,
                                 aIID,
                                 aResult );
}

Here is the call graph for this function:

NS_IMETHODIMP mozLineTerm::GetSecurePrincipal ( nsIDOMDocument domDoc,
char **  aPrincipalStr 
) [protected]

Checks if document principal is secure and returns principal string.

Checks document principal to ensure it has LineTerm creation privileges.

Parameters:
domDOCDOM document object
aPrincipalStr(output) document principal string

Returns the principal string if the principal is secure, and a (zero length) null string if the principal is insecure.

Definition at line 212 of file mozLineTerm.cpp.

{
  XMLT_LOG(mozLineTerm::GetSecurePrincipal,30,("\n"));

  if (!aPrincipalStr)
    return NS_ERROR_FAILURE;

  *aPrincipalStr = nsnull;

  // Get principal string
  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
  if (!doc)
    return NS_ERROR_FAILURE;

  nsIPrincipal *principal = doc->GetPrincipal();
  if (!principal) 
    return NS_ERROR_FAILURE;

#if 0  // Temporarily commented out, because |ToString()| is not implemented.
  if (NS_FAILED(principal->ToString(aPrincipalStr)) || !*aPrincipalStr)
    return NS_ERROR_FAILURE;
#else
  const char temStr[] = "unknown";
  PRInt32 temLen = strlen(temStr);
  *aPrincipalStr = strncpy((char*) nsMemory::Alloc(temLen+1),
                           temStr, temLen+1);
#endif

  XMLT_LOG(mozLineTerm::GetSecurePrincipal,32,("aPrincipalStr=%s\n",
                                               *aPrincipalStr));

  // Check if principal is secure
  PRBool insecure = PR_FALSE;
  if (insecure) {
    // Return null string
    XMLT_ERROR("mozLineTerm::GetSecurePrincipal: Error - "
               "Insecure document principal %s\n", *aPrincipalStr);
    nsMemory::Free(*aPrincipalStr);
    *aPrincipalStr = (char*) nsMemory::Alloc(1);
    **aPrincipalStr = '\0';
  }

  return NS_OK;
}

Here is the call graph for this function:

void mozILineTerm::Open ( in wstring  command,
in wstring  initInput,
in wstring  promptRegexp,
in PRInt32  options,
in PRInt32  processType,
in nsIDOMDocument  domDoc 
) [inherited]

Opens LineTerm, a line-oriented terminal interface (without graphics)

Parameters:
commandname of command to be executed; usually a shell, e.g., "/bin/sh"; if set to null string, the command name is determined from the environment variable SHELL (ASCII only)
initInputinitial input string to be transmitted to terminal; set to null string, if none. (ASCII only)
promptRegexpcommand prompt regular expression (for future use); at the moment, any string terminated by one of the characters "#$%>?", followed by a space, is assumed to be a prompt
optionsLineTerm option bits (usually 0; see lineterm.h)
processTypecommand shell type; if set to -1, type is determined from the command name
domDocDOM document object associated with the LineTerm (document.cookie will be defined for this document on return)
void mozILineTermAux::openAux ( in wstring  command,
in wstring  initInput,
in wstring  promptRegexp,
in PRInt32  options,
in PRInt32  processType,
in PRInt32  nRows,
in PRInt32  nCols,
in PRInt32  xPixels,
in PRInt32  yPixels,
in nsIDOMDocument  domDoc,
in nsIObserver  anObserver,
in nsNativeStringRef  aCookie 
) [inherited]

Opens LineTerm, a line-oriented terminal interface (without graphics)

Parameters:
commandname of command to be executed; usually a shell, e.g., "/bin/sh"; if set to null string, the command name is determined from the environment variable SHELL
promptRegexpcommand prompt regular expression (for future use); at the moment, any string terminated by one of the characters "#$%>?", followed by a space, is assumed to be a prompt
optionsLineTerm option bits (usually 0; see lineterm.h)
processTypecommand shell type; if set to -1, type is determined from the command name
nRowsno. of screen rows
nColsno. of screen columns
xPixelsscreen width in pixels (or 0 if unknown)
yPixelsscreen height in pixels (or 0 if unknown)
domDocDOM document object associated with the LineTerm (document.cookie will be defined for this document on return)
aCookie(output) cookie associated with LineTerm
wstring mozILineTerm::Read ( out PRInt32  opcodes,
out PRInt32  opvals,
out PRInt32  buf_row,
out PRInt32  buf_col,
in wstring  aCookie 
) [inherited]

Read output data string and parameters from LineTerm (command output)

Parameters:
opcodes(output) output data descriptor bits (see lineterm.h)
opvals(output) output data value(s)
buf_row(output) row number (>=-1) (-1 denotes line mode and 0 represents bottom row)
buf_col(output) column number (>=0)
aCookiedocument.cookie string for authentication
Returns:
output data string from LineTerm
void mozILineTermAux::readAux ( out long  opcodes,
out long  opvals,
out long  buf_row,
out long  buf_col,
out wstring  retval,
out wstring  retstyle 
) [inherited]

Read output data and style strings and parameters from LineTerm.

Parameters:
opcodes(output) output data descriptor bits (see lineterm.h)
opvals(output) output data value(s)
buf_row(output) row number (>=-1) (-1 denotes line mode and 0 represents bottom row)
buf_col(output) column number (>=0)
_retval(output) success code
retstyle(output) output style string
Returns:
output data string from LineTerm
void mozILineTermAux::resizeAux ( in long  nRows,
in long  nCols 
) [inherited]

Resizes XMLterm to match a resized window.

Parameters:
nRowsnumber of rows
nColsnumber of columns
void mozILineTermAux::suspendAux ( in boolean  suspend) [inherited]

Suspend/restores LineTerm operation.

Parameters:
aSuspendsuspension state flag
void mozILineTerm::Write ( in wstring  buf,
in wstring  aCookie 
) [inherited]

Writes string to LineTerm as if the user had typed it (command input)

Parameters:
bufstring to be transmitted to LineTerm
aCookiedocument.cookie string for authentication

Member Data Documentation

Definition at line 177 of file mozILineTerm.idl.

Definition at line 176 of file mozILineTerm.idl.

Definition at line 178 of file mozILineTerm.idl.

cookie string used for authentication (stored in document.cookie)

Definition at line 116 of file mozLineTerm.h.

current cursor column position

Definition at line 102 of file mozLineTerm.h.

current cursor row position

Definition at line 99 of file mozLineTerm.h.

flag controlling input echo in LineTerm

Definition at line 108 of file mozLineTerm.h.

record of last time when timestamp was displayed in user input log

Definition at line 119 of file mozLineTerm.h.

PRBool mozLineTerm::mLoggingEnabled [static, protected]

Flag controlling logging of user input to STDERR.

Definition at line 122 of file mozLineTerm.h.

Definition at line 124 of file mozLineTerm.h.

int mozLineTerm::mLTerm [protected]

lineterm descriptor index returned by lterm_new (>= 0)

Definition at line 96 of file mozLineTerm.h.

non-owning reference to Observer to be notified when data is available for reading from LineTerm

Definition at line 113 of file mozLineTerm.h.

flag controlling whether is LineTerm is suspended

Definition at line 105 of file mozLineTerm.h.


The documentation for this class was generated from the following files: