[gnome-documents] miners: Port JS proxy code to GDBus



commit adef4f4828f9006410d79d7e85d2cef42db08bb6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jul 18 21:26:07 2012 -0400

    miners: Port JS proxy code to GDBus
    
    Make both miners use the same interface so that we can generalize
    the code a bit better.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680219

 src/Makefile-js.am             |    3 +--
 src/application.js             |   10 ++++------
 src/gDataMiner.js              |   40 ----------------------------------------
 src/miner/gdata-miner-main.c   |    2 +-
 src/miner/zpj-miner-main.c     |    2 +-
 src/{zpjMiner.js => miners.js} |   38 +++++++++++++++++++-------------------
 6 files changed, 26 insertions(+), 69 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 8900798..725c7ba 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -5,12 +5,12 @@ dist_js_DATA = \
     documents.js \
     embed.js \
     errorBox.js \
-    gDataMiner.js \
     global.js \
     main.js \
     mainToolbar.js \
     mainWindow.js \
     manager.js \
+    miners.js \
     notifications.js \
     offsetController.js \
     preview.js \
@@ -25,7 +25,6 @@ dist_js_DATA = \
     utils.js \
     view.js \
     windowMode.js \
-    zpjMiner.js \
     path.js
 
 jsutildir = $(pkgdatadir)/js/util/
diff --git a/src/application.js b/src/application.js
index 75aaa93..095c074 100644
--- a/src/application.js
+++ b/src/application.js
@@ -19,7 +19,6 @@
  *
  */
 
-const DBus = imports.dbus;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Gettext = imports.gettext;
@@ -37,12 +36,12 @@ const Tracker = imports.gi.Tracker;
 const ChangeMonitor = imports.changeMonitor;
 const Documents = imports.documents;
 const Format = imports.format;
-const GDataMiner = imports.gDataMiner;
 const Global = imports.global;
 const Main = imports.main;
 const MainWindow = imports.mainWindow;
 const MainToolbar = imports.mainToolbar;
 const Manager = imports.manager;
+const Miners = imports.miners;
 const Notifications = imports.notifications;
 const Path = imports.path;
 const Query = imports.query;
@@ -52,7 +51,6 @@ const TrackerController = imports.trackerController;
 const Tweener = imports.util.tweener;
 const Utils = imports.utils;
 const WindowMode = imports.windowMode;
-const ZpjMiner = imports.zpjMiner;
 
 const MINER_REFRESH_TIMEOUT = 60; /* seconds */
 
@@ -164,7 +162,7 @@ const Application = new Lang.Class({
         if (env)
             return false;
 
-        miner.RefreshDBRemote(DBus.CALL_FLAG_START, Lang.bind(this,
+        miner.RefreshDBRemote(Lang.bind(this,
             function(res, error) {
                 if (error) {
                     log('Error updating the cache: ' + error.toString());
@@ -217,11 +215,11 @@ const Application = new Lang.Class({
         Global.notificationManager = new Notifications.NotificationManager();
 
         // startup a refresh of the gdocs cache
-        let gdataMiner = new GDataMiner.GDataMiner();
+        let gdataMiner = new Miners.GDataMiner();
         this._refreshMinerNow(gdataMiner);
 
         // startup a refresh of the skydrive cache
-        let zpjMiner = new ZpjMiner.ZpjMiner();
+        let zpjMiner = new Miners.ZpjMiner();
         this._refreshMinerNow(zpjMiner);
 
         this._initActions();
diff --git a/src/miner/gdata-miner-main.c b/src/miner/gdata-miner-main.c
index 0d98c6f..0a96cc9 100644
--- a/src/miner/gdata-miner-main.c
+++ b/src/miner/gdata-miner-main.c
@@ -29,7 +29,7 @@
 
 static const gchar introspection_xml[] =
   "<node>"
-  "  <interface name='org.gnome.Documents.GDataMiner'>"
+  "  <interface name='org.gnome.Documents.Miner'>"
   "    <method name='RefreshDB'>"
   "    </method>"
   "  </interface>"
diff --git a/src/miner/zpj-miner-main.c b/src/miner/zpj-miner-main.c
index e48f3c2..d07e529 100644
--- a/src/miner/zpj-miner-main.c
+++ b/src/miner/zpj-miner-main.c
@@ -29,7 +29,7 @@
 
 static const gchar introspection_xml[] =
   "<node>"
-  "  <interface name='org.gnome.Documents.ZpjMiner'>"
+  "  <interface name='org.gnome.Documents.Miner'>"
   "    <method name='RefreshDB'>"
   "    </method>"
   "  </interface>"
diff --git a/src/zpjMiner.js b/src/miners.js
similarity index 52%
rename from src/zpjMiner.js
rename to src/miners.js
index 6f749a4..d6bb5ba 100644
--- a/src/zpjMiner.js
+++ b/src/miners.js
@@ -15,27 +15,27 @@
  * with Gnome Documents; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
- * Author: Debarshi Ray <debarshir gnome org>
- *
+ * Authors:
+ *    Cosimo Cecchi <cosimoc redhat com>
+ *    Debarshi Ray <debarshir gnome org>
  */
 
-const DBus = imports.dbus;
+const Gio = imports.gi.Gio;
+
+const MinerIface = <interface name="org.gnome.Documents.Miner">
+    <method name="RefreshDB" />
+</interface>;
 
-const ZpjMinerIface = {
-    name: 'org.gnome.Documents.ZpjMiner',
-    methods: [{ name: 'RefreshDB',
-                inSignature: '' }]
-};
+var MinerProxy = Gio.DBusProxy.makeProxyWrapper(MinerIface);
 
-const ZpjMiner = function() {
-    this._init();
-};
+function GDataMiner(iface, path) {
+    return new MinerProxy(Gio.DBus.session,
+                          'org.gnome.Documents.GDataMiner',
+                          '/org/gnome/Documents/GDataMiner');
+}
 
-ZpjMiner.prototype = {
-    _init: function() {
-        DBus.session.proxifyObject(this,
-                                   'org.gnome.Documents.ZpjMiner',
-                                   '/org/gnome/Documents/ZpjMiner');
-    }
-};
-DBus.proxifyPrototype(ZpjMiner.prototype, ZpjMinerIface);
+function ZpjMiner(iface, path) {
+    return new MinerProxy(Gio.DBus.session,
+                          'org.gnome.Documents.ZpjMiner',
+                          '/org/gnome/Documents/ZpjMiner');
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]