New Design of
  OneRing
     2011.02
Old Design
3 components, 4 communication types

                      WebKit
    JS-QObject                            AJAX
       bridge
                 JS-QObject     pub/sub
                  Signal-Slot
                    bridge

    OS                                       App
WebKit -> OS
JS-QObject Bridge
var tray = _OneRing.new_SystemTrayIcon();

tray.show();

class SystemTrayIcon : public QSystemTrayIcon
{

public:

    Q_INVOKABLE void show(void);

}
OS -> WebKit
tray.click.connect(function() {...});


class SystemTrayIcon : public QSystemTrayIcon {

signals:

      void click(void);

}

...

emit click();

...
WebKit -> App
ONERING.getJSON('onering://radio/get_bid',
function(bid) {...});



class get_bid:

    GET(self):

        return dict(bid=b64encode(os.urandom(8)).rstrip('='))
App -> WebKit
ONERING.subscribe('new-instance',
function(){...});

def new_instance_launched():

   print "new instance"

   onering.publish("new-instance")
Problems
•   Communication between WebKit and OS is Qt-
    bound
•   Hard to trace callings of QtWebKit bridge
•   QtWebKit signal-slot bridge has memory
    management issue
•   Hard to handle cases where function returns object
•   JavaScript binding cause endless code bloating
•   sync calling is more friendly than Ajax
New Design
            Unify OS and App
                       WebKit

        call_app                          call_app
                   pub/sub      pub/sub



       OS                                       App

collection of apps               collection of apps
WebKit -> OS
var tray = new SystemTrayIcon();

tray.show();
SystemTrayIcon.prototype.show = function()

{

    // POST onering://systray/show

    // with body: {"id": "12345678"}

    ONERING.call_app("systray", "SystemTrayIcon.show")

}
QByteArray SysTrayApp::processCall(const QString &command, const QVariantMap &param)

{

    if (command == "show") {

        QSystamTrayIcon *icon = static_cast<QSystemTrayIcon *>(getInstance(param["id"]);

        icon->show();

        return "null";

    }

    return "{"err":"invalid command"}";

}
OS -> WebKit
tray.bind('click', function(){...});


SystemTrayIcon.prototype.bind = function(event, callback)

{

    // subscribe to "systray.SystemTrayIcon.123456.click"

    ONERING.subscribe(self.appname+"."+self.type+"."

                      +self.id+"."+event, callback)

}
void * SysTrayApp::create()
{
    QSystemTrayIcon *icon = new QSystemTrayIcon();
    connect(icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(notifyClicked(QSystemTrayIcon::ActivationReason)));
    return icon;
}


void SystamTrayApp::notifyClicked(QSystemTrayIcon::ActivationReason reason)
{
    QSystemTrayIcon *icon = static_cast<QSystemTrayIcon *>(sender());


    if (reason == QSystemTrayIcon::Trigger) {
        // onering_publish("systray.SystemTrayIcon.123456.click", "{}")
        publishEvent("SystemTrayIcon", icon, "click");
    }
}
Pros

• small core
• app could be Qt independent
• explicit and flexible js binding interface
• less memory management issue
• easy to trace
Cons

• extra layers
 • URL dispatch to C++ code
 • JSON <--> C++ object
• slightly more code and slower
Future: Plugin

• Every app can be considered as a plugin
• plugin: js + (optional) native code
• /onering-plugins/systray.dll (or directory)
• auto discovery and load
• plugin repository and community

More Related Content

PDF
OneRing @ OSCamp 2010
PDF
RDSDataSource: Мастер-класс по Dip
PDF
Reactive, component 그리고 angular2
PDF
Talk KVO with rac by Philippe Converset
PDF
RxSwift to Combine
PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
PDF
RxSwift to Combine
PDF
Testing Backbone applications with Jasmine
OneRing @ OSCamp 2010
RDSDataSource: Мастер-класс по Dip
Reactive, component 그리고 angular2
Talk KVO with rac by Philippe Converset
RxSwift to Combine
Aplicações assíncronas no Android com
Coroutines & Jetpack
RxSwift to Combine
Testing Backbone applications with Jasmine

What's hot (20)

PDF
Finch.io - Purely Functional REST API with Finagle
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PPTX
The State of JavaScript (2015)
PPTX
ES6 is Nigh
PDF
Découvrir dtrace en ligne de commande.
PDF
IoT Best practices
PDF
Présentation de HomeKit
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
PDF
Introduction to Nodejs
PDF
Map kit light
PPTX
Avoiding callback hell in Node js using promises
PDF
Swift Sequences & Collections
PDF
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
PDF
Introduction to reactive programming & ReactiveCocoa
PPTX
introduction to node.js
PDF
Nodejs Explained with Examples
PDF
Aplicações assíncronas no Android com Coroutines & Jetpack
PDF
Scalable Angular 2 Application Architecture
PDF
Fast C++ Web Servers
PDF
Realm.io par Clement Sauvage
Finch.io - Purely Functional REST API with Finagle
FalsyValues. Dmitry Soshnikov - ECMAScript 6
The State of JavaScript (2015)
ES6 is Nigh
Découvrir dtrace en ligne de commande.
IoT Best practices
Présentation de HomeKit
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Introduction to Nodejs
Map kit light
Avoiding callback hell in Node js using promises
Swift Sequences & Collections
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Introduction to reactive programming & ReactiveCocoa
introduction to node.js
Nodejs Explained with Examples
Aplicações assíncronas no Android com Coroutines & Jetpack
Scalable Angular 2 Application Architecture
Fast C++ Web Servers
Realm.io par Clement Sauvage
Ad

Viewers also liked (7)

PDF
服务框架: Thrift & PasteScript
PDF
豆瓣技术架构的发展历程 @ QCon Beijing 2009
PDF
Python高级编程(二)
PDF
Python于Web 2.0网站的应用 - QCon Beijing 2010
PDF
合久必分,分久必合
KEY
Python在豆瓣的应用
服务框架: Thrift & PasteScript
豆瓣技术架构的发展历程 @ QCon Beijing 2009
Python高级编程(二)
Python于Web 2.0网站的应用 - QCon Beijing 2010
合久必分,分久必合
Python在豆瓣的应用
Ad

Similar to New Design of OneRing (15)

PDF
Hybrid Apps (Native + Web) using WebKit
PDF
Hybrid Apps (Native + Web) using WebKit
PDF
Hybrid Apps (Native + Web) via QtWebKit
PDF
Qt & Webkit
PDF
Developments in the Qt WebKit Integration
PDF
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
PDF
The Mobility Project
PDF
How to Make Your Qt App Look Native
PDF
The WebKit project
PDF
下午1 intel yang, elton_mee_go-arch-update-final
PPTX
Go & multi platform GUI Trials and Errors
KEY
webOS: The Web? We Haz It.
PDF
WebKit2 And You (GUADEC 2013)
PPT
Palm WebOS Overview
PDF
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) via QtWebKit
Qt & Webkit
Developments in the Qt WebKit Integration
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
The Mobility Project
How to Make Your Qt App Look Native
The WebKit project
下午1 intel yang, elton_mee_go-arch-update-final
Go & multi platform GUI Trials and Errors
webOS: The Web? We Haz It.
WebKit2 And You (GUADEC 2013)
Palm WebOS Overview
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 3

Recently uploaded (20)

PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPT
What is a Computer? Input Devices /output devices
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Architecture types and enterprise applications.pdf
PPTX
The various Industrial Revolutions .pptx
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
Modernising the Digital Integration Hub
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
Geologic Time for studying geology for geologist
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Final SEM Unit 1 for mit wpu at pune .pptx
A comparative study of natural language inference in Swahili using monolingua...
What is a Computer? Input Devices /output devices
Assigned Numbers - 2025 - Bluetooth® Document
NewMind AI Weekly Chronicles – August ’25 Week III
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Hindi spoken digit analysis for native and non-native speakers
Univ-Connecticut-ChatGPT-Presentaion.pdf
observCloud-Native Containerability and monitoring.pptx
1 - Historical Antecedents, Social Consideration.pdf
Architecture types and enterprise applications.pdf
The various Industrial Revolutions .pptx
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Modernising the Digital Integration Hub
Getting started with AI Agents and Multi-Agent Systems
sustainability-14-14877-v2.pddhzftheheeeee
Geologic Time for studying geology for geologist
DP Operators-handbook-extract for the Mautical Institute
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf

New Design of OneRing

  • 1. New Design of OneRing 2011.02
  • 2. Old Design 3 components, 4 communication types WebKit JS-QObject AJAX bridge JS-QObject pub/sub Signal-Slot bridge OS App
  • 3. WebKit -> OS JS-QObject Bridge var tray = _OneRing.new_SystemTrayIcon(); tray.show(); class SystemTrayIcon : public QSystemTrayIcon { public: Q_INVOKABLE void show(void); }
  • 4. OS -> WebKit tray.click.connect(function() {...}); class SystemTrayIcon : public QSystemTrayIcon { signals: void click(void); } ... emit click(); ...
  • 5. WebKit -> App ONERING.getJSON('onering://radio/get_bid', function(bid) {...}); class get_bid: GET(self): return dict(bid=b64encode(os.urandom(8)).rstrip('='))
  • 6. App -> WebKit ONERING.subscribe('new-instance', function(){...}); def new_instance_launched(): print "new instance" onering.publish("new-instance")
  • 7. Problems • Communication between WebKit and OS is Qt- bound • Hard to trace callings of QtWebKit bridge • QtWebKit signal-slot bridge has memory management issue • Hard to handle cases where function returns object • JavaScript binding cause endless code bloating • sync calling is more friendly than Ajax
  • 8. New Design Unify OS and App WebKit call_app call_app pub/sub pub/sub OS App collection of apps collection of apps
  • 9. WebKit -> OS var tray = new SystemTrayIcon(); tray.show(); SystemTrayIcon.prototype.show = function() { // POST onering://systray/show // with body: {"id": "12345678"} ONERING.call_app("systray", "SystemTrayIcon.show") }
  • 10. QByteArray SysTrayApp::processCall(const QString &command, const QVariantMap &param) { if (command == "show") { QSystamTrayIcon *icon = static_cast<QSystemTrayIcon *>(getInstance(param["id"]); icon->show(); return "null"; } return "{"err":"invalid command"}"; }
  • 11. OS -> WebKit tray.bind('click', function(){...}); SystemTrayIcon.prototype.bind = function(event, callback) { // subscribe to "systray.SystemTrayIcon.123456.click" ONERING.subscribe(self.appname+"."+self.type+"." +self.id+"."+event, callback) }
  • 12. void * SysTrayApp::create() { QSystemTrayIcon *icon = new QSystemTrayIcon(); connect(icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(notifyClicked(QSystemTrayIcon::ActivationReason))); return icon; } void SystamTrayApp::notifyClicked(QSystemTrayIcon::ActivationReason reason) { QSystemTrayIcon *icon = static_cast<QSystemTrayIcon *>(sender()); if (reason == QSystemTrayIcon::Trigger) { // onering_publish("systray.SystemTrayIcon.123456.click", "{}") publishEvent("SystemTrayIcon", icon, "click"); } }
  • 13. Pros • small core • app could be Qt independent • explicit and flexible js binding interface • less memory management issue • easy to trace
  • 14. Cons • extra layers • URL dispatch to C++ code • JSON <--> C++ object • slightly more code and slower
  • 15. Future: Plugin • Every app can be considered as a plugin • plugin: js + (optional) native code • /onering-plugins/systray.dll (or directory) • auto discovery and load • plugin repository and community

Editor's Notes