MoSync 3.3
Wormhole Library

Classes

class  Wormhole::Encoder
 Class with methods to encode/decode data as strings. More...
class  Wormhole::FileUtil
 Class that contains utility methods. More...
class  Wormhole::HighLevelBinaryDownloader
class  Wormhole::HighLevelReader
 Base class for helper classes that handle the download. We have only one such class right now, HighLevelReaderThatReadsChunks. More...
class  Wormhole::HighLevelReaderThatReadsChunks
 Class that handles download when content-length is NOT known. Here we read in chunks until we get result CONNERR_CLOSED in connRecvFinished. More...
class  Wormhole::HighLevelHttpConnection
class  Wormhole::HighLevelImageDownloader
class  Wormhole::HighLevelTextDownloader
class  Wormhole::HybridMoblet
 Moblet designed to make it easy to add custom C++ code that can be invoked from JavaScript. This class provides a Wormhole-enabled WebView, methods to extract and load your HTML files and JavaScript code, and a structure for communicating with JavaScript. More...
class  Wormhole::MessageProtocol
 Class that checks a Wormhole protocol. More...
class  Wormhole::MessageStream
 Class that parses messages from the WebView. More...
class  Wormhole::MessageStreamJSON
 Class that parses JSON messages from the WebView. More...
class  Wormhole::WebAppMoblet
 A Moblet with additional functionality that allows easier interaction with JavaScript code. It provides a wormhole-enabled WebView, methods to extract and load your HTML files and JavaScript code, and a structure for communicating with your JS code. More...
class  Wormhole::WebViewMessage
 Class that parses messages from the WebView. More...

Namespaces

namespace  Wormhole
 

Classes for Hybrid app support.


Files

file  Encoder.h
 

Class for encoding/decoding data.


file  FileUtil.h
file  HighLevelBinaryDownloader.h
 

A high-level object for downloading binary files.


file  HighLevelHttpConnection.h
 

A high-level HTTP connection object.


file  HighLevelImageDownloader.h
 

A high-level object for downloading image files.


file  HighLevelTextDownloader.h
 

A high-level object for downloading text files.


file  HybridMoblet.h
 

High-level moblet that has a WebView and supports communication between a JavaScript and C++.


file  MessageProtocol.h
 

Class for reading the protocol of a message from a WebView.


file  MessageStream.h
 

Class for parsing a stream of messages from a WebView.


file  MessageStreamJSON.h
 

Class for parsing JSON messages from a WebView.


file  WebAppMoblet.h
 

High-level moblet that has a WebView and supports communication between a JavaScript and C++.


file  WebViewMessage.h
 

Class for parsing messages from a WebView.


Defines

#define WORMHOLE_HTTP_SUCCESS   1
#define WORMHOLE_HTTP_ERROR   -1

Functions

static MAUtil::String Wormhole::Encoder::unescape (const MAUtil::String &str)
static MAUtil::String Wormhole::Encoder::escape (const MAUtil::String &str)
static MAUtil::String Wormhole::Encoder::JSONStringify (const char *str)
static MAUtil::String Wormhole::Encoder::base64Encode (const void *data, int length)
static int Wormhole::Encoder::base64Decode (const char *input, void **output, int *outputLength)
 Wormhole::FileUtil::FileUtil ()
virtual Wormhole::FileUtil::~FileUtil ()
virtual MAUtil::String Wormhole::FileUtil::getLocalPath ()
virtual MAUtil::String Wormhole::FileUtil::getAppPath ()
virtual void Wormhole::FileUtil::setAppPath (const MAUtil::String &fullPath)
virtual bool Wormhole::FileUtil::extractFileSystem (MAHandle handle, const MAUtil::String &destinationPath)
virtual bool Wormhole::FileUtil::extractLocalFiles ()
virtual int Wormhole::FileUtil::getFileSystemChecksum (MAHandle handle)
virtual MAHandle Wormhole::FileUtil::openFileForWriting (const MAUtil::String &filePath)
virtual MAHandle Wormhole::FileUtil::openFileForReading (const MAUtil::String &filePath)
virtual bool Wormhole::FileUtil::writeDataToFile (const MAUtil::String &filePath, MAHandle outData)
virtual bool Wormhole::FileUtil::writeTextToFile (const MAUtil::String &filePath, const MAUtil::String &outText)
virtual bool Wormhole::FileUtil::readDataFromFile (const MAUtil::String &filePath, MAHandle inPlaceholder)
virtual bool Wormhole::FileUtil::readTextFromFile (const MAUtil::String &filePath, MAUtil::String &inText)
virtual MAUtil::String Wormhole::FileUtil::createTextFromHandle (MAHandle data)
 Wormhole::HighLevelBinaryDownloader::HighLevelBinaryDownloader ()
virtual Wormhole::HighLevelBinaryDownloader::~HighLevelBinaryDownloader ()
virtual void Wormhole::HighLevelBinaryDownloader::onDownloadComplete (MAHandle data)=0
virtual void Wormhole::HighLevelBinaryDownloader::dataDownloaded (MAHandle data, int result)
 Wormhole::HighLevelReader::HighLevelReader (HighLevelHttpConnection *connection)
virtual Wormhole::HighLevelReader::~HighLevelReader ()
virtual void Wormhole::HighLevelReader::startRecvToData ()=0
virtual void Wormhole::HighLevelReader::connRecvFinished (int result)=0
int Wormhole::HighLevelReader::getContentLength ()
 Wormhole::HighLevelReaderThatReadsChunks::HighLevelReaderThatReadsChunks (HighLevelHttpConnection *downloader)
virtual Wormhole::HighLevelReaderThatReadsChunks::~HighLevelReaderThatReadsChunks ()
virtual void Wormhole::HighLevelReaderThatReadsChunks::startRecvToData ()
virtual void Wormhole::HighLevelReaderThatReadsChunks::connRecvFinished (int result)
bool Wormhole::HighLevelReaderThatReadsChunks::readNextChunk ()
void Wormhole::HighLevelReaderThatReadsChunks::finishedDownloadingChunkedData ()
 Wormhole::HighLevelHttpConnection::HighLevelHttpConnection ()
virtual Wormhole::HighLevelHttpConnection::~HighLevelHttpConnection ()
int Wormhole::HighLevelHttpConnection::postRequest (const char *url, MAUtil::Vector< MAUtil::String > &httpParams, const void *requestBody, int requestLength)
int Wormhole::HighLevelHttpConnection::postJsonRequest (const char *url, const char *jsonData)
int Wormhole::HighLevelHttpConnection::get (const char *url)
void Wormhole::HighLevelHttpConnection::downloadSuccess (MAHandle handle)
void Wormhole::HighLevelHttpConnection::downloadError (int result)
virtual void Wormhole::HighLevelHttpConnection::dataDownloaded (MAHandle data, int result)=0
void Wormhole::HighLevelHttpConnection::httpFinished (MAUtil::HttpConnection *connection, int result)
void Wormhole::HighLevelHttpConnection::connWriteFinished (MAUtil::Connection *connection, int result)
void Wormhole::HighLevelHttpConnection::connRecvFinished (MAUtil::Connection *connection, int result)
void Wormhole::HighLevelHttpConnection::connReadFinished (MAUtil::Connection *connection, int result) __attribute__((noreturn))
void Wormhole::HighLevelHttpConnection::deallocateData ()
void Wormhole::HighLevelHttpConnection::deleteReader ()
 Wormhole::HighLevelImageDownloader::HighLevelImageDownloader ()
virtual Wormhole::HighLevelImageDownloader::~HighLevelImageDownloader ()
virtual void Wormhole::HighLevelImageDownloader::onDownloadComplete (MAHandle image)=0
virtual void Wormhole::HighLevelImageDownloader::dataDownloaded (MAHandle data, int result)
 Wormhole::HighLevelTextDownloader::HighLevelTextDownloader ()
virtual Wormhole::HighLevelTextDownloader::~HighLevelTextDownloader ()
virtual void Wormhole::HighLevelTextDownloader::onDownloadComplete (char *text)=0
static void Wormhole::HighLevelTextDownloader::freeData (char *text)
virtual void Wormhole::HighLevelTextDownloader::dataDownloaded (MAHandle data, int result)
 Wormhole::HybridMoblet::HybridMoblet ()
virtual Wormhole::HybridMoblet::~HybridMoblet ()
virtual void Wormhole::HybridMoblet::initialize ()
virtual void Wormhole::HybridMoblet::openWormhole (MAHandle webViewHandle)
virtual void Wormhole::HybridMoblet::createUI ()
virtual NativeUI::WebViewWormhole::HybridMoblet::getWebView ()
virtual FileUtil * Wormhole::HybridMoblet::getFileUtil ()
virtual void Wormhole::HybridMoblet::showPage (const MAUtil::String &url)
virtual void Wormhole::HybridMoblet::showNativeUI (const MAUtil::String &url)
virtual void Wormhole::HybridMoblet::showWebView ()
virtual void Wormhole::HybridMoblet::setBeepSound (MAHandle beepSoundResource)
virtual MessageHandler * Wormhole::HybridMoblet::getMessageHandler ()
virtual void Wormhole::HybridMoblet::setMessageHandler (MessageHandler *handler)
virtual void Wormhole::HybridMoblet::addMessageFun (const char *command, Wormhole::FunTable::MessageHandlerFun fun)
virtual void Wormhole::HybridMoblet::handleWebViewMessage (MAWidgetHandle webViewHandle, MAHandle data)
virtual void Wormhole::HybridMoblet::printWebViewMessage (MAHandle dataHandle)
virtual void Wormhole::HybridMoblet::customEvent (const MAEvent &event)
virtual void Wormhole::HybridMoblet::keyPressEvent (int keyCode, int nativeCode)
virtual void Wormhole::HybridMoblet::callJS (const MAUtil::String &script)
virtual void Wormhole::HybridMoblet::callJS (MAWidgetHandle webViewHandle, const MAUtil::String &script)
virtual void Wormhole::HybridMoblet::sendDeviceScreenSizeToJavaScript ()
virtual void Wormhole::HybridMoblet::sendWebViewHandleToJavaScript ()
virtual void Wormhole::HybridMoblet::enableWebViewMessages ()
virtual void Wormhole::HybridMoblet::disableWebViewMessages ()
virtual void Wormhole::HybridMoblet::extractFileSystem ()
virtual bool Wormhole::HybridMoblet::checksumHasChanged ()
virtual void Wormhole::HybridMoblet::writeChecksum ()
 Wormhole::MessageProtocol::MessageProtocol (MAHandle dataHandle)
virtual Wormhole::MessageProtocol::~MessageProtocol ()
bool Wormhole::MessageProtocol::matches (const char *protocol)
bool Wormhole::MessageProtocol::isMessageStream ()
bool Wormhole::MessageProtocol::isMessageStreamJSON ()
 Wormhole::MessageStream::MessageStream (MAWidgetHandle webViewHandle, MAHandle dataHandle)
 Wormhole::MessageStream::MessageStream::MessageStream (NativeUI::WebView *webView, MAHandle dataHandle)
virtual Wormhole::MessageStream::~MessageStream ()
bool Wormhole::MessageStream::isValid ()
MAWidgetHandle Wormhole::MessageStream::getWebViewHandle ()
NativeUI::WebViewWormhole::MessageStream::getWebView ()
void Wormhole::MessageStream::callJS (const MAUtil::String &script)
const char * Wormhole::MessageStream::getNext (int *length=NULL)
void Wormhole::MessageStream::MessageStream::initialize (MAHandle dataHandle)
int Wormhole::MessageStream::xtoi (char *s, char **newPos)
int Wormhole::MessageStream::raise (int base, int e)
 Wormhole::MessageStreamJSON::MessageStreamJSON (MAWidgetHandle webViewHandle, MAHandle dataHandle)
 Wormhole::MessageStreamJSON::MessageStreamJSON::MessageStreamJSON (NativeUI::WebView *webView, MAHandle dataHandle)
virtual Wormhole::MessageStreamJSON::~MessageStreamJSON ()
MAWidgetHandle Wormhole::MessageStreamJSON::getWebViewHandle ()
NativeUI::WebViewWormhole::MessageStreamJSON::getWebView ()
void Wormhole::MessageStreamJSON::callJS (const MAUtil::String &script)
bool Wormhole::MessageStreamJSON::next ()
bool Wormhole::MessageStreamJSON::is (const char *paramName)
MAUtil::String Wormhole::MessageStreamJSON::getParam (const char *paramName)
int Wormhole::MessageStreamJSON::getParamInt (const char *paramName)
bool Wormhole::MessageStreamJSON::hasParam (const char *paramName)
MAUtil::YAJLDom::Value * Wormhole::MessageStreamJSON::getParamNode (const char *paramName)
MAUtil::YAJLDom::Value * Wormhole::MessageStreamJSON::getJSONRoot ()
void Wormhole::MessageStreamJSON::parse (MAHandle dataHandle)
 Wormhole::WebAppMoblet::WebAppMoblet ()
virtual Wormhole::WebAppMoblet::~WebAppMoblet ()
virtual NativeUI::WebViewWormhole::WebAppMoblet::getWebView ()
virtual FileUtil * Wormhole::WebAppMoblet::getFileUtil ()
virtual void Wormhole::WebAppMoblet::enableWebViewMessages ()
virtual void Wormhole::WebAppMoblet::disableWebViewMessages ()
virtual void Wormhole::WebAppMoblet::showPage (const MAUtil::String &url)
virtual void Wormhole::WebAppMoblet::showWebView ()
virtual void Wormhole::WebAppMoblet::callJS (const MAUtil::String &script)
virtual void Wormhole::WebAppMoblet::handleWebViewMessage (NativeUI::WebView *webView, MAHandle urlData)
virtual void Wormhole::WebAppMoblet::keyPressEvent (int keyCode, int nativeCode)
virtual void Wormhole::WebAppMoblet::extractFileSystem ()
virtual bool Wormhole::WebAppMoblet::checksumHasChanged ()
virtual void Wormhole::WebAppMoblet::writeChecksum ()
static MAUtil::String Wormhole::WebViewMessage::unescape (const MAUtil::String &str)
static MAUtil::String Wormhole::WebViewMessage::escape (const MAUtil::String &str)
 Wormhole::WebViewMessage::WebViewMessage (NativeUI::WebView *webView, MAHandle dataHandle)
virtual Wormhole::WebViewMessage::~WebViewMessage ()
virtual NativeUI::WebViewWormhole::WebViewMessage::getWebView ()
virtual bool Wormhole::WebViewMessage::is (const MAUtil::String &messageName)
virtual MAUtil::String Wormhole::WebViewMessage::getParam (const MAUtil::String &paramName)
virtual int Wormhole::WebViewMessage::getParamInt (const MAUtil::String &paramName)
virtual bool Wormhole::WebViewMessage::hasParam (const MAUtil::String &paramName)
virtual void Wormhole::WebViewMessage::parse (MAHandle dataHandle)

Variables

MAUtil::String Wormhole::FileUtil::mAppPath
HighLevelHttpConnection * Wormhole::HighLevelReader::mConnection
int Wormhole::HighLevelReader::mContentLength
MAUtil::Vector< MAHandleWormhole::HighLevelReaderThatReadsChunks::mDataChunks
int Wormhole::HighLevelReaderThatReadsChunks::mDataChunkSize
int Wormhole::HighLevelReaderThatReadsChunks::mDataChunkOffset
NativeUI::ScreenWormhole::HybridMoblet::mScreen
NativeUI::WebViewWormhole::HybridMoblet::mWebView
HybridMoblet_WebViewListener * Wormhole::HybridMoblet::mWebViewListener
FileUtil * Wormhole::HybridMoblet::mFileUtil
MessageHandler * Wormhole::HybridMoblet::mMessageHandler
bool Wormhole::HybridMoblet::mInitialized
char Wormhole::MessageProtocol::mProtocol [3]
MAWidgetHandle Wormhole::MessageStream::mWebViewHandle
NativeUI::WebViewWormhole::MessageStream::mWebView
char * Wormhole::MessageStream::mData
int Wormhole::MessageStream::mDataSize
char * Wormhole::MessageStream::mStart
char * Wormhole::MessageStream::mEnd
MAWidgetHandle Wormhole::MessageStreamJSON::mWebViewHandle
NativeUI::WebViewWormhole::MessageStreamJSON::mWebView
MAUtil::YAJLDom::Value * Wormhole::MessageStreamJSON::mJSONRoot
int Wormhole::MessageStreamJSON::mCurrentMessageIndex
NativeUI::ScreenWormhole::WebAppMoblet::mScreen
NativeUI::WebViewWormhole::WebAppMoblet::mWebView
WebAppMoblet_WebViewListener * Wormhole::WebAppMoblet::mWebViewListener
FileUtil * Wormhole::WebAppMoblet::mFileUtil
bool Wormhole::WebAppMoblet::mFileSystemIsExtracted
NativeUI::WebViewWormhole::WebViewMessage::mWebView
MAUtil::String Wormhole::WebViewMessage::mMessageName
MAUtil::HashMap
< MAUtil::String,
MAUtil::String
Wormhole::WebViewMessage::mMessageParams

Define Documentation

#define WORMHOLE_HTTP_SUCCESS   1
#define WORMHOLE_HTTP_ERROR   -1

Function Documentation

static MAUtil::String Wormhole::Encoder::unescape ( const MAUtil::String str) [static]

Take a string that is "percent encoded" and decode it.

Parameters:
strEncoded string.
Returns:
Decoded string.
static MAUtil::String Wormhole::Encoder::escape ( const MAUtil::String str) [static]

Take a string and "percent encode" it.

Parameters:
strString to be encoded.
Returns:
Encoded string.
static MAUtil::String Wormhole::Encoder::JSONStringify ( const char *  str) [static]

Make a JSON stringified string.

Parameters:
strString to be in JSON literal format.
Returns:
Stringified string.
static MAUtil::String Wormhole::Encoder::base64Encode ( const void *  data,
int  length 
) [static]

Encode data as base64.

Parameters:
dataPointer to data to be encoded.
lengthNumber of bytes to be encoded.
Returns:
String object with encoded data.
static int Wormhole::Encoder::base64Decode ( const char *  input,
void **  output,
int *  outputLength 
) [static]

Decode Base64 encoded data. NOTE: The data buffer returned in the output parameter must be deallocated using free().

Parameters:
inputPointer to zero-terminated string with encoded data.
outputPointer to pointer that will point to the decoded data.
inputPointer int that will contain the length of the decoded data.
Returns:
1 on success, 0 on error.

Constructor.

virtual Wormhole::FileUtil::~FileUtil ( ) [virtual]

Destructor.

Get the path to the local file system.

Returns:
Path that ends with a slash.

Get the path to the directory to be used as the root path by File APIs.

Returns:
Full path to the current root directory.
virtual void Wormhole::FileUtil::setAppPath ( const MAUtil::String fullPath) [virtual]

Set the path to the directory to be used as the root path by File APIs.

Parameters:
fullPathFull path to the root directory.
virtual bool Wormhole::FileUtil::extractFileSystem ( MAHandle  handle,
const MAUtil::String destinationPath 
) [virtual]

Extract a file system bundle to a directory in the local file system on the device/emulator.

Parameters:
handleThe resource handle of the bundled file system. Bundles are created with the Bundle tool that comes with MoSync.
destinationPathThe path of the directory where the file system will be extracted.
virtual bool Wormhole::FileUtil::extractLocalFiles ( ) [virtual]

Extract the files in the file system bundle defined as the first resource in the resource file. Files are extracted to the root of the local file system on the device/emulator.

This function is intended as a high-level way to extract files packaged in the standard way used in the HTML5 Project Template.

virtual int Wormhole::FileUtil::getFileSystemChecksum ( MAHandle  handle) [virtual]

Get the checksum of a file bundle.

Parameters:
handleThe resource handle of the bundled file system. Bundles are created with the Bundle tool that comes with MoSync.
Returns:
A 32-bit checksum.
virtual MAHandle Wormhole::FileUtil::openFileForWriting ( const MAUtil::String filePath) [virtual]

Open a file for writing. Create the file if it does not exist. Note: Will truncate the file if it exists.

Returns:
Handle to the open file, <0 on error.
virtual MAHandle Wormhole::FileUtil::openFileForReading ( const MAUtil::String filePath) [virtual]

Open a file for reading.

Returns:
Handle to the open file, <0 on error.
virtual bool Wormhole::FileUtil::writeDataToFile ( const MAUtil::String filePath,
MAHandle  outData 
) [virtual]

Write a data object to a file.

Returns:
true on success, false on error.
virtual bool Wormhole::FileUtil::writeTextToFile ( const MAUtil::String filePath,
const MAUtil::String outText 
) [virtual]

Write a text string to a file.

Returns:
true on success, false on error.
virtual bool Wormhole::FileUtil::readDataFromFile ( const MAUtil::String filePath,
MAHandle  inPlaceholder 
) [virtual]

Read a data object from a file.

Parameters:
filePathFull path of file to read.
inPlaceholderPlaceholder handle for data object.
Returns:
true on success, false on error.
virtual bool Wormhole::FileUtil::readTextFromFile ( const MAUtil::String filePath,
MAUtil::String inText 
) [virtual]

Read a text string from a file.

Returns:
true on success, false on error.

Create a text string from data handle.

Override to do something with the data that is downloaded. If download fails, data is NULL. Note that data must be deallocated using maDestroyPlaceholder().

virtual void Wormhole::HighLevelBinaryDownloader::dataDownloaded ( MAHandle  data,
int  result 
) [protected, virtual]

Inherited from HighLevelHttpConnection. Called when the HTTP connection has finished downloading data. Calls onDownloadComplete.

Parameters:
dataHandle to the data, will be 0 on error, > 0 on success.
resultResult code, RES_OK on success, otherwise an HTTP error code.

Implements Wormhole::HighLevelHttpConnection.

Destructor.

virtual void Wormhole::HighLevelReader::startRecvToData ( ) [pure virtual]

Start downloading data.

Implemented in Wormhole::HighLevelReaderThatReadsChunks.

virtual void Wormhole::HighLevelReader::connRecvFinished ( int  result) [pure virtual]

Called when the new data is available.

Implemented in Wormhole::HighLevelReaderThatReadsChunks.

Start downloading data.

Implements Wormhole::HighLevelReader.

virtual void Wormhole::HighLevelReaderThatReadsChunks::connRecvFinished ( int  result) [virtual]

Called when the new data is available.

Implements Wormhole::HighLevelReader.

int Wormhole::HighLevelHttpConnection::postRequest ( const char *  url,
MAUtil::Vector< MAUtil::String > &  httpParams,
const void *  requestBody,
int  requestLength 
)

Post an HTTP request.

The HTTP header parameters must be a vector (possibly empty) of strings, ordered as key/value pairs.

Parameters:
urlThe url of the POST request.
httpParamsHTTP header parameters.
requestBodyData written to the request body.
requestLengthLength of the request body.
Returns:
WORMHOLE_HTTP_SUCCESS if successful, WORMHOLE_HTTP_ERROR on error.
int Wormhole::HighLevelHttpConnection::postJsonRequest ( const char *  url,
const char *  jsonData 
)

This is the starting point of the JSON request.

Returns:
WORMHOLE_HTTP_SUCCESS if successful, WORMHOLE_HTTP_ERROR on error.
int Wormhole::HighLevelHttpConnection::get ( const char *  url)

This is the starting point of a GET request.

Called by an HighLevelReader when download is successfully finished.

Called by an HighLevelReader when there is a download error.

virtual void Wormhole::HighLevelHttpConnection::dataDownloaded ( MAHandle  data,
int  result 
) [protected, pure virtual]

Implement this method in a subclass of this class. Called when the HTTP connection has finished downloading data.

Parameters:
dataHandle to the data, will be 0 on error, > 0 on success.
resultResult code, RES_OK on success, otherwise an HTTP error code. The subclass takes ownership of this data and has the responsibility of deallocating the data.

Implemented in Wormhole::HighLevelTextDownloader, Wormhole::HighLevelBinaryDownloader, and Wormhole::HighLevelImageDownloader.

void Wormhole::HighLevelHttpConnection::httpFinished ( MAUtil::HttpConnection connection,
int  result 
) [protected, virtual]

This method is called when the HTTP request is complete. Now all data is sent to the server and we can start reading the reply and download data.

Implements MAUtil::HttpConnectionListener.

void Wormhole::HighLevelHttpConnection::connWriteFinished ( MAUtil::Connection conn,
int  result 
) [protected, virtual]

Called when a write operation finishes.

Parameters:
connThe Connection that ran the operation.
result> 0 on success, or a CONNERR code < 0 on failure.

Reimplemented from MAUtil::ConnectionListener.

void Wormhole::HighLevelHttpConnection::connRecvFinished ( MAUtil::Connection conn,
int  result 
) [protected, virtual]

Called when a recv operation finishes.

Parameters:
connThe Connection that ran the operation.
resultThe number of bytes read on success, or a CONNERR code < 0 on failure.

Reimplemented from MAUtil::ConnectionListener.

void Wormhole::HighLevelHttpConnection::connReadFinished ( MAUtil::Connection conn,
int  result 
) [protected, virtual]

Called when a read operation finishes.

Parameters:
connThe Connection that ran the operation.
result> 0 on success, or a CONNERR code < 0 on failure.

Reimplemented from MAUtil::ConnectionListener.

Delete the reader object (this is the object that performs the download).

Destructor.

virtual void Wormhole::HighLevelImageDownloader::onDownloadComplete ( MAHandle  image) [pure virtual]

Override to do something with the image that is downloaded. If download fails, image is 0. Note that image must be deallocated using maDestroyPlaceholder.

virtual void Wormhole::HighLevelImageDownloader::dataDownloaded ( MAHandle  data,
int  result 
) [protected, virtual]

Inherited from HighLevelHttpConnection. Called when the HTTP connection has finished downloading data. Calls onDownloadComplete.

Parameters:
dataHandle to the data, will be 0 on error, > 0 on success.
resultResult code, RES_OK on success, otherwise an HTTP error code.

Implements Wormhole::HighLevelHttpConnection.

Destructor.

virtual void Wormhole::HighLevelTextDownloader::onDownloadComplete ( char *  text) [pure virtual]

Override to do something with the text that is downloaded. If download fails, text is NULL. Note that text must be deallocated using HighLevelTextDownloader::freeData().

static void Wormhole::HighLevelTextDownloader::freeData ( char *  text) [static]

Use to free data passed by onDownloadComplete.

virtual void Wormhole::HighLevelTextDownloader::dataDownloaded ( MAHandle  data,
int  result 
) [protected, virtual]

Inherited from HighLevelHttpConnection. Called when the HTTP connection has finished downloading data. Calls onDownloadComplete.

Parameters:
dataHandle to the data, will be 0 on error, > 0 on success.
resultResult code, RES_OK on success, otherwise an HTTP error code.

Implements Wormhole::HighLevelHttpConnection.

Destructor.

virtual void Wormhole::HybridMoblet::initialize ( ) [virtual]

Initialize the moblet.

virtual void Wormhole::HybridMoblet::openWormhole ( MAHandle  webViewHandle) [virtual]

Initialize the Wormhole JS library. Should be called after the page has been displayed.

virtual void Wormhole::HybridMoblet::createUI ( ) [virtual]

Creates the main UI elements, but does not connect them.

Get the WebView widget displayed by this moblet.

Returns:
Pointer to the WebView instance.
virtual FileUtil* Wormhole::HybridMoblet::getFileUtil ( ) [virtual]

Get a file utility object used for accessing the device's local file system.

Returns:
Pointer to a FileUtil instance.
virtual void Wormhole::HybridMoblet::showPage ( const MAUtil::String url) [virtual]

Display a page in the main WebView of this moblet. Will automatically call initialize() if not called previously.

Parameters:
urlUrl of page to open.
virtual void Wormhole::HybridMoblet::showNativeUI ( const MAUtil::String url) [virtual]

Display a NativeUI page.

Parameters:
urlUrl of NativeUI page to open.
virtual void Wormhole::HybridMoblet::showWebView ( ) [virtual]

Display the main WebView of this moblet.

virtual void Wormhole::HybridMoblet::setBeepSound ( MAHandle  beepSoundResource) [virtual]

Set the sound used for the PhoneGap beep notification.

Parameters:
beepSoundResourceHandle to the "beep" sound played by the PhoneGap API.
virtual MessageHandler* Wormhole::HybridMoblet::getMessageHandler ( ) [virtual]

Return the message handler object used by this moblet.

virtual void Wormhole::HybridMoblet::setMessageHandler ( MessageHandler handler) [virtual]

Set the message handler object used by this moblet. Any previous handler is deleted. The moblet takes ownership of the handler and deletes it when destroyed.

virtual void Wormhole::HybridMoblet::addMessageFun ( const char *  command,
Wormhole::FunTable::MessageHandlerFun  fun 
) [virtual]

Add a function invoked when a message is sent from JavaScript.

Invoke from JavaScript using this format:

mosync.bridge.send(["Custom", "Vibrate"]);

First parameter must always be "Custom". Then the string (command name) used to identify the function. Optionally you can send additional parameters and retrieve them from the message stream.

Parameters:
commandString identifying the command.
funFunction of type MessageHandlerFun. This function must be a member of a subclass of the class FunObject (HybridMoblet inherits FunObject, methods in subclasses of HybridMoblet work fine).
virtual void Wormhole::HybridMoblet::handleWebViewMessage ( MAWidgetHandle  webViewHandle,
MAHandle  data 
) [virtual]

This method handles messages sent from the WebView.

Note that the data object will be valid only during the life-time of the call of this method, then it will be deallocated.

Parameters:
webViewThe WebView that sent the message.
urlDataData object that holds message content.
virtual void Wormhole::HybridMoblet::printWebViewMessage ( MAHandle  dataHandle) [virtual]

Prints the incoming webview message. Used for debugging.

To call this method, override HybridMoblet::handleWebViewMessage in your moblet with the following method:

void handleWebViewMessage(MAHandle webViewHandle, MAHandle data) { printWebViewMessage(data); HybridMoblet::handleWebViewMessage(webViewHandle, data); }

virtual void Wormhole::HybridMoblet::customEvent ( const MAEvent event) [virtual]

Handles HOOK_INVOKED events for WebViews in the app. This code enables WebViews to send messages to each other.

The only thing that work reliable from other WebViews than the main one, are CallJS and calls that do not return anything, like mosync.app.sendToBackground().

Apps are supposed to use the main WebView to for accessing the fulll Wormhole JS API, and only use mosync.nativeui.callJS() from other WebViews. This way, the main WebView becomes a mediator, which is a good design because native access is restricted to one point.

Reimplemented from Wormhole::CustomMoblet.

virtual void Wormhole::HybridMoblet::keyPressEvent ( int  keyCode,
int  nativeCode 
) [virtual]

This method is called when a key is pressed. Forwards the event to PhoneGapMessageHandler. Override to implement your own behaviour.

Reimplemented from Wormhole::CustomMoblet.

virtual void Wormhole::HybridMoblet::callJS ( const MAUtil::String script) [virtual]

Run JavaScript code in the main WebView of this moblet.

Parameters:
scriptJavaScript code to evaluate.
virtual void Wormhole::HybridMoblet::callJS ( MAWidgetHandle  webViewHandle,
const MAUtil::String script 
) [virtual]

Evaluate JavaScript code in a WebView.

Parameters:
webViewHandleThe MoSync handle to the WebView in which to evaluate the script (this handle is an integer id).
scriptJavaScript string.

Sends the Device Screen size to JavaScript.

Sends the web view handle to JavaScript.

Enable JavaScript to C++ communication.

Disable JavaScript to C++ communication.

virtual void Wormhole::HybridMoblet::extractFileSystem ( ) [virtual]

Extract HTML/CSS/JS/Media files to the local file system.

virtual bool Wormhole::HybridMoblet::checksumHasChanged ( ) [virtual]
Returns:
true if the checksum has changed (or if the old value did not exist, such as on first time load).
virtual void Wormhole::HybridMoblet::writeChecksum ( ) [virtual]

Write the current checksum to file.

bool Wormhole::MessageProtocol::matches ( const char *  protocol)
Wormhole::MessageStream::MessageStream ( MAWidgetHandle  webViewHandle,
MAHandle  dataHandle 
)

Constructor.

Destructor.

Returns:
true if this is a valid message stream.

Get the WebView widget handle associated with this message.

Returns:
Handle to WebView widget.

Get the WebView object associated with this message.

Returns:
WebView object. NULL may be returned if the MessageStream constructor was not called with a WebView object. Use getWebViewHandle() instead, or use callJS() if you wish to evaluate JavScript in the WebViewthat sent this message.
Deprecated:

Evaluate JavaScript the WebView associated with this message.

Parameters:
scriptJavaScript string.
const char* Wormhole::MessageStream::getNext ( int *  length = NULL)

Get a pointer to the next string in the message stream, and optionally get the length of the string.

Parameters:
lengthLength of the string is returned in this parameter. Can be set to NULL (default value) in which case it is not used.
Returns:
Pointer to the string, NULL if there are no more strings in the message.
void Wormhole::MessageStream::MessageStream::initialize ( MAHandle  dataHandle) [protected]

Read data and initialise the stream.

int Wormhole::MessageStream::xtoi ( char *  s,
char **  newPos 
) [protected]

TODO: Add error handling.

int Wormhole::MessageStream::raise ( int  base,
int  e 
) [protected]

TODO: Add error handling.

Constructor.

Destructor.

Get the WebView widget handle associated with this message.

Returns:
Handle to WebView widget.

Get the WebView object associated with this message.

Returns:
WebView object.
Deprecated:

Evaluate JavaScript the WebView associated with this message.

Parameters:
scriptJavaScript string.

Move to the next message. Initially, the message pointer is positioned right before the first message. Do a call to this method to get the first message.

Returns:
true if moved to next message, false if there are no more messages.
bool Wormhole::MessageStreamJSON::is ( const char *  paramName)

Checks if this message matches the given message name.

Returns the string value of a top-level message parameter.

Returns:
The param value as a string.
int Wormhole::MessageStreamJSON::getParamInt ( const char *  paramName)

Returns the integer value of a top-level message parameter.

Returns:
The param value as an int.
bool Wormhole::MessageStreamJSON::hasParam ( const char *  paramName)

Checks if the given top-level parameter name is in the message.

MAUtil::YAJLDom::Value* Wormhole::MessageStreamJSON::getParamNode ( const char *  paramName)

Get the node of a top-level parameter in the current message.

MAUtil::YAJLDom::Value* Wormhole::MessageStreamJSON::getJSONRoot ( )
Returns:
The JSON root node.

Parse the message. This finds the message name and creates a dictionary with the message parameters.

Destructor.

Get the WebView widget displayed by this moblet.

Returns:
Pointer to the WebView instance.
virtual FileUtil* Wormhole::WebAppMoblet::getFileUtil ( ) [virtual]

Get a file utility object used for accessing the device's local file system.

Returns:
Pointer to a FileUtil instance.

Enable JavaScript to C++ communication.

Disable JavaScript to C++ communication.

virtual void Wormhole::WebAppMoblet::showPage ( const MAUtil::String url) [virtual]

Display a page in the WebView of this moblet.

Parameters:
urlUrl of page to open.
virtual void Wormhole::WebAppMoblet::showWebView ( ) [virtual]

Display the WebView.

virtual void Wormhole::WebAppMoblet::callJS ( const MAUtil::String script) [virtual]

Run JavaScript code in the WebView.

virtual void Wormhole::WebAppMoblet::handleWebViewMessage ( NativeUI::WebView webView,
MAHandle  urlData 
) [virtual]

This method handles messages sent from the WebView. Implement this method in a subclass of this class.

Parameters:
webViewThe WebView that sent the message.
urlDataData object that holds message content. Note that the data object will be valid only during the life-time of the call of this method, then it will be deallocated.
virtual void Wormhole::WebAppMoblet::keyPressEvent ( int  keyCode,
int  nativeCode 
) [virtual]

This method is called when a key is pressed. It closes the application when the back key (on Android) is pressed. Override to implement your own behaviour.

Reimplemented from MAUtil::Moblet.

virtual void Wormhole::WebAppMoblet::extractFileSystem ( ) [virtual]

Extract HTML/CSS/JS/Media files to the local file system.

virtual bool Wormhole::WebAppMoblet::checksumHasChanged ( ) [virtual]
Returns:
true if the checksum has changed (or if the old value did not exist, such as on first time load).
virtual void Wormhole::WebAppMoblet::writeChecksum ( ) [virtual]

Write the current checksum to file.

Take a string that is "percent encoded" and decode it.

Parameters:
strEncoded string.
Returns:
The decoded string.
Deprecated:
Use method unescape in class Encoder.

Take a string and "percent encode" it.

Parameters:
strString to be encoded.
Returns:
The encoded string.
Deprecated:
Use method escape in class Encoder.

Constructor.

Destructor.

Get the WebView widget associated with this message.

Returns:
Pointer to WebView object.
virtual bool Wormhole::WebViewMessage::is ( const MAUtil::String messageName) [virtual]

Checks if this message matches the given message name.

virtual MAUtil::String Wormhole::WebViewMessage::getParam ( const MAUtil::String paramName) [virtual]

Returns the string value of a message parameter.

Returns:
The param value as a string.
virtual int Wormhole::WebViewMessage::getParamInt ( const MAUtil::String paramName) [virtual]

Returns the integer value of a message parameter.

Returns:
The param value as an int.
virtual bool Wormhole::WebViewMessage::hasParam ( const MAUtil::String paramName) [virtual]

Checks if the given parameter name is in the message.

virtual void Wormhole::WebViewMessage::parse ( MAHandle  dataHandle) [protected, virtual]

Parse the message. This finds the message name and creates a dictionary with the message parameters.


Variable Documentation

Full path to the current root directory to be used by File APIs.

HighLevelHttpConnection* Wormhole::HighLevelReader::mConnection [protected]

The connection object served by this reader.

Total length of downloaded data (accumulated value).

Vector with chunks used while downloading data.

Size of a chunk of data.

Current location (write offset) in the current chunk.

The screen widget that is the root of the UI.

The WebView widget that displays the application UI.

HybridMoblet_WebViewListener* Wormhole::HybridMoblet::mWebViewListener [protected]

JavaScript message listener.

FileUtil* Wormhole::HybridMoblet::mFileUtil [protected]

File utility object.

MessageHandler* Wormhole::HybridMoblet::mMessageHandler [protected]

Handles messages sent from JavaScript.

Is the moblet initialized?

The WebView widget handle of this message.

The WebView widget handle of this message.

Deprecated:
char* Wormhole::MessageStream::mData [protected]

Variables for internal use only, but made protected if some future need for subclassing would arise.

char* Wormhole::MessageStream::mEnd [protected]

The WebView widget handle of this message.

The WebView widget handle of this message.

Deprecated:
MAUtil::YAJLDom::Value* Wormhole::MessageStreamJSON::mJSONRoot [protected]

Table for message parameters.

Index of current message.

The screen widget that is the root of the UI.

The WebView widget that displays the application UI.

WebAppMoblet_WebViewListener* Wormhole::WebAppMoblet::mWebViewListener [protected]

JavsScript message listener.

FileUtil* Wormhole::WebAppMoblet::mFileUtil [protected]

File utility object.

The WebView of this message.

The message name is the "command name".

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines