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 756580 - geoclue: Make use of new convenience library
geoclue: Make use of new convenience library
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2015-10-14 17:13 UTC by Zeeshan Ali
Modified: 2015-10-23 13:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
geoclue: Make use of new convenience library (6.21 KB, patch)
2015-10-14 17:13 UTC, Zeeshan Ali
none Details | Review
geoclue: Make use of new convenience library (6.26 KB, patch)
2015-10-14 17:40 UTC, Zeeshan Ali
none Details | Review
geoclue: Make use of new convenience library (6.32 KB, patch)
2015-10-15 16:48 UTC, Zeeshan Ali
none Details | Review
geoclue: Make use of new convenience library (6.32 KB, patch)
2015-10-15 21:15 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2015-10-14 17:13:32 UTC
I want Maps to be the first one to take advantage of the new geoclue convenience library. I wouldn't merge this patch yet though and wait for the new API to be released first. It goes without saying that this is meant for 3.20.
Comment 1 Zeeshan Ali 2015-10-14 17:13:38 UTC
Created attachment 313314 [details] [review]
geoclue: Make use of new convenience library
Comment 3 Zeeshan Ali 2015-10-14 17:40:38 UTC
Created attachment 313318 [details] [review]
geoclue: Make use of new convenience library

v2: The import line in previous version was all wrong. I also realized that I didn't actually get to test the patch since the location was from a previous run and I get a crash not long after the launch (in jhbuild) with this on console:

(org.gnome.Maps:17168): folks-WARNING **: Error preparing persona store 'bluez:F8:84:F2:A5:DA:D7': An OBEX address book transfer from device ‘Zeeshan's galaxy’ could not be started: GDBus.Error:org.bluez.obex.Error.Failed: Unable to find service record

(org.gnome.Maps:17168): GLib-ERROR **: Creating pipes for GWakeup: Too many open files
Comment 4 Jonas Danielsson 2015-10-15 05:23:24 UTC
Love it! Thanks! Will try it out later to make sure all use-cases still work.
So when will the next GeoClue release be do you think?
Comment 5 Zeeshan Ali 2015-10-15 13:47:39 UTC
(In reply to Jonas Danielsson from comment #4)
> Love it!

Great. :)

> Thanks! Will try it out later to make sure all use-cases still work.

Cool, please do. I didn't really get to test it due to that issue.

> So when will the next GeoClue release be do you think?

Actually, I think the patch should be merged already if it works so that we can get new API tested before I can release. I can release before 3.19.1 tarballs due date.
Comment 6 Zeeshan Ali 2015-10-15 16:48:19 UTC
Created attachment 313388 [details] [review]
geoclue: Make use of new convenience library

v2: This one I tested. :)
Comment 7 Mattias Bengtsson 2015-10-15 18:11:06 UTC
Review of attachment 313388 [details] [review]:

Just some small nits. Great work Zeeshan!

::: src/geoclue.js
@@ +22,2 @@
 const GObject = imports.gi.GObject;
+const GClue = imports.gi.Geoclue;

This should be Geoclue (for consistency).

@@ +114,3 @@
     },
 
+    _onSimpleReady: function(object, result) {

I'd just make this an anonymous function passed to GClue.Simple.new

@@ +132,3 @@
         this.state = State.ON;
+
+        this._onLocationUpdated(this._simple);

We use present tense for most signal handlers I believe. So I think you should go with this._onLocationUpdate instead.
Comment 8 Zeeshan Ali 2015-10-15 20:42:00 UTC
Review of attachment 313388 [details] [review]:

::: src/geoclue.js
@@ +22,2 @@
 const GObject = imports.gi.GObject;
+const GClue = imports.gi.Geoclue;

It was but it conflicts with the 'const Geoclue' below.

@@ +114,3 @@
     },
 
+    _onSimpleReady: function(object, result) {

Why? IMO code is less clean with anonymous functions.

@@ +132,3 @@
         this.state = State.ON;
+
+        this._onLocationUpdated(this._simple);

I did not come up with a new function or name in this patch, I just had to change the signature of it for the new API.
Comment 9 Jonas Danielsson 2015-10-15 20:46:08 UTC
Review of attachment 313388 [details] [review]:

::: src/geoclue.js
@@ +132,3 @@
         this.state = State.ON;
+
+        this._onLocationUpdated(this._simple);

Yeah, but when we are changing stuff we might as well change it!
Comment 10 Zeeshan Ali 2015-10-15 21:10:48 UTC
Review of attachment 313388 [details] [review]:

::: src/geoclue.js
@@ +132,3 @@
         this.state = State.ON;
+
+        this._onLocationUpdated(this._simple);

ok. :)
Comment 11 Zeeshan Ali 2015-10-15 21:15:45 UTC
Created attachment 313401 [details] [review]
geoclue: Make use of new convenience library

v2: Better name for notify handler function and id field.
Comment 12 Mattias Bengtsson 2015-10-15 22:35:42 UTC
Review of attachment 313388 [details] [review]:

::: src/geoclue.js
@@ +22,2 @@
 const GObject = imports.gi.GObject;
+const GClue = imports.gi.Geoclue;

True and also a bit is awkward. We could rename this whole class to locationService or something I guess, but let's keep it as GClue for now. :)

@@ +114,3 @@
     },
 
+    _onSimpleReady: function(object, result) {

Because it isn't used anywhere else and because this is more about doing async workflow then event handling.
Comment 13 Zeeshan Ali 2015-10-16 12:11:28 UTC
Review of attachment 313388 [details] [review]:

::: src/geoclue.js
@@ +114,3 @@
     },
 
+    _onSimpleReady: function(object, result) {

If it was simply completing the async call and had < 3 LOCs, I'd also prefer anonymous function. I don't think async vs event handling is relevant here. There is a discussion here about the subject: http://stackoverflow.com/questions/1960517/anonymous-functions-considered-harmful . The keypoint "deep indentation is considered bad programming practice, and generally points out at design issues if you indent more than three or four levels." is important IMO and I always tend to avoid indentation, whenever possible.
Comment 14 Zeeshan Ali 2015-10-23 12:46:33 UTC
(In reply to Zeeshan Ali (Khattak) from comment #11)
> Created attachment 313401 [details] [review] [review]
> geoclue: Make use of new convenience library
> 
> v2: Better name for notify handler function and id field.

So is this good now?
Comment 15 Jonas Danielsson 2015-10-23 13:02:30 UTC
Review of attachment 313401 [details] [review]:

Thanks!
Comment 16 Zeeshan Ali 2015-10-23 13:15:46 UTC
Attachment 313401 [details] pushed as a79b23b - geoclue: Make use of new convenience library