After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678516 - mount-operation: implement org.Gtk.MountOperationHandler
mount-operation: implement org.Gtk.MountOperationHandler
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-06-21 02:57 UTC by Cosimo Cecchi
Modified: 2012-06-22 20:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mount-operation: implement org.Gtk.MountOperationHandler (14.86 KB, patch)
2012-06-21 02:57 UTC, Cosimo Cecchi
needs-work Details | Review
mount-operation: implement org.Gtk.MountOperationHandler (15.11 KB, patch)
2012-06-21 14:56 UTC, Cosimo Cecchi
accepted-commit_now Details | Review
mount-operation: implement org.Gtk.MountOperationHandler (14.56 KB, patch)
2012-06-22 17:15 UTC, Cosimo Cecchi
reviewed Details | Review
mount-operation: implement org.Gtk.MountOperationHandler (14.56 KB, patch)
2012-06-22 19:59 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2012-06-21 02:57:41 UTC
This is a bug for the shell side implementation of org.Gtk.MountOperationHandler proposed in bug 674963
Comment 1 Cosimo Cecchi 2012-06-21 02:57:44 UTC
Created attachment 216889 [details] [review]
mount-operation: implement org.Gtk.MountOperationHandler

Use the ShellMountOperation dialogs we have to implement a DBus API
allowing other processes to display them.
Since GtkMountOperation now tries to call into our DBus implementation,
every application that uses a GtkMountOperation will gain integration
with our shell dialogs (but will still handle the actual communication
with GVfs).
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-06-21 04:06:53 UTC
Review of attachment 216889 [details] [review]:

Mostly fine.

::: js/ui/shellDBus.js
@@ +12,3 @@
 const Flashspot = imports.ui.flashspot;
 const Main = imports.ui.main;
+const ShellMountOperation = imports.ui.shellMountOperation;

?

::: js/ui/shellMountOperation.js
@@ +521,3 @@
+        this._currentType = ShellMountOperationType.NONE;
+        this._currentResponse = Gio.MountOperationResult.UNHANDLED;
+        this._currentResponseDetails = { };

{}

@@ +527,3 @@
+        if (this._currentInvocation) {
+            this._currentInvocation.return_value(
+                GLib.Variant.new('(ua{sv})', [ this._currentResponse, this._currentResponseDetails ]));

Not the biggest fan of the stateful approach, but it works. I'd rather see something like:

    this._returnRequest(invocation, HANDLED, {'password_save': GLib.Variant.new('u', NEVER),
                                              'password': GLib.Variant.new('s': 'hunter2')});

@@ +534,3 @@
+
+    _createGIcon: function(iconName) {
+        let realIconName = (iconName && iconName.length > 0) ? iconName : 'drive-harddisk';

For a string, just iconName ? iconName : 'drive-harddisk' is enough. The empty string evalutes to false.

@@ +560,3 @@
+     */
+    AskPasswordAsync: function(params, invocation) {
+        let [ id, message, iconName, defaultUser, defaultDomain, flags ] = params;

No spaces between [ and ].

@@ +578,3 @@
+        this._dialog.connect('response', Lang.bind(this,
+            function(object, choice, password, remember) {
+                if (choice == '-1') {

This looks smelly.

@@ +702,3 @@
+
+        if (this._dialog) {
+            this._dialog.close(global.get_current_time());

Unnecessary.
Comment 3 Cosimo Cecchi 2012-06-21 14:56:11 UTC
Created attachment 216933 [details] [review]
mount-operation: implement org.Gtk.MountOperationHandler

---

Fixed review comments:
- I'd rather keep the stateful approach for now, as it's nice being able to dynamically append properties to the response details variant, and we could need to do it more of it when we start supporting username/domain fields in the future
- also, updated the documentation of the methods to match the new one from bug 674963
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-06-21 18:46:04 UTC
Review of attachment 216933 [details] [review]:

Looks fine.
Comment 5 Cosimo Cecchi 2012-06-22 17:15:07 UTC
Created attachment 217036 [details] [review]
mount-operation: implement org.Gtk.MountOperationHandler

---

- fixes some problems with multiple dialogs being shown at the same time
- removes the response data from the current state of the handler, as suggested by a previous comment of Jasper
- cleanup the request/response code
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-06-22 18:56:58 UTC
Review of attachment 217036 [details] [review]:

I'm not the biggest fan of the half-stateful half-stateless approach, but I guess we don't have any other options.

::: js/ui/shellMountOperation.js
@@ +524,3 @@
+    _sendResponse: function(response, details) {
+        if (this._currentInvocation) {
+            this._currentInvocation.return_value(

Function name is a bit silly, as it could won't send anything if there's no current invocation.

@@ +532,3 @@
+
+    _flushCurrentRequest: function() {
+        this._sendResponse(Gio.MountOperationResult.UNHANDLED, {});

This isn't really a flush anymore. I would just move the sendResponse in the two places it's used.
Comment 7 Cosimo Cecchi 2012-06-22 19:59:57 UTC
Created attachment 217044 [details] [review]
mount-operation: implement org.Gtk.MountOperationHandler

---

- removed _flushCurrentRequest()
- renamed _sendResponse() to _clearCurrentRequest()

It's not really half-stateful/half-stateless, just that the state is defined only by an [invocation, id, type] tuple, and the response values are not part of it. I don't really see any way around it, since we need to keep track of those to implement the "update dialog with new values" behavior.
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-06-22 20:21:10 UTC
Review of attachment 217044 [details] [review]:

Right. This looks good.
Comment 9 Cosimo Cecchi 2012-06-22 20:49:57 UTC
Attachment 217044 [details] pushed as 6b5f9a6 - mount-operation: implement org.Gtk.MountOperationHandler

Thanks, pushed to master.