diff --git a/fix-auto-get-location.patch b/fix-auto-get-location.patch new file mode 100644 index 0000000..b28292b --- /dev/null +++ b/fix-auto-get-location.patch @@ -0,0 +1,112 @@ +diff -Naur indicator-china-weather-3.1.0/src/geoipworker.cpp indicator-china-weather-3.1.0~/src/geoipworker.cpp +--- indicator-china-weather-3.1.0/src/geoipworker.cpp 2021-11-27 03:59:19.000000000 +0800 ++++ indicator-china-weather-3.1.0~/src/geoipworker.cpp 2022-01-10 14:49:04.598862385 +0800 +@@ -264,29 +264,33 @@ + + const QString automaicCity() + { +- QString ip; +- QString city; ++// QString ip; ++// QString city; + +- getIpAndCityByUbuntu(UbuntuUrl, ip, city); +- if (ip.isEmpty() || ip == "0.0.0.0") { +- ip = getIpByPconline(PconlineUrl); +- } +- +-// qDebug() << "ip:" << ip; +- +- if (city.isEmpty()) { +- city = getCityFromIPAddr(ip);//根据ip从geoip库定位城市 +- if (city.isEmpty()) { +- city = getCityFromIpByAmap(ip);//根据ip从高德API定位城市,该方式使用高德key,访问次数有限 +- } +- if (city.isEmpty()) { +- city = getCityFromIpByTaobao(ip);//根据ip从淘宝service定位城市,该方式访问速度慢,可能访问失败 +- } +- } +- +-// qDebug() << "city:" << city; +- +- return city; ++// getIpAndCityByUbuntu(UbuntuUrl, ip, city); ++// if (ip.isEmpty() || ip == "0.0.0.0") { ++// ip = getIpByPconline(PconlineUrl); ++// } ++// if (city.isEmpty()) { ++// city = getCityFromIPAddr(ip);//根据ip从geoip库定位城市 ++// if (city.isEmpty()) { ++// city = getCityFromIpByAmap(ip);//根据ip从高德API定位城市,该方式使用高德key,访问次数有限 ++// } ++// if (city.isEmpty()) { ++// city = getCityFromIpByTaobao(ip);//根据ip从淘宝service定位城市,该方式访问速度慢,可能访问失败 ++// } ++// } ++// return city; ++ QNetworkAccessManager *manager = new QNetworkAccessManager(); ++ QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("http://myip.ipip.net"))); ++ QByteArray responseData ; ++ QEventLoop eventLoop; ++ QObject::connect(manager,&QNetworkAccessManager::finished,&eventLoop,&QEventLoop::quit); ++ eventLoop.exec(); ++ responseData = reply->readAll(); ++ QString str = responseData; ++ QStringList respList = str.split(' '); ++ return respList[5]; + } + + } // namespace +diff -Naur indicator-china-weather-3.1.0/src/geoipworker.h indicator-china-weather-3.1.0~/src/geoipworker.h +--- indicator-china-weather-3.1.0/src/geoipworker.h 2021-11-27 03:59:19.000000000 +0800 ++++ indicator-china-weather-3.1.0~/src/geoipworker.h 2022-01-10 14:49:04.574862040 +0800 +@@ -21,6 +21,10 @@ + #define GEOIP_WORKER_H + + #include ++#include ++#include ++#include ++#include + + class QNetworkAccessManager; + class QNetworkReply; +diff -Naur indicator-china-weather-3.1.0/src/mainwindow.cpp indicator-china-weather-3.1.0~/src/mainwindow.cpp +--- indicator-china-weather-3.1.0/src/mainwindow.cpp 2021-11-27 03:59:19.000000000 +0800 ++++ indicator-china-weather-3.1.0~/src/mainwindow.cpp 2022-01-10 14:49:04.606862500 +0800 +@@ -361,11 +361,12 @@ + //根据获取到网络探测的结果分别处理 + connect(m_weatherManager, &WeatherManager::nofityNetworkStatus, this, [=] (const QString &status) { + if (status == "OK") { +- //m_weatherManager->startAutoLocationTask();//开始自动定位城市 ++ m_weatherManager->startAutoLocationTask();//开始自动定位城市 + + //CN101010100,beijing,北京,CN,China,中国 +- // m_weatherManager->startGetTheWeatherData("101010100"); ++// m_weatherManager->startGetTheWeatherData("101010100"); + QStringList listCityId = getCityList().split(","); ++ qDebug()<<"listCityId:"<startGetTheWeatherData(listCityId.at(0)); + } else { + if (status == "Fail") { +@@ -381,6 +382,9 @@ + connect(m_weatherManager, &WeatherManager::requestAutoLocationData, this, [=] (const CitySettingData &info, bool success) { + if (success) { + //自动定位城市成功后,更新各个ui,然后获取天气数据 ++ m_weatherManager->startGetTheWeatherData(info.id); ++ ++ + } else { + //自动定位城市失败后,获取天气数据 + } +diff -Naur indicator-china-weather-3.1.0/src/weathermanager.cpp indicator-china-weather-3.1.0~/src/weathermanager.cpp +--- indicator-china-weather-3.1.0/src/weathermanager.cpp 2021-11-27 03:59:19.000000000 +0800 ++++ indicator-china-weather-3.1.0~/src/weathermanager.cpp 2022-01-10 14:49:04.559861824 +0800 +@@ -165,7 +165,6 @@ + } + file.close(); + } +- + if (autoSuccess) { + emit this->requestAutoLocationData(info, true); + } else { diff --git a/indicator-china-weather.spec b/indicator-china-weather.spec index 9d1e794..086a358 100644 --- a/indicator-china-weather.spec +++ b/indicator-china-weather.spec @@ -1,7 +1,7 @@ %define debug_package %{nil} Name: indicator-china-weather Version: 3.1.0 -Release: 7 +Release: 8 Summary: The weather data are from the heweather API s6 version. License: GPL-3.0+ URL: https://github.com/UbuntuKylin/indicator-china-weather @@ -24,6 +24,7 @@ BuildRequires: GeoIP-devel #patch0: 0001-remove-about.patch #patch1: 0001-fix-vnc-show-issue.patch patch0: fix-gsetting-issue.patch +patch1: fix-auto-get-location.patch %description Indicator that displays China weather information @@ -34,6 +35,7 @@ patch0: fix-gsetting-issue.patch %prep %setup -q %patch0 -p1 +%patch1 -p1 %build %{qmake_qt5} %{_qt5_qmake_flags} CONFIG+=enable-by-default indicator-china-weather.pro @@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/man/man1/indicator-china-weather.1.gz %changelog +* Mon Jan 10 2022 douyan - 3.1.0-8 +- add fix-auto-get-location.patch + * Wed Dec 8 2021 douyan - 3.1.0-7 - update to upstream version 3.1.0-36 - fix open failed caused by gsetting