before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
else if (commonPlaylist != playlistsView.end())
{
// Found a common playlist, so assume it's that
const auto& playlistInformation{playlists.at(*commonPlaylist)};
CLog::LogF(LOGDEBUG, "Single Episode - found using common playlist method");
CLog::LogF(LOGDEBUG, "Candidate playlist {}", *commonPlaylist... | ```suggestion
std::ranges::copy_if(playlistGroup, std::back_inserter(uniqueGroups.emplace_back()),
CandidatePlaylistInformationNotDuplicate(seenDurations));
``` | else if (commonPlaylist != playlistsView.end())
{
// Found a common playlist, so assume it's that
const auto& playlistInformation{playlists.at(*commonPlaylist)};
CLog::LogF(LOGDEBUG, "Single Episode - found using common playlist method");
CLog::LogF(LOGDEBUG, "Candidate playlist {}", *commonPlaylist... | @@ -384,40 +398,163 @@ void CDiscDirectoryHelper::UseLongOrCommonMethodForSingleEpisode(unsigned int ep
}
}
-void CDiscDirectoryHelper::UseGroupMethod(unsigned int episodeIndex, const PlaylistMap& playlists)
+std::vector<std::vector<CDiscDirectoryHelper::CandidatePlaylistInformation>> CDiscDirectoryHelper::
+ ... | xbmc/filesystem/DiscDirectoryHelper.cpp | 26 | C++ | 1 | refactor | 192 | 51 | 51 | false | [Video][Bluray] Further improvements to episode matching heuristics. | 26,750 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
for (unsigned int i = 0; i < m_numEpisodes; ++i)
{
if (m_allEpisodes != AllEpisodes::ALL &&
i != episodeIndex - m_numSpecials) // Specials before episodes in episodesOnDisc
continue;
m_candidatePlaylists.emplace(group[i].playlist,
CandidatePlaylistInformation{... | ```suggestion
const std::vector groups{GetGroupsWithoutDuplicates(m_groups)};
``` | if (m_allEpisodes != AllEpisodes::ALL &&
i != episodeIndex - m_numSpecials) // Specials before episodes in episodesOnDisc
continue;
m_candidatePlaylists.emplace(group[i].playlist,
CandidatePlaylistInformation{.playlist = group[i].playlist,
... | @@ -384,40 +398,163 @@ void CDiscDirectoryHelper::UseLongOrCommonMethodForSingleEpisode(unsigned int ep
}
}
-void CDiscDirectoryHelper::UseGroupMethod(unsigned int episodeIndex, const PlaylistMap& playlists)
+std::vector<std::vector<CDiscDirectoryHelper::CandidatePlaylistInformation>> CDiscDirectoryHelper::
+ ... | xbmc/filesystem/DiscDirectoryHelper.cpp | 26 | C++ | 0.857 | refactor | 85 | 51 | 51 | false | [Video][Bluray] Further improvements to episode matching heuristics. | 26,750 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
std::chrono::milliseconds duration{0ms};
std::chrono::milliseconds durationDelta{0ms};
int multiple{0};
unsigned int chapters{0};
std::vector<unsigned int> clips;
std::string languages;
// Used for inserting into a set where playlist is the key
bool operator<(const CandidatePlaylistInfo... | ```suggestion
std::set<int64_t>& m_seen;
``` | std::chrono::milliseconds duration{0ms};
std::chrono::milliseconds durationDelta{0ms};
int multiple{0};
unsigned int chapters{0};
std::vector<unsigned int> clips;
std::string languages;
// Used for inserting into a set where playlist is the key
bool operator<(const CandidatePlaylistInfo... | @@ -139,12 +139,27 @@ class CDiscDirectoryHelper
std::vector<unsigned int> clips;
std::string languages;
+ // Used for inserting into a set where playlist is the key
bool operator<(const CandidatePlaylistInformation& rhs) const noexcept
{
return playlist < rhs.playlist;
}
};
+ ... | xbmc/filesystem/DiscDirectoryHelper.h | 26 | C/C++ | 0.857 | suggestion | 50 | 51 | 51 | false | [Video][Bluray] Further improvements to episode matching heuristics. | 26,750 | xbmc/xbmc | 17,740 | C++ | neo1973 | 78andyp |
using namespace PVR;
void CPVRGUIChannelIconUpdater::SearchAndUpdateMissingChannelIcons() const
{
const std::string iconPath = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_PVRMENU_ICONPATH);
if (iconPath.empty())
return;
// fetch files in icon path for fast lookup
CF... | Possible optimization:
```suggestion
fileItemMap.try_emplace(std::move(baseName), item->GetPath());
``` | using namespace PVR;
void CPVRGUIChannelIconUpdater::SearchAndUpdateMissingChannelIcons() const
{
const std::string iconPath = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_PVRMENU_ICONPATH);
if (iconPath.empty())
return;
// fetch files in icon path for fast lookup
CF... | @@ -48,13 +48,14 @@ void CPVRGUIChannelIconUpdater::SearchAndUpdateMissingChannelIcons() const
CLog::Log(LOGINFO, "Starting PVR channel icon search");
// create a map for fast lookup of normalized file base name
- std::map<std::string, std::string> fileItemMap;
+ using FileNamesMap = std::map<std::string, std... | xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp | 26 | C++ | 1 | suggestion | 110 | 51 | 51 | false | [PVR] SonarQube findings, round 3 | 26,752 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
int SeekChapter(int iChapter) override;
void SeekTime(int64_t iTime) override;
bool SeekTimeRelative(int64_t iTime) override;
void SetSpeed(float speed) override;
void SetTempo(float tempo) override;
bool SupportsTempo() const override;
void FrameAdvance(int frames) override;
bool OnAction(const CActi... | The new method needs to be added to the `IPlayer` interface, then overridden here. | int SeekChapter(int iChapter) override;
void SeekTime(int64_t iTime) override;
bool SeekTimeRelative(int64_t iTime) override;
void SetSpeed(float speed) override;
void SetTempo(float tempo) override;
bool SupportsTempo() const override;
void FrameAdvance(int frames) override;
bool OnAction(const CActi... | @@ -347,6 +347,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer,
unsigned int GetOrientation() const override;
void TriggerUpdateResolution() override;
bool IsRenderingVideo() const override;
+ bool IsLiveStream() const;
bool Supports(EINTERLACEMETHOD method) const override; | xbmc/cores/VideoPlayer/VideoPlayer.h | 26 | C/C++ | 0.357 | suggestion | 82 | 51 | 51 | false | [guiinfo][Estuary] Add guiinfo bool Player.IsLive, update Estuary video OSD to use it | 26,764 | xbmc/xbmc | 17,740 | C++ | ksooo | lpuglia |
/// <p><hr>
/// @skinning_v19 **[New Infolabel]** \link Player_Chapters `Player.Chapters`\endlink
/// <p>
/// }
/// \table_row3{ <b>`Player.IsExternal`</b>,
/// \anchor Player_IsExternal
/// _boolean_,
/// @return **True** if the playing player is an external play... | v22 - the new label will not be available in v21 | /// <p><hr>
/// @skinning_v19 **[New Infolabel]** \link Player_Chapters `Player.Chapters`\endlink
/// <p>
/// }
/// \table_row3{ <b>`Player.IsExternal`</b>,
/// \anchor Player_IsExternal
/// _boolean_,
/// @return **True** if the playing player is an external play... | @@ -834,14 +834,23 @@ constexpr std::array<InfoMap, 7> integer_bools = {{
/// @skinning_v21 **[New Boolean Condition]** \link Player_IsRemote `Player.IsRemote`\endlink
/// <p>
/// }
+/// \table_row3{ <b>`Player.IsLive`</b>,
+/// \anchor Player_IsLive
+/// _boolean_,
+/... | xbmc/GUIInfoManager.cpp | 26 | C++ | 0.071 | suggestion | 48 | 51 | 51 | false | [guiinfo][Estuary] Add guiinfo bool Player.IsLive, update Estuary video OSD to use it | 26,764 | xbmc/xbmc | 17,740 | C++ | ksooo | lpuglia |
bool CApplicationPlayer::IsPlayingAudio() const
{
return (IsPlaying() && !HasVideo() && HasAudio());
}
bool CApplicationPlayer::IsPlayingVideo() const
{
return (IsPlaying() && HasVideo());
}
bool CApplicationPlayer::IsPlayingGame() const
{
return (IsPlaying() && HasGame());
}
bool CApplicationPlayer::IsPlaying... | As you already defined a new pure virtual function in class `IPlayer`, and have overridden it in `CVideoPlayer`, the cast is not necessary here. Could be as simple as with the other methods here.
```c++
const std::shared_ptr<const IPlayer> player = GetInternal();
if (player)
return player->IsLiveStream();
``` | bool CApplicationPlayer::IsPlayingAudio() const
{
return (IsPlaying() && !HasVideo() && HasAudio());
}
bool CApplicationPlayer::IsPlayingVideo() const
{
return (IsPlaying() && HasVideo());
}
bool CApplicationPlayer::IsPlayingGame() const
{
return (IsPlaying() && HasGame());
}
bool CApplicationPlayer::IsPlaying... | @@ -278,6 +278,16 @@ bool CApplicationPlayer::IsPlayingRDS() const
return (IsPlaying() && HasRDS());
}
+bool CApplicationPlayer::IsLiveStream() const
+{
+ std::shared_ptr<const IPlayer> player = GetInternal();
+ const CVideoPlayer* vp = dynamic_cast<const CVideoPlayer*>(player.get());
+ if (vp)
+ return vp-... | xbmc/application/ApplicationPlayer.cpp | 26 | C++ | 1 | suggestion | 320 | 51 | 51 | false | [guiinfo][Estuary] Add guiinfo bool Player.IsLive, update Estuary video OSD to use it | 26,764 | xbmc/xbmc | 17,740 | C++ | ksooo | lpuglia |
{
m_renderManager.GetVideoRect(source, dest, view);
}
unsigned int CVideoPlayer::GetOrientation() const
{
return m_renderManager.GetOrientation();
}
void CVideoPlayer::TriggerUpdateResolution()
{
std::string stereomode;
m_renderManager.TriggerUpdateResolution(0, 0, 0, stereomode);
}
bool CVideoPlayer::IsRend... | Just a personal thing, but I would remove the curly braces here. The add no real value, not even for readability. | {
m_renderManager.GetVideoRect(source, dest, view);
}
unsigned int CVideoPlayer::GetOrientation() const
{
return m_renderManager.GetOrientation();
}
void CVideoPlayer::TriggerUpdateResolution()
{
std::string stereomode;
m_renderManager.TriggerUpdateResolution(0, 0, 0, stereomode);
}
bool CVideoPlayer::IsRend... | @@ -5213,6 +5213,15 @@ bool CVideoPlayer::IsRenderingVideo() const
return m_renderManager.IsConfigured();
}
+bool CVideoPlayer::IsLiveStream() const
+{
+ if (m_pInputStream)
+ {
+ return m_pInputStream->IsRealtime();
+ } | xbmc/cores/VideoPlayer/VideoPlayer.cpp | 26 | C++ | 0.5 | style | 113 | 51 | 51 | false | [guiinfo][Estuary] Add guiinfo bool Player.IsLive, update Estuary video OSD to use it | 26,764 | xbmc/xbmc | 17,740 | C++ | ksooo | lpuglia |
return true;
case PLAYER_PROCESS_VIDEODAR:
value = StringUtils::Format("{:.2f}", CServiceBroker::GetDataCacheCore().GetVideoDAR());
return true;
case PLAYER_PROCESS_VIDEOWIDTH:
value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetVideoWidth());
return true;
c... | Well, could you please re-insert this line? | return true;
case PLAYER_PROCESS_VIDEODAR:
value = StringUtils::Format("{:.2f}", CServiceBroker::GetDataCacheCore().GetVideoDAR());
return true;
case PLAYER_PROCESS_VIDEOWIDTH:
value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetVideoWidth());
return true;
c... | @@ -340,7 +340,6 @@ bool CPlayerGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con
case PLAYER_PROCESS_AUDIOBITSPERSAMPLE:
value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetAudioBitsPerSample());
return true;
- | xbmc/guilib/guiinfo/PlayerGUIInfo.cpp | 26 | C++ | 0.286 | question | 43 | 51 | 51 | false | [guiinfo][Estuary] Add guiinfo bool Player.IsLive, update Estuary video OSD to use it | 26,764 | xbmc/xbmc | 17,740 | C++ | ksooo | lpuglia |
if (name && favourite->FirstChild())
{
const std::string favURL(
CFavouritesURL(CExecString(favourite->FirstChild()->Value())).GetURL());
if (!items.Contains(favURL))
{
const auto item{std::make_shared<CFileItem>(name)};
item->SetPath(favURL);
if (thumb)
... | I'd say SQ is wrong here, the parameter is not a read-only string. Switching to `std::string_view` doesn't allow moving strings into the function anymore like here:
https://github.com/xbmc/xbmc/blob/5709641d55b7d49167a7e52573c542c11f523fee/xbmc/profiles/ProfileManager.cpp#L418
`GetProfileUserDataFolder()` return... | if (name && favourite->FirstChild())
{
const std::string favURL(
CFavouritesURL(CExecString(favourite->FirstChild()->Value())).GetURL());
if (!items.Contains(favURL))
{
const auto item{std::make_shared<CFileItem>(name)};
item->SetPath(favURL);
if (thumb)
... | @@ -144,16 +144,17 @@ bool LoadFromFile(const std::string& strPath, CFileItemList& items)
}
} // unnamed namespace
-CFavouritesService::CFavouritesService(std::string userDataFolder) : m_favourites("favourites://")
+CFavouritesService::CFavouritesService(std::string_view userDataFolder)
+ : m_favourites("favourite... | xbmc/favourites/FavouritesService.cpp | 26 | C++ | 0.857 | bug | 530 | 51 | 51 | false | Misc Sonarqube findings, part 3 | 26,785 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
void CPVRClient::HandleAddonCallback(const char* strFunctionName,
void* kodiInstance,
F function,
bool bForceCall /* = false */)
{
// Check preconditions.
auto* client{static_cast<CPVRClient*>(kodiInstance... | Just a suggestion, instead of creating an almost copy of the function you could also change the existing function in this way:
```cpp
template<typename F, typename KodiInstance>
void CPVRClient::HandleAddonCallback(const char* strFunctionName,
KodiInstance* kodiInstance,
... | template<typename F, typename KodiInstance>
void CPVRClient::HandleAddonCallback(const char* strFunctionName,
KodiInstance* kodiInstance,
F function,
bool bForceCall /* = false */)
{
using Client = std::cond... | @@ -2211,6 +2209,31 @@ void CPVRClient::HandleAddonCallback(const char* strFunctionName,
function(client);
}
+template<typename F>
+void CPVRClient::HandleAddonCallback(const char* strFunctionName,
+ const void* kodiInstance,
+ F function,
+ ... | xbmc/pvr/addons/PVRClient.cpp | 26 | C++ | 1 | suggestion | 647 | 51 | 51 | false | Misc Sonarqube findings, part 3 | 26,785 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
#pragma once
/*!
\file GUIInfoColor.h
\brief
*/
#include "guilib/GUIListItem.h"
#include "utils/ColorUtils.h"
#include <string>
class CGUIListItem;
namespace KODI::GUILIB::GUIINFO
{
class CGUIInfoColor
{
public:
explicit constexpr CGUIInfoColor(KODI::UTILS::COLOR::Color color = 0) : m_color(color) {}
constexp... | This can be `constexpr` as well. | #pragma once
/*!
\file GUIInfoColor.h
\brief
*/
#include "guilib/GUIListItem.h"
#include "utils/ColorUtils.h"
#include <string>
class CGUIListItem;
namespace KODI::GUILIB::GUIINFO
{
class CGUIInfoColor
{
public:
explicit constexpr CGUIInfoColor(KODI::UTILS::COLOR::Color color = 0) : m_color(color) {}
constexp... | @@ -26,9 +26,16 @@ namespace KODI::GUILIB::GUIINFO
class CGUIInfoColor
{
public:
- constexpr CGUIInfoColor(UTILS::COLOR::Color color = 0) : m_color(color) {}
- constexpr CGUIInfoColor(UTILS::COLOR::Color color, int info) : m_info(info), m_color(color) {}
-
+ explicit constexpr CGUIInfoColor(KODI::UTILS::COLOR::Co... | xbmc/guilib/guiinfo/GUIInfoColor.h | 26 | C/C++ | 0.286 | suggestion | 32 | 48 | 48 | false | Misc Sonarqube findings, part 3 | 26,785 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
explicit CDVDMsgPlayerSetVideoStream(int streamId) : CDVDMsg(PLAYER_SET_VIDEOSTREAM) { m_streamId = streamId; }
~CDVDMsgPlayerSetVideoStream() override = default;
int GetStreamId() const { return m_streamId; }
private:
int m_streamId;
};
class CDVDMsgPlayerSetSubtitleStream : public CDVDMsg
{
public:
explic... | Could the method itself be `const`? | explicit CDVDMsgPlayerSetVideoStream(int streamId) : CDVDMsg(PLAYER_SET_VIDEOSTREAM) { m_streamId = streamId; }
~CDVDMsgPlayerSetVideoStream() override = default;
int GetStreamId() const { return m_streamId; }
private:
int m_streamId;
};
class CDVDMsgPlayerSetSubtitleStream : public CDVDMsg
{
public:
explic... | @@ -184,7 +184,8 @@ class CDVDMsgPlayerSetState : public CDVDMsg
explicit CDVDMsgPlayerSetState(const std::string& state) : CDVDMsg(PLAYER_SET_STATE), m_state(state) {}
~CDVDMsgPlayerSetState() override = default;
- std::string GetState() { return m_state; }
+ const std::string& GetState() { return m_state; } | xbmc/cores/VideoPlayer/DVDMessage.h | 26 | C/C++ | 0.5 | question | 35 | 51 | 51 | false | [cppcheck] fix performance checks | 26,807 | xbmc/xbmc | 17,740 | C++ | ksooo | Rechi |
};
// These conflics are caused by having two implementations of the
// same thing. Given a std::string representing a file/path description
// you may wish to extract its filename. (ie `abc.bat` from
// `C:\\Users\\name\\scripts\\abc.bat`.
//
// URIUtils::GetFileName() does exactly as described above.
... | Can somebody explain why CURL::Parse checks for an input string "?" and skips parsing. I understand that ? could be a delimiter to CURL options. However, a local file could be named `?` and a local file cannot contain path options. IMO the CURL::Parse check and early abort should be removed and `?` should be accepted a... | /*
* 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.
*/
#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/MultiPathDirectory.h"
#include "settings/AdvancedSettings.h"
#i... | @@ -600,3 +600,118 @@ TEST_F(TestURIUtils, UpdateUrlEncoding)
EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
+
+TEST(TestPathStringUtils, ServiceAvailabilityInTestEnvironment)
+{
+ URIUtils::IsOnLAN("ftp://some.where/foo.avi", LanCheckMode::ANY_PRIVATE_SUB... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.857 | suggestion | 339 | 51 | 623 | false | [CURL][tests] Fixed encoding of rar files to be consistent with zip etc... | 26,830 | xbmc/xbmc | 17,740 | C++ | damienruscoe | damienruscoe |
}
TEST(TestPathStringUtils, GetFileNameConflicts)
{
auto URIUtils_Split = [=](const std::string& in) {
std::string _, splitCurlFileName;
URIUtils::Split(in, _, splitCurlFileName);
return splitCurlFileName;
};
auto CURL_FileName_URIUtils_Split = [=](const std::string& in) {
return URIUtils_Split(C... | IMO `URIUtils::GetFileName("C:")` is incorrect here. This should return an empty string in this case. | /*
* 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.
*/
#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/MultiPathDirectory.h"
#include "settings/AdvancedSettings.h"
#i... | @@ -600,3 +600,118 @@ TEST_F(TestURIUtils, UpdateUrlEncoding)
EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
+
+TEST(TestPathStringUtils, ServiceAvailabilityInTestEnvironment)
+{
+ URIUtils::IsOnLAN("ftp://some.where/foo.avi", LanCheckMode::ANY_PRIVATE_SUB... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.714 | bug | 101 | 51 | 623 | false | [CURL][tests] Fixed encoding of rar files to be consistent with zip etc... | 26,830 | xbmc/xbmc | 17,740 | C++ | damienruscoe | damienruscoe |
//
// URIUtils::GetFileName() does exactly as described above.
//
// CURL::GetFileName() actually returns the full path from the parsed
// protocol description (a misleading name). Although, from there we
// can cut off the path and retreive the filename.
// std::string -> CURL -> fullpath -> filename
/... | IMO `URIUtils::GetFileName()` is returning the correct result here. The slash should prefix in the result should not be present. This appears to only appear on files in the filesystem root.
*EDIT* This comment is against line 686 where `URIUtils::Split()` is correct. The incorrect return value is on line [#681](http... | /*
* 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.
*/
#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/MultiPathDirectory.h"
#include "settings/AdvancedSettings.h"
#i... | @@ -600,3 +600,122 @@ TEST_F(TestURIUtils, UpdateUrlEncoding)
EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
+
+TEST(TestPathStringUtils, ServiceAvailabilityInTestEnvironment)
+{
+ URIUtils::IsOnLAN("ftp://some.where/foo.avi", LanCheckMode::ANY_PRIVATE_SUB... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.857 | bug | 568 | 51 | 623 | false | [CURL][tests] Fixed encoding of rar files to be consistent with zip etc... | 26,830 | xbmc/xbmc | 17,740 | C++ | damienruscoe | damienruscoe |
// Zip, APK, UDF, ISO9660 and bluray are known to store "the parent in the
// hostname". This means that the hostname probably should be "encoded" (%2f etc).
//
// RAR is also a filetype which acts as a file container, although this file
// does not get its file encoded (the filename is stored in the hostname... | From my understanding; the path encoded in the hostname should be encoded such that it can be unambiguously parsed later. My knowledge here is limitted and I am basing my opinions on the result of ZIP and APK files. I think the RAR file should also follow the same encoding techneque. | /*
* 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.
*/
#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/MultiPathDirectory.h"
#include "settings/AdvancedSettings.h"
#i... | @@ -600,3 +600,122 @@ TEST_F(TestURIUtils, UpdateUrlEncoding)
EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
+
+TEST(TestPathStringUtils, ServiceAvailabilityInTestEnvironment)
+{
+ URIUtils::IsOnLAN("ftp://some.where/foo.avi", LanCheckMode::ANY_PRIVATE_SUB... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.571 | suggestion | 285 | 29 | 623 | false | [CURL][tests] Fixed encoding of rar files to be consistent with zip etc... | 26,830 | xbmc/xbmc | 17,740 | C++ | damienruscoe | damienruscoe |
if (m_gameVideoHandle->SupportsScalingMethod(scalingMethodProps.scalingMethod))
{
RETRO::CRenderVideoSettings videoSettings;
videoSettings.SetScalingMethod(scalingMethodProps.scalingMethod);
CFileItemPtr item =
std::make_shared<CFileItem>(g_localizeStrings.Get(scalingMet... | While reviewing this I expanded the code below and saw:
```c++
CLog::LogF(LOGERROR, "Looking for shader preset XML at {}", CURL::GetRedacted(xmlPath));
```
Wanna change this to LOGDEBUG? | if (m_gameVideoHandle->SupportsScalingMethod(scalingMethodProps.scalingMethod))
{
RETRO::CRenderVideoSettings videoSettings;
videoSettings.SetScalingMethod(scalingMethodProps.scalingMethod);
CFileItemPtr item =
std::make_shared<CFileItem>(g_localizeStrings.Get(scalingMet... | @@ -107,7 +107,7 @@ void CDialogGameVideoFilter::InitVideoFilters()
std::string xmlPath;
std::unique_ptr<CXBMCTinyXML> xml;
- // TODO: Have the add-on give us the xml as a string (or parse it)
+ //! @todo Have the add-on give us the xml as a string (or parse it) | xbmc/games/dialogs/osd/DialogGameVideoFilter.cpp | 26 | C++ | 1 | bug | 196 | 51 | 51 | false | RetroPlayer: Add SCALINGMETHOD::AUTO to supported scaling methods | 26,853 | xbmc/xbmc | 17,740 | C++ | garbear | KOPRajs |
/*
* Copyright (C) 2023 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 "PlatformLinux.h"
class CPlatformWebOS : public CPlatformLinux
{
public:
bool InitStageOne() override;
boo... | This function should be private | /*
* Copyright (C) 2023 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 "PlatformLinux.h"
class CPlatformWebOS : public CPlatformLinux
{
public:
bool InitStageOne() override;
boo... | @@ -18,5 +18,6 @@ class CPlatformWebOS : public CPlatformLinux
static CPlatform* CreateInstance();
protected:
+ std::string GetHomePath(); | xbmc/platform/linux/PlatformWebOS.h | 21 | C/C++ | 0.286 | suggestion | 31 | 24 | 26 | false | Fix launching kodi on webOS with non standard path from SSH in a locked down jailer | 26,859 | xbmc/xbmc | 17,740 | C++ | sundermann | cscd98 |
void CDialogGameVideoFilter::InitGetMoreButton()
{
using namespace ADDON;
CAddonMgr& addonManager = CServiceBroker::GetAddonMgr();
// Show the "Get more" icon if add-on is disabled or missing
bool showGetMore = false;
if (addonManager.IsAddonInstalled(PRESETS_ADDON_NAME))
{
if (addonManager.IsAddonD... | I suggest to use `auto` here to avoid repetition of types. | item.SetLabel2(videoFilter.folder);
item.SetProperty("game.videofilter", CVariant{videoFilter.path});
item.SetArt("icon", ICON_VIDEO);
m_items.Add(std::move(item));
}
}
void CDialogGameVideoFilter::InitGetMoreButton()
{
using namespace ADDON;
CAddonMgr& addonManager = CServiceBroker::GetAddonMg... | @@ -185,7 +195,38 @@ void CDialogGameVideoFilter::InitVideoFilters()
CFileItem item{videoFilter.name};
item.SetLabel2(videoFilter.folder);
item.SetProperty("game.videofilter", CVariant{videoFilter.path});
+ item.SetArt("icon", ICON_VIDEO);
+
+ m_items.Add(std::move(item));
+ }
+}
+
+void CDialogGa... | xbmc/games/dialogs/osd/DialogGameVideoFilter.cpp | 26 | C++ | 0.857 | suggestion | 58 | 51 | 51 | false | [Shaders] Add "Get more..." button to install shader add-on | 26,869 | xbmc/xbmc | 17,740 | C++ | ksooo | garbear |
::CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
for (int i = 0; i < m_items.Size(); i++)
{
std::string videoFilter;
GetProperties(*m_items[i], videoFilter);
if (videoFilter == gameSettings.VideoFilter())
{
return i;
}
}
return 0;
}
void CDi... | I think this could even be `const std::shared_ptr<const CFileItem>`. | gameSettings.NotifyObservers(ObservableMessageSettingsChanged);
}
}
}
unsigned int CDialogGameVideoFilter::GetFocusedItem() const
{
::CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
for (int i = 0; i < m_items.Size(); i++)
{
std::string videoFilter;
GetP... | @@ -250,19 +285,101 @@ void CDialogGameVideoFilter::PostExit()
bool CDialogGameVideoFilter::OnClickAction()
{
+ if (static_cast<int>(m_focusedItemIndex) < m_items.Size())
+ {
+ const std::shared_ptr<CFileItem> focusedItem = m_items[m_focusedItemIndex]; | xbmc/games/dialogs/osd/DialogGameVideoFilter.cpp | 26 | C++ | 0.571 | suggestion | 68 | 51 | 51 | false | [Shaders] Add "Get more..." button to install shader add-on | 26,869 | xbmc/xbmc | 17,740 | C++ | ksooo | garbear |
}
else if (!addonManager.IsAddonInstalled(PRESETS_ADDON_NAME))
{
AddonPtr addon;
success = CAddonInstaller::GetInstance().InstallModal(PRESETS_ADDON_NAME, addon,
InstallModalPrompt::CHOICE_NO);
}
... | Reverse the terms to save some CPU cycles? `HasAddons` is quite expensive, IIRC and no need to call if timed out. | {
success = addonManager.EnableAddon(PRESETS_ADDON_NAME);
}
else if (!addonManager.IsAddonInstalled(PRESETS_ADDON_NAME))
{
AddonPtr addon;
success = CAddonInstaller::GetInstance().InstallModal(PRESETS_ADDON_NAME, addon,
... | @@ -250,19 +285,101 @@ void CDialogGameVideoFilter::PostExit()
bool CDialogGameVideoFilter::OnClickAction()
{
+ if (static_cast<int>(m_focusedItemIndex) < m_items.Size())
+ {
+ const std::shared_ptr<CFileItem> focusedItem = m_items[m_focusedItemIndex];
+
+ // "Get more..." button has an empty string for the... | xbmc/games/dialogs/osd/DialogGameVideoFilter.cpp | 26 | C++ | 0.5 | performance | 114 | 43 | 45 | false | [Shaders] Add "Get more..." button to install shader add-on | 26,869 | xbmc/xbmc | 17,740 | C++ | ksooo | garbear |
*/
class CDialogGameVideoFilter : public CDialogGameVideoSelect
{
public:
CDialogGameVideoFilter();
~CDialogGameVideoFilter() override = default;
protected:
// implementation of CDialogGameVideoSelect
std::string GetHeading() override;
void PreInit() override;
void GetItems(CFileItemList& items) override;... | Encapsulate as much as you can. Is there a reason for not putting this as a helper function into an unnamed namespace in the cpp file? | */
class CDialogGameVideoFilter : public CDialogGameVideoSelect
{
public:
CDialogGameVideoFilter();
~CDialogGameVideoFilter() override = default;
protected:
// implementation of CDialogGameVideoSelect
std::string GetHeading() override;
void PreInit() override;
void GetItems(CFileItemList& items) override;... | @@ -34,14 +34,16 @@ class CDialogGameVideoFilter : public CDialogGameVideoSelect
unsigned int GetFocusedItem() const override;
void PostExit() override;
bool OnClickAction() override;
+ void RefreshList() override;
private:
void InitScalingMethods();
void InitVideoFilters();
+ void InitGetMoreButton... | xbmc/games/dialogs/osd/DialogGameVideoFilter.h | 26 | C/C++ | 0.286 | refactor | 135 | 45 | 43 | false | [Shaders] Add "Get more..." button to install shader add-on | 26,869 | xbmc/xbmc | 17,740 | C++ | ksooo | garbear |
}
}
void CDialogGameVideoFilter::GetItems(CFileItemList& items)
{
for (const auto& item : m_items)
items.Add(item);
}
void CDialogGameVideoFilter::OnItemFocus(unsigned int index)
{
if (static_cast<int>(index) < m_items.Size())
{
CFileItemPtr item = m_items[index];
std::string videoFilter;
std... | this can be a const reference i guess |
CLog::Log(LOGDEBUG, "Loaded {} shader presets from default XML, {}", videoFilters.size(),
CURL::GetRedacted(xmlPath));
for (const auto& videoFilter : videoFilters)
{
bool canLoadPreset =
CServiceBroker::GetGameServices().VideoShaders().CanLoadPreset(videoFilter.path);
if (!canLoadPr... | @@ -185,11 +202,42 @@ void CDialogGameVideoFilter::InitVideoFilters()
CFileItem item{videoFilter.name};
item.SetLabel2(videoFilter.folder);
item.SetProperty("game.videofilter", CVariant{videoFilter.path});
+ item.SetArt("icon", ICON_VIDEO);
m_items.Add(std::move(item));
}
}
+void CDialogG... | xbmc/games/dialogs/osd/DialogGameVideoFilter.cpp | 26 | C++ | 0.071 | suggestion | 37 | 51 | 51 | false | [Shaders] Add "Get more..." button to install shader add-on | 26,869 | xbmc/xbmc | 17,740 | C++ | howie-f | garbear |
if (!pImp->Stat(newAuthUrl, buffer))
{
return 0;
}
}
}
else
{
if (pImp.get() && !pImp->Stat(authUrl, buffer))
{
return 0;
}
}
}
}
catch (...) { CLog::Log(LOGERROR, "{} - Unhandled exception", __FUNCTION__... | `TARGET_POSIX` isn't allowed in generic code. It must be in a platform abstraction.
EDIT: Or removed entirely and a generic exists function should be used. | return 0;
}
}
}
}
catch (...) { CLog::Log(LOGERROR, "{} - Unhandled exception", __FUNCTION__); }
CLog::Log(LOGERROR, "{} - Error statting {}", __FUNCTION__, file.GetRedacted());
return -1;
}
bool CFile::FileExists(const std::string& path)
{
struct __stat64 s;
if (XFILE::CFile::S... | @@ -592,6 +592,20 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer)
return -1;
}
+bool CFile::FileExists(const std::string& path)
+{
+ struct __stat64 s;
+ if (XFILE::CFile::Stat(path, &s) == 0)
+ {
+#ifdef TARGET_POSIX | xbmc/filesystem/File.cpp | 26 | C++ | 0.714 | refactor | 158 | 51 | 51 | false | [CURL] Refactored archive CURL parsing | 26,871 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
CLog::Log(LOGDEBUG, "File::Stat - redirecting implementation for {}", file.GetRedacted());
if (pRedirectEx && pRedirectEx->m_pNewFileImp)
{
std::unique_ptr<IFile> pImp(pRedirectEx->m_pNewFileImp);
std::unique_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
delete pRedirectEx;
if (pNewUrl... | We already have `CFile::Exists()` or `CDirectory::Exists()`, can either of these simply be used? | {
if (pImp)
{
CURL newAuthUrl = URIUtils::AddCredentials(*pNewUrl);
if (!pImp->Stat(newAuthUrl, buffer))
{
return 0;
}
}
}
else
{
if (pImp.get() && !pImp->Stat(authUrl, buffer))
{
return 0;
... | @@ -592,6 +592,20 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer)
return -1;
}
+bool CFile::FileExists(const std::string& path) | xbmc/filesystem/File.cpp | 26 | C++ | 0.571 | question | 96 | 51 | 51 | false | [CURL] Refactored archive CURL parsing | 26,871 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
// strURL can be one of the following:
// format 1: protocol://[username:password]@hostname[:port]/directoryandfile
// format 2: protocol://file
// format 3: drive:directoryandfile
//
// first need 2 check if this is a protocol or just a normal drive & path
if (strURL.empty())
return;
if (strURL ==... | `static constexpr const char* ...` - this table can be filled at compile time. |
// strURL can be one of the following:
// format 1: protocol://[username:password]@hostname[:port]/directoryandfile
// format 2: protocol://file
// format 3: drive:directoryandfile
//
// first need 2 check if this is a protocol or just a normal drive & path
if (strURL.empty())
return;
// form is f... | @@ -75,51 +75,40 @@ void CURL::Parse(std::string strURL1)
size_t iPos = strURL.find("://");
if (iPos == std::string::npos)
{
- // This is an ugly hack that needs some work.
- // example: filename /foo/bar.zip/alice.rar/bob.avi
- // This should turn into zip://rar:///foo/bar.zip/alice.rar/bob.avi
- ... | xbmc/URL.cpp | 26 | C++ | 0.357 | suggestion | 78 | 51 | 51 | false | [CURL] Refactored archive CURL parsing | 26,871 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
// first need 2 check if this is a protocol or just a normal drive & path
if (strURL.empty())
return;
if (strURL == "?") return;
// form is format 1 or 2
// format 1: protocol://[domain;][username:password]@hostname[:port]/directoryandfile
// format 2: protocol://file
// decode protocol
size_t iPo... | You can make the loop a little more compact like this:
```cpp
for (const auto& [ext, proto] : protocolReplacements)
{
for (size_t extPos = strURL.find(ext); extPos != std::string::npos;
extPos = strURL.find(ext, extPos))
{
extPos += ext.length() - 1;
const auto arc... | // first need 2 check if this is a protocol or just a normal drive & path
if (strURL.empty())
return;
// form is format 1 or 2
// format 1: protocol://[domain;][username:password]@hostname[:port]/directoryandfile
// format 2: protocol://file
// decode protocol
size_t iPos = strURL.find("://");
if ... | @@ -75,51 +75,40 @@ void CURL::Parse(std::string strURL1)
size_t iPos = strURL.find("://");
if (iPos == std::string::npos)
{
- // This is an ugly hack that needs some work.
- // example: filename /foo/bar.zip/alice.rar/bob.avi
- // This should turn into zip://rar:///foo/bar.zip/alice.rar/bob.avi
- ... | xbmc/URL.cpp | 26 | C++ | 1 | suggestion | 574 | 51 | 51 | false | [CURL] Refactored archive CURL parsing | 26,871 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
{
/* Consider files with the extensions {.zip .apk .rar} as special if they exist
* on the filesystem and convert the archive paths into archive protocols.
* Example:
* [input] /foo/bar.zip/alice.rar/bob.avi
* [result] zip://rar:///foo/bar.zip/alice.rar/bob.avi
*/
static constexp... | ```suggestion
*this = CURL(std::move(oss).str());
``` | * on the filesystem and convert the archive paths into archive protocols.
* Example:
* [input] /foo/bar.zip/alice.rar/bob.avi
* [result] zip://rar:///foo/bar.zip/alice.rar/bob.avi
*/
static constexpr const std::string_view protocolReplacements[][2] = {
{".zip/", "zip://"},
... | @@ -75,51 +76,39 @@ void CURL::Parse(std::string strURL1)
size_t iPos = strURL.find("://");
if (iPos == std::string::npos)
{
- // This is an ugly hack that needs some work.
- // example: filename /foo/bar.zip/alice.rar/bob.avi
- // This should turn into zip://rar:///foo/bar.zip/alice.rar/bob.avi
- ... | xbmc/URL.cpp | 26 | C++ | 0.857 | suggestion | 65 | 51 | 51 | false | [CURL] Refactored archive CURL parsing | 26,871 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
* for CFileItem objects, or at least restricted to essentially be equivalent
* to construction. This would require re-formulating a bunch of CFileItem
* construction, and also allowing CFileItemList to have its own (public)
* SetURL() function, so for now we give direct access.
*/
const std::string& CFileItem::GetPath(... | Wouldn't it make more sense to drop the `const` qualifier from the return type here instead since the object is copied anyway. Returning by const value doesn't make much sense
`const_cast` should be avoided. | {
std::vector<CVariant> thumbs = CServiceBroker::GetSettingsComponent()->GetSettings()->GetList(
CSettings::SETTING_MUSICLIBRARY_MUSICTHUMBS);
for (const auto& i : thumbs)
{
std::string strFileName = i.asString();
std::string folderThumb(ART::GetFolderThumb(*this, strFileName));
... | @@ -1719,15 +1745,28 @@ void CFileItem::SetFromSong(const CSong &song)
* construction, and also allowing CFileItemList to have its own (public)
* SetURL() function, so for now we give direct access.
*/
+const std::string& CFileItem::GetPath() const
+{
+ return m_strPath;
+}
+
+void CFileItem::SetPath(const std::str... | xbmc/FileItem.cpp | 26 | C++ | 1 | suggestion | 210 | 51 | 51 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | sundermann | damienruscoe |
/*
* 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
/*!
\file FileItem.h
\brief
*/
#include "SourceType.h"
#include "URL.h"
#include "XBDateTime.h"
#include "guil... | Is the include actually needed or would a forward declaration be sufficient? | /*
* 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
/*!
\file FileItem.h
\brief
*/
#include "SourceType.h"
#include "URL.h"
#include "XBDateTime.h"
#include "guil... | @@ -14,6 +14,7 @@
*/
#include "SourceType.h"
+#include "URL.h" | xbmc/FileItem.h | 17 | C/C++ | 0.143 | question | 76 | 42 | 42 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
if (StringUtils::StartsWithNoCase(m_mimetype, "video/x-ms-"))
CCurlFile::GetMimeType(GetDynURL(), m_mimetype, "NSPlayer/11.00.6001.7000");
// make sure there are no options set in mime-type
// mime-type can look like "video/x-ms-asf ; charset=utf8"
size_t i = m_mimetype.find(';');
... | Please, no `auto` for "trivial" types. | if (StringUtils::StartsWithNoCase(m_mimetype, "video/x-ms-"))
CCurlFile::GetMimeType(GetDynURL(), m_mimetype, "NSPlayer/11.00.6001.7000");
// make sure there are no options set in mime-type
// mime-type can look like "video/x-ms-asf ; charset=utf8"
size_t i = m_mimetype.find(';');
... | @@ -1193,9 +1194,11 @@ void CFileItem::FillInMimeType(bool lookup /*= true*/)
StringUtils::StartsWithNoCase(m_mimetype, "application/x-mms-framed"))
{
if (m_strDynPath.empty())
- m_strDynPath = m_strPath;
+ SetDynPath(m_strPath);
- StringUtils::Replace(m_strDynPath, "http:", "mms:");
+ a... | xbmc/FileItem.cpp | 26 | C++ | 0.571 | suggestion | 38 | 51 | 51 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
const KODI::UTILS::CLockInfo& GetLockInfo() const { return m_lockInfo; }
void SetCueDocument(const std::shared_ptr<CCueDocument>& cuePtr);
void LoadEmbeddedCue();
bool HasCueDocument() const;
bool LoadTracksFromCueDocument(CFileItemList& scannedItems);
private:
/*! \brief Recalculate item's MIME type if i... | May I suggest to rename the member to `m_urlPath` (omit the 'c') - reading the current name I was immediately thinking about a relationship to `libcurl` here... |
void SetCueDocument(const std::shared_ptr<CCueDocument>& cuePtr);
void LoadEmbeddedCue();
bool HasCueDocument() const;
bool LoadTracksFromCueDocument(CFileItemList& scannedItems);
private:
/*! \brief Recalculate item's MIME type if it is not set or is set to "application/octet-stream".
Resolve the MIME t... | @@ -555,6 +557,8 @@ class CFileItem : public CGUIListItem, public IArchivable, public ISerializable,
*/
void FillMusicInfoTag(const std::shared_ptr<const PVR::CPVREpgInfoTag>& tag);
+ mutable std::optional<CURL> m_curlPath; | xbmc/FileItem.h | 26 | C/C++ | 0.714 | suggestion | 160 | 51 | 51 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
void SetCueDocument(const std::shared_ptr<CCueDocument>& cuePtr);
void LoadEmbeddedCue();
bool HasCueDocument() const;
bool LoadTracksFromCueDocument(CFileItemList& scannedItems);
private:
/*! \brief Recalculate item's MIME type if it is not set or is set to "application/octet-stream".
Resolve the MIME t... | May I suggest to rename the member to `m_urlDynPath` (omit the 'c') - reading the current name I was immediately thinking about a relationship to `libcurl` here... | void SetCueDocument(const std::shared_ptr<CCueDocument>& cuePtr);
void LoadEmbeddedCue();
bool HasCueDocument() const;
bool LoadTracksFromCueDocument(CFileItemList& scannedItems);
private:
/*! \brief Recalculate item's MIME type if it is not set or is set to "application/octet-stream".
Resolve the MIME ty... | @@ -555,6 +557,8 @@ class CFileItem : public CGUIListItem, public IArchivable, public ISerializable,
*/
void FillMusicInfoTag(const std::shared_ptr<const PVR::CPVREpgInfoTag>& tag);
+ mutable std::optional<CURL> m_curlPath;
+ mutable std::optional<CURL> m_curlDynPath; | xbmc/FileItem.h | 26 | C/C++ | 0.714 | suggestion | 163 | 51 | 51 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
{
if( !h.GetValue("icy-notice1").empty()
|| !h.GetValue("icy-name").empty()
|| !h.GetValue("icy-br").empty() )
h.AddParam("Content-Type", "audio/mpeg");
}
/* hack for google video */
if (StringUtils::EqualsNoCase(h.GetMimeType(),"text/html")
&& !h.GetValue("Content-Disposition").empty() )
... | Replace `auto`by actual type `std::shared_ptr<CDNSNameCache>`?
Maybe this even could be `const std::shared_ptr<CDNSNameCache>`?
Why the new nullptr check? Did you experience any crashes? Isn't the cache supposed to be always available? | {
if( !h.GetValue("icy-notice1").empty()
|| !h.GetValue("icy-name").empty()
|| !h.GetValue("icy-br").empty() )
h.AddParam("Content-Type", "audio/mpeg");
}
/* hack for google video */
if (StringUtils::EqualsNoCase(h.GetMimeType(),"text/html")
&& !h.GetValue("Content-Disposition").empty() )
... | @@ -748,7 +748,8 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2)
// lookup host in DNS cache
std::string resolvedHost;
- if (CServiceBroker::GetDNSNameCache()->GetCached(url2.GetHostName(), resolvedHost))
+ auto dnsCache = CServiceBroker::GetDNSNameCache(); | xbmc/filesystem/CurlFile.cpp | 26 | C++ | 1 | bug | 237 | 51 | 51 | false | [CURL] Reduce the number of constructions of CURL objects. | 26,873 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
return "";
}
}
VideoDbContentType ContentToVideoDbType(CONTENT_TYPE content)
{
switch (content)
{
case CONTENT_MOVIES:
return VideoDbContentType::MOVIES;
case CONTENT_MUSICVIDEOS:
return VideoDbContentType::MUSICVIDEOS;
case CONTENT_TVSHOWS:
return Vi... | Instead of flagging the moved methods `static` you should put both of them into an unnamed namespace. This is more the "modern" approach, although the effect is the same as `static`, to keep the function local to the compilation unit. | if (pItem->IsFolder())
movieDetails.m_strPath = pItem->GetPath();
std::string strTitle(movieDetails.m_strTitle);
if (showInfo && content == ContentType::TVSHOWS)
{
strTitle = StringUtils::Format("{} - {}x{} - {}", showInfo->m_strTitle,
movieDetails.m_iS... | @@ -1645,7 +1644,13 @@ CVideoInfoScanner::~CVideoInfoScanner()
}
}
- std::string CVideoInfoScanner::GetArtTypeFromSize(unsigned int width, unsigned int height)
+ /*! \brief Retrieve the art type for an image from the given size.
+ \param width the width of the image.
+ \param height the height of the im... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.786 | suggestion | 234 | 51 | 51 | false | [VideoInfoScanner] Removed unused class variables. Moved private stat… | 26,880 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
{
if (itemType != VideoDbContentType::MOVIES)
return false;
int idFile = GetFileIdByMovie(dbIdSource);
if (idFile < 0)
return false;
BeginTransaction();
if (dbIdSource != dbIdTarget)
{
// Transfer all assets (versions, extras,...) to the new movie.
UpdateAssetsOwner(MediaTypeMovie, dbIdSo... | was this runtime tested? I doubt this query executes successfully. | auto item(std::make_shared<CFileItem>(infoTag));
item->SetTitle(name);
item->SetLabel(name);
CVideoDbUrl itemUrl;
if (itemUrl.FromString(StringUtils::Format("videodb://{}/videoversions/{}",
CMediaTypes::ToPlural(mediaType), id))... | @@ -12875,20 +12868,20 @@ bool CVideoDatabase::ConvertVideoToVersion(VideoDbContentType itemType,
if (dbIdSource != dbIdTarget)
{
// Transfer all assets (versions, extras,...) to the new movie.
- UpdateAssetsOwner(mediaType, dbIdSource, dbIdTarget);
+ UpdateAssetsOwner(MediaTypeMovie, dbIdSource, dbIdT... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.143 | suggestion | 66 | 51 | 51 | false | [VideoDatabase] Better interface for `VideoContentTypeToString` | 26,883 | xbmc/xbmc | 17,740 | C++ | CrystalP | damienruscoe |
return false;
if (IsDefaultVideoVersion(idFile))
return false;
const bool inTransaction{m_pDB->in_transaction()};
try
{
if (!inTransaction)
BeginTransaction();
const std::string path = GetSingleValue(PrepareSQL(
"SELECT strPath FROM path JOIN files ON files.idPath=path.idPath W... | Can you drop this change from the diff? | if (idFile < 0)
return false;
BeginTransaction();
if (dbIdSource != dbIdTarget)
{
// Transfer all assets (versions, extras,...) to the new movie.
UpdateAssetsOwner(mediaType, dbIdSource, dbIdTarget);
// version-level art doesn't need any change.
// 'movie' art is converted to 'videoversio... | @@ -12887,15 +12886,14 @@ bool CVideoDatabase::ConvertVideoToVersion(VideoDbContentType itemType,
return false;
BeginTransaction();
- | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.286 | question | 39 | 51 | 51 | false | [VideoDatabase] Better interface for `VideoContentTypeToString` | 26,883 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
std::string path;
if (StringUtils::StartsWith(videoInfoTagPath, "removable://"))
path = videoInfoTagPath;
else
path = item.GetPath();
if (videodatabase.LoadVideoInfo(path, tag, VideoDbDetailsNone))
id = tag.GetDatabaseId();
videodatabase.Close();
}
else
... | I think we can get rid of the temporary entirely and do:
```c++
objItem["type"] = CVideoDatabase::VideoContentTypeToString(item.GetVideoContentType());
``` | std::string path;
if (StringUtils::StartsWith(videoInfoTagPath, "removable://"))
path = videoInfoTagPath;
else
path = item.GetPath();
if (videodatabase.LoadVideoInfo(path, tag))
id = tag.GetDatabaseId();
videodatabase.Close();
}
else
{
CLog::LogFC... | @@ -88,7 +88,7 @@ void CopyVideoTagInfoToObject(CFileItem& item, CVariant& object)
else
{
std::string type;
- CVideoDatabase::VideoContentTypeToString(item.GetVideoContentType(), type);
+ type = CVideoDatabase::VideoContentTypeToString(item.GetVideoContentType());
objItem["type"] = type; | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 1 | suggestion | 160 | 51 | 51 | false | [VideoDatabase] Better interface for `VideoContentTypeToString` | 26,883 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
namespace
{
void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
{
auto& objItem = object["item"];
objItem["type"] = "channel";
objItem["title"] = channel.ChannelName();
objItem["channeltype"] =... | Nitpick: This can be replaced by a simple `return item.GetProperty(LOOKUP_PROPERTY).asBoolean(true)`. Maybe we do not need the new helper function at all? | const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
namespace
{
void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
{
auto& objItem = object["item"];
objItem["type"] = "channel";
objItem["title"] = channel.ChannelName();
objItem["channeltype"] =... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.714 | refactor | 154 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
}
if (!tag.m_type.empty())
{
objItem["type"] = tag.m_type;
}
else
{
std::string type;
CVideoDatabase::VideoContentTypeToString(item.GetVideoContentType(), type);
objItem["type"] = type;
}
if (id <= 0)
{
//! @todo Can be removed once this is properly handled when starting playback... | `using enum VideoDbContentType;` + removal of `VideoDbContentType::` in the case statements increases readability a bit. |
if (!tag.m_type.empty())
{
objItem["type"] = tag.m_type;
}
else
{
std::string type;
CVideoDatabase::VideoContentTypeToString(item.GetVideoContentType(), type);
objItem["type"] = type;
}
if (id <= 0)
{
//! @todo Can be removed once this is properly handled when starting playback of ... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.786 | suggestion | 120 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
objItem["id"] = channel.ChannelID();
}
bool ShouldLookup(const CFileItem& item)
{
return !item.HasProperty(LOOKUP_PROPERTY) || item.GetProperty(LOOKUP_PROPERTY).asBoolean();
}
void CopyVideoTagInfoToObject(const CFileItem& constItem, CVariant& object)
{
/* Make a copy of the file item so it can be modified */
... | Nitpick: For consistency reasons you should decide for one init pattern for vars (initializer list, ctor or assignment). | objItem["id"] = channel.ChannelID();
}
void CopyVideoTagInfoToObject(CFileItem& item, CVariant& object)
{
CVideoInfoTag& tag = *item.GetVideoInfoTag();
auto& objItem = object["item"];
int id = tag.GetDatabaseId();
//! @todo Can be removed once this is properly handled when starting playback of a file
if ... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.5 | nitpick | 120 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
if (copyPlayerId)
{
object["player"]["playerid"] =
static_cast<int>(channel.IsRadio() ? PLAYLIST::Id::TYPE_MUSIC : PLAYLIST::Id::TYPE_VIDEO);
}
objItem["id"] = channel.ChannelID();
}
bool ShouldLookup(const CFileItem& item)
{
return !item.HasProperty(LOOKUP_PROPERTY) || item.GetProperty(LOOKUP_P... | No need to init `path` with `item.GetPath()` (line 74) in this case. Add an `else`case here to to this. | if (copyPlayerId)
{
object["player"]["playerid"] =
static_cast<int>(channel.IsRadio() ? PLAYLIST::Id::TYPE_MUSIC : PLAYLIST::Id::TYPE_VIDEO);
}
objItem["id"] = channel.ChannelID();
}
void CopyVideoTagInfoToObject(CFileItem& item, CVariant& object)
{
CVideoInfoTag& tag = *item.GetVideoInfoTag();
... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.5 | nitpick | 104 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
int id = tag.GetDatabaseId();
objItem["type"] = MediaTypeSong;
//! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && ShouldLookup(item))
{
CMusicDatabase musicdatabase;
if (musicdatabase.Open())
{
CSong song;
... | As far as I can see `item`is a local (!) copy of the const item passed in. So, what sense does it make to set the property at an instance that will be destructed at the end of this function? I do not understand the local copy of the item at all, tbh.
The original code sets the prop at a `shared_ptr` to a non-const ... | //! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && item.GetProperty(LOOKUP_PROPERTY).asBoolean(true))
{
CMusicDatabase musicdatabase;
if (musicdatabase.Open())
{
CSong song;
if (musicdatabase.GetSongByFileName(i... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.643 | suggestion | 352 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
if (!tag.m_artist.empty())
objItem["artist"] = StringUtils::Join(tag.m_artist, " / ");
break;
default:
break;
}
}
else
{
objItem["id"] = id;
}
}
void CopyMusicTagInfoToObject(const CFileItem& constItem, CVariant& object)
{
/* Make a copy of the file item so it ... | Log an error if `Open()` fails. | if (!tag.m_artist.empty())
objItem["artist"] = StringUtils::Join(tag.m_artist, " / ");
break;
default:
break;
}
}
else
{
objItem["id"] = id;
}
}
void CopyMusicTagInfoToObject(CFileItem& item, CVariant& object)
{
MUSIC_INFO::CMusicInfoTag& tag = *item.GetMusicIn... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.571 | bug | 31 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
if (id <= 0)
{
//! @todo Can be removed once this is properly handled when starting playback of a file
item.SetProperty(LOOKUP_PROPERTY, false);
objItem["title"] = tag.GetTitle();
if (objItem["title"].empty())
objItem["title"] = item.GetLabel();
if (tag.GetTrackNumber() > 0)
objIt... | Could be `const CVariant` if I read the code correctly. | }
}
if (id <= 0)
{
//! @todo Can be removed once this is properly handled when starting playback of a file
item.SetProperty(LOOKUP_PROPERTY, false);
objItem["title"] = tag.GetTitle();
if (objItem["title"].empty())
objItem["title"] = item.GetLabel();
if (tag.GetTrackNumber() > 0)
... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.571 | suggestion | 55 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
item.SetProperty(LOOKUP_PROPERTY, false);
objItem["title"] = tag.GetTitle();
if (objItem["title"].empty())
objItem["title"] = item.GetLabel();
if (tag.GetTrackNumber() > 0)
objItem["track"] = tag.GetTrackNumber();
if (!tag.GetAlbum().empty())
objItem["album"] = tag.GetAlbum();
... | Really? `auto` for a bool? Does not even safe typing some letters but decreases readability. Please use `const bool` here. | {
//! @todo Can be removed once this is properly handled when starting playback of a file
item.SetProperty(LOOKUP_PROPERTY, false);
objItem["title"] = tag.GetTitle();
if (objItem["title"].empty())
objItem["title"] = item.GetLabel();
if (tag.GetTrackNumber() > 0)
objItem["track"] = ta... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.714 | suggestion | 122 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
objItem["type"] = "channel";
objItem["title"] = channel.ChannelName();
objItem["channeltype"] = channel.IsRadio() ? "radio" : "tv";
if (copyPlayerId)
{
object["player"]["playerid"] =
static_cast<int>(channel.IsRadio() ? PLAYLIST::Id::TYPE_MUSIC : PLAYLIST::Id::TYPE_VIDEO);
}
objItem["id"] =... | Log an error if `Open()`fails. |
objItem["type"] = "channel";
objItem["title"] = channel.ChannelName();
objItem["channeltype"] = channel.IsRadio() ? "radio" : "tv";
if (copyPlayerId)
{
object["player"]["playerid"] =
static_cast<int>(channel.IsRadio() ? PLAYLIST::Id::TYPE_MUSIC : PLAYLIST::Id::TYPE_VIDEO);
}
objItem["id"] =... | @@ -30,6 +30,195 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.571 | bug | 30 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
auto& objItem = object["item"];
int id = tag.GetDatabaseId();
//! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && item.GetProperty(LOOKUP_PROPERTY).asBoolean(true))
{
CVideoDatabase videodatabase;
if (videodatabase.Open())... | Instead of using `__FUNCTION__`, use `CLog::LogFC` - The F takes care to log method signature, the C stands for the log component, which is `LOGANNOUNCE` here. |
auto& objItem = object["item"];
int id = tag.GetDatabaseId();
//! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && item.GetProperty(LOOKUP_PROPERTY).asBoolean(true))
{
CVideoDatabase videodatabase;
if (videodatabase.Open())... | @@ -30,6 +30,203 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.714 | suggestion | 159 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
MUSIC_INFO::CMusicInfoTag& tag = *item.GetMusicInfoTag();
auto& objItem = object["item"];
int id = tag.GetDatabaseId();
objItem["type"] = MediaTypeSong;
//! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && item.GetProperty(LOOKUP... | Same as above, use `CLog::LogFC` |
auto& objItem = object["item"];
int id = tag.GetDatabaseId();
objItem["type"] = MediaTypeSong;
//! @todo Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item.GetPath().empty() && item.GetProperty(LOOKUP_PROPERTY).asBoolean(true))
{
CMusicDatabase musicdata... | @@ -30,6 +30,203 @@ using namespace KODI;
const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc";
+namespace
+{
+
+void CopyPVRTagInfoToObject(const PVR::CPVRChannel& channel, bool copyPlayerId, CVariant& object)
+{
+ auto& objItem = object["item"];
+
+ objItem["type"] = "channel";
+ objItem["titl... | xbmc/interfaces/AnnouncementManager.cpp | 26 | C++ | 0.5 | suggestion | 32 | 51 | 51 | false | [AnnouncementManager] Refactor large method into 4 smaller functions | 26,903 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
if (byDate)
{
if (!GetAirDateFromRegExp(reg, episode))
continue;
CLog::Log(LOGDEBUG, "VideoInfoScanner: Found date based match {} ({}) [{}]",
CURL::GetRedacted(episode.strPath), episode.cDate.GetAsLocalizedDate(),
expression[i].regexp);
}... | How does forcing sorting consistency avoid hash mismatches between platforms? Just seeking some more clarity. Also better is "case sensitivity". |
if (m_database.GetPathHash(item->GetPath(), dbHash) && (allowEmptyHash || !hash.empty()) && StringUtils::EqualsNoCase(dbHash, hash))
{
// fast hashes match - no need to process anything
bSkip = true;
}
// fast hash cannot be computed or we need to rescan. fetch the listing.
... | @@ -1035,6 +1035,9 @@ CVideoInfoScanner::~CVideoInfoScanner()
// fast hash failed - compute slow one
if (hash.empty())
{
+ // force sorting consistency to avoid hash mismatch between platforms
+ // sort by filename as always present for any files, but keep case sensitiveness... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.5 | question | 144 | 51 | 51 | false | Fix CVideoInfoScanner strHash mismatch between linux and win32 platform | 26,921 | xbmc/xbmc | 17,740 | C++ | garbear | JackCarterSmith |
// Create a hash based on the filenames, filesize and filedate. Also count the number of files
if (0 == items.Size()) return 0;
CDigest digest{CDigest::Type::MD5};
int count = 0;
for (int i = 0; i < items.Size(); ++i)
{
const CFileItemPtr pItem = items[i];
digest.Update(pItem->GetPa... | Can you wrap comments at 80 chars for readers with small screens or large fonts? | {
std::string thumb = CScraperUrl::GetThumbUrl(image);
if (!thumb.empty() && thumb.find('/') == std::string::npos &&
thumb.find('\\') == std::string::npos)
{
std::string strPath = URIUtils::GetDirectory(itemPath);
thumb = URIUtils::AddFileToFolder(strPath, thumb);
}
return thum... | @@ -2285,9 +2288,14 @@ CVideoInfoScanner::~CVideoInfoScanner()
{
const int64_t size{pItem->GetSize()};
digest.Update(&size, sizeof(size));
- KODI::TIME::FileTime time{};
- pItem->GetDateTime().GetAsTimeStamp(time);
- digest.Update(&time, sizeof(time));
+ // linux and... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.143 | question | 80 | 51 | 51 | false | Fix CVideoInfoScanner strHash mismatch between linux and win32 platform | 26,921 | xbmc/xbmc | 17,740 | C++ | garbear | JackCarterSmith |
digest.Update(pItem->GetPath());
if (pItem->IsPlugin())
{
// allow plugin to calculate hash itself using strings rather than binary data for size and date
// according to ListItem.setInfo() documentation date format should be "d.m.Y"
const int64_t size{pItem->GetSize()};
... | Small style nitpick, but if you surround the indented line with {}, it becomes easier to read when two blocks end at once below. | }
return thumb;
}
CInfoScanner::InfoRet CVideoInfoScanner::OnProcessSeriesFolder(
EPISODELIST& files,
const ADDON::ScraperPtr& scraper,
bool useLocal,
const CVideoInfoTag& showInfo,
CGUIDialogProgress* pDlgProgress /* = NULL */)
{
if (pDlgProgress)
{
pDlgProgre... | @@ -2285,9 +2288,14 @@ CVideoInfoScanner::~CVideoInfoScanner()
{
const int64_t size{pItem->GetSize()};
digest.Update(&size, sizeof(size));
- KODI::TIME::FileTime time{};
- pItem->GetDateTime().GetAsTimeStamp(time);
- digest.Update(&time, sizeof(time));
+ // linux and... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 0.286 | nitpick | 128 | 51 | 51 | false | Fix CVideoInfoScanner strHash mismatch between linux and win32 platform | 26,921 | xbmc/xbmc | 17,740 | C++ | garbear | JackCarterSmith |
const int64_t size{pItem->GetSize()};
if (size)
digest.Update(std::to_string(size));
const CDateTime& dateTime{pItem->GetDateTime()};
if (dateTime.IsValid())
{
digest.Update(StringUtils::Format("{:02}.{:02}.{:04}", dateTime.GetDay(),
... | Looking at the details of CDateTime, more efficient for similar and equally valid result:
```suggestion
digest.Update(dateTime.GetAsDBDateTime());
```
However most likely even more efficient, convert the CDateTime to a time_t, which has a resolution of the second, which should align linux and Windows beha... | EPISODELIST& files,
const ADDON::ScraperPtr& scraper,
bool useLocal,
const CVideoInfoTag& showInfo,
CGUIDialogProgress* pDlgProgress /* = NULL */)
{
if (pDlgProgress)
{
pDlgProgress->SetLine(1, CVariant{20361}); // Loading episode details
pDlgProgress->SetPercentage(0... | @@ -2278,16 +2281,27 @@ CVideoInfoScanner::~CVideoInfoScanner()
const CDateTime& dateTime{pItem->GetDateTime()};
if (dateTime.IsValid())
+ {
digest.Update(StringUtils::Format("{:02}.{:02}.{:04}", dateTime.GetDay(),
dateTime.GetMonth(), d... | xbmc/video/VideoInfoScanner.cpp | 26 | C++ | 1 | performance | 565 | 51 | 51 | false | Fix CVideoInfoScanner strHash mismatch between linux and win32 platform | 26,921 | xbmc/xbmc | 17,740 | C++ | CrystalP | JackCarterSmith |
m_lastSMBFileErr = GetLastError(); // set real error state
return attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
int CWin32File::Stat(const CURL& url, struct __stat64* statData)
{
assert((!m_smbFile && url.GetProtocol().empty()) || (m_smbFile && url.IsProtocol("smb"))); // func... | This change is is not in the original PR 26921:
Is intentional?
Is needed this change in master branch to fix the issue? | m_lastSMBFileErr = GetLastError(); // set real error state
return attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
int CWin32File::Stat(const CURL& url, struct __stat64* statData)
{
assert((!m_smbFile && url.GetProtocol().empty()) || (m_smbFile && url.IsProtocol("smb"))); // func... | @@ -466,6 +466,11 @@ int CWin32File::Stat(const CURL& url, struct __stat64* statData)
return -1;
}
+ // -- BP PR-26921
+ // stat of directories requires the removal of the trailing slash
+ if (pathnameW.back() == L'\\')
+ pathnameW.pop_back();
+ | xbmc/platform/win32/filesystem/Win32File.cpp | 26 | C++ | 0.5 | question | 124 | 51 | 51 | false | BP #26921 Fix CVideoInfoScanner strHash mismatch between linux and win32 platform | 26,926 | xbmc/xbmc | 17,740 | C++ | thexai | JackCarterSmith |
{
class CDirectoryCache
{
class CDir
{
public:
explicit CDir(CacheType cacheType);
CDir(CDir&& dir) = default;
CDir& operator=(CDir&& dir) = default;
virtual ~CDir();
void SetLastAccess(unsigned int &accessCounter);
unsigned int GetLastAccess() const { return m_lastA... | We should probably add `class CURL;` right below `class CFileItem;` forward declaration. CURL is forward-declared in IDirectory.h but now that it's used here it can also be declared in this file in case the IDirectory.h include is ever removed. | {
class CDirectoryCache
{
class CDir
{
public:
explicit CDir(CacheType cacheType);
CDir(CDir&& dir) = default;
CDir& operator=(CDir&& dir) = default;
virtual ~CDir();
void SetLastAccess(unsigned int &accessCounter);
unsigned int GetLastAccess() const { return m_lastA... | @@ -43,14 +43,14 @@ namespace XFILE
public:
CDirectoryCache(void);
virtual ~CDirectoryCache(void);
- bool GetDirectory(const std::string& strPath, CFileItemList &items, bool retrieveAll = false);
- void SetDirectory(const std::string& strPath, const CFileItemList& items, CacheType cacheType);
- vo... | xbmc/filesystem/DirectoryCache.h | 26 | C/C++ | 0.786 | suggestion | 244 | 51 | 51 | false | [DirectoryCache] Reduce construction of expensive CURL objects. | 26,927 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
{
m_cacheType = cacheType;
m_lastAccess = 0;
m_Items->SetIgnoreURLOptions(true);
m_Items->SetFastLookup(true);
}
CDirectoryCache::CDir::~CDir() = default;
void CDirectoryCache::CDir::SetLastAccess(unsigned int &accessCounter)
{
m_lastAccess = accessCounter++;
}
CDirectoryCache::CDirectoryCache(void)
{
m_... | type prefixing is discouraged https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#88-variables. Would path be ambiguous? The same applies to many other places in the PR. | {
m_cacheType = cacheType;
m_lastAccess = 0;
m_Items->SetIgnoreURLOptions(true);
m_Items->SetFastLookup(true);
}
CDirectoryCache::CDir::~CDir() = default;
void CDirectoryCache::CDir::SetLastAccess(unsigned int &accessCounter)
{
m_lastAccess = accessCounter++;
}
CDirectoryCache::CDirectoryCache(void)
{
m_... | @@ -51,12 +51,12 @@ CDirectoryCache::CDirectoryCache(void)
CDirectoryCache::~CDirectoryCache(void) = default;
-bool CDirectoryCache::GetDirectory(const std::string& strPath, CFileItemList &items, bool retrieveAll)
+bool CDirectoryCache::GetDirectory(const CURL& urlPath, CFileItemList& items, bool retrieveAll) | xbmc/filesystem/DirectoryCache.cpp | 26 | C++ | 0.571 | suggestion | 182 | 51 | 51 | false | [DirectoryCache] Reduce construction of expensive CURL objects. | 26,927 | xbmc/xbmc | 17,740 | C++ | CrystalP | damienruscoe |
EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
oldUrl = "zip://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2ezip/video.avi";
newUrl = "zip://%2fpath%2fto%2farchive%2fsome-archive.file.zip/video.avi";
EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
... | What is the point of the `IsHostOnLAN` check here and bellow with URLs instead of host names? |
#ifdef TARGET_WINDOWS
ref = "\\\\path\\to\\file\\";
EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
ref = "path\\to\\file";
EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("..\\path\\to\\file").c_str());
EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(".\\path\\to\\file").c_str());
ref = "... | @@ -600,3 +600,64 @@ TEST_F(TestURIUtils, UpdateUrlEncoding)
EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
+
+TEST_F(TestURIUtils, ServiceAvailabilityInTestEnvironment)
+{
+ URIUtils::IsOnLAN("ftp://some.where/foo.avi", LanCheckMode::ANY_PRIVATE_SUBNET);
... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.571 | question | 93 | 51 | 51 | false | [CURL] Trying to test functions which call DNSCache::Lookup failed du… | 26,930 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
EXPECT_EQ("udf://%2fpath%2fthing/my/archived/path",
URIUtils::CreateArchivePath("udf", curl, "/my/archived/path").Get());
EXPECT_EQ("iso9660://%2fpath%2fthing/my/archived/path",
URIUtils::CreateArchivePath("iso9660", curl, "/my/archived/path").Get());
EXPECT_EQ("rar://%2fpath%2fthing/my/... | Are those tests of any use? `URIUtils::IsOnLAN` is for URIs, it will always return `false` for `ANY_PRIVATE_SUBNET` if tested with invalid input. E.g. change `URIUtils::IsOnLAN("192.168.0.3", ANY_PRIVATE_SUBNET)` into `URIUtils::IsOnLAN("http://192.168.0.3", ANY_PRIVATE_SUBNET)` and it returns the expected `true`. | EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("zip://%2fpath%2fto%2fsome%2f..%2fzip/subpath/to/file").c_str());
// test zip/zip path
ref ="zip://zip%3a%2f%2f%252Fpath%252Fto%252Fzip%2fpath%2fto%2fzip/subpath/to/file";
EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("zip://zip%3a%2f%2f%252Fpath%252Fto... | @@ -620,3 +620,52 @@ TEST_F(TestURIUtils, ContainersEncodeHostnamePaths)
EXPECT_EQ("rar://%2fpath%2fthing/my/archived/path",
URIUtils::CreateArchivePath("rar", curl, "/my/archived/path").Get());
}
+
+TEST_F(TestURIUtils, ServiceAvailabilityInTestEnvironment)
+{
+ using enum LanCheckMode;
+ {
+ EXP... | xbmc/utils/test/TestURIUtils.cpp | 26 | C++ | 0.857 | suggestion | 315 | 51 | 51 | false | [CURL] Trying to test functions which call DNSCache::Lookup failed du… | 26,930 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
{
if (nullptr == m_pDB)
return -1;
if (nullptr == m_pDS)
return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->CreateDataset());
if (nullptr == pDS)
return -1;
int idFile = GetFileId(strFilenameAndPath);
if (id... | pDS remains open after this block. it's not a good idea to rely on dataset self-protection logic to close automatically when it's used again. | return -1;
}
int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEpisode, int idSeason) // input value is episode/season number hint - for multiparters
{
try
{
if (nullptr == m_pDB)
return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset... | @@ -1415,52 +1421,77 @@ int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEp
{
if (nullptr == m_pDB)
return -1;
- if (nullptr == m_pDS)
- return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->Crea... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 141 | 51 | 51 | false | [Video][Bluray] Fix duplicate movie/episode entry created after library update if a bluray movie/episode has been played and folder rescanned (eg. adding file, post-import etc.) | 26,936 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
return -1;
if (nullptr == m_pDS)
return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->CreateDataset());
if (nullptr == pDS)
return -1;
int idFile = GetFileId(strFilenameAndPath);
if (idFile < 0)
return -1;
... | The hint idEpisode and idSeason are not the db idEpisode and idSeason but the episode and season numbers, please change the parameter names to the clearer "episode" and "season". |
int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEpisode, int idSeason) // input value is episode/season number hint - for multiparters
{
try
{
if (nullptr == m_pDB)
return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.... | @@ -1415,52 +1421,77 @@ int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEp
{
if (nullptr == m_pDB)
return -1;
- if (nullptr == m_pDS)
- return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->Crea... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 178 | 51 | 51 | false | [Video][Bluray] Fix duplicate movie/episode entry created after library update if a bluray movie/episode has been played and folder rescanned (eg. adding file, post-import etc.) | 26,936 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
return -1;
int idFile = GetFileId(strFilenameAndPath);
if (idFile < 0)
return -1;
std::string strSQL=PrepareSQL("select idEpisode from episode where idFile=%i", idFile);
CLog::LogFC(LOGDEBUG, LOGDATABASE, "({}), query = {}", CURL::GetRedacted(strFilenameAndPath),
strSQL);
... | Kind of expensive and inefficient because of the loop, and comes in addition to the previous query,
If the hint episode is not provided then query directly episode_view by idFile to retrieve all rows and get the season and episode (c12 c13) for the comparison
That way it may be possible to get rid of the local pD... | // need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->CreateDataset());
if (nullptr == pDS)
return -1;
const int idFile{GetFileId(strFilenameAndPath)};
int idReturnEpisode{-1};
if (idFile > 0)
{
const std::string strSQL{PrepareSQL... | @@ -1415,52 +1421,77 @@ int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEp
{
if (nullptr == m_pDB)
return -1;
- if (nullptr == m_pDS)
- return -1;
// need this due to the nested GetEpisodeInfo query
std::unique_ptr<Dataset> pDS;
pDS.reset(m_pDB->Crea... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.643 | performance | 623 | 51 | 51 | false | [Video][Bluray] Fix duplicate movie/episode entry created after library update if a bluray movie/episode has been played and folder rescanned (eg. adding file, post-import etc.) | 26,936 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
url.SetFileName(strFile);
strParent = url.Get();
return true;
}
std::string URIUtils::GetBasePath(const std::string& strPath)
{
std::string strCheck{strPath};
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirectory(strCheck);
if (IsIn... | did this pass ci? i'm getting a linker error when building on Debian 12
```
[100%] Linking CXX executable kodi-x11
build/utils/utils.a(URIUtils.cpp.o):URIUtils.cpp:function URIUtils::GetBasePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&):
error: undefined reference to ... | AddSlashAtEnd(strFile);
url.SetFileName(strFile);
strParent = url.Get();
return true;
}
std::string URIUtils::GetBasePath(const std::string& strPath)
{
std::string strCheck{strPath};
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(strPath);
std::string strDirectory = GetDirect... | @@ -450,23 +451,32 @@ bool URIUtils::GetParentPath(const std::string& strPath, std::string& strParent)
std::string URIUtils::GetBasePath(const std::string& strPath)
{
- std::string strCheck(strPath);
+ std::string strCheck{strPath};
if (IsStack(strPath))
strCheck = CStackDirectory::GetFirstStackedFile(str... | xbmc/utils/URIUtils.cpp | 26 | C++ | 1 | security | 1,481 | 51 | 51 | false | [Video] Fix GetMovieName(), GetMovieBasePath() and GetBasePath() to better handle optical media, bluray:// paths and Disc n subdirectories. Add tests. | 26,938 | xbmc/xbmc | 17,740 | C++ | howie-f | 78andyp |
#include <map>
#include <string>
#include <vector>
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::string strGenre;
};
class CFileItem;
// Struct to store chapter information from m... | Can you include units? Either:
```c++
unsigned int startTimeMs{0};
```
or
```c++
unsigned int startTime{0}; // Milliseconds
```
I think the first will make the code more clear in other areas.
You can also use C++ time types. | #include <chrono>
#include <map>
#include <string>
#include <vector>
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::string strGenre;
};
class CFileItem;
// Struct to store chapter ... | @@ -40,6 +40,16 @@ class CGenre
class CFileItem;
+// Struct to store chapter information from mp3 files (could be used for m4b or mka files too)
+struct chapterDetails
+{
+ std::string name;
+ unsigned int startTime{0}; | xbmc/music/Song.h | 26 | C/C++ | 1 | suggestion | 243 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | garbear | the-black-eagle |
bool Load(const std::string& strFileName, MUSIC_INFO::CMusicInfoTag& tag,
const std::string& fallbackFileExtension, EmbeddedArt *art = nullptr);
static std::vector<std::string> SplitMBID(const std::vector<std::string> &values);
protected:
static void SetArtist(MUSIC_INFO::CMusicInfoTag &tag, const st... | Please include units for time values in headers. | EmbeddedArt *art = nullptr) override;
bool Load(const std::string& strFileName, MUSIC_INFO::CMusicInfoTag& tag,
const std::string& fallbackFileExtension, EmbeddedArt *art = nullptr);
static std::vector<std::string> SplitMBID(const std::vector<std::string> &values);
protected:
static void ... | @@ -48,7 +48,9 @@ class CTagLoaderTagLib : public MUSIC_INFO::IMusicInfoTagLoader
static void AddArtistInstrument(MUSIC_INFO::CMusicInfoTag &tag, const std::vector<std::string> &values);
static int POPMtoXBMC(int popm);
-template<typename T>
- static bool ParseTag(T *tag, EmbeddedArt *art, MUSIC_INFO::CMusicI... | xbmc/music/tags/TagLoaderTagLib.h | 26 | C/C++ | 0.071 | suggestion | 48 | 28 | 31 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | garbear | the-black-eagle |
#include "utils/EmbeddedArt.h"
#include "utils/ISerializable.h"
#include <map>
#include <string>
#include <vector>
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::string strGenre;
};... | coding guidelines: struct names shall start with an uppercase letter. | #include "utils/EmbeddedArt.h"
#include "utils/ISerializable.h"
#include <chrono>
#include <map>
#include <string>
#include <vector>
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::s... | @@ -40,6 +40,16 @@ class CGenre
class CFileItem;
+// Struct to store chapter information from mp3 files (could be used for m4b or mka files too)
+struct chapterDetails | xbmc/music/Song.h | 26 | C/C++ | 0.143 | suggestion | 69 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::string strGenre;
};
class CFileItem;
// Struct to store chapter information from mp3 files (could be used for m4b or mka files too)
st... | coding guidelines: type names shall start with an uppercase letter. |
class CVariant;
/*!
\ingroup music
\brief Class to store and read album information from CMusicDatabase
\sa CSong, CMusicDatabase
*/
class CGenre
{
public:
int idGenre;
std::string strGenre;
};
class CFileItem;
// Struct to store chapter information from mp3 files (could be used for m4b or mka files too)
s... | @@ -40,6 +40,16 @@ class CGenre
class CFileItem;
+// Struct to store chapter information from mp3 files (could be used for m4b or mka files too)
+struct chapterDetails
+{
+ std::string name;
+ unsigned int startTime{0};
+ unsigned int endTime{0};
+};
+
+using chapterMarks = std::map<int, chapterDetails>; | xbmc/music/Song.h | 26 | C/C++ | 0.429 | suggestion | 67 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
CDateTime m_dateAdded;
CDateTime m_dateUpdated;
bool m_bCompilation;
int m_iDuration;
int m_iTrack; // consists of the disk number in the high 16 bits, the track number in the low 16bits
int m_iDbId;
MediaType m_type; ///< item type "music", "song", "album", "artist"
bool m_bLoaded;
float m_Rating... | I suggest to name the member `m_chapterMarks` to reflect its purpose a bit better. | CDateTime m_dateUpdated;
bool m_bCompilation;
int m_iDuration;
int m_iTrack; // consists of the disk number in the high 16 bits, the track number in the low 16bits
int m_iDbId;
MediaType m_type; ///< item type "music", "song", "album", "artist"
bool m_bLoaded;
float m_Rating;
int m_Userrating;
i... | @@ -259,6 +262,7 @@ class CMusicInfoTag final : public IArchivable, public ISerializable, public ISo
std::string m_stationName;
std::string m_stationArt; // Used to fetch thumb URL for Shoutcasts
std::string m_songVideoURL; // link to a video for a song
+ chapterMarks m_chapters; // Ch No., name, start time, ... | xbmc/music/tags/MusicInfoTag.h | 26 | C/C++ | 0.571 | suggestion | 83 | 33 | 32 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
m_albumReleaseType = releaseType;
}
void CMusicInfoTag::SetType(MediaType_view mediaType)
{
m_type = mediaType;
}
// This is the Musicbrainz release status tag. See https://musicbrainz.org/doc/Release#Status
void CMusicInfoTag::SetAlbumReleaseStatus(std::string_view ReleaseStatus)
{
m_strReleaseStatus = Releas... | I agree with copilots comment:
```suggestion
void CMusicInfoTag::SetChapterMarks(const ChapterMarks& chapters)
``` | m_albumReleaseType = releaseType;
}
void CMusicInfoTag::SetType(MediaType_view mediaType)
{
m_type = mediaType;
}
// This is the Musicbrainz release status tag. See https://musicbrainz.org/doc/Release#Status
void CMusicInfoTag::SetAlbumReleaseStatus(std::string_view ReleaseStatus)
{
m_strReleaseStatus = Releas... | @@ -784,6 +789,11 @@ void CMusicInfoTag::SetSongVideoURL(std::string_view songVideoURL)
m_songVideoURL = songVideoURL;
}
+void CMusicInfoTag::SetChapterMarks(ChapterMarks& chapters) | xbmc/music/tags/MusicInfoTag.cpp | 26 | C++ | 1 | suggestion | 117 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | neo1973 | the-black-eagle |
std::string strMood;
std::string strCueSheet;
float rating;
int userrating;
int votes;
int iTrack;
int iDuration;
std::string strOrigReleaseDate;
std::string strReleaseDate;
std::string strDiscSubtitle;
int iTimesPlayed;
CDateTime lastPlayed;
CDateTime dateAdded; // File creation or modificati... | Is it intentional to not use the type definition as given in line 52?
The member name should start with `m_` followed by a lower case letter. This rule is violated for the existing members, but for new code we should follow our coding guidelines.
Maybe you wanted to look the line like `ChapterMarks m_chapterMarks... | std::string strMood;
std::string strCueSheet;
float rating;
int userrating;
int votes;
int iTrack;
int iDuration;
std::string strOrigReleaseDate;
std::string strReleaseDate;
std::string strDiscSubtitle;
int iTimesPlayed;
CDateTime lastPlayed;
CDateTime dateAdded; // File creation or modificati... | @@ -195,6 +206,7 @@ class CSong final : public ISerializable
std::string strRecordLabel; // Record label from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
std::string strAlbumType; // (Musicbrainz release type) album type from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
... | xbmc/music/Song.h | 26 | C/C++ | 1 | question | 412 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
template<>
bool CTagLoaderTagLib::ParseTag(ID3v1::Tag* id3v1,
EmbeddedArt* art,
CMusicInfoTag& tag,
std::chrono::milliseconds totalLen)
{
if (!id3v1) return false;
tag.SetTitle(id3v1->title().to8Bit(true));
tag.SetArti... | You could use the type definition you have defined in "Song.h". Then this would read : `ChapterMarks chapters;` You need to include "Song.h" for this of course. | template<>
bool CTagLoaderTagLib::ParseTag(ID3v1::Tag* id3v1,
EmbeddedArt* art,
CMusicInfoTag& tag,
std::chrono::milliseconds totalLen)
{
if (!id3v1) return false;
tag.SetTitle(id3v1->title().to8Bit(true));
tag.SetArti... | @@ -276,10 +283,14 @@ bool CTagLoaderTagLib::ParseTag(ID3v1::Tag *id3v1, EmbeddedArt *art, CMusicInfoT
}
template<>
-bool CTagLoaderTagLib::ParseTag(ID3v2::Tag *id3v2, EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag)
+bool CTagLoaderTagLib::ParseTag(ID3v2::Tag* id3v2,
+ EmbeddedArt* ... | xbmc/music/tags/TagLoaderTagLib.cpp | 26 | C++ | 1 | suggestion | 161 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
std::string strMood;
std::string strCueSheet;
float rating;
int userrating;
int votes;
int iTrack;
int iDuration;
std::string strOrigReleaseDate;
std::string strReleaseDate;
std::string strDiscSubtitle;
int iTimesPlayed;
CDateTime lastPlayed;
CDateTime dateAdded; // File creation or modificati... | Well, as you have the "using ChapterMarks" in line 52, you should use it here: => `ChapterMarks m_chapters;` | std::string strMood;
std::string strCueSheet;
float rating;
int userrating;
int votes;
int iTrack;
int iDuration;
std::string strOrigReleaseDate;
std::string strReleaseDate;
std::string strDiscSubtitle;
int iTimesPlayed;
CDateTime lastPlayed;
CDateTime dateAdded; // File creation or modificati... | @@ -195,6 +206,7 @@ class CSong final : public ISerializable
std::string strRecordLabel; // Record label from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
std::string strAlbumType; // (Musicbrainz release type) album type from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
... | xbmc/music/Song.h | 26 | C/C++ | 0.714 | suggestion | 108 | 51 | 51 | false | [Music] Add chapter frame reading for mp3 files to taglib. Store the… | 26,941 | xbmc/xbmc | 17,740 | C++ | ksooo | the-black-eagle |
int zoomFactor = (int)screenHeight / sourceHeight;
zoomAmount = (zoomFactor * sourceHeight) / screenHeight;
}
else
{
int zoomFactor = (int)screenWidth / (sourceWidth * pixelRatio);
zoomAmount = (zoomFactor * sourceWidth * pixelRatio) / screen... | Do we need `STRETCHMODE::Original1x1`? Doesn't this discard DAR? | const int zoomFactor = static_cast<int>(screenHeight / sourceHeight);
zoomAmount = (zoomFactor * sourceHeight) / screenHeight;
}
else
{
const int zoomFactor = static_cast<int>(screenWidth / (sourceWidth * pixelRatio));
zoomAmount = (zoomFacto... | @@ -55,31 +68,143 @@ void CRenderUtils::CalculateStretchMode(STRETCHMODE stretchMode,
}
case STRETCHMODE::Stretch4x3:
{
- // Stretch to 4:3 ratio
- pixelRatio = (4.0f / 3.0f) / frameAspectRatio;
+ switch (rotationDegCCW)
+ {
+ case 90:
+ case 270:
+ {
+ p... | xbmc/cores/RetroPlayer/rendering/RenderUtils.cpp | 26 | C++ | 0.357 | question | 64 | 51 | 51 | false | RetroPlayer: Add integer scaling support | 26,951 | xbmc/xbmc | 17,740 | C++ | garbear | KOPRajs |
break;
}
zoomAmount = 1.0f;
break;
}
case STRETCHMODE::Fullscreen:
{
// Stretch to the limits of the screen
pixelRatio = (screenWidth / screenHeight) / sourceFrameRatio;
zoomAmount = 1.0f;
break;
}
case STRETCHMODE::Integer:
{
switch (r... | Please use c++ casts, e.g. static_cast<int>(screenHeight / sourceWidth)
Also, slap a `const` on the var, no need for it to be mutable. | break;
}
zoomAmount = 1.0f;
break;
}
case STRETCHMODE::Fullscreen:
{
// Stretch to the limits of the screen
pixelRatio = (screenWidth / screenHeight) / sourceFrameRatio;
zoomAmount = 1.0f;
break;
}
case STRETCHMODE::Integer:
{
switch (r... | @@ -55,31 +68,143 @@ void CRenderUtils::CalculateStretchMode(STRETCHMODE stretchMode,
}
case STRETCHMODE::Stretch4x3:
{
- // Stretch to 4:3 ratio
- pixelRatio = (4.0f / 3.0f) / frameAspectRatio;
+ switch (rotationDegCCW)
+ {
+ case 90:
+ case 270:
+ {
+ p... | xbmc/cores/RetroPlayer/rendering/RenderUtils.cpp | 26 | C++ | 1 | suggestion | 137 | 51 | 51 | false | RetroPlayer: Add integer scaling support | 26,951 | xbmc/xbmc | 17,740 | C++ | garbear | KOPRajs |
if (m_pShaders.empty())
return false;
// Each pass except the last one must have its own texture and the opposite is also true
if (m_pShaders.size() != m_pShaderTextures.size() + 1)
return updateFailed("A shader or texture failed to init");
m_bPresetNeedsUpdate = false;
return true;
}
void CShaderP... | I have removed this, because it is not needed here, it is going to be updated directly from the _RenderUpdate()_. Also, the _Update()_ can fail here, but the return value is not handled. | if (m_pShaders.empty())
return false;
// Each pass except the last one must have its own texture and the opposite is also true
if (m_pShaders.size() != m_pShaderTextures.size() + 1)
return updateFailed("A shader or texture failed to init");
m_bPresetNeedsUpdate = false;
return true;
}
void CShaderP... | @@ -159,21 +159,13 @@ bool CShaderPreset::Update()
return true;
}
-void CShaderPreset::UpdateViewPort()
-{
- CRect viewPort;
- m_context.GetViewPort(viewPort);
- UpdateViewPort(viewPort);
-}
-
void CShaderPreset::UpdateViewPort(CRect viewPort)
{
const float2 currentViewPortSize = {viewPort.Width(), viewPo... | xbmc/cores/RetroPlayer/shaders/ShaderPreset.cpp | 26 | C++ | 0.786 | bug | 186 | 51 | 51 | false | RetroPlayer: Add integer scaling support | 26,951 | xbmc/xbmc | 17,740 | C++ | KOPRajs | KOPRajs |
if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSSE3)
m_cpuFeatures |= CPU_FEATURE_SSSE3;
if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSE4)
m_cpuFeatures |= CPU_FEATURE_SSE4;
if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSE42)
m_cpuFeatures |= CPU_FEATURE_SSE42;
}
__cpuid(CPUInfo, 0... | Why not reuse the existing MaxExtInfoType that is filled with the same value (and a more appropriate name)?
Should be const btw, and please use the constant CPUID_INFOTYPE_EXTENDED_IMPLEMENTED instead. | if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSSE3)
m_cpuFeatures |= CPU_FEATURE_SSSE3;
if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSE4)
m_cpuFeatures |= CPU_FEATURE_SSE4;
if (CPUInfo[CPUINFO_ECX] & CPUID_00000001_ECX_SSE42)
m_cpuFeatures |= CPU_FEATURE_SSE42;
}
__cpuid(CPUInfo, C... | @@ -78,6 +78,24 @@ CCPUInfoWin10::CCPUInfoWin10()
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_3DNOWEXT)
m_cpuFeatures |= CPU_FEATURE_3DNOWEXT;
}
+
+ __cpuid(CPUInfo, 0x80000000); | xbmc/platform/win10/CPUInfoWin10.cpp | 26 | C++ | 0.857 | question | 203 | 51 | 51 | false | [UWP][Xbox] Implement CPU name detection | 26,966 | xbmc/xbmc | 17,740 | C++ | CrystalP | thexai |
__cpuid(CPUInfo, CPUID_INFOTYPE_EXTENDED);
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_MMX)
m_cpuFeatures |= CPU_FEATURE_MMX;
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_MMX2)
m_cpuFeatures |= CPU_FEATURE_MMX2;
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_3DNOW)
m_cpuFeatures |= ... | what about the vendor? the following works on desktop
```
__cpuid(CPUInfo, CPUID_INFOTYPE_MANUFACTURER);
m_cpuVendor.append(reinterpret_cast<const char*>(CPUInfo + 1), 4);
m_cpuVendor.append(reinterpret_cast<const char*>(CPUInfo + 3), 4);
m_cpuVendor.append(reinterpret_cast<const char*>(CPUInfo + 2... | __cpuid(CPUInfo, CPUID_INFOTYPE_EXTENDED);
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_MMX)
m_cpuFeatures |= CPU_FEATURE_MMX;
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_MMX2)
m_cpuFeatures |= CPU_FEATURE_MMX2;
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_3DNOW)
m_cpuFeatures |= ... | @@ -78,6 +78,24 @@ CCPUInfoWin10::CCPUInfoWin10()
if (CPUInfo[CPUINFO_EDX] & CPUID_80000001_EDX_3DNOWEXT)
m_cpuFeatures |= CPU_FEATURE_3DNOWEXT;
}
+
+ __cpuid(CPUInfo, 0x80000000);
+ MaxStdInfoType = CPUInfo[0];
+
+ // Get CPU brand string
+ if (MaxStdInfoType >= CPUID_INFOTYPE_PROCESSOR_3)
+ {
+ ... | xbmc/platform/win10/CPUInfoWin10.cpp | 26 | C++ | 1 | question | 490 | 51 | 51 | false | [UWP][Xbox] Implement CPU name detection | 26,966 | xbmc/xbmc | 17,740 | C++ | CrystalP | thexai |
* See LICENSES/README.md for more information.
*/
#pragma once
#include "video/guilib/VideoAction.h"
#include <memory>
class CFileItem;
namespace KODI::VIDEO::GUILIB
{
class CVideoActionProcessorBase
{
public:
explicit CVideoActionProcessorBase(const std::shared_ptr<CFileItem>& item) : m_item(item) {}
virtu... | I think for const correctness it should be this:
```suggestion
std::shared_ptr<CFileItem> GetItem() { return m_item; }
std::shared_ptr<const CFileItem> GetItem() const { return m_item; }
```
This won't compile because of stuff in VideoPlayActionProcessor.cpp which is IMO the correct behavior, e.g. an "active" ... | * See LICENSES/README.md for more information.
*/
#pragma once
#include "video/guilib/VideoAction.h"
#include <memory>
class CFileItem;
namespace KODI::VIDEO::GUILIB
{
class CVideoActionProcessorBase
{
public:
explicit CVideoActionProcessorBase(const std::shared_ptr<CFileItem>& item) : m_item(item) {}
virtu... | @@ -26,15 +26,18 @@ class CVideoActionProcessorBase
bool ProcessAction(Action action);
bool UserCancelled() const { return m_userCancelled; }
+ void SetUserCancelled(bool set) { m_userCancelled = set; }
+
+ std::shared_ptr<CFileItem> GetItem() const { return m_item; } | xbmc/video/guilib/VideoActionProcessorBase.h | 26 | C/C++ | 1 | suggestion | 371 | 39 | 40 | false | [video] SonarQube finding: Make CVideoActionProcessorBase members m_item and m_userCancelled private. | 26,975 | xbmc/xbmc | 17,740 | C++ | neo1973 | ksooo |
#include "settings/lib/Setting.h"
#include "settings/lib/SettingsManager.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include <cstring>
#include <set>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/dist_sink.h>
#include <spdlog/sinks/dup_filter_sink.h>
namespace
{
constexpr unsign... | Can we use a `constexpr CMap` here so the calls are translated at compile time? | #include "settings/lib/Setting.h"
#include "settings/lib/SettingsManager.h"
#include "utils/Map.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include <cstring>
#include <set>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/dist_sink.h>
#include <spdlog/sinks/dup_filter_sink.h>
names... | @@ -33,7 +33,51 @@ namespace
constexpr unsigned char Utf8Bom[3] = {0xEF, 0xBB, 0xBF};
const std::string LogFileExtension = ".log";
const std::string LogPattern = "%Y-%m-%d %T.%e T:%-5t %7l <%n>: %v";
-} // namespace
+
+struct ComponentInfo
+{
+ std::string name;
+ uint32_t stringId{0};
+};
+
+// clang-format off
+... | xbmc/utils/log.cpp | 26 | C++ | 0.571 | question | 79 | 51 | 51 | false | [utils/log.*] Use a dedicated logger for every pre-defined logging component | 26,983 | xbmc/xbmc | 17,740 | C++ | sundermann | ksooo |
bool CShaderPresetGL::CreateShaderTextures()
{
m_pShaderTextures.clear();
unsigned int major{0};
unsigned int minor{0};
CServiceBroker::GetRenderSystem()->GetRenderVersion(major, minor);
float2 prevSize = m_videoSize;
float2 prevTextureSize = m_videoSize;
const auto numPasses = static_cast<unsigned int... | Unfortunately, it seems like we are going to have a merge conflict again. I've already tried to de-duplicate this part in https://github.com/xbmc/xbmc/pull/26961, which is ready to be merged. | bool CShaderPresetGL::CreateShaderTextures()
{
m_pShaderTextures.clear();
unsigned int major{0};
unsigned int minor{0};
CServiceBroker::GetRenderSystem()->GetRenderVersion(major, minor);
float2 prevSize = m_videoSize;
float2 prevTextureSize = m_videoSize;
const auto numPasses = static_cast<unsigned int... | @@ -88,31 +88,34 @@ bool CShaderPresetGL::CreateShaderTextures()
// Resolve final texture resolution, taking scale type and scale multiplier into account
float2 scaledSize;
float2 textureSize;
+
+ using enum ScaleType;
+
switch (pass.fbo.scaleX.scaleType)
{
- case ScaleType::ABSOLUTE_SC... | xbmc/cores/RetroPlayer/shaders/gl/ShaderPresetGL.cpp | 26 | C++ | 0.286 | refactor | 191 | 51 | 51 | false | Random SonarQube findings which were introduced lately | 26,994 | xbmc/xbmc | 17,740 | C++ | KOPRajs | ksooo |
struct ShaderPass
{
std::string sourcePath;
std::string vertexSource;
std::string fragmentSource;
FilterType filterType{FilterType::NONE};
WrapType wrapType{WrapType::BORDER};
unsigned int frameCountMod{0};
FboScale fbo;
bool mipmap{false};
std::vector<ShaderLut> luts;
std::vector<ShaderParameter> ... | I learned this was added in C++20. Good change. | struct ShaderPass
{
std::string sourcePath;
std::string vertexSource;
std::string fragmentSource;
FilterType filterType{FilterType::NONE};
WrapType wrapType{WrapType::BORDER};
unsigned int frameCountMod{0};
FboScale fbo;
bool mipmap{false};
std::vector<ShaderLut> luts;
std::vector<ShaderParameter> ... | @@ -98,11 +98,10 @@ struct float2
template<typename T>
float2(T x_, T y_) : x(static_cast<float>(x_)), y(static_cast<float>(y_))
{
- static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
+ static_assert(std::is_arithmetic_v<T>, "Not an arithmetic type");
}
- bool operator==(const f... | xbmc/cores/RetroPlayer/shaders/ShaderTypes.h | 26 | C/C++ | 0.286 | suggestion | 47 | 44 | 43 | false | Random SonarQube findings which were introduced lately | 26,994 | xbmc/xbmc | 17,740 | C++ | garbear | ksooo |
/*!
\brief Sets the progress of the progress bar to the given value.
\param[in] currentStep Current step being processed
\param[in] totalSteps Total steps to be processed
*/
void SetProgress(int currentStep, int totalSteps) const;
/*!
\brief Marks the progress as finished by setting it to 100%.
... | Alright, and now we can remove init from the different ctors, right?
https://github.com/xbmc/xbmc/blob/master/xbmc/utils/ProgressJob.cpp#L21-L22
https://github.com/xbmc/xbmc/blob/master/xbmc/utils/ProgressJob.cpp#L27
Icing on the cake would be to remove this as well:
https://github.com/xbmc/xbmc/blob/master/xbm... |
/*!
\brief Sets the progress of the progress bar to the given value.
\param[in] currentStep Current step being processed
\param[in] totalSteps Total steps to be processed
*/
void SetProgress(int currentStep, int totalSteps) const;
/*!
\brief Marks the progress as finished by setting it to 100%.
... | @@ -158,6 +158,6 @@ class CProgressJob : public CJob
bool m_autoClose = true;
bool m_updateProgress = true;
bool m_updateInformation = true;
- CGUIDialogProgressBarHandle* m_progress;
- CGUIDialogProgress* m_progressDialog;
+ CGUIDialogProgressBarHandle* m_progress = nullptr;
+ CGUIDialogProgress* m_progre... | xbmc/utils/ProgressJob.h | 26 | C/C++ | 0.643 | refactor | 347 | 28 | 28 | false | [Utils] Remove redundant mutable keyword. | 26,995 | xbmc/xbmc | 17,740 | C++ | ksooo | damienruscoe |
/*!
\brief Sets the progress of the progress bar to the given value.
\param[in] currentStep Current step being processed
\param[in] totalSteps Total steps to be processed
*/
void SetProgress(int currentStep, int totalSteps) const;
/*!
\brief Marks the progress as finished by setting it to 100%.
... | Also, our style guide changed since the above lines were written, and we decided it's better follow it for new code over code consistency, so can you do:
```c++
CGUIDialogProgressBarHandle* m_progress{nullptr};
```
Sorry for such a nit. Thanks! |
/*!
\brief Sets the progress of the progress bar to the given value.
\param[in] currentStep Current step being processed
\param[in] totalSteps Total steps to be processed
*/
void SetProgress(int currentStep, int totalSteps) const;
/*!
\brief Marks the progress as finished by setting it to 100%.
... | @@ -158,6 +158,6 @@ class CProgressJob : public CJob
bool m_autoClose = true;
bool m_updateProgress = true;
bool m_updateInformation = true;
- mutable CGUIDialogProgressBarHandle* m_progress;
- mutable CGUIDialogProgress* m_progressDialog;
+ CGUIDialogProgressBarHandle* m_progress = nullptr;
+ CGUIDialogPr... | xbmc/utils/ProgressJob.h | 26 | C/C++ | 1 | bug | 254 | 28 | 28 | false | [Utils] Remove redundant mutable keyword. | 26,995 | xbmc/xbmc | 17,740 | C++ | garbear | damienruscoe |
} // namespace dbiplus
// return codes of Cleaning up the Database
// numbers are strings from strings.po
constexpr int ERROR_OK = 317;
constexpr int ERROR_CANCEL = 0;
constexpr int ERROR_DATABASE = 315;
constexpr int ERROR_REORG_SONGS = 319;
constexpr int ERROR_REORG_ARTIST = 321;
constexpr int ERROR_REORG_OTHER = 32... | This can be moved to the cpp file in an anonymous namespace. | } // namespace dbiplus
// return codes of Cleaning up the Database
// numbers are strings from strings.po
constexpr int ERROR_OK = 317;
constexpr int ERROR_CANCEL = 0;
constexpr int ERROR_DATABASE = 315;
constexpr int ERROR_REORG_SONGS = 319;
constexpr int ERROR_REORG_ARTIST = 321;
constexpr int ERROR_REORG_OTHER = 32... | @@ -51,6 +52,33 @@ constexpr int ERROR_REORG_ALBUM = 327;
constexpr int ERROR_WRITING_CHANGES = 329;
constexpr int ERROR_COMPRESSING = 332;
+/*!
+ * @brief Check if a string contains only digit characters (ignoring leading/trailing whitespace).
+ *
+ * This function trims any leading and trailing whitespace from th... | xbmc/music/MusicDatabase.h | 26 | C/C++ | 0.357 | suggestion | 60 | 51 | 51 | false | Add mp3 chapters to music database and display in GUI | 26,997 | xbmc/xbmc | 17,740 | C++ | garbear | the-black-eagle |
| transform(toChapterFrame) // cast
| filter([](auto* p) { return p; }); // keep non‑null
std::size_t chapNumber = 0;
for (auto* chapFrame : chapterFrames)
{
ChapterDetails chapter;
// Title - music db will generate a localised "c... | Adding a `std::move` here would make me very happy :slightly_smiling_face: | | transform(toChapterFrame) // cast
| filter([](auto* p) { return p; }); // keep non‑null
std::size_t chapNumber = 0;
for (auto* chapFrame : chapterFrames)
{
ChapterDetails chapter;
// Title - music db will generate a localised "c... | @@ -505,7 +505,7 @@ bool CTagLoaderTagLib::ParseTag(ID3v2::Tag* id3v2,
CLog::Log(LOGDEBUG, "CTagLoaderTagLib - Chapter {}, {} start point {}, endpoint {}",
chapNumber + 1, chapter.name, startTimeMs.count(), endTimeMs.count());
-
+ chapters.emplace_back(chapter); | xbmc/music/tags/TagLoaderTagLib.cpp | 26 | C++ | 0.571 | suggestion | 75 | 51 | 51 | false | Add mp3 chapters to music database and display in GUI | 26,997 | xbmc/xbmc | 17,740 | C++ | neo1973 | the-black-eagle |
{
CStackDirectory::CStackDirectory() = default;
CStackDirectory::~CStackDirectory() = default;
bool CStackDirectory::GetDirectory(const CURL& url, CFileItemList& items)
{
items.Clear();
std::vector<std::string> files;
const std::string pathToUrl(url.Get());
if (!GetPaths(pathToUrl, files))
... | Use the real type instead of the legacy typedefs: `std::vector<CRegExp>`. Here and in all other instances for newly added or changed code | {
CStackDirectory::CStackDirectory() = default;
CStackDirectory::~CStackDirectory() = default;
bool CStackDirectory::GetDirectory(const CURL& url, CFileItemList& items)
{
items.Clear();
std::vector<std::string> files;
const std::string pathToUrl(url.Get());
if (!GetPaths(pathToUrl, files))
... | @@ -46,21 +46,8 @@ namespace XFILE
std::string CStackDirectory::GetStackedTitlePath(const std::string &strPath)
{
- // Load up our REs
- VECCREGEXP RegExps;
- CRegExp tempRE(true, CRegExp::autoUtf8);
- const std::vector<std::string>& strRegExps = CServiceBroker::GetSettingsComponent()->GetAdvan... | xbmc/filesystem/StackDirectory.cpp | 26 | C++ | 1 | suggestion | 137 | 51 | 51 | false | [FileItemList][RegExUtils] Avoid calling compilations of a list of regexes in a hot path. | 26,998 | xbmc/xbmc | 17,740 | C++ | sundermann | damienruscoe |
#include "utils/XMLUtils.h"
#include "utils/log.h"
#include <algorithm>
#include <climits>
#include <regex>
#include <string>
#include <vector>
using namespace ADDON;
namespace
{
bool validateVideoStackRegex(const CRegExp& regex)
{
if (regex.GetCaptureTotal() != 4)
{
CLog::Log(LOGERROR, "Invalid video stack... | ```suggestion
std::vector<CRegExp> CompileRegexesFromXML(TiXmlElement* folderStacking)
``` | #include "utils/XMLUtils.h"
#include "utils/log.h"
#include <algorithm>
#include <climits>
#include <regex>
#include <string>
#include <vector>
using namespace ADDON;
namespace
{
bool ValidateVideoStackRegex(const CRegExp& regex)
{
if (regex.GetCaptureTotal() != 4)
{
CLog::Log(LOGERROR, "Invalid video stack... | @@ -36,6 +36,29 @@
using namespace ADDON;
+namespace
+{
+
+bool validateVideoStackRegex(const CRegExp& regex)
+{
+ if (regex.GetCaptureTotal() != 4)
+ {
+ CLog::Log(LOGERROR, "Invalid video stack RE ({}). Must have exactly 4 captures.",
+ regex.GetPattern());
+ return false;
+ }
+ return tru... | xbmc/settings/AdvancedSettings.cpp | 26 | C++ | 0.857 | suggestion | 90 | 51 | 51 | false | [FileItemList][RegExUtils] Avoid calling compilations of a list of regexes in a hot path. | 26,998 | xbmc/xbmc | 17,740 | C++ | sundermann | damienruscoe |
//! Are we even going to have predefined paths??
std::string tmp;
if (XMLUtils::GetPath(pRootElement, "cachepath", tmp))
m_cachePath = tmp;
URIUtils::AddSlashAtEnd(m_cachePath);
g_LangCodeExpander.LoadUserCodes(pRootElement->FirstChildElement("languagecodes"));
// trailer matching regexps
TiXmlEleme... | ```suggestion
std::ranges::move(regexes, std::back_inserter(m_videoStackRegExps));
``` | CLangInfo::LoadTokens(pRootElement->FirstChild("sorttokens"), m_vecTokens);
//! @todo Should cache path be given in terms of our predefined paths??
//! Are we even going to have predefined paths??
std::string tmp;
if (XMLUtils::GetPath(pRootElement, "cachepath", tmp))
m_cachePath = tmp;
URIUtils::AddSl... | @@ -1009,12 +1034,20 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
// video stacking regexps
TiXmlElement* pVideoStacking = pRootElement->FirstChildElement("moviestacking");
if (pVideoStacking)
- GetCustomRegexps(pVideoStacking, m_videoStackRegExps);
+ {
+ auto regexes = CompileR... | xbmc/settings/AdvancedSettings.cpp | 26 | C++ | 0.857 | suggestion | 92 | 51 | 51 | false | [FileItemList][RegExUtils] Avoid calling compilations of a list of regexes in a hot path. | 26,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
// trailer matching regexps
TiXmlElement* pTrailerMatching = pRootElement->FirstChildElement("trailermatching");
if (pTrailerMatching)
GetCustomRegexps(pTrailerMatching, m_trailerMatchRegExps);
//everything that's a trailer is not a movie
m_moviesExcludeFromScanRegExps.insert(m_moviesExcludeFromScanRegEx... | ```suggestion
std::ranges::move(regexes, std::back_inserter(m_folderStackRegExps));
``` |
g_LangCodeExpander.LoadUserCodes(pRootElement->FirstChildElement("languagecodes"));
// trailer matching regexps
TiXmlElement* pTrailerMatching = pRootElement->FirstChildElement("trailermatching");
if (pTrailerMatching)
GetCustomRegexps(pTrailerMatching, m_trailerMatchRegExps);
//everything that's a tra... | @@ -1009,12 +1034,20 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
// video stacking regexps
TiXmlElement* pVideoStacking = pRootElement->FirstChildElement("moviestacking");
if (pVideoStacking)
- GetCustomRegexps(pVideoStacking, m_videoStackRegExps);
+ {
+ auto regexes = CompileR... | xbmc/settings/AdvancedSettings.cpp | 26 | C++ | 0.857 | suggestion | 93 | 51 | 51 | false | [FileItemList][RegExUtils] Avoid calling compilations of a list of regexes in a hot path. | 26,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | damienruscoe |
if (bIsDisabled)
UnregisterLoader(shaderAddon.get());
else
m_shaderAddons.try_emplace(addonId, std::move(shaderAddon));
}
// Look for new add-ons
for (const AddonInfoPtr& shaderAddon : addonInfo)
{
const std::string& addonId = shaderAddon->ID();
const bool bIsNew = (!m_shaderAddons... | A better fix is imo to change line 127 to `std::string addonId =`, not to remove `std::move` here. | if (bIsDisabled)
UnregisterLoader(shaderAddon.get());
else
m_shaderAddons.try_emplace(addonId, std::move(shaderAddon));
}
// Look for new add-ons
for (const AddonInfoPtr& shaderAddon : addonInfo)
{
std::string addonId = shaderAddon->ID();
const bool bIsNew = (!m_shaderAddons.contai... | @@ -140,11 +140,11 @@ void CShaderPresetFactory::UpdateAddons()
{
for (const auto& extension : addonPtr->GetExtensions())
RegisterLoader(addonPtr.get(), extension);
- m_shaderAddons.emplace(std::move(addonId), std::move(addonPtr));
+ m_shaderAddons.emplace(addonId, std::move(addonPtr)); | xbmc/cores/RetroPlayer/shaders/ShaderPresetFactory.cpp | 26 | C++ | 0.571 | suggestion | 98 | 34 | 34 | false | [clang-tidy] fix performance-* warnings | 27,004 | xbmc/xbmc | 17,740 | C++ | ksooo | Rechi |
}
// Look for new add-ons
for (const AddonInfoPtr& shaderAddon : addonInfo)
{
const std::string& addonId = shaderAddon->ID();
const bool bIsNew = (!m_shaderAddons.contains(addonId));
if (!bIsNew)
continue;
const bool bIsFailed = (m_failedAddons.contains(addonId));
if (bIsFailed)
... | A better fix is imo to change line 127 to `std::string addonId =`, not to remove `std::move` here. | }
// Look for new add-ons
for (const AddonInfoPtr& shaderAddon : addonInfo)
{
std::string addonId = shaderAddon->ID();
const bool bIsNew = (!m_shaderAddons.contains(addonId));
if (!bIsNew)
continue;
const bool bIsFailed = (m_failedAddons.contains(addonId));
if (bIsFailed)
cont... | @@ -140,11 +140,11 @@ void CShaderPresetFactory::UpdateAddons()
{
for (const auto& extension : addonPtr->GetExtensions())
RegisterLoader(addonPtr.get(), extension);
- m_shaderAddons.emplace(std::move(addonId), std::move(addonPtr));
+ m_shaderAddons.emplace(addonId, std::move(addonPtr));
... | xbmc/cores/RetroPlayer/shaders/ShaderPresetFactory.cpp | 26 | C++ | 0.571 | suggestion | 98 | 30 | 30 | false | [clang-tidy] fix performance-* warnings | 27,004 | xbmc/xbmc | 17,740 | C++ | ksooo | Rechi |
if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_curlDisableHTTP2)
g_curlInterface.easy_setopt(h, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
else
// enable HTTP2 support. default: CURL_HTTP_VERSION_1_1. Curl >= 7.62.0 defaults to CURL_HTTP_VERSION_2TLS
g_curlInterface.easy_setopt... | ```suggestion
static std::vector<uint8_t> cachedBuffer;
static std::once_flag loadBufferFlag;
std::call_once(loadBufferFlag, []() {
XFILE::CFile file;
file.LoadFile(CSpecialProtocol::TranslatePath("special://xbmc/system/certs/cacert.pem"), cachedBuffer);
});
```
This is pretty lightweight in terms of locking overhe... | if (!m_cipherlist.empty())
g_curlInterface.easy_setopt(h, CURLOPT_SSL_CIPHER_LIST, m_cipherlist.c_str());
if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_curlDisableHTTP2)
g_curlInterface.easy_setopt(h, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
else
// enable HTTP2 support. d... | @@ -691,12 +691,29 @@ void CCurlFile::SetCommonOptions(CReadState* state, bool failOnError /* = true *
// set CA bundle file
std::string caCert = CSpecialProtocol::TranslatePath(
CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_caTrustFile);
-#ifdef TARGET_WINDOWS_STORE
- // UWP Curl - Set... | xbmc/filesystem/CurlFile.cpp | 26 | C++ | 1 | bug | 394 | 51 | 51 | false | [Windows][Xbox] Bump Python to 3.13.5 + OpenSSL 3.0.17 | 27,010 | xbmc/xbmc | 17,740 | C++ | sundermann | thexai |
VideoDbContentType type,
int mediaId,
int oldIdFile,
const CDateTime& dateAdded,
int playcount,
const CD... | Why not use the AddFile(url, parentPath, dateAdded, playcount, lastPlayed) overload?
Looks to me like less duplication and more consistent handling of 0 playCount and invalid lastPlayed with the rest of the code.
edit: nvm, the file may already exist, in which case AddFile skips the field-setting. But please use th... | details.m_iIdRating = AddRatings(idTvShow, MediaTypeTvShow, details.m_ratings, details.GetDefaultRating());
// add unique ids
details.m_iIdUniqueID = AddUniqueIDs(idTvShow, MediaTypeTvShow, details);
// add "all seasons" - the rest are added in SetDetailsForEpisode
AddSeason(idTvShow, -1);
// add any nam... | @@ -3153,57 +3153,57 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details,
int CVideoDatabase::SetFileForMedia(const std::string& fileAndPath,
VideoDbContentType type,
int mediaId,
- int oldI... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.643 | question | 428 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
sql += PrepareSQL(", name='%s'", details.m_strSortTitle.c_str());
if (details.m_iUserRating > 0 && details.m_iUserRating < 11)
sql += PrepareSQL(", userrating = %i", details.m_iUserRating);
else
sql += ", userrating = NULL";
sql += PrepareSQL(" WHERE idSeason=%i", idSeason);
m_pDS->exe... | Not blocking, but that's quite a few parameters. Maybe introduce a structure that holds the fields of the old files record? |
return idTvShow;
}
bool CVideoDatabase::UpdateDetailsForTvShow(int idTvShow,
CVideoInfoTag& details,
const KODI::ART::Artwork& artwork,
const KODI::ART::SeasonsArtwork& seasonArt)
{
... | @@ -3153,57 +3153,57 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details,
int CVideoDatabase::SetFileForMedia(const std::string& fileAndPath,
VideoDbContentType type,
int mediaId,
- int oldI... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.286 | question | 123 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
CVideoInfoTag& details,
const KODI::ART::Artwork& artwork,
const KODI::ART::SeasonsArtwork& seasonArt,
int idTvShow = -1);
bool UpdateDetailsForTvShow(int idTvShow,
CVideoInfoTag& deta... | `{}` not needed on classes and structs with initializers. | CVideoInfoTag& details,
const KODI::ART::Artwork& artwork,
const KODI::ART::SeasonsArtwork& seasonArt,
int idTvShow = -1);
bool UpdateDetailsForTvShow(int idTvShow,
CVideoInfoTag& deta... | @@ -712,10 +712,30 @@ class CVideoDatabase : public CDatabase
const KODI::ART::Artwork& artwork,
int idShow,
int idEpisode = -1);
- int SetFileForMedia(const std::string& fileAndPath,
- VideoDbContentType type,
- ... | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.357 | suggestion | 57 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
const KODI::ART::Artwork& artwork,
const KODI::ART::SeasonsArtwork& seasonArt);
int SetDetailsForSeason(const CVideoInfoTag& details,
const KODI::ART::Artwork& artwork,
int idShow,
... | Can you remove the `{}` from CDateTime? It's also a class with a constructor. | const KODI::ART::Artwork& artwork,
const KODI::ART::SeasonsArtwork& seasonArt);
int SetDetailsForSeason(const CVideoInfoTag& details,
const KODI::ART::Artwork& artwork,
int idShow,
... | @@ -712,10 +712,30 @@ class CVideoDatabase : public CDatabase
const KODI::ART::Artwork& artwork,
int idShow,
int idEpisode = -1);
- int SetFileForMedia(const std::string& fileAndPath,
- VideoDbContentType type,
- ... | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.571 | suggestion | 77 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | garbear | 78andyp |
{
m_pDS->exec(PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i", newIdFile,
oldIdFile, idMovie));
m_pDS->exec(PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
newIdFile, oldIdFile, idMovie));
... | please be consistent with the other functions, so newIdFile parameter name. | {
m_pDS->exec(PrepareSQL("UPDATE movie SET idFile=%i WHERE idFile=%i AND idMovie=%i", newIdFile,
oldIdFile, idMovie));
m_pDS->exec(PrepareSQL(
"UPDATE videoversion SET idFile=%i WHERE idFile=%i AND media_type='movie' AND idMedia=%i",
newIdFile, oldIdFile, idMovie));
... | @@ -3218,130 +3250,107 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details,
int CVideoDatabase::SetFileForMedia(const std::string& fileAndPath,
VideoDbContentType type,
int mediaId,
- int ol... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.143 | suggestion | 75 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
: "NULL"};
const std::string lastPlayed{fileInfo.m_lastPlayed.IsValid()
? "'" + fileInfo.m_lastPlayed.GetAsDBDateTime() + "'"
: "NULL"};
sql = PrepareSQL("SELECT idFile FROM files ... | clang-format requires this? strange. you could try m_pDS->exec(PrepareSQL(...)) in case it looks better. | : "NULL"};
const std::string lastPlayed{fileInfo.m_lastPlayed.IsValid()
? "'" + fileInfo.m_lastPlayed.GetAsDBDateTime() + "'"
: "NULL"};
sql = PrepareSQL("SELECT idFile FROM files ... | @@ -997,61 +997,93 @@ bool CVideoDatabase::GetSourcePath(const std::string &path, std::string &sourceP
return false;
}
-//********************************************************************************************************************************
int CVideoDatabase::AddFile(const std::string& strFileNameAndP... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 104 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
bool GetTvShowsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
bool GetSeasonsNav(const std::string& strBaseDir,... | I thought about this later, short single words are not always safe as they may conflict with compiler/standard lib/etc defines, also upper case. It happened to me recently and either YES or NO was already defined on TVOS causing a failure.
So I'd suggest ACTION_NONE and ACTION_UPDATE instead. | bool GetTvShowsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
bool GetSeasonsNav(const std::string& strBaseDir,... | @@ -1063,6 +1076,17 @@ class CVideoDatabase : public CDatabase
const std::set<int>& paths = std::set<int>(),
bool showProgress = true);
+ enum class FileExistsAction
+ {
+ NONE,
+ UPDATE | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.571 | bug | 294 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
bool GetInProgressT... | I forgot the const FileRecord& fileInfo. | bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
bool GetInProgressT... | @@ -1063,6 +1076,17 @@ class CVideoDatabase : public CDatabase
const std::set<int>& paths = std::set<int>(),
bool showProgress = true);
+ enum class FileExistsAction
+ {
+ NONE,
+ UPDATE
+ };
+
+ int AddOrUpdateFile(const std::string& fileAndPath,
+ ... | xbmc/video/VideoDatabase.h | 26 | C/C++ | 0.071 | suggestion | 40 | 51 | 51 | false | [Video][Bluray] More robust update of playcount/lastplayed/dateadded fields when saving bluray:// file or creating bluray:// versions. | 27,015 | xbmc/xbmc | 17,740 | C++ | CrystalP | 78andyp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.