[kde-workspace] More bbcukmet fixes.

Kevin Kofler kkofler at fedoraproject.org
Mon Mar 24 22:01:27 UTC 2014


commit 10bb2f99789febfbb80c06f136fab74b772cec0c
Author: Kevin Kofler <Kevin at tigcc.ticalc.org>
Date:   Mon Mar 24 23:01:20 2014 +0100

    More bbcukmet fixes.
    
    * Mon Mar 24 2014 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.11.7-5
    - bbcukmet: fix typo in the condition->icon matching ("clar sky" -> "clear sky")
    - bbcukmet: fix a crash (#1079296/kde#332392) and improve error handling

 ...ace-4.11.7-weather-fix-bbcukmet-clear-sky.patch |   12 ++
 ...1.7-weather-fix-bbcukmet-crash-kde#332392.patch |  160 ++++++++++++++++++++
 kde-workspace.spec                                 |   20 ++-
 3 files changed, 189 insertions(+), 3 deletions(-)
---
diff --git a/kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky.patch b/kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky.patch
new file mode 100644
index 0000000..99c1708
--- /dev/null
+++ b/kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky.patch
@@ -0,0 +1,12 @@
+diff -ur kde-workspace-4.11.7-weather-fix-bbcukmet-temp/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp
+--- kde-workspace-4.11.7-weather-fix-bbcukmet-temp/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp	2014-03-16 00:53:22.000000000 +0100
++++ kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp	2014-03-24 02:27:37.000000000 +0100
+@@ -75,7 +75,7 @@
+     dayList["sunny"] = ClearDay;
+     //dayList["sunny night"] = ClearNight;
+     dayList["clear"] = ClearDay;
+-    dayList["clar sky"] = ClearDay;
++    dayList["clear sky"] = ClearDay;
+     dayList["sunny intervals"] = PartlyCloudyDay;
+     //dayList["sunny intervals night"] = ClearNight;
+     dayList["partly cloudy"] = PartlyCloudyDay;
diff --git a/kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392.patch b/kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392.patch
new file mode 100644
index 0000000..37fc76e
--- /dev/null
+++ b/kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392.patch
@@ -0,0 +1,160 @@
+diff -ur kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp
+--- kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp	2014-03-24 02:27:37.000000000 +0100
++++ kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp	2014-03-24 22:53:19.000000000 +0100
+@@ -23,6 +23,13 @@
+ 
+ #include <KIO/Job>
+ #include <KUnitConversion/Converter>
++#include <KDateTime>
++
++WeatherData::WeatherData()
++        : obsTime("N/A"), iconPeriodHour(12), iconPeriodMinute(0),
++          longitude(0.), latitude(0.), condition("N/A")
++{
++}
+ 
+ // ctor, dtor
+ UKMETIon::UKMETIon(QObject *parent, const QVariantList &args)
+@@ -553,16 +560,31 @@
+ 
+                 // Get the observation time and condition
+                 int splitIndex = conditionString.lastIndexOf(':');
+-                QStringRef conditionData = conditionString.midRef(splitIndex + 1); // Include ':'
+-                data.obsTime = conditionString.midRef(0, splitIndex).toString();
++                if (splitIndex >= 0) {
++                    QString conditionData = conditionString.mid(splitIndex + 1); // Skip ':'
++                    data.obsTime = conditionString.left(splitIndex);
++
++                    if (data.obsTime.contains('-')) {
++                        // Saturday - 13:00 CET
++                        // Saturday - 12:00 GMT
++                        m_dateFormat = KDateTime::fromString(data.obsTime.section('-', 1, 1).trimmed(),
++                                                             "%H:%M %Z").toLocalZone().dateTime();
++                        if (m_dateFormat.isValid()) {
++                            data.iconPeriodHour = m_dateFormat.toString("hh").toInt();
++                            data.iconPeriodMinute = m_dateFormat.toString("mm").toInt();
++                        }
++                    } else {
++                        m_dateFormat = QDateTime();
++                    }
+ 
+-                // Saturday - 13:00 CET
+-                // Saturday - 12:00 GMT
+-                m_dateFormat = QDateTime::fromString(data.obsTime.split("-")[1].trimmed(), "hh:mm 'GMT'");
+-                data.iconPeriodHour = m_dateFormat.toString("hh").toInt();
+-                data.iconPeriodMinute = m_dateFormat.toString("mm").toInt();
++                    if (data.condition.contains(',')) {
++                        data.condition = conditionData.section(',', 0, 0).trimmed();
++                    }
+ 
+-                data.condition = conditionData.toString().split(',')[0].trimmed();
++                    if (data.condition == "null") {
++                        data.condition = "N/A";
++                    }
++                }
+ 
+             } else if (xml.name() == "link") {
+                 m_place[source].forecastHTMLUrl = xml.readElementText();
+@@ -705,12 +727,12 @@
+ 
+             // Sometimes only one of min or max are reported
+             if (high.indexIn(line.split(',')[1]) == -1)
+-                forecast->tempHigh = 0;
++                forecast->tempHigh = UNKNOWN_TEMPERATURE;
+             else
+                 forecast->tempHigh = high.cap(1).toInt();
+ 
+             if (low.indexIn(line.split(',')[1]) == -1)
+-                forecast->tempLow = 0;
++                forecast->tempLow = UNKNOWN_TEMPERATURE;
+             else
+                 forecast->tempLow = low.cap(1).toInt();
+ 
+@@ -775,18 +797,22 @@
+     data.insert("Current Conditions", i18nc("weather condition", condition(source).toUtf8()));
+     kDebug() << "i18n condition string: " << qPrintable(i18nc("weather condition", condition(source).toUtf8()));
+ 
+-    const double lati = periodLatitude(source);
+-    const double longi = periodLongitude(source);
+-    const Plasma::DataEngine::Data timeData = m_timeEngine->query(
+-            QString("Local|Solar|Latitude=%1|Longitude=%2|DateTime=%3")
+-                .arg(lati).arg(longi).arg(m_dateFormat.toString(Qt::ISODate)));
+-
+-    // Tell applet which icon to use for conditions and provide mapping for condition type to the icons to display
+-    if (timeData["Corrected Elevation"].toDouble() >= 0.0) {
+-        //kDebug() << "Using daytime icons\n";
+-        data.insert("Condition Icon", getWeatherIcon(dayIcons(), condition(source)));
++    if (m_dateFormat.isValid()) {
++        const double lati = periodLatitude(source);
++        const double longi = periodLongitude(source);
++        const Plasma::DataEngine::Data timeData = m_timeEngine->query(
++                QString("Local|Solar|Latitude=%1|Longitude=%2|DateTime=%3")
++                    .arg(lati).arg(longi).arg(m_dateFormat.toString(Qt::ISODate)));
++
++        // Tell applet which icon to use for conditions and provide mapping for condition type to the icons to display
++        if (timeData["Corrected Elevation"].toDouble() >= 0.0) {
++            //kDebug() << "Using daytime icons\n";
++            data.insert("Condition Icon", getWeatherIcon(dayIcons(), condition(source)));
++        } else {
++            data.insert("Condition Icon", getWeatherIcon(nightIcons(), condition(source)));
++        }
+     } else {
+-        data.insert("Condition Icon", getWeatherIcon(nightIcons(), condition(source)));
++        data.insert("Condition Icon", getWeatherIcon(dayIcons(), condition(source)));
+     }
+ 
+     data.insert("Latitude", lati);
+@@ -969,12 +995,22 @@
+             m_weatherData[source].forecasts[i]->period.replace("Friday", i18nc("Short for Friday", "Fri"));
+         }
+ 
++        int tempHigh = m_weatherData[source].forecasts[i]->tempHigh;
++        QString tempHighStr = (tempHigh == UNKNOWN_TEMPERATURE)
++                              ? QString::fromLatin1("N/A")
++                              : QString::number(tempHigh);
++
++        int tempLow = m_weatherData[source].forecasts[i]->tempLow;
++        QString tempLowStr = (tempLow == UNKNOWN_TEMPERATURE)
++                             ? QString::fromLatin1("N/A")
++                             : QString::number(tempLow);
++
+         forecastData.append(QString("%1|%2|%3|%4|%5|%6") \
+                             .arg(m_weatherData[source].forecasts[i]->period) \
+                             .arg(m_weatherData[source].forecasts[i]->iconName) \
+                             .arg(m_weatherData[source].forecasts[i]->summary) \
+-                            .arg(m_weatherData[source].forecasts[i]->tempHigh) \
+-                            .arg(m_weatherData[source].forecasts[i]->tempLow) \
++                            .arg(tempHighStr) \
++                            .arg(tempLowStr) \
+                             .arg("N/U"));
+         //.arg(m_weatherData[source].forecasts[i]->windSpeed)
+         //arg(m_weatherData[source].forecasts[i]->windDirection));
+diff -ur kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.h kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.h
+--- kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.h	2014-02-28 00:09:20.000000000 +0100
++++ kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392/plasma/generic/dataengines/weather/ions/bbcukmet/ion_bbcukmet.h	2014-03-24 22:34:59.000000000 +0100
+@@ -24,6 +24,7 @@
+ 
+ #include <QtXml/QXmlStreamReader>
+ #include <QDateTime>
++#include <climits>
+ 
+ #include "../ion.h"
+ #include "../dataengineconsumer.h"
+@@ -39,6 +40,8 @@
+ {
+ 
+ public:
++    WeatherData();
++
+     QString place;
+     QString stationName;
+     // Current observation information.
+@@ -171,6 +174,8 @@
+ 
+     QDateTime m_dateFormat;
+     QStringList m_sourcesToReset;
++
++    static const int UNKNOWN_TEMPERATURE = INT_MIN;
+ };
+ 
+ K_EXPORT_PLASMA_DATAENGINE(bbcukmet, UKMETIon)
diff --git a/kde-workspace.spec b/kde-workspace.spec
index e5eb709..a204f33 100644
--- a/kde-workspace.spec
+++ b/kde-workspace.spec
@@ -16,7 +16,7 @@
 Summary: KDE Workspace
 Name:    kde-workspace
 Version: 4.11.7
-Release: 4%{?dist}
+Release: 5%{?dist}
 
 License: GPLv2
 URL:     https://projects.kde.org/projects/kde/kde-workspace
@@ -117,13 +117,21 @@ Patch57: kde-workspace-4.8.0-bug796969.patch
 Patch58: kde-workspace-4.11.0-backlight_actual_brightness.patch
 
 # https://bugs.kde.org/show_bug.cgi?id=330773#c5
-# Update to BBC's new json-based search and modified xml
+# bbcukmet: update to BBC's new json-based search and modified xml
 Patch59: kde-workspace-4.11.7-weather-fix-bbcukmet.patch
 
 # https://bugs.kde.org/show_bug.cgi?id=330773#c6
-# Handle cases where min. or max. temperatures are not reported
+# bbcukmet: handle cases where min. or max. temperatures are not reported
 Patch60: kde-workspace-4.11.7-weather-fix-bbcukmet-temp.patch
 
+# https://bugs.kde.org/show_bug.cgi?id=330773#c16
+# bbcukmet: fix typo in the condition->icon matching ("clar sky" -> "clear sky")
+Patch61: kde-workspace-4.11.7-weather-fix-bbcukmet-clear-sky.patch
+
+# https://bugs.kde.org/show_bug.cgi?id=332392
+# bbcukmet: fix a crash (#1079296/kde#332392) and improve error handling
+Patch62: kde-workspace-4.11.7-weather-fix-bbcukmet-crash-kde#332392.patch
+
 ## upstream patches
 Patch101: 0001-bookmarks-runner-Also-consider-iceweasel.patch
 Patch102: 0002-Place-a-new-panel-to-bottom-when-possible.patch
@@ -482,6 +490,8 @@ cp -pf %{SOURCE1} startkde.cmake
 %patch58 -p1 -b .backlight_actual_brightness
 %patch59 -p1 -b .weather-fix-bbcukmet
 %patch60 -p1 -b .weather-fix-bbcukmet-temp
+%patch61 -p1 -b .weather-fix-bbcukmet-clear-sky
+%patch62 -p1 -b .weather-fix-bbcukmet-crash
 
 # upstream patches
 %patch101 -p1 -b .0001
@@ -1035,6 +1045,10 @@ fi
 
 
 %changelog
+* Mon Mar 24 2014 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.11.7-5
+- bbcukmet: fix typo in the condition->icon matching ("clar sky" -> "clear sky")
+- bbcukmet: fix a crash (#1079296/kde#332392) and improve error handling
+
 * Sat Mar 15 2014 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.11.7-4
 - apply fixes for kde#330773 (BBC weather no longer working) from bugs.kde.org
 


More information about the scm-commits mailing list