[gnome-shell/hotplug: 7/21] autorun: integrate with the shell sniffer process



commit dbfd8e45e31f0d10526f96f2e52d13ac48c814c5
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Jun 21 18:32:32 2011 -0400

    autorun: integrate with the shell sniffer process

 js/ui/autorunManager.js |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
index 66f07bb..1ce84cb 100644
--- a/js/ui/autorunManager.js
+++ b/js/ui/autorunManager.js
@@ -1,6 +1,7 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
 const Lang = imports.lang;
+const DBus = imports.dbus;
 const Gio = imports.gi.Gio;
 const St = imports.gi.St;
 
@@ -51,6 +52,26 @@ function startAppForMount(app, mount) {
 
 /******************************************/
 
+const HotplugSnifferIface = {
+    name: 'org.gnome.Shell.HotplugSniffer',
+    methods: [{ name: 'SniffURI',
+                inSignature: 's',
+                outSignature: 's' }]
+};
+
+const HotplugSniffer = function() {
+    this._init();
+};
+
+HotplugSniffer.prototype = {
+    _init: function() {
+        DBus.session.proxifyObject(this,
+                                   'org.gnome.Shell.HotplugSniffer',
+                                   '/org/gnome/Shell/HotplugSniffer');
+    },
+};
+DBus.proxifyPrototype(HotplugSniffer.prototype, HotplugSnifferIface);
+
 function ContentTypeDiscoverer(callback) {
     this._init(callback);
 }
@@ -77,6 +98,26 @@ ContentTypeDiscoverer.prototype = {
                 + ': ' + e.toString());
         }
 
+        if (!contentTypes.length) {
+            let root = mount.get_root();
+
+            let hotplugSniffer = new HotplugSniffer();
+            hotplugSniffer.SniffURIRemote
+                (root.get_uri(), DBus.CALL_FLAG_START,
+                 Lang.bind(this, function(contentType) {
+                     if (contentType && contentType != '') {
+                         contentTypes = new Array();
+                         contentTypes.push(contentType);
+                     }
+
+                     this._emitCallback(mount, contentTypes);
+                 }));
+        } else {
+            this._emitCallback(mount, contentTypes);
+        }
+    },
+
+    _emitCallback: function(mount, contentTypes) {
         // we're not interested in win32 software content types here
         contentTypes = contentTypes.filter(function(type) {
             return (type != 'x-content/win32-software');



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