Sash XB for Linux
Home |  Documentation  ... Contact

Using the Core extension

SashCore provides some basic weblication functionality.


1. Sash.Core

Properties
readonly sashIChannelCollection Channels
Access the various properties of Core.
readonly sashICursor Cursor
readonly sashIProcess Process
readonly sashIUI UI
readonly sashINet Net
readonly sashIPlatform Platform
readonly string WeblicationDataPath
A read-only string property that holds the path to the data directory of the currently running weblication (usually ~/.sash/{weblication-guid}/data)
Methods
void ExecAction(string weblicationGUID, string actionGUID)
Executes the weblication with ID given by weblicationGUID. Execution starts with the action specified by actionGUID . By default a weblication has no permission to execute other weblications
void ExecDefaultWebBrowser(string startURL)
Launches the default web browser with the URL given by startURL. By default weblications have no security permission to launch the browser
string GetNewGUID()
Generates and returns as string a new GUID (Global Unique IDentifier)
string GetSashVersion()
Returns a string with the current version of SashXB
void Sleep(long milliseconds)
Suspends the weblication for a time specified by milliseconds.
nsIVariant Include(string file_or_url)
Reads and evals another file or URL, returns the values learned from the eval.
boolean WeblicationIsInstalled(string weblicationGUID)
Returns true if there is an installed weblication with GUID matching weblicationGUID

2. Sash.Core.Channels


Sash Channels provide the means for communication between the different actions of a single weblication and between multiple weblications. There are two channel lists: a private list and a public list. Public channels can be seen by other weblications, and private channels can only be seen by the current weblication. Choose between the two by setting the boolean argument isPublic.

2.1. Sash.Core.Channels base functionality


Methods
sashIChannel Add(string name [, boolean isPublic])
Creates a new channel called name. The parameter isPublic must be set to true if the channel is to be available to other weblications. Returns a Channel object representing the newly created channel
sashIChannel Item({long, string} index [, boolean isPublic])
Access a channel object by specifying its index in the public / private list or its name. If index is an integer, it is used as a position in the public channel list (isPublic is true) or the private channel list (isPublic is false). If index is a string, it specifies the channel name to be found. Returns a Channel object representing the selected channel
array List([boolean isPublic])
Returns an array with the names of the available channels from the public list (if isPublic is true), or the private list
boolean Remove({long, string} index [, boolean isPublic])
Removes a channel specified in the same way as in Item(...). Returns true on success

2.2. The Channel object


Event
Receiver prototype
Description
OnMemberLeft
handler(long destChannel)
Fires when a member leaves the channel.
OnMessage
handler( sashIChannelMessage message, long destChannel )
Fires when a message arrives on the specified channel.
OnNewMember
handler(long destChannel)
Fires when a new member arrives on the channel.

Properties
long MemberCount
Returns the number of clients listening on the channel.
string Name
Returns the name of the channel as named when added to the channels collection.
boolean Public
Determines whether the Channel can be accessed from other weblications.
Methods
boolean SendMessage( sashIChannelMessage msg)
Sends a channel message object on the channel.

2.3. The Message object


Properties
long ID
The identifier of the channel message.
string Text
The text of the channel message.

3. Sash.Core.Cursor

Sash Cursor allows you to get and set the position of the cursor and set its appearance.

Constants
readonly long APPSTARTING
Numeric constants for operating system-defined cursors.
Additional Linux-only cursor types can be found in sashICursor.idl
readonly long ARROW
readonly long CROSS
readonly long DEFAULT
readonly long HELP
readonly long IBEAM
readonly long ICON
readonly long NO
readonly long SIZEALL
readonly long SIZENESW
readonly long SIZENS
readonly long SIZENSWE
readonly long SIZEWE
readonly long UPARROW
readonly long WAIT
Methods
void SetStandard(long s)
Set the cursor for the dialog. Pass in one of the above constants.
{long, array} GetPosition([boolean specific_coord])
Retrieves the cursor's position, in screen coordinates. If specific_coord is true, the X coordinate is returned. If specific_coord is false, the X coordinate is returned. If specific_coord is null, then the array [X, Y] is returned.
void SetPosition( short newx, short newy)
Moves the cursor to the specified screen coordinates.

4. Sash.Core.Process

