QtScript

    krake's picture

    Akonadi Workspace Integration

    2010
    17
    Jul

    With Akonadi most operations are running behind the scenes, carried out by background helper processes called Akonadi Agents.

    While we do have respective progress monitoring in KMail2, users will eventually take advantage of fact that they are no longer tied to specific applications. At which point they might want to be able to check on the status of these background processes without launching some front end applications.

    Back in April, during one of our development sprints, I've created a Plasma DataEngine which provides information about running Akonadi agents.

    I was kind of hoping that somebody with actual widget skills would be curious enough to try some Plasma widgets on top of it, alas this didn't happen.

    Therefore I sat down today and wrote one myself, using the opportuntiy to also have a first real attempt in doing some KDE<->JavaScript coding.

    The code for it more or less looks like this:

    layout = new LinearLayout( plasmoid );
    layout.orientation = QtVertical;
    
    engine = dataEngine( "akonadiagents" );
    agents = engine.sources;
    
    resources = new Array;
    
    addAgent = function( name ) {
      label = new IconWidget();
      label.orientation = QtHorizontal;
      layout.addItem( label );
      resources[ name ] = label;
    
      engine.connectSource( name, plasmoid );
    }
    
    plasmoid.dataUpdated = function( name, data ) {
      label = resources[ name ];
    
      label.text = data.name;
      label.icon = data.typeIcon;
    
      label.infoText = data.statusMessage;
      if ( !data.online ) {
        label.enabled = false;
      } else {
        label.enabled = true;
        if ( data.status == 1 ) { // running
          label.infoText = data.statusMessage + " (" + data.progress + "%)";
        }
      }
    }
    
    while ( agents.length > 0 ) {
      agent = agents.pop();
    
      // ideally this would be using the agent type's capabilities, but the DataEngine::Data as returned by
      // DataEngine::query() is not accessible from within JavaScript (or at least nobody on #plasma knew)
      if ( agent.indexOf( "resource" ) != -1 ) {
        addAgent( agent );
      }
    }
    

    I am sure this is not very pretty from the point of view of skilled JavaScript users, you are welcome to beat me on that :D

    Anyway, screen cast of the Plasmoid in action, as usual on blip.tv

    It shows the widget running in plasmoidviewer side by side with Akonadiconsole to demonstrate that the data engine really exposes the same data.
    I start with toggling a local VCard file resource between Offline and Online state, which the widget visualizes by disabling/enabling the respective item.

    Finally I synchronize all collections of the IMAP resource, showing status and progres reporting.

    richard dale's picture

    JSmoke bindings KDE hello world working

    2009
    8
    Dec

    The Smoke based QtScript bindings are progressing well, and are now called 'JSmoke' in the style of 'JQuery' the JavaScript library or 'JScript' the .NET JavaScript implementation. In KDE promo-like words, I hope this will 'raise the brand recognition' of the state of the art KDE Smoke dynamic language bindings technology.

    The project now has 24 QtScript plugins for the following libraries:

    dipesh's picture

    State of Kross in KDE4

    2008
    8
    Jan

    Kross, the scripting framework, is one of the pillars new with KDE4. While the project started already a while back in 2004 it enveloped over the time to a rather big codebase. During the KDE4-process one of the main-goals was to decrease the codebase what can be even more difficult then writting new code.