Skip to content

Commit

Permalink
Merge pull request xbmc#21972 from notspiff/header_cleanups
Browse files Browse the repository at this point in the history
Some header cleanups
  • Loading branch information
notspiff committed Oct 6, 2022
2 parents f52170e + 4220274 commit a3335e0
Show file tree
Hide file tree
Showing 45 changed files with 217 additions and 117 deletions.
59 changes: 1 addition & 58 deletions xbmc/XBDateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,13 @@
#pragma once

#include "utils/IArchivable.h"
#include "utils/TimeFormat.h"
#include "utils/XTimeUtils.h"

#include <string>

#include "PlatformDefs.h"

/*! \brief TIME_FORMAT enum/bitmask used for formatting time strings
Note the use of bitmasking, e.g.
TIME_FORMAT_HH_MM_SS = TIME_FORMAT_HH | TIME_FORMAT_MM | TIME_FORMAT_SS
\sa StringUtils::SecondsToTimeString
\note For InfoLabels use the equivalent value listed (bold)
on the description of each enum value.
\note<b>Example:</b> 3661 seconds => h=1, hh=01, m=1, mm=01, ss=01, hours=1, mins=61, secs=3661
<p><hr>
@skinning_v18 **[Infolabels Updated]** Added <b>secs</b>, <b>mins</b>, <b>hours</b> (total time) and **m** as possible formats for
InfoLabels that support the definition of a time format. Examples are:
- \link Player_SeekOffset_format `Player.SeekOffset(format)`\endlink
- \link Player_TimeRemaining_format `Player.TimeRemaining(format)`\endlink
- \link Player_Time_format `Player.Time(format)`\endlink
- \link Player_Duration_format `Player.Duration(format)`\endlink
- \link Player_FinishTime_format `Player.FinishTime(format)`\endlink
- \link Player_StartTime_format `Player.StartTime(format)` \endlink
- \link Player_SeekNumeric_format `Player.SeekNumeric(format)`\endlink
- \link ListItem_Duration_format `ListItem.Duration(format)`\endlink
- \link PVR_EpgEventDuration_format `PVR.EpgEventDuration(format)`\endlink
- \link PVR_EpgEventElapsedTime_format `PVR.EpgEventElapsedTime(format)`\endlink
- \link PVR_EpgEventRemainingTime_format `PVR.EpgEventRemainingTime(format)`\endlink
- \link PVR_EpgEventSeekTime_format `PVR.EpgEventSeekTime(format)`\endlink
- \link PVR_EpgEventFinishTime_format `PVR.EpgEventFinishTime(format)`\endlink
- \link PVR_TimeShiftStart_format `PVR.TimeShiftStart(format)`\endlink
- \link PVR_TimeShiftEnd_format `PVR.TimeShiftEnd(format)`\endlink
- \link PVR_TimeShiftCur_format `PVR.TimeShiftCur(format)`\endlink
- \link PVR_TimeShiftOffset_format `PVR.TimeShiftOffset(format)`\endlink
- \link PVR_TimeshiftProgressDuration_format `PVR.TimeshiftProgressDuration(format)`\endlink
- \link PVR_TimeshiftProgressEndTime `PVR.TimeshiftProgressEndTime`\endlink
- \link PVR_TimeshiftProgressEndTime_format `PVR.TimeshiftProgressEndTime(format)`\endlink
- \link ListItem_NextDuration_format `ListItem.NextDuration(format)` \endlink
<p>
*/
enum TIME_FORMAT
{
TIME_FORMAT_GUESS = 0, ///< usually used as the fallback value if the format value is empty
TIME_FORMAT_SS = 1, ///< <b>ss</b> - seconds only
TIME_FORMAT_MM = 2, ///< <b>mm</b> - minutes only (2-digit)
TIME_FORMAT_MM_SS = 3, ///< <b>mm:ss</b> - minutes and seconds
TIME_FORMAT_HH = 4, ///< <b>hh</b> - hours only (2-digit)
TIME_FORMAT_HH_SS = 5, ///< <b>hh:ss</b> - hours and seconds (this is not particularly useful)
TIME_FORMAT_HH_MM = 6, ///< <b>hh:mm</b> - hours and minutes
TIME_FORMAT_HH_MM_SS = 7, ///< <b>hh:mm:ss</b> - hours, minutes and seconds
TIME_FORMAT_XX = 8, ///< <b>xx</b> - returns AM/PM for a 12-hour clock
TIME_FORMAT_HH_MM_XX =
14, ///< <b>hh:mm xx</b> - returns hours and minutes in a 12-hour clock format (AM/PM)
TIME_FORMAT_HH_MM_SS_XX =
15, ///< <b>hh:mm:ss xx</b> - returns hours (2-digit), minutes and seconds in a 12-hour clock format (AM/PM)
TIME_FORMAT_H = 16, ///< <b>h</b> - hours only (1-digit)
TIME_FORMAT_H_MM_SS = 19, ///< <b>hh:mm:ss</b> - hours, minutes and seconds
TIME_FORMAT_H_MM_SS_XX =
27, ///< <b>hh:mm:ss xx</b> - returns hours (1-digit), minutes and seconds in a 12-hour clock format (AM/PM)
TIME_FORMAT_SECS = 32, ///< <b>secs</b> - total time in seconds
TIME_FORMAT_MINS = 64, ///< <b>mins</b> - total time in minutes
TIME_FORMAT_HOURS = 128, ///< <b>hours</b> - total time in hours
TIME_FORMAT_M = 256 ///< <b>m</b> - minutes only (1-digit)
};

class CDateTime;

class CDateTimeSpan
Expand Down
3 changes: 2 additions & 1 deletion xbmc/addons/RepositoryUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "XBDateTime.h"
#include "addons/AddonEvents.h"
#include "addons/Repository.h"
#include "settings/lib/ISettingCallback.h"
Expand All @@ -18,6 +17,8 @@

#include <vector>

class CDateTime;

namespace ADDON
{

Expand Down
1 change: 0 additions & 1 deletion xbmc/addons/binary-addons/AddonDll.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "BinaryAddonManager.h"
#include "DllAddon.h"
#include "addons/Addon.h"
#include "utils/XMLUtils.h"

// Global addon callback handle classes
#include "addons/interfaces/AddonBase.h"
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/RetroPlayer/savestates/ISavestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#pragma once

#include "SavestateTypes.h"
#include "XBDateTime.h"

#include <stdint.h>
#include <string>
#include <vector>

class CDateTime;

namespace KODI
{
namespace RETRO
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/RetroPlayer/savestates/SavestateFlatBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "SavestateFlatBuffer.h"

#include "XBDateTime.h"
#include "savestate_generated.h"
#include "utils/log.h"

Expand Down
1 change: 1 addition & 0 deletions xbmc/dialogs/GUIDialogNumeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "GUIDialogNumeric.h"

#include "ServiceBroker.h"
#include "XBDateTime.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUILabelControl.h"
#include "guilib/GUIWindowManager.h"
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogNumeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#pragma once

#include "XBDateTime.h"
#include "guilib/GUIDialog.h"
#include "utils/XTimeUtils.h"

#include <cstdint>

Expand Down
7 changes: 5 additions & 2 deletions xbmc/filesystem/SpecialProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
*/

#include "SpecialProtocol.h"

#include "ServiceBroker.h"
#include "URL.h"
#include "Util.h"
#include "windowing/GraphicContext.h"
#include "profiles/ProfileManager.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
#include "utils/log.h"
#include "windowing/GraphicContext.h"

#include <cassert>

#include "PlatformDefs.h"
#ifdef TARGET_POSIX
#include <dirent.h>
#include "utils/StringUtils.h"
Expand Down
12 changes: 6 additions & 6 deletions xbmc/guilib/guiinfo/PlayerGUIInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,13 @@ std::string CPlayerGUIInfo::GetContentRanges(int iInfo) const
CDataCacheCore& data = CServiceBroker::GetDataCacheCore();
std::vector<std::pair<float, float>> ranges;

time_t start;
std::time_t start;
int64_t current;
int64_t min;
int64_t max;
data.GetPlayTimes(start, current, min, max);

time_t duration = max - start * 1000;
std::time_t duration = max - start * 1000;
if (duration > 0)
{
switch (iInfo)
Expand Down Expand Up @@ -685,7 +685,7 @@ std::string CPlayerGUIInfo::GetContentRanges(int iInfo) const
}

std::vector<std::pair<float, float>> CPlayerGUIInfo::GetEditList(const CDataCacheCore& data,
time_t duration) const
std::time_t duration) const
{
std::vector<std::pair<float, float>> ranges;

Expand All @@ -700,7 +700,7 @@ std::vector<std::pair<float, float>> CPlayerGUIInfo::GetEditList(const CDataCach
}

std::vector<std::pair<float, float>> CPlayerGUIInfo::GetCuts(const CDataCacheCore& data,
time_t duration) const
std::time_t duration) const
{
std::vector<std::pair<float, float>> ranges;

Expand All @@ -718,7 +718,7 @@ std::vector<std::pair<float, float>> CPlayerGUIInfo::GetCuts(const CDataCacheCor
}

std::vector<std::pair<float, float>> CPlayerGUIInfo::GetSceneMarkers(const CDataCacheCore& data,
time_t duration) const
std::time_t duration) const
{
std::vector<std::pair<float, float>> ranges;

Expand All @@ -736,7 +736,7 @@ std::vector<std::pair<float, float>> CPlayerGUIInfo::GetSceneMarkers(const CData
}

std::vector<std::pair<float, float>> CPlayerGUIInfo::GetChapters(const CDataCacheCore& data,
time_t duration) const
std::time_t duration) const
{
std::vector<std::pair<float, float>> ranges;

Expand Down
12 changes: 7 additions & 5 deletions xbmc/guilib/guiinfo/PlayerGUIInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#pragma once

#include "XBDateTime.h"
#include "guilib/guiinfo/GUIInfoProvider.h"
#include "utils/EventStream.h"
#include "utils/TimeFormat.h"

#include <atomic>
#include <ctime>
#include <memory>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -76,12 +77,13 @@ class CPlayerGUIInfo : public CGUIInfoProvider

std::string GetContentRanges(int iInfo) const;
std::vector<std::pair<float, float>> GetEditList(const CDataCacheCore& data,
time_t duration) const;
std::vector<std::pair<float, float>> GetCuts(const CDataCacheCore& data, time_t duration) const;
std::time_t duration) const;
std::vector<std::pair<float, float>> GetCuts(const CDataCacheCore& data,
std::time_t duration) const;
std::vector<std::pair<float, float>> GetSceneMarkers(const CDataCacheCore& data,
time_t duration) const;
std::time_t duration) const;
std::vector<std::pair<float, float>> GetChapters(const CDataCacheCore& data,
time_t duration) const;
std::time_t duration) const;
};

} // namespace GUIINFO
Expand Down
1 change: 1 addition & 0 deletions xbmc/interfaces/json-rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(SOURCES AddonsOperations.cpp
InputOperations.cpp
JSONRPC.cpp
JSONServiceDescription.cpp
JSONUtils.cpp
PlayerOperations.cpp
PlaylistOperations.cpp
ProfilesOperations.cpp
Expand Down
38 changes: 38 additions & 0 deletions xbmc/interfaces/json-rpc/JSONUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 "JSONUtils.h"

#include "XBDateTime.h"

namespace JSONRPC
{

void CJSONUtils::SetFromDBDate(const CVariant& jsonDate, CDateTime& date)
{
if (!jsonDate.isString())
return;

if (jsonDate.empty())
date.Reset();
else
date.SetFromDBDate(jsonDate.asString());
}

void CJSONUtils::SetFromDBDateTime(const CVariant& jsonDate, CDateTime& date)
{
if (!jsonDate.isString())
return;

if (jsonDate.empty())
date.Reset();
else
date.SetFromDBDateTime(jsonDate.asString());
}

} // namespace JSONRPC
25 changes: 4 additions & 21 deletions xbmc/interfaces/json-rpc/JSONUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include "JSONRPCUtils.h"
#include "XBDateTime.h"
#include "playlists/SmartPlayList.h"
#include "utils/JSONVariantParser.h"
#include "utils/JSONVariantWriter.h"
Expand All @@ -21,6 +20,8 @@
#include <string.h>
#include <vector>

class CDateTime;

namespace JSONRPC
{
/*!
Expand Down Expand Up @@ -462,27 +463,9 @@ namespace JSONRPC
stringArray.push_back(it->asString());
}

static void SetFromDBDate(const CVariant &jsonDate, CDateTime &date)
{
if (!jsonDate.isString())
return;

if (jsonDate.empty())
date.Reset();
else
date.SetFromDBDate(jsonDate.asString());
}
static void SetFromDBDate(const CVariant& jsonDate, CDateTime& date);

static void SetFromDBDateTime(const CVariant &jsonDate, CDateTime &date)
{
if (!jsonDate.isString())
return;

if (jsonDate.empty())
date.Reset();
else
date.SetFromDBDateTime(jsonDate.asString());
}
static void SetFromDBDateTime(const CVariant& jsonDate, CDateTime& date);

static bool GetXspFiltering(const std::string &type, const CVariant &filter, std::string &xsp)
{
Expand Down
5 changes: 5 additions & 0 deletions xbmc/peripherals/devices/Peripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,8 @@ bool CPeripheral::operator!=(const PeripheralScanResult& right) const
{
return !(*this == right);
}

CDateTime CPeripheral::LastActive()
{
return CDateTime();
}
4 changes: 2 additions & 2 deletions xbmc/peripherals/devices/Peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "XBDateTime.h"
#include "games/controllers/ControllerTypes.h"
#include "input/joysticks/interfaces/IInputProvider.h"
#include "input/keyboard/interfaces/IKeyboardInputProvider.h"
Expand All @@ -21,6 +20,7 @@
#include <vector>

class TiXmlDocument;
class CDateTime;
class CSetting;
class IKeymap;

Expand Down Expand Up @@ -250,7 +250,7 @@ class CPeripheral : public KODI::JOYSTICK::IInputProvider,
*
* \return The time of last activation, or invalid if unknown/never active
*/
virtual CDateTime LastActive() { return CDateTime(); }
virtual CDateTime LastActive();

/*!
* \brief Get the controller profile that best represents this peripheral
Expand Down
1 change: 1 addition & 0 deletions xbmc/peripherals/devices/PeripheralCecAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CPeripheralCecAdapter : public CPeripheral
#else

#include "PeripheralHID.h"
#include "XBDateTime.h"
#include "interfaces/AnnouncementManager.h"
#include "threads/CriticalSection.h"
#include "threads/Thread.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/peripherals/devices/PeripheralJoystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Peripheral.h"
#include "XBDateTime.h"
#include "input/joysticks/JoystickTypes.h"
#include "input/joysticks/interfaces/IDriverReceiver.h"
#include "threads/CriticalSection.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/peripherals/devices/PeripheralKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Peripheral.h"
#include "XBDateTime.h"
#include "input/keyboard/interfaces/IKeyboardDriverHandler.h"
#include "threads/CriticalSection.h"

Expand Down
Loading

0 comments on commit a3335e0

Please sign in to comment.