Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LiveScratcher.Messenger
07-17-2009, 06:54 PM
Post: #1
LiveScratcher.Messenger
The Messenger package contains 4 object types, and 1 event handler type. Here is a quick list of the types and their functions/properties, and a quick example below.
  • Messenger
    • autoSignin()
    • signout()
    • openConversation(contact) //contact can be either a Contact object or a string email-address
    • getContact(contact) //contact can be a string or a Contact object (in which case the same contact is returned)
    • version //string, e.g. "14.0.1234", read only
    • versionComparable //number representation of version (major<<24 | minor <<16 | build), can be compared like numbers, read only
    • versionMajor //number, e.g. 14, read-only
    • versionMinor //number, e.g. 0, read-only
    • versionBuild //number, e.g. 1234, read-only
    • getConversations() //returns Array of Conversation objects
    • receiveFileDirectory //string, directory for received files
    • getContactList() //returns Array of Contact objects, contact list
    • myEmail //string, Current user e-mail address, read-only
    • mySigninName //Same as above
    • myStatus //Status object indicating your current status, read-write
    • myFriendlyName //String, current friendly name, read-write
    • myPersonalStatusMessage //String, current PSM, read-write
    • myCurrentMedia //String, current media, read-write
    • myDisplayPicture //String, path to current display picture, read-write
    • contactListWndHandle //Number, HWND to contact list, read-only
    • isInitialized //Boolean, indicates if messenger is loaded. read-only
    • addEventHandler(object) //Add event handler, returns a cookie that should be kept for removeEventHandler
    • removeEventHandler(cookie) //Remove previously added event handler
    • showToast(object) //Shows a toast, might crash if used too early. Use carefully before sign-in, see below for properties the object should have.
    • Contact //Contact constructor, new Messenger.Contact("test@test.com) is same as Messenger.getContact
    • Conversation //Conversation constructor, only useful for (x instanceof Messenger.Conversation)
    • Status //Status constructor, use for x instanceof Messenger.Status
    • Status.Online //All statusses to compare to. All statusses should be here, use for (var i in Messenger.Status) Console.print(i); to get all.
    • Status["Online"] //Same as above
  • Contact (All properties are read-only with the exception of isBlocked)
    • signinName //Sign-in name, same as e-mail address except for Yahoo contacts, where it's yahoo:email@address.com
    • email //String
    • friendlyName //String
    • personalStatusMessage //String
    • currentMedia //String
    • displayPicture //String
    • isBlocked //Boolean, read-write
    • status //Status object
  • Conversation
    • sendText(text)
    • inviteParticipant(contact) //Should be Contact object or string
    • getParticipants() //Returns Array of Contact's
    • close()
    • wndHandle //Number, read-only
  • Status (all properties read-only)
    • name //String, e.g. "Be right back"
    • protocolName //String, e.g. "BRB"
    • isLocal //Boolean, is this a local-only status like Appear offline or Findig server?
    • isSignedin //Is this status signed in?
    • isAvailable //Is this status equivalent to the WLM9 available?
    • isBusy //See above
    • isAway //See above
  • Events (an event handler can contain the following functions)
    • onInitialize()
    • onDeinitialize()
    • onSigninStart(email)
    • onSignedin()
    • onSigninFailed()
    • onSignout
    • onContactListAdded(contact)
    • onContactListRemoved(contact)
    • onConversationCreated(conversation)
    • onConversationDestroyed(conversation)
    • onMyStatusChanged(status)
    • onMyFriendlyNameChanged(name)
    • onMyPersonalStatusMessageChanged(psm)
    • onMyCurrentMediaChanged(media)
    • onContactFriendlyNameChanged(contact,name)
    • onContactPersonalStatusMessageChanged(contact,psm)
    • onContactCurrentMediaChanged(contact,media)
    • onContactSignedin(contact)
    • onContactSignedout(contact)
    • onContactStatusChanged(contact,status)
    • onContactBlocked(contact)
    • onContactUnblocked(contact)
    • onConversationContactJoin(conversation,contact)
    • onConversationContactLeave(conversation,contact)
  • Toast-object (A toast object should contain the following properties or functions)
    • text //String, text for on the toast
    • clickCmd //String, possible URL/Program that should be executed when clicked
    • optionsCmd //String, possible URL/Program that should be executed when "Options" is clicked
    • onClosed(reason) //reason is a string reason why the toast was closed
    • onClicked() //Toast was clicked
    • onOptionsClicked() //"Options" link on toast was clicked.

Example: (don't forget to add LiveScratcher.Console and LiveScratcher.Messenger as dependencies)
JAVASCRIPT Code
//Global functions
function getGlobal(){
	return (function(){
		return this;
	}).call(null);
}
 
function registerDependencies(packageapi) {
	var g=getGlobal();
	var dependencies=packageapi.getDependencies();
	for (var i in dependencies) {
		var name=dependencies[i];
		var shortname=name.split(".").pop();
		g[shortname]=packageapi.getExport(name);
	}
}
//Signout toast
function SignoutToast(contact) {
	this.contact=contact;
	this.text=contact.friendlyName+" has just signed out.";
	return this;
}
 
SignoutToast.prototype.onOptionsClicked=function() {
	Console.print("Can't do that yet, sorry!");
}
 
SignoutToast.prototype.onClicked=function() {
	Messenger.openConversation(this.contact);
}
 
//Messenger events
function MessengerEvents() { return this; };
 
MessengerEvents.prototype.onInitialize=function() {
	Console.print("Messenger version "+Messenger.version+" initialized");
}
 
MessengerEvents.prototype.onSignedin=function() {
	Console.print("Hello "+Messenger.myFriendlyName+"!");
}
 
MessengerEvents.prototype.onContactSignedout=function(contact) {
	Messenger.showToast(new SignoutToast(contact));
}
//Initialize function
var MessengerEventsCookie=0;
function onInitialize(packageapi) {
	registerDependencies(packageapi);
	MessengerEventsCookie=Messenger.addEventHandler(new MessengerEvents());
}
 
function onDeinitialize() {
	Messenger.removeEventHandler(MessengerEventsCookie);
}

Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: