weather: Handle GeoClue not responding
If GeoClue is not responding for some reason, the callback of Geoclue.Simple.new would not get called, meaning that _gclueFailed remains false. This is preventing the fallback to the most recently used location in gnome-weather, because it requires _gclueFailed to be true (or auto-location to be disabled). So neither code path sets a location and the libgweather default (New York City) is being used instead. https://bugzilla.gnome.org/show_bug.cgi?id=779898
This commit is contained in:
parent
4373d390dc
commit
ce5875f365
@ -24,7 +24,7 @@ const WeatherClient = new Lang.Class({
|
|||||||
|
|
||||||
this._gclueService = null;
|
this._gclueService = null;
|
||||||
this._gclueStarted = false;
|
this._gclueStarted = false;
|
||||||
this._gclueFailed = false;
|
this._gclueStarting = false;
|
||||||
this._gclueLocationChangedId = 0;
|
this._gclueLocationChangedId = 0;
|
||||||
|
|
||||||
this._world = GWeather.Location.get_world();
|
this._world = GWeather.Location.get_world();
|
||||||
@ -125,21 +125,21 @@ const WeatherClient = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_startGClueService: function() {
|
_startGClueService: function() {
|
||||||
if (this._gclueStarted)
|
if (this._gclueStarting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._gclueStarted = true;
|
this._gclueStarting = true;
|
||||||
|
|
||||||
Geoclue.Simple.new('org.gnome.Shell', Geoclue.AccuracyLevel.CITY, null,
|
Geoclue.Simple.new('org.gnome.Shell', Geoclue.AccuracyLevel.CITY, null,
|
||||||
(o, res) => {
|
(o, res) => {
|
||||||
try {
|
try {
|
||||||
this._gclueService = Geoclue.Simple.new_finish(res);
|
this._gclueService = Geoclue.Simple.new_finish(res);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Failed to connect to Geoclue2 service: ' + e.message);
|
log('Failed to connect to Geoclue2 service: ' + e.message);
|
||||||
this._gclueFailed = true;
|
|
||||||
this._setLocation(this._mostRecentLocation);
|
this._setLocation(this._mostRecentLocation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this._gclueStarted = true;
|
||||||
this._gclueService.get_client().distance_threshold = 100;
|
this._gclueService.get_client().distance_threshold = 100;
|
||||||
this._updateLocationMonitoring();
|
this._updateLocationMonitoring();
|
||||||
});
|
});
|
||||||
@ -163,12 +163,10 @@ const WeatherClient = new Lang.Class({
|
|||||||
|
|
||||||
this._updateLocationMonitoring();
|
this._updateLocationMonitoring();
|
||||||
|
|
||||||
if (this._useAutoLocation) {
|
if (this._useAutoLocation)
|
||||||
if (!this._gclueStarted)
|
this._startGClueService();
|
||||||
this._startGClueService();
|
else
|
||||||
} else {
|
|
||||||
this._setLocation(this._mostRecentLocation);
|
this._setLocation(this._mostRecentLocation);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onLocationsChanged: function(settings, key) {
|
_onLocationsChanged: function(settings, key) {
|
||||||
@ -183,7 +181,7 @@ const WeatherClient = new Lang.Class({
|
|||||||
|
|
||||||
this._mostRecentLocation = mostRecentLocation;
|
this._mostRecentLocation = mostRecentLocation;
|
||||||
|
|
||||||
if (!this._useAutoLocation || this._gclueFailed)
|
if (!this._useAutoLocation || !this._gclueStarted)
|
||||||
this._setLocation(this._mostRecentLocation);
|
this._setLocation(this._mostRecentLocation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user