summaryrefslogtreecommitdiffstats
path: root/xbmc/weather/WeatherManager.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/weather/WeatherManager.h
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/weather/WeatherManager.h')
-rw-r--r--xbmc/weather/WeatherManager.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/xbmc/weather/WeatherManager.h b/xbmc/weather/WeatherManager.h
new file mode 100644
index 0000000..c729f4c
--- /dev/null
+++ b/xbmc/weather/WeatherManager.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "settings/lib/ISettingCallback.h"
+#include "utils/InfoLoader.h"
+
+#include <string>
+
+#define WEATHER_LABEL_LOCATION 10
+#define WEATHER_IMAGE_CURRENT_ICON 21
+#define WEATHER_LABEL_CURRENT_COND 22
+#define WEATHER_LABEL_CURRENT_TEMP 23
+#define WEATHER_LABEL_CURRENT_FEEL 24
+#define WEATHER_LABEL_CURRENT_UVID 25
+#define WEATHER_LABEL_CURRENT_WIND 26
+#define WEATHER_LABEL_CURRENT_DEWP 27
+#define WEATHER_LABEL_CURRENT_HUMI 28
+
+static const std::string ICON_ADDON_PATH = "resource://resource.images.weathericons.default";
+
+struct ForecastDay
+{
+ std::string m_icon;
+ std::string m_overview;
+ std::string m_day;
+ std::string m_high;
+ std::string m_low;
+};
+
+#define NUM_DAYS 7
+
+class CWeatherInfo
+{
+public:
+ ForecastDay forecast[NUM_DAYS];
+
+ void Reset()
+ {
+ lastUpdateTime.clear();
+ currentIcon.clear();
+ currentConditions.clear();
+ currentTemperature.clear();
+ currentFeelsLike.clear();
+ currentWind.clear();
+ currentHumidity.clear();
+ currentUVIndex.clear();
+ currentDewPoint.clear();
+
+ for (ForecastDay& f : forecast)
+ {
+ f.m_icon.clear();
+ f.m_overview.clear();
+ f.m_day.clear();
+ f.m_high.clear();
+ f.m_low.clear();
+ }
+ };
+
+ std::string lastUpdateTime;
+ std::string location;
+ std::string currentIcon;
+ std::string currentConditions;
+ std::string currentTemperature;
+ std::string currentFeelsLike;
+ std::string currentUVIndex;
+ std::string currentWind;
+ std::string currentDewPoint;
+ std::string currentHumidity;
+ std::string busyString;
+ std::string naIcon;
+};
+
+class CWeatherManager
+: public CInfoLoader, public ISettingCallback
+{
+public:
+ CWeatherManager(void);
+ ~CWeatherManager(void) override;
+ static bool GetSearchResults(const std::string &strSearch, std::string &strResult);
+
+ std::string GetLocation(int iLocation);
+ const std::string& GetLastUpdateTime() const { return m_info.lastUpdateTime; }
+ const ForecastDay &GetForecast(int day) const;
+ bool IsFetched();
+ void Reset();
+
+ void SetArea(int iLocation);
+ int GetArea() const;
+protected:
+ CJob *GetJob() const override;
+ std::string TranslateInfo(int info) const override;
+ std::string BusyInfo(int info) const override;
+ void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
+
+ void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
+ void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;
+
+private:
+
+ CWeatherInfo m_info;
+};