View Single Post
Old 04-09-2013, 01:39 PM   #1
PaulFreund
*
PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.
 
PaulFreund's Avatar
 
Posts: 35
Karma: 145852
Join Date: Apr 2013
Device: Kindle Touch
Catching system events from mesqute

EDIT:

This code is now included in pillowHelper and should not be used without removing the callback default_status_bar before closing!

Old Statement:

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: 
    // https://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

Last edited by PaulFreund; 04-09-2013 at 03:27 PM. Reason: Added reference to implementation in pillowHelper
PaulFreund is offline   Reply With Quote