New Design of OneRing

  • 1,030 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,030
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
29
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. New Design of OneRing 2011.02
  • 2. Old Design3 components, 4 communication types WebKit JS-QObject AJAX bridge JS-QObject pub/sub Signal-Slot bridge OS App
  • 3. WebKit -> OSJS-QObject Bridgevar tray = _OneRing.new_SystemTrayIcon();tray.show();class SystemTrayIcon : public QSystemTrayIcon{public: Q_INVOKABLE void show(void);}
  • 4. OS -> WebKittray.click.connect(function() {...});class SystemTrayIcon : public QSystemTrayIcon {signals: void click(void);}...emit click();...
  • 5. WebKit -> AppONERING.getJSON(onering://radio/get_bid,function(bid) {...});class get_bid: GET(self): return dict(bid=b64encode(os.urandom(8)).rstrip(=))
  • 6. App -> WebKitONERING.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 Appcollection of apps collection of apps
  • 9. WebKit -> OSvar 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 -> WebKittray.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