Sash.Core.Process allows you to manage processes. Processes can be created and killed.

Methods
long Create(string array command)
Spawns a new process.
For example, if you wanted to run "ls -al", you could use the following code:

	var command = "ls -al";
	Sash.Core.Process.Create(command.split(' '));
    
boolean IsAlive(long pid)
Checks the status of a process.
booleanTerminate(long pid)
Terminates a running process. The PID passed is the one returned from CreateProcess.

5. Sash.Core.UI

Sash.Core.UI presents generic user input boxes and returns the responses.

Constants
readonly long IDCANCEL
Indicates when a user clicks the Cancel button in a message box.
readonly long IDABORT
Indicates when a user clicks the Abort button in a message box.
readonly long IDIGNORE Indicates when a user clicks the Ignore button in a message box.
readonly long IDNO
Indicates when a user clicks the No button in a message box.
readonly long IDOK
Indicates when a user clicks the OK button in a message box.
readonly long IDRETRY
Indicates when a user clicks the Retry button in a message box.
readonly long IDYES
Indicates when a user clicks the Yes button in a message box.
readonly long MB_DEFBUTTON1
Indicates the first button is the default.
readonly long MB_DEFBUTTON2
Indicates the second button is the default.
readonly long MB_DEFBUTTON3
Indicates the third button is the default.
readonly long MB_ICONERROR
Indicates the fourth button is the default.
readonly long MB_ICONINFORMATION
Displays an information icon consisting of a lowercase letter i in a circle in the message box.
readonly long MB_ICONWARNING
Displays an exclamation point icon in the message box.
readonly long MB_OK
Specifies message box will contain one button: OK.
readonly long MB_OKCANCEL
Specifies message box will contain two buttons: OK and Cancel.
readonly long MB_RETRYCANCEL
Specifies message box will contain two buttons: Retry and Cancel.
readonly long MB_SETFOREGROUND
The message box becomes the foreground window.
readonly long MB_SYSTEMMODAL
Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention.
readonly long MB_YESNO
Specifies message box will contain two buttons: Yes and No.
readonly long MB_YESNOCANCEL
Specifies message box will contain three buttons: Yes, No, and Cancel.
readonly long MB_ABORTRETRYIGNORE
Specifies message box will contain three buttons: Abort, Retry, and Ignore.
Methods
long MessageBox(string message, string title, long type)
Creates, displays, and operates a message box. Accepts an MB_*
constant as the type and returns an ID* constant depending on the user response..
string PromptForValue(string title, string prompt, string default_value)
Displays a dialog box that accepts a string input.
{long, array} PromptChoice(string title, string prompt, nsIVariant choicelist[, long default_value[, boolean multiselect]])
Displays a dialog box with list of string choices. Accepts choicelist as an array of strings, and returns the index of the choice selected if multiselect is false and returns an array of indices selected if multiselect is true. The default value of multiselect is false

6. Sash.Core.Net

Download and upload data and files. NOTE: This extension has not been fully tested, and may not work in all situations. The basic download functionality has been tested.

6.1. Sash.Core.Net base functionality

Event
Receiver prototype
Description
OnConnectStateChange
handler(boolean ConnectState)
Invoked when the connect state changes. NOTE: This is not currently implemented.

Constructor
URLConnection
Create a new URL connection.
Properties
string HomeServer
Setting this triggers the event OnConnectStateChange to occur whenever there is a state change. The port or service name (http, ftp, smtp, https) should follow the server name and a colon in a single string. example: "server:service" or "server:port". NOTE: This is not currently supported.
boolean InternetConnectState
State of the internet connection. NOTE: This is not currently supported. To test connectivity of a URLConnection, use the URLConnection.ConnectionActive attribute.
Methods
boolean CheckConnection(string Server, long nPort, long nTimeOut)
Tries to establish a connection within the specified timeout. NOTE: This is not currently supported. Use URLConnection.Execute to initiate a connection.
boolean ConnectToInternet(string URL)
NOTE: This is not currently supported.

6.2. Sash.Core.Net.URLConnection

Event
Receiver prototype
Description
OnAbort
handler(sashIURLConnection connection)
Invoked when a request has been aborted.
OnComplete
handler(sashIURLConnection connection)
Invoked when a request has been completed.
OnProgress
handler(sashIURLConnection connection, long bytesDownloaded, long bytesTotal, long secondsElapsed)
Invoked to give a progress update (bytesDownloaded of bytesTotal finished). This event is called every ProgressEventFrequency
OnStart
handler(sashIURLConnection connection)
Invoked when a request has been started.

Constants
readonly long GET
The type of request for the URLConnection. Appropriate values for the URLConnection.ConnectionType attribute.
readonly long POST
readonly long STATUS_CANCEL
Various response types. Appropriate values for the URLConnection.Status attribute.
readonly long STATUS_FAIL
readonly long STATUS_NAME_NOT_RESOLVED
readonly long STATUS_PROGRESS
readonly long STATUS_SUCCESS
readonly long STATUS_TIMEOUT
Properties
long ProgressEventFrequency
Interval for progress events (in seconds).
string URL
URL to connect to.
string Protocol
The protocol being used for the transfer.
long ConnectionType
Can be URLConnection.GET or URLConnection.POST.
readonly boolean ConnectionActive
Returns true if the connection is active.
long Status
Status of the response. Value is one of the URLConnection.Status_* constants.
readonly string ErrorMessage
Holds a brief message if there is an error.
boolean Async
If true, the transfer will happen asynchronously, meaning that the weblication can continue to execute while the transfer occurs. If false, the weblication cannot continue execution until the transfer is complete. All events will still be called.
boolean SaveResponseToFile
If true, save the response to a LocalSaveFile.
string LocalSaveFile
Local file to save to, if SaveResponseToFile is true.
readonly sashIURLConnectionHeaders RequestHeaders
Request headers of the HTTP request.
string RequestBody
Setting the POST request body can be done in three ways:
1) set the RequestBody attribute. This sets the POST body directly.
2) set one or more with the SetRequestParameter() method, which are key-value pairs. These will be used to construct the body in the form of "key1=value1&key2=value2 etc."
3) set the RequestFile property to the name of a file for an HTTP POST file upload.
You can only use one of the above methods at a time.
string RequestFile
readonly sashIURLConnectionHeaders ResponseHeaders
Response headers of the HTTP request.
readonly long ResponseCode
Returns the HTTP response code.
readonly string Response
If it was a file request, this contains the name of the new local file. Otherwise it returns the text of the response.
readonly string ResponseAsString
Response of the request.
long TimeOut
Number of milliseconds for a timeout for a download or upload action attribute long TimeOut. NOTE: This is not currently supported.
long Retries
Number of times to retry the connection before giving up. NOTE: This is not currently supported.
string UserAgent
NOTE: This is not currently supported.
boolean ForceMultiPartPost
NOTE: This is not currently supported.
Methods
void Abort()
Aborts the URLConnection request.
void Execute()
Starts the URLConnection request.
void SetRequestParameter(string Key, string Value)
Set a request parameter. These parameters will be used to construct a request body in the form "Key1=Value1&Key2=Value2 etc." If you use SetRequestParameter(), do not set RequestBody or RequestFile.
void ClearRequestParameters()
Clear all request parameters.
void SetRequestFile(string Key, string Filename)
Set the name of a file to be uploaded. Useful for posting multiple files. NOTE: This is not currently implemented.
void ClearRequestFiles()
Clear all request files. NOTE: This is not currently implemented.

6.3. Sash.Core.Net.URLConnectionHeaders

Properties
readonly unsigned long Count
The number of headers.
Methods
void Clear()
Clear all of the connection headers.
string GetValue(string HeaderName)
Get the header value for the HeaderName field.
string Name(unsigned long Index)
Get the name of the element specified by Index.
string Value(unsigned long Index)
Get the value of the element specified by Index.
void Remove(unsigned long Index)
Remove the header name and value of the element specified by Index.
void SetValue(string Name, string Value)
Set a header pair specified by (Name, Value).

7. Sash.Core.Platform

Platform allows you to get information about the platform that the weblication is running on.

Properties
string OS
Returns a string defining the Operating System.
string Shell
Returns a string representation of the OS shell being used.


Wing Yung, Stefan Atev
Last modified: Tue Jun 11 16:37:45 EDT 2002

  
© Copyright 2002, All Rights Reserved. Contact