Quantcast
Channel: MobileRead Forums - Kindle Developer's Corner
Viewing all articles
Browse latest Browse all 4410

WAF Catching system events from mesqute

$
0
0
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.

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(messagevalue
    {
        
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 

PS: I think we should rename the WAF tag in the board to Mesquite

Viewing all articles
Browse latest Browse all 4410

Trending Articles