Core Yahoo! Mail application UI and webservice methods.
int
callWebService
(
service
,
handler
)
service
< Object >
An object describing the Web service to call.
Attribute values expected are listed below.
url: String Target URL. Can
include pathInfo or attr=value params. Note that
if you include parameters here, it is your
responsibility to URL encode (or not, as
appropriate
for the receiving service) via something like
encodeURIComponent().method: String "GET" or "POST".
Neither the GET nor the POST will ever
encodeURIComponents() on any values that might be
provided in the URL.parameters: Object A map of
key/value pairs to use as the query string or
the POST body. These parameters will be run thru
encodeURIComponent() before being sent across
the network.headers: Array of String An array of
HTTP headers as strings. You can set any arbitrary
headers if it is accepted by cross-domain policy file.
Content-Type header is always accepted.
It is only supported for "POST"dataformat: String "text"(default) or "binary".
"binary" returns Base64-encoded binary data.handler
< function >
A callback function. Response Object returned from
callback has the following data:
ERR_FLASH_REQUIRED: The flash
plugin is not installed.
User should install Flash 9.0 and restart
the browser to successfully run OpenMail
applications.
ERR_FLASH_ERR: The OpenMail
application's call to callWebService failed
due to a Flash runtime error. User should
verify that Flash is configured correctly
and executable in this browser.
ERR_FLASH_LAUNCH_ERR: The OpenMail
application's call to callWebService failed
because FLASH could not be launched. Flash may
be blocked by a Flash Blocker Plugin or another
error has occurred with starting Flash. User
should verify that
Flash is configured correctly and executable
in this browser.
int
int
closeView
(
view
,
handler
)
null for view.
view
< Object | null >
If view is not null,
it must be an object that includes the following:
id: String (Required) Application-defined id.
handler
< function >
A callback function. If a view closes itself,
callback will not be called. Callback response
Object has the following data.
response.error is
ERR_NONEresponse.error contains
a generic error code or ERR_VIEW_NOT_FOUND.
int
int
filterHTML
(
args
,
handler
)
args
< Object >
An object with one member, html,
which is a String that contains the HTML to validate.
handler
< function >
A callback function to receive the response.
Callback response
Object has the following data:
response.html
contains filtered html result. response.error
contains an error code,
response.errorMsg contains
a string describing the error.
int
int
getAttachmentUrl
(
args
,
handler
)
message.read event provides response.message.attachment
member object to access the attachments associated with an email.
Each of these attachment objects will have
the 'url' member which can be used with getAttachmentUrl API
to get to the actual attachment
content. The returned URL is time sensitive and cannot be tampered with.
Also, note that the attachment pointed to by the returned URL is not virus scanned.
var om = openmail;
function handleAttachment(resp) {
var attachments = resp.message.attachment;
function onGotAttachment(attachment){
alert(attachment.data);
}
function onGotAttachmentURL(aURL) {
if(aURL.error){
alert(aURL.error);
return;
}
om.Application.callWebService(
{ url : aURL.url, method : 'GET', parameters : {} }, onGotAttachment);
}
for(var i = 0; i < attachments.length; i += 1){
var mimeurl = attachments[i].url
om.Application.getAttachmentUrl( {url : mimeurl}, onGotAttachmentURL );
return;
}
}
om.Application.setListener( {event : "message.read"}, {afterRender : handleAttachment} );
args
< Object >
An object containing a member 'url' of type String
with the mimepart attachment URL.
handler
< function >
A callback function. Callback response
Object has the following data:
data.url contains the time
sensitive dotted quad actual URL for the
attachment content.data.mimeurl contains the
original passed in mime part URL from the app.
data.error contains an error
message describing the failure.data.mimeurl contains the
original passed in mime part URL from the app.
int
Object
getAuthService
(
conf
)
conf
< Object >
An object containing the configuration
of authorization service requested. Object has the following members:profile: The name of the stored profileurl: URL of the target service; only needed if
service is used with http proxyproxy: URL of the proxy;
only needed if service is used with http.
Object
int
getData
(
keys
,
handler
)
<script>
...
openmail.Application.getData({keys:['name','timeWeFirstMet']}, onGotData);
...
</script>
<script>
function getAllData() {
openmail.Application.getData({ keys: [ "*" ] },
function( result ) {
var s = "";
for ( var keyName in result.data) {
s += keyName + "=" + result.data[keyName] = "\n";
}
alert( s );
}
);
}
</script>
keys
< Object >
Key names of the data to retrieve. This object must
have a single data member named keys;
this is array of key names to retrieve. The wildcards
"*" (any arbitrary string) and "?" (any single character)
are supported.
handler
< function >
A callback function. Callback response
Object has the following data:
response.error is
ERR_NONE.response.error contains
a generic error code. Has following members:
data: Object The data requested.
Member names are the keys requested; values are
the stored data.version: Object Version number
of application instance. Members names are the
keys requested; values are version numbers.errorCode: Object Error codes
for the requested data, which corresponds to the
error codes in module.openmail.
Member names are the keys requested;
values are the error codes for each corresponding
key.totalCount: Number Number of
keys in the returned data set.
int
response.error)
for error status of data fetch.
int
getParameters
(
handler
)
openView(),
data property is the same as the
parameters argument passed to openView().
For example, in the
"Kitchen Sink" example application, if an email message is dragged and
dropped onto the application, then
the data is JSON representation of email message.
handler
< function >
The callback function that receives the response.
Callback response object has a member
object
response.user. This object has following members:
guid: unique user identifier as string,
not human-friendly.intl: internationalization domain (e.g. "us").
lang: user's language preferences as an
array (e.g. ["en-US"]).
See also getUserLanguages().theme: user's ymail options color theme
(e.g. "mountain").themeinfo: user's ymail options color theme
object (contains name -
themename and css - theme file path ), this is available only
in new version.response.context: the value of the
context node
in the configuration XML of application.response.data: message JSON object.response.index: The index of the subfolder
that the message was
dropped on. This member will not be
present if the message was dropped on the main application
folder.response.reason: "data/message".response.context: the value of the
context
node in the configuration XML of the application.response.data: null.response.reason: "events/click".openView() call:
response.context: the value passed to
context argument of openView().
response.data: the value passed to
parameters argument of
openView().
response.reason: "api/openView".response.context: the value of the
context
node in the configuration XML of the application.response.reason: "events/uninstall".
int
array
getUserLanguages
(
)
array
int
openView
(
view
,
handler
)
view
< Object >
Should include the following:
id: String An application-defined id
used to reference the view in other API calls view: String The name of a view to load
(e.g. "main.html" ) as uploaded with ymdt.
target: String A valid target for the
view to load that supports the following views:
"tab", "dialog", and "hidden". parameters: Object A map of values available
to the loaded view through the
getParameters() API call. context: Object A value specifying the
context of the opened view that can be retrieved through
the getParameters() API call.width: Number "Dialog" view only.
The default width of the dialog view is 400 px. height: Number "Dialog" view only.
The default height of the dialog view is 400 px. ttl: Number "Hidden" view only.
The "time to live" of the view in seconds.
The view will be forcibly closed afterward.
A ttl of zero means the view will
never be forcibly closed.
The default value for ttl is 60 seconds.
title: String "Tab" and "dialog" only. The
title is shown in the tab or dialog header area.options: Object A map of values that can be
added to view. May include element Title: String
to describe the Title for the view's iframe.handler
< function >
A callback function. reponse
Object has the following information:
response.error is ERR_NONEresponse.error contains a generic
error code, ERR_INVALID_TARGET,
or ERR_VIEW_EXISTS.response.warn contains
ERR_BAD_ARG if the width or
height are not specified for a "Dialog" view.
int
int
removeData
(
keys
,
handler
)
keys
< Object >
Key names of the data to remove. This object must
have a single data member named keys,
which is an array of key names to remove.
The wildcards "*" (any arbitrary string)
and "?" (any single character) are NOT supported.
handler
< function >
A callback function. Callback response
Object has the following data
response.error is
ERR_NONEresponse.error is
ERR_REMOVE_DATA and
response.errorMsg
contains an error message.
int
response.error) for error status.
int
sendMessage
(
params
)
// Broadcast "Hello World" to all views subscribed to "view.message" event,
// including the sending view
openmail.Application.sendMessage({ msg: "Hello World" });
// Send object to view id 'dashboard', the view must be subscribed to
// "view.message" event
openmail.Application.sendMessage({
msg: { action: 'updateStatus', status: 'online' },
target: 'dashboard'
});
params
<Object>
May include the following:
msg: Object|Array|String|Number|Boolean
Message content.target: String (Optional) Target view id to
send the message to. If omitted, message will be sent
to all the views.
int
int
setData
(
data
,
handler
)
<script>
...
// Handler for when the user submits their name.
function onJustMet() {
var dataStruct = {
keys : { "name" : who, "timeWeFirstMet" : now }
}
openmail.Application.setData( dataStruct, onResponse);
}
...
</script>
data
< Object >
An object describing the data to set. It can
include the following.
keys: Object The key/value pairs to store
(Required)ttl: Object key/ttl pairs. Member names should
match the keys in keys. The value is the time-to-live
in seconds for the corresponding keys.handler
< function >
A callback function. Callback response
has the following data:
response.error is ERR_NONE.response.error contains a generic
error code.
int
response.error ) for error status of data storage.
int
setFolderConfig
(
config
,
handler
)
config
object.
Short of giving a full specification of the JSON format accepted for
config, here's an example:
{
label: " - Beta",
tooltip: "click me",
subFolders: [{
label: "eden_people",
tooltip: "sub1 tt",
},
{
label: "flexcoders",
tooltip: "sub2 tt",
},
{
label: "shoop da woop",
tooltip: "blah"
}]
}
... <script>var state = [</script> ...{label:"Sample 1", query:"test"}, {label:"Sample 2", query:"openmail"}]; ... function updateFolders(){var obj = {}subFolders:[]} for (var i=0;i<state.length;i++) {var s = state[i]; obj.subFolders.push(s);} openmail.Application.setFolderConfig(obj);
config
< Object >
An object that describes the folder configuration.
Can include the following:
label: String Text to be appended to the
application's foldertooltip: String Tooltip to display for the
applicationsubFolders: Array of Objects
An array of objects.
Each object in the subFolders
array can include the following:
label: String Name of the subfolder
(Required).tooltip: String Tooltip for the
subfolder.handler
< function >
The callback function that receives the response.
Callback response has the following data.
response.error can be
ERR_BAD_ARG or
ERR_NONE.
int
int
setListener
(
registration
,
handler
)
setListener() to run
a search for a subfolder.
... var state = [{label:"Sample 1", query:"test"}, {label:"Sample 2", query:"openmail"}];
...
function omSubfolderClick(args) {subfolderIndex = args.index; openmail.Application.getData({keys:["state"]}, doSearch);}
function loadHandler() {updateFolders(); openmail.Application.setListener( {event: "subfolder.click"}, omSubfolderClick);} ...
registration
< Object >
Object with one member, event.
Value should be a string specifying the
event to listen for, e.g. 'subfolder.click'.
Supported events are described here.
handler
< function >
A callback function that takes a single object.
See individual event definitions
for event-specific callback object members.
int
void
setTabCloseMessage
(
config
)
config
< Object >
An object containing API parameters
id: String View Id of a tab targetzone to display close message.msg: String Message to display when user attempting to close the tab.
void
int
upgradeIfNecessary
(
args
,
handler
)
args
< Object >
Optional object. Has one member,
'suppressMessaging', that, if true, will suppress alerting
the user if an upgrade does occur.
handler
< function >
A callback function invoked if an upgrade
was not necessary or if an error occurs. Not invoked if an
upgrade does occur. Callback result object has the
following data:
result.data contains a string
describing the app version.data.error contains an error code.data.errorMsg contains a string with extra
diagnostic information.
int
app
< String >
unique application identifier as string,
not human-friendly.
appName
< String >
human-friendly application name.
url
< String >
the URL where the script error was
encountered.
lineno
< Number >
the line number where the script errori
was encountered.
message
< String >
the error message.
uninstall section in its config.xml.
The app should perform custom cleanup and then call
Application.closeView.
config.xml, specify <uninstall> event with uninstall launch target zone:
... <events> <uninstall> <action> <launch> <view>sample.html</view> <target_zone>uninstall</target_zone> </launch> </action> </uninstall> </events> ...
sample.html, set up a listener for app.uninstall event:
openmail.Application.setListener({ event: 'app.uninstall' }, function() {
// Perform app clean up here
...
// Signal Mail to continue app uninstall process
openmail.Application.closeView();
});
uninstall
< Boolean >
Always true.
<events> <compose> <action> <launch> <view>compose</view> </launch> </action> </compose> </events>
openmail.Application.setListener({event:'compose.sendstart'},
handleSendstart
);handleSendstart
callback whenever the 'send' button is pressed. The app may
decide to attach a panel view to the sendconfirm page once
sending is complete.
data
< Object >
Data object that contains the following members:
recipients an object containing:
to The To header as an array of objects
with the following members:
email Stringname Stringcc The CC header as an array of objects with
the following members:
email Stringname Stringbcc The BCC header as an array of objects
with the following members:
email Stringname Stringfrom The From header object with the following
members:
email Stringname Stringsubject The Subject header as a string.proceed
< Function >
A function to call if the app wants to
enhance the sendconfirm page. The function
takes an object as an argument.
The object may have the following members:
view The name of the view to load
into an iframe (eg, "list.html")width (optional) The CSS string for
the width of the iframe (eg, "100%")height (optional) The CSS string for
the height of the iframe (eg, "120px")cancel
<Function>
The function the app should call to cancel
its invocation.
<events> <compose> <action> <launch> <view>compose</view> </launch> </action> </compose> </events>
openmail.Application.setListener({event:'compose.user_event',
label:'click me', tooltip:'click me now!', tab:'format' }, handleCompose
);handleCompose
callback invoked whenever the button is pressed. The only other
valid tab is 'attachments'.
data
< Object >
Data object that contains the following members:
recipients an object containing:
to The To header as an array of objects
with the following members:
email Stringname Stringcc The CC header as an array of objects with
the following members:
email Stringname Stringbcc The BCC header as an array of objects
with the following members:
email Stringname Stringfrom The From header object with the following
members:
email Stringname Stringsubject The Subject header as a string.body
< String >
the value of the message body in the composer.
action
< String >
The action that opened the compose tab: 'compose', 'reply', or 'forward'
elemID
< String >
Unique identifier of the button
instance
< String >
Unique identifier of the compose tab instance (useful in case multiple compose tabs are open)
returnMessage
< Function >
function the app should call to
return data back the mail client. The function
takes an Object as an argument with the following
fields:
body String - the modified email body.
cancel
<Function>
the function the app should call to cancel
its invocation.
<events> <message_read> <match> <header> <name>subject</name> <regex>/.*?Flickr.*/</regex> </header> </match> <message_actions> <enhance_message> <css> <path>/yahoo/mail/assets/enhance.css</path> </css> <js> <path>/yahoo/mail/assets/enhance.js</path> </js> </enhance_message> </message_actions> </message_read> </events>
<header>: name element supports the following values
(from, to, subject, attachment.filename, attachment.type and attachment.subtype).
regex element can have any JS regular expression string value.<flag>: name element supports the following values
(hasAttachment, inAddressBook, isDraft, isFlagged, isForwarded, isHam, isSpam,
isRead, isRecent and isReplied). regex element can check whether value is 1 or 0.<annotation>: name element supports the arbitrary identifiers
such as person, place, event and etc.
regex element can have any JS regular expression string value.
openmail.Application.setListener( {event:"message.read"}, {
beforeRender:beforeRenderHandler,
afterRender:afterRenderHandler
});
response
< Object >
- Data object that contains the following members:
view: view object that contains the following members:
doc: document object of the message pane that
the message is rendered or will be rendered.win: window object of the message pane that
the message is rendered or will be rendered.fullView: Boolean value,
false if this message is rendered in preview pane.
Otherwise, trueYUI: YUI global object
message: message object that contains the following members:
node: Message node to be inserted (beforeRender) or
already inserted (afterRender) into the document.subject: The Subject header as an HTML-entity-encoded
string.from: The From header as an array of email
address / person name pairs.to:The To header as an array of objects with
the following members:
email: Stringname: Stringcc:The CC header as an array of array of objects
with the following members:
email: Stringname: Stringreplyto:The Reply To header as an array of
array of objects with the following members:
email: Stringname: StringsuppressImages: Boolean value,
the user's requested image blocking behavior,
true if remote resources must not be fetched. Applications must not fetch
remote resources or fire any remote beacons if this is true.imagesBlocked: Boolean value,
true if images have actually been suppressed
for this message. Indicates whether the user will see ui
indicating there are images
being suppressed.body: The text of the mail message,
as an object with the following members:
content: Stringtruncated: Boolean value, true if message body
is truncated. Message is truncated by default when its
size >100kb unless user chooses to view full message.
false when message body is not truncated.sandboxPrefix: String Element id
of the DOM node enclosing the message. This prefix is also prepended
to all id and class attributes within the message.annotation: The annotations for the response
is an object where each attribute is a type of annotation
(email_address, day_of_week, etc).
within the array usually contains:
text: String text that triggered the annotion.
eg: Wednesdayid: String for ease of access,
each entry is surrounded by a dom
node (<span>) with this id.context: String a snippet of the
surrounding message where the match occurred.attachment: The attachments for the message have
an array of objects with the following members:
type: String Content Type, e.g. applicationsubtype: String Sub Content Type,
e.g. mswordurl: String An URL that can be used with
openmail.Application.getAttachementUrl()<events> <message_read> <match> <header> <name>subject</name> <regex>/.*?Flickr.*/</regex> </header> </match> <message_actions> <enhance_message> <js> <path>/yahoo/mail/assets/add-button.js</path> </js> </enhance_message> </message_actions> </message_read> </events>
openmail.Application.setListener({event:'message.user_event',
label:'click me', tooltip:'click me now!' }, handleMessageUserEvent
);
response
< Object >
- The response object is identical to the
message.read response object.
index
< Number >
The index of the subfolder that was clicked on.
name
< String >
New theme name.
css
< String >
New theme file path, app has to import
the new css file.
msg
< Object|Array|String|Number|Boolean >
Message content.
origin
< String >
id of the view that sent the message.