This code ueses the pillowHelper library to communicate with the pillow app default_status_bar. It enables you to receive system events as a message. I'm pretty sure it is able to catch DBUS events, see description why.
PS: I think we should rename the WAF tag in the board to Mesquite
PHP Code:
// Get system events from Mesquite. I am pretty sure these are actually DBUS events!
// For example I can subscribe to org.freedesktop.DBus - NameOwnerChanged
// runAsPillow in pillowHelper.js which is located here at:
// http://www.mobileread.com/forums/showthread.php?p=2476587#post2476587
// Hook callback
kindle.messaging.receiveMessage('persistantCallback', function(message, value)
{
document.write(value);
});
// Hooking into statusBar event list - Method 1
runAsPillow(
'default_status_bar',
'com.PaulFreund.WebLaunch',
function()
{
// Create a persistant callback
document.body.persistantCallback = function(a)
{
// Call the default eventCallback as it will be overwriten
StatusBar.eventsCallback(a);
// Notify myself about the data
nativeBridge.setLipcProperty(
'com.PaulFreund.WebLaunch',
'persistantCallback',
JSON.stringify(a)
);
};
// Subscribe to additional events
nativeBridge.subscribeToEvent('com.lab126.powerd', 'testMsg');
// Overwrite the default eventHandler callback
nativeBridge.registerEventsWatchCallback(document.body.persistantCallback);
}
);
// Hooking into statusBar event list - Method 2
// Method 2 is building upon the SubscribedEvents object and its
// SubscribedEvents.sources array of handlers, but it would require
// more function proxying if the desired messages already have a handler
// for more information see:
// /usr/share/webkit-1.0/pillow/javascripts/default_status_bar.js