SlideShare a Scribd company logo
1 of 15
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

What's hot

Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Tom Croucher
 

What's hot (20)

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

Viewers also liked (7)

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

Similar to New Design of OneRing

Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype API
Ryo Jin
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
 
Create a dynamic website that functions like a calculator. Add featu.pdf
Create a dynamic website that functions like a calculator. Add featu.pdfCreate a dynamic website that functions like a calculator. Add featu.pdf
Create a dynamic website that functions like a calculator. Add featu.pdf
arshiartpalace
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mohammad Shaker
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
Peeyush Ranjan
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Provectus
 

Similar to New Design of OneRing (20)

Qt & Webkit
Qt & WebkitQt & Webkit
Qt & Webkit
 
Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype API
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Create a dynamic website that functions like a calculator. Add featu.pdf
Create a dynamic website that functions like a calculator. Add featu.pdfCreate a dynamic website that functions like a calculator. Add featu.pdf
Create a dynamic website that functions like a calculator. Add featu.pdf
 
QA Fest 2019. Алексей Альтер-Песоцкий. Snapshot testing with native mobile fr...
QA Fest 2019. Алексей Альтер-Песоцкий. Snapshot testing with native mobile fr...QA Fest 2019. Алексей Альтер-Песоцкий. Snapshot testing with native mobile fr...
QA Fest 2019. Алексей Альтер-Песоцкий. Snapshot testing with native mobile fr...
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
 
Qtp test
Qtp testQtp test
Qtp test
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to Swift
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
Async Best Practices
Async Best PracticesAsync Best Practices
Async Best Practices
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n