Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

New Design of OneRing

1.981 visualizaciones

Publicado el

Publicado en: Tecnología
  • Sé el primero en comentar

New Design of OneRing

  1. 1. New Design of OneRing 2011.02
  2. 2. Old Design3 components, 4 communication types WebKit JS-QObject AJAX bridge JS-QObject pub/sub Signal-Slot bridge OS App
  3. 3. WebKit -> OSJS-QObject Bridgevar tray = _OneRing.new_SystemTrayIcon();tray.show();class SystemTrayIcon : public QSystemTrayIcon{public: Q_INVOKABLE void show(void);}
  4. 4. OS -> WebKittray.click.connect(function() {...});class SystemTrayIcon : public QSystemTrayIcon {signals: void click(void);}...emit click();...
  5. 5. WebKit -> AppONERING.getJSON(onering://radio/get_bid,function(bid) {...});class get_bid: GET(self): return dict(bid=b64encode(os.urandom(8)).rstrip(=))
  6. 6. App -> WebKitONERING.subscribe(new-instance,function(){...});def new_instance_launched(): print "new instance" onering.publish("new-instance")
  7. 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. 8. New Design Unify OS and App WebKit call_app call_app pub/sub pub/sub OS Appcollection of apps collection of apps
  9. 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. 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. 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. 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. 13. Pros• small core• app could be Qt independent• explicit and flexible js binding interface• less memory management issue• easy to trace
  14. 14. Cons• extra layers • URL dispatch to C++ code • JSON <--> C++ object• slightly more code and slower
  15. 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

×