• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
New Design of OneRing
 

New Design of OneRing

on

  • 1,207 views

 

Statistics

Views

Total Views
1,207
Views on SlideShare
1,207
Embed Views
0

Actions

Likes
1
Downloads
27
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

New Design of OneRing New Design of OneRing Presentation Transcript

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