Debian Codegraph @

xbmc/guilib/guiinfo/WeatherGUIInfo.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "guilib/guiinfo/WeatherGUIInfo.h"
10
11 #include "FileItem.h"
12 #include "LangInfo.h"
13 #include "ServiceBroker.h"
14 #include "guilib/guiinfo/GUIInfo.h"
15 #include "guilib/guiinfo/GUIInfoLabels.h"
16 #include "settings/Settings.h"
17 #include "settings/SettingsComponent.h"
18 #include "utils/StringUtils.h"
19 #include "utils/URIUtils.h"
20 #include "weather/WeatherManager.h"
21
22 using namespace KODI::GUILIB::GUIINFO;
23
24 bool CWeatherGUIInfo::InitCurrentItem(CFileItem *item)
25 {
26 return false;
27 }
28
29 bool CWeatherGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const
30 {
31 switch (info.m_info)
32 {
33 ///////////////////////////////////////////////////////////////////////////////////////////////
34 // WEATHER_*
35 ///////////////////////////////////////////////////////////////////////////////////////////////
36 case WEATHER_CONDITIONS_TEXT:
37 value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_CURRENT_COND);
38 StringUtils::Trim(value);
39 return true;
40 case WEATHER_CONDITIONS_ICON:
41 value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_IMAGE_CURRENT_ICON);
42 return true;
43 case WEATHER_TEMPERATURE:
44 value = StringUtils::Format(
45 "{}{}", CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_CURRENT_TEMP),
46 g_langInfo.GetTemperatureUnitString());
47 return true;
48 case WEATHER_LOCATION:
49 value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_LOCATION);
50 return true;
51 case WEATHER_FANART_CODE:
52 value = URIUtils::GetFileName(CServiceBroker::GetWeatherManager().GetInfo(WEATHER_IMAGE_CURRENT_ICON));
53 URIUtils::RemoveExtension(value);
54 return true;
55 case WEATHER_PLUGIN:
56 value = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_WEATHER_ADDON);
57 return true;
58 }
59
60 return false;
61 }
62
63 bool CWeatherGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
64 {
65 return false;
66 }
67
68 bool CWeatherGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
69 {
70 switch (info.m_info)
71 {
72 ///////////////////////////////////////////////////////////////////////////////////////////////
73 // WEATHER_*
74 ///////////////////////////////////////////////////////////////////////////////////////////////
75 case WEATHER_IS_FETCHED:
76 value = CServiceBroker::GetWeatherManager().IsFetched();
77 return true;;
78 }
79
80 return false;
81 }