@@ -66,6 +66,9 @@ namespace {
66
66
const QString LocationSettingsHereEnabledKey = QStringLiteral(" here\\ enabled" );
67
67
const QString LocationSettingsHereAgreementAcceptedKey = QStringLiteral(" here\\ agreement_accepted" );
68
68
const QString LocationSettingsHereOnlineEnabledKey = QStringLiteral(" here\\ online_enabled" );
69
+ const QString LocationSettingsYandexLocatorEnabledKey = QStringLiteral(" yandex\\ enabled" );
70
+ const QString LocationSettingsYandexLocatorAgreementAcceptedKey = QStringLiteral(" yandex\\ agreement_accepted" );
71
+ const QString LocationSettingsYandexLocatorOnlineEnabledKey = QStringLiteral(" yandex\\ online_enabled" );
69
72
const QMap<LocationSettings::DataSource, QString> AllowedDataSourcesKeys {
70
73
{ LocationSettings::OnlineDataSources, QStringLiteral (" allowed_data_sources\\ online" ) },
71
74
{ LocationSettings::DeviceSensorsData, QStringLiteral (" allowed_data_sources\\ device_sensors" ) },
@@ -180,7 +183,9 @@ LocationSettingsPrivate::LocationSettingsPrivate(LocationSettings::Mode mode, Lo
180
183
, m_locationEnabled(false )
181
184
, m_gpsEnabled(false )
182
185
, m_mlsEnabled(true )
186
+ , m_yandexLocatorEnabled(true )
183
187
, m_mlsOnlineState(LocationSettings::OnlineAGpsAgreementNotAccepted)
188
+ , m_yandexLocatorOnlineState(LocationSettings::OnlineAGpsAgreementNotAccepted)
184
189
, m_hereState(LocationSettings::OnlineAGpsAgreementNotAccepted)
185
190
, m_locationMode(LocationSettings::CustomMode)
186
191
, m_settingLocationMode(true )
@@ -201,6 +206,10 @@ LocationSettingsPrivate::LocationSettingsPrivate(LocationSettings::Mode mode, Lo
201
206
this , &LocationSettingsPrivate::recalculateLocationMode);
202
207
connect (q, &LocationSettings::mlsOnlineStateChanged,
203
208
this , &LocationSettingsPrivate::recalculateLocationMode);
209
+ connect (q, &LocationSettings::yandexLocatorEnabledChanged,
210
+ this , &LocationSettingsPrivate::recalculateLocationMode);
211
+ connect (q, &LocationSettings::yandexLocatorOnlineStateChanged,
212
+ this , &LocationSettingsPrivate::recalculateLocationMode);
204
213
connect (q, &LocationSettings::hereStateChanged,
205
214
this , &LocationSettingsPrivate::recalculateLocationMode);
206
215
@@ -271,25 +280,28 @@ void LocationSettingsPrivate::findGpsTech()
271
280
LocationSettings::LocationMode
272
281
LocationSettingsPrivate::calculateLocationMode () const
273
282
{
283
+ bool nls = m_mlsEnabled || m_yandexLocatorEnabled;
284
+ bool nls_available = mlsAvailable () || yandexLocatorAvailable ();
285
+
274
286
if (m_gpsEnabled
275
- && (!mlsAvailable () ||
276
- (m_mlsEnabled && m_mlsOnlineState == LocationSettings::OnlineAGpsEnabled))
287
+ && (!nls_available ||
288
+ (nls && ( m_mlsOnlineState == LocationSettings::OnlineAGpsEnabled || m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsEnabled) ))
277
289
&& (!hereAvailable () || m_hereState == LocationSettings::OnlineAGpsEnabled)) {
278
290
return LocationSettings::HighAccuracyMode;
279
291
} else if (!m_gpsEnabled
280
- && (!mlsAvailable () ||
281
- (m_mlsEnabled &&
282
- (m_mlsOnlineState == LocationSettings::OnlineAGpsEnabled
283
- || m_mlsOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted)))
292
+ && (!nls_available ||
293
+ (nls &&
294
+ (( m_mlsOnlineState == LocationSettings::OnlineAGpsEnabled || m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsEnabled )
295
+ || ( m_mlsOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted || m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted) )))
284
296
&& (!hereAvailable () ||
285
297
(m_hereState == LocationSettings::OnlineAGpsEnabled
286
298
|| m_hereState == LocationSettings::OnlineAGpsAgreementNotAccepted))) {
287
299
return LocationSettings::BatterySavingMode;
288
300
} else if (m_gpsEnabled
289
- && (!mlsAvailable () ||
290
- (m_mlsEnabled &&
291
- (m_mlsOnlineState == LocationSettings::OnlineAGpsDisabled
292
- || m_mlsOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted)))
301
+ && (!nls_available ||
302
+ (nls &&
303
+ (( m_mlsOnlineState == LocationSettings::OnlineAGpsDisabled || m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsDisabled)
304
+ ||( m_mlsOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted || m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsAgreementNotAccepted) )))
293
305
&& (!hereAvailable () ||
294
306
(m_hereState == LocationSettings::OnlineAGpsDisabled
295
307
|| m_hereState == LocationSettings::OnlineAGpsAgreementNotAccepted))) {
@@ -315,6 +327,11 @@ bool LocationSettingsPrivate::mlsAvailable() const
315
327
return QFile::exists (QStringLiteral (" /usr/libexec/geoclue-mlsdb" ));
316
328
}
317
329
330
+ bool LocationSettingsPrivate::yandexLocatorAvailable () const
331
+ {
332
+ return QFile::exists (QStringLiteral (" /usr/libexec/geoclue-yandex" ));
333
+ }
334
+
318
335
bool LocationSettingsPrivate::hereAvailable () const
319
336
{
320
337
return QFile::exists (QStringLiteral (" /usr/libexec/geoclue-here" ));
@@ -409,6 +426,8 @@ bool LocationSettings::gpsAvailable() const
409
426
return QFile::exists (QStringLiteral (" /usr/libexec/geoclue-hybris" ));
410
427
}
411
428
429
+ /* Mozilla Location services*/
430
+
412
431
bool LocationSettings::mlsEnabled () const
413
432
{
414
433
Q_D (const LocationSettings);
@@ -448,6 +467,48 @@ bool LocationSettings::mlsAvailable() const
448
467
return d->mlsAvailable ();
449
468
}
450
469
470
+ /* Yandex locator services*/
471
+
472
+ bool LocationSettings::yandexLocatorEnabled () const
473
+ {
474
+ Q_D (const LocationSettings);
475
+ return d->m_yandexLocatorEnabled ;
476
+ }
477
+
478
+ void LocationSettings::setYandexLocatorEnabled (bool enabled)
479
+ {
480
+ Q_D (LocationSettings);
481
+ if (enabled != d->m_yandexLocatorEnabled ) {
482
+ d->m_yandexLocatorEnabled = enabled;
483
+ d->writeSettings ();
484
+ emit yandexLocatorEnabledChanged ();
485
+ }
486
+ }
487
+
488
+ LocationSettings::OnlineAGpsState LocationSettings::yandexLocatorOnlineState () const
489
+ {
490
+ Q_D (const LocationSettings);
491
+ return d->m_yandexLocatorOnlineState ;
492
+ }
493
+
494
+ void LocationSettings::setYandexLocatorOnlineState (LocationSettings::OnlineAGpsState state)
495
+ {
496
+ Q_D (LocationSettings);
497
+ if (state == d->m_yandexLocatorOnlineState )
498
+ return ;
499
+
500
+ d->m_yandexLocatorOnlineState = state;
501
+ d->writeSettings ();
502
+ emit yandexLocatorOnlineStateChanged ();
503
+ }
504
+
505
+ bool LocationSettings::yandexLocatorAvailable () const
506
+ {
507
+ Q_D (const LocationSettings);
508
+ return d->yandexLocatorAvailable ();
509
+ }
510
+
511
+ /* HERE*/
451
512
LocationSettings::OnlineAGpsState LocationSettings::hereState () const
452
513
{
453
514
Q_D (const LocationSettings);
@@ -498,6 +559,12 @@ void LocationSettings::setLocationMode(LocationMode locationMode)
498
559
setMlsOnlineState (LocationSettings::OnlineAGpsEnabled);
499
560
}
500
561
}
562
+ if (yandexLocatorAvailable ()) {
563
+ setYandexLocatorEnabled (true );
564
+ if (yandexLocatorOnlineState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
565
+ setYandexLocatorOnlineState (LocationSettings::OnlineAGpsEnabled);
566
+ }
567
+ }
501
568
if (hereAvailable ()) {
502
569
if (hereState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
503
570
setHereState (LocationSettings::OnlineAGpsEnabled);
@@ -511,6 +578,12 @@ void LocationSettings::setLocationMode(LocationMode locationMode)
511
578
setMlsOnlineState (LocationSettings::OnlineAGpsEnabled);
512
579
}
513
580
}
581
+ if (yandexLocatorAvailable ()) {
582
+ setYandexLocatorEnabled (true );
583
+ if (yandexLocatorOnlineState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
584
+ setYandexLocatorOnlineState (LocationSettings::OnlineAGpsEnabled);
585
+ }
586
+ }
514
587
if (hereAvailable ()) {
515
588
if (hereState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
516
589
setHereState (LocationSettings::OnlineAGpsEnabled);
@@ -524,6 +597,12 @@ void LocationSettings::setLocationMode(LocationMode locationMode)
524
597
setMlsOnlineState (LocationSettings::OnlineAGpsDisabled);
525
598
}
526
599
}
600
+ if (yandexLocatorAvailable ()) {
601
+ setYandexLocatorEnabled (true );
602
+ if (yandexLocatorOnlineState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
603
+ setYandexLocatorOnlineState (LocationSettings::OnlineAGpsDisabled);
604
+ }
605
+ }
527
606
if (hereAvailable ()) {
528
607
if (hereState () != LocationSettings::OnlineAGpsAgreementNotAccepted) {
529
608
setHereState (LocationSettings::OnlineAGpsDisabled);
@@ -561,6 +640,7 @@ void LocationSettingsPrivate::readSettings()
561
640
bool oldMlsEnabled = false ;
562
641
bool oldHereEnabled = false ;
563
642
bool oldHereAgreementAccepted = false ;
643
+ bool oldYandexLocatorEnabled = false ;
564
644
565
645
// current key values
566
646
bool locationEnabled = false ;
@@ -569,6 +649,10 @@ void LocationSettingsPrivate::readSettings()
569
649
bool mlsEnabled = false ;
570
650
bool mlsAgreementAccepted = false ;
571
651
bool mlsOnlineEnabled = false ;
652
+ bool yandexLocatorEnabled = false ;
653
+ bool yandexLocatorAgreementAccepted = false ;
654
+ bool yandexLocatorOnlineEnabled = false ;
655
+
572
656
bool hereEnabled = false ;
573
657
bool hereAgreementAccepted = false ;
574
658
@@ -595,6 +679,9 @@ void LocationSettingsPrivate::readSettings()
595
679
ini.readBool (LocationSettingsSection, LocationSettingsMlsEnabledKey, &mlsEnabled, oldMlsEnabled);
596
680
ini.readBool (LocationSettingsSection, LocationSettingsMlsAgreementAcceptedKey, &mlsAgreementAccepted);
597
681
ini.readBool (LocationSettingsSection, LocationSettingsMlsOnlineEnabledKey, &mlsOnlineEnabled);
682
+ ini.readBool (LocationSettingsSection, LocationSettingsYandexLocatorEnabledKey, &yandexLocatorEnabled, oldYandexLocatorEnabled);
683
+ ini.readBool (LocationSettingsSection, LocationSettingsYandexLocatorAgreementAcceptedKey, &yandexLocatorAgreementAccepted);
684
+ ini.readBool (LocationSettingsSection, LocationSettingsYandexLocatorOnlineEnabledKey, &yandexLocatorOnlineEnabled);
598
685
ini.readBool (LocationSettingsSection, LocationSettingsHereEnabledKey, &hereEnabled, oldHereEnabled);
599
686
ini.readBool (LocationSettingsSection, LocationSettingsHereAgreementAcceptedKey, &hereAgreementAccepted, oldHereAgreementAccepted);
600
687
@@ -639,6 +726,11 @@ void LocationSettingsPrivate::readSettings()
639
726
emit q->mlsEnabledChanged ();
640
727
}
641
728
729
+ if (m_yandexLocatorEnabled != yandexLocatorEnabled) {
730
+ m_yandexLocatorEnabled = yandexLocatorEnabled;
731
+ emit q->yandexLocatorEnabledChanged ();
732
+ }
733
+
642
734
LocationSettings::OnlineAGpsState mlsOnlineState = mlsAgreementAccepted
643
735
? ((mlsOnlineEnabled && m_mlsEnabled) ? LocationSettings::OnlineAGpsEnabled : LocationSettings::OnlineAGpsDisabled)
644
736
: LocationSettings::OnlineAGpsAgreementNotAccepted;
@@ -647,6 +739,14 @@ void LocationSettingsPrivate::readSettings()
647
739
emit q->mlsOnlineStateChanged ();
648
740
}
649
741
742
+ LocationSettings::OnlineAGpsState yandexLocatorOnlineState = yandexLocatorAgreementAccepted
743
+ ? ((yandexLocatorOnlineEnabled && m_yandexLocatorEnabled) ? LocationSettings::OnlineAGpsEnabled : LocationSettings::OnlineAGpsDisabled)
744
+ : LocationSettings::OnlineAGpsAgreementNotAccepted;
745
+ if (m_yandexLocatorOnlineState != yandexLocatorOnlineState) {
746
+ m_yandexLocatorOnlineState = yandexLocatorOnlineState;
747
+ emit q->yandexLocatorOnlineStateChanged ();
748
+ }
749
+
650
750
if ((m_locationMode == LocationSettings::CustomMode) != customMode) {
651
751
if (customMode) {
652
752
m_locationMode = LocationSettings::CustomMode;
@@ -671,13 +771,16 @@ void LocationSettingsPrivate::writeSettings()
671
771
}
672
772
673
773
// set the available location providers value based upon the enabled providers
674
- QString agps_providers;
675
- if (m_mlsEnabled && m_hereState == LocationSettings::OnlineAGpsEnabled) {
676
- agps_providers = QStringLiteral (" \" mls,here\" " );
677
- } else if (m_mlsEnabled) {
678
- agps_providers = QStringLiteral (" \" mls\" " );
679
- } else if (m_hereState == LocationSettings::OnlineAGpsEnabled) {
680
- agps_providers = QStringLiteral (" \" here\" " );
774
+ QStringList agps_providers;
775
+
776
+ if (m_mlsEnabled) {
777
+ agps_providers.append (" mls" );
778
+ }
779
+ if (m_hereState == LocationSettings::OnlineAGpsEnabled) {
780
+ agps_providers.append (" here" );
781
+ }
782
+ if (m_yandexLocatorEnabled) {
783
+ agps_providers.append (" yandex" );
681
784
}
682
785
683
786
// write the values to the conf file
@@ -696,12 +799,15 @@ void LocationSettingsPrivate::writeSettings()
696
799
ini.writeBool (LocationSettingsSection, LocationSettingsMlsEnabledKey, m_mlsEnabled);
697
800
ini.writeBool (LocationSettingsSection, LocationSettingsMlsAgreementAcceptedKey, m_mlsOnlineState != LocationSettings::OnlineAGpsAgreementNotAccepted);
698
801
ini.writeBool (LocationSettingsSection, LocationSettingsMlsOnlineEnabledKey, m_mlsOnlineState == LocationSettings::OnlineAGpsEnabled);
802
+ ini.writeBool (LocationSettingsSection, LocationSettingsYandexLocatorEnabledKey, m_yandexLocatorEnabled);
803
+ ini.writeBool (LocationSettingsSection, LocationSettingsYandexLocatorAgreementAcceptedKey, m_yandexLocatorOnlineState != LocationSettings::OnlineAGpsAgreementNotAccepted);
804
+ ini.writeBool (LocationSettingsSection, LocationSettingsYandexLocatorOnlineEnabledKey, m_yandexLocatorOnlineState == LocationSettings::OnlineAGpsEnabled);
699
805
ini.writeBool (LocationSettingsSection, LocationSettingsHereEnabledKey, m_hereState == LocationSettings::OnlineAGpsEnabled);
700
806
ini.writeBool (LocationSettingsSection, LocationSettingsHereAgreementAcceptedKey, m_hereState != LocationSettings::OnlineAGpsAgreementNotAccepted);
701
807
ini.writeBool (LocationSettingsSection, LocationSettingsHereOnlineEnabledKey, m_hereState == LocationSettings::OnlineAGpsEnabled);
702
808
703
809
// write the available location providers based on the enabled plugins
704
- ini.writeString (LocationSettingsSection, LocationSettingsAgpsProvidersKey, agps_providers);
810
+ ini.writeString (LocationSettingsSection, LocationSettingsAgpsProvidersKey, " \" " + agps_providers. join ( " , " )+ " \" " );
705
811
706
812
// write the MDM allowed allowed data source keys
707
813
for (QMap<LocationSettings::DataSource, QString>::const_iterator
0 commit comments