11 #include "pvr/channels/PVRChannelGroupSettings.h" 12 #include "pvr/channels/PVRChannelNumber.h" 13 #include "pvr/channels/PVRChannelsPath.h" 14 #include "utils/EventStream.h" 27 static constexpr
int PVR_GROUP_TYPE_REMOTE = 0;
28 static constexpr
int PVR_GROUP_TYPE_ALL_CHANNELS = 1;
29 static constexpr
int PVR_GROUP_TYPE_LOCAL = 2;
31 static constexpr
int PVR_GROUP_CLIENT_ID_UNKNOWN = -2;
32 static constexpr
int PVR_GROUP_CLIENT_ID_LOCAL = -1;
34 static constexpr
int PVR_GROUP_ID_UNNKOWN{-1};
39 class CPVRChannelGroupMember;
46 IGNORE_NUMBERING_FROM_ONE = 1
49 using GroupMemberPair =
50 std::pair<std::shared_ptr<CPVRChannelGroupMember>, std::shared_ptr<CPVRChannelGroupMember>>;
58 static const int INVALID_GROUP_ID = -1;
66 const std::shared_ptr<CPVRChannelGroup>& allChannelsGroup);
90 bool LoadFromDatabase(
const std::map<std::pair<int, int>, std::shared_ptr<CPVRChannel>>& channels,
91 const std::vector<std::shared_ptr<CPVRClient>>& clients);
108 virtual bool UpdateFromClients(
const std::vector<std::shared_ptr<CPVRClient>>& clients) = 0;
139 virtual bool RemoveFromGroup(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
146 virtual bool AppendToGroup(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
153 virtual bool IsGroupMember(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember)
const;
160 void SetGroupName(
const std::string& strGroupName,
bool isUserSetName =
false);
252 bool Renumber(RenumberMode mode = NORMAL);
257 void UseBackendChannelOrderChanged()
override;
258 void UseBackendChannelNumbersChanged()
override;
259 void StartGroupChannelNumbersFromOneChanged()
override;
267 int iCurrentChannel = -1)
const;
303 const std::shared_ptr<CPVRChannelGroupMember>& groupMember)
const;
311 const std::shared_ptr<CPVRChannelGroupMember>& groupMember)
const;
318 std::shared_ptr<CPVRChannel>
GetByChannelID(
int iChannelID)
const;
332 std::vector<std::shared_ptr<CPVRChannelGroupMember>>
GetMembers(
333 Include eFilter = Include::ALL)
const;
375 std::shared_ptr<CPVRChannel>
GetByUniqueID(
int iUniqueChannelId,
int iClientID)
const;
382 std::shared_ptr<CPVRChannelGroupMember>
GetByUniqueID(
const std::pair<int, int>&
id)
const;
384 bool SetHidden(
bool bHidden);
385 bool IsHidden()
const;
492 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
499 bool UpdateGroupEntries(
const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
516 std::shared_ptr<CPVRChannelGroupSettings> GetSettings()
const;
526 std::vector<std::shared_ptr<CPVRChannelGroupMember>>
528 std::map<std::pair<int, int>, std::shared_ptr<CPVRChannelGroupMember>>
530 mutable CCriticalSection m_critSection;
531 std::vector<int> m_failedClients;
533 mutable std::shared_ptr<CPVRChannelGroupSettings> m_settings;
536 static CCriticalSection m_settingsSingletonCritSection;
537 static std::weak_ptr<CPVRChannelGroupSettings> m_settingsSingleton;
543 virtual int GroupType()
const = 0;
550 int LoadFromDatabase(
const std::vector<std::shared_ptr<CPVRClient>>& clients);
556 void DeleteGroupMembersFromDb(
557 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& membersToDelete);
564 bool UpdateFromClient(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
571 bool AddAndUpdateGroupMembers(
572 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
574 void OnSettingChanged();
576 std::shared_ptr<CPVRChannelGroup> m_allChannelsGroup;
578 bool m_bDeleted =
false;
579 mutable std::optional<int> m_clientPriority;
580 bool m_isUserSetName{
false};
581 std::string m_clientGroupName;
582 int m_iClientPosition{0};
void SetLastWatched(time_t iLastWatched)
Last time group has been watched.
Definition: PVRChannelGroup.cpp:1064
bool LoadFromDatabase(const std::map< std::pair< int, int >, std::shared_ptr< CPVRChannel >> &channels, const std::vector< std::shared_ptr< CPVRClient >> &clients)
Load the channels from the database.
Definition: PVRChannelGroup.cpp:97
virtual bool RemoveFromGroup(const std::shared_ptr< CPVRChannelGroupMember > &groupMember)
Remove a channel group member from this container.
Definition: PVRChannelGroup.cpp:759
uint64_t m_iLastOpened
Definition: PVRChannelGroup.h:523
std::shared_ptr< CPVRChannelGroupMember > GetByChannelNumber(const CPVRChannelNumber &channelNumber) const
Get a channel group member given it's active channel number.
Definition: PVRChannelGroup.cpp:371
void Sort()
Sort the group.
Definition: PVRChannelGroup.cpp:208
int GetClientID() const
Get the identifier of the client that serves this channel group.
Definition: PVRChannelGroup.cpp:140
std::shared_ptr< CPVRChannelGroupMember > GetNextChannelGroupMember(const std::shared_ptr< CPVRChannelGroupMember > &groupMember) const
Get the next channel group member in this group.
Definition: PVRChannelGroup.cpp:387
Definition: ContextMenuManager.h:24
int CleanupCachedImages()
Erase stale texture db entries and image files.
Definition: PVRChannelGroup.cpp:1173
std::string ClientGroupName() const
Get the name of this group on the client.
Definition: PVRChannelGroup.cpp:1031
std::shared_ptr< CPVRChannelGroupMember > GetLastPlayedChannelGroupMember(int iCurrentChannel=-1) const
Get the channel group member that was played last.
Definition: PVRChannelGroup.cpp:309
virtual bool SupportsDelete() const =0
Check whether this group could be deleted by the user.
time_t m_iLastWatched
Definition: PVRChannelGroup.h:522
CPVRChannelNumber GetClientChannelNumber(const std::shared_ptr< CPVRChannel > &channel) const
Get the client channel number in this group of the given channel.
Definition: PVRChannelGroup.cpp:363
virtual bool IsChannelsOwner() const =0
Check whether this group is owner of the channel instances it contains.
std::shared_ptr< CPVRChannel > GetByChannelID(int iChannelID) const
Get a channel given it's channel ID.
Definition: PVRChannelGroup.cpp:299
int GetPosition() const
Get the local position of this group.
Definition: PVRChannelGroup.cpp:1137
A container class for channel groups.
Definition: PVRChannelGroups.h:30
int GetClientPriority() const
Get the priority of the client that provides this group.
Definition: PVRChannelGroup.cpp:1188
void UpdateClientPriorities()
Update the client priority for this group and all members of this group.
Definition: PVRChannelGroup.cpp:235
Definition: PVRChannelsPath.h:17
virtual std::vector< std::shared_ptr< CPVRChannelGroupMember > > RemoveDeletedGroupMembers(const std::vector< std::shared_ptr< CPVRChannelGroupMember >> &groupMembers)
Remove deleted group members from this group.
Definition: PVRChannelGroup.cpp:670
void FillAddonData(PVR_CHANNEL_GROUP &group) const
Copy over data to the given PVR_CHANNEL_GROUP instance.
Definition: PVRChannelGroup.cpp:66
std::shared_ptr< CPVRChannel > GetByUniqueID(int iUniqueChannelId, int iClientID) const
Get a channel given the channel number on the client.
Definition: PVRChannelGroup.cpp:291
void GetChannelNumbers(std::vector< std::string > &channelNumbers) const
Get the list of active channel numbers in a group.
Definition: PVRChannelGroup.cpp:473
std::string GroupName() const
The name of this group.
Definition: PVRChannelGroup.cpp:1002
bool UpdateGroupEntries(const std::vector< std::shared_ptr< CPVRChannelGroupMember >> &groupMembers)
Update the current channel group members with the given list.
Definition: PVRChannelGroup.cpp:729
CPVRChannelNumber GetChannelNumber(const std::shared_ptr< CPVRChannel > &channel) const
Get the channel number in this group of the given channel.
Definition: PVRChannelGroup.cpp:355
void SetLastOpened(uint64_t iLastOpened)
Set the time in milliseconds from epoch this group was last opened.
Definition: PVRChannelGroup.cpp:1084
bool Persist()
Persist changed or new data.
Definition: PVRChannelGroup.cpp:823
bool HasChannels() const
Check whether this container has any channels.
Definition: PVRChannelGroup.cpp:1104
bool m_bChanged
Definition: PVRChannelGroup.h:520
size_t Size() const
Definition: PVRChannelGroup.cpp:1098
void SetClientPosition(int iPosition)
Set the client-supplied position of this group.
Definition: PVRChannelGroup.cpp:1161
void SetPosition(int iPosition)
Set the local position of this group.
Definition: PVRChannelGroup.cpp:1143
bool HasValidDataForClients(const std::vector< std::shared_ptr< CPVRClient >> &clients) const
Check, whether data for given pvr clients are currently valid. For instance, data can be invalid beca...
Definition: PVRChannelGroup.cpp:641
CPVRChannelGroup(const CPVRChannelsPath &path, const std::shared_ptr< CPVRChannelGroup > &allChannelsGroup)
Create a new channel group instance.
Definition: PVRChannelGroup.cpp:40
void SetGroupName(const std::string &strGroupName, bool isUserSetName=false)
Change the name of this group.
Definition: PVRChannelGroup.cpp:1008
virtual bool UpdateFromClients(const std::vector< std::shared_ptr< CPVRClient >> &clients)=0
Update data with channel group members from the given clients, sync with local data.
bool IsUserSetName() const
Check whether the group name was set by the user.
Definition: PVRChannelGroup.h:172
bool UpdateChannelNumbersFromAllChannelsGroup()
Update the channel numbers according to the all channels group and publish event. ...
Definition: PVRChannelGroup.cpp:650
std::shared_ptr< CPVRChannelGroupMember > GetPreviousChannelGroupMember(const std::shared_ptr< CPVRChannelGroupMember > &groupMember) const
Get the previous channel group member in this group.
Definition: PVRChannelGroup.cpp:415
const CPVRChannelsPath & GetPath() const
Get the path of this group.
Definition: PVRChannelGroup.cpp:160
bool Renumber(RenumberMode mode=NORMAL)
Remove invalid channels and updates the channel numbers.
Definition: PVRChannelGroup.cpp:872
bool m_bLoaded
Definition: PVRChannelGroup.h:519
virtual bool SupportsMemberRemove() const =0
Check whether members could be removed from this group by the user.
bool HasChanges() const
Definition: PVRChannelGroup.cpp:930
int m_iPosition
Definition: PVRChannelGroup.h:525
bool HasHiddenChannels() const
Check whether this container has any hidden channels.
Definition: PVRChannelGroup.cpp:1110
int GetClientPosition() const
Get the position of this group as supplied by the PVR client.
Definition: PVRChannelGroup.cpp:1155
Definition: SmartPlayList.cpp:137
void SortByClientChannelNumber()
Sort the current channel list by client channel number.
Definition: PVRChannelGroup.cpp:223
"C" PVR add-on channel group.
Definition: pvr_channel_groups.h:30
int GroupID() const
The database ID of this group.
Definition: PVRChannelGroup.cpp:984
bool HasValidDataForClient(int iClientId) const
Check, whether data for a given pvr client are currently valid. For instance, data can be invalid bec...
Definition: PVRChannelGroup.cpp:635
std::map< std::pair< int, int >, std::shared_ptr< CPVRChannelGroupMember > > m_members
Definition: PVRChannelGroup.h:529
bool SortAndRenumber()
Sort the group and fix up channel numbers.
Definition: PVRChannelGroup.cpp:216
void SetPath(const CPVRChannelsPath &path)
Set the path of this group.
Definition: PVRChannelGroup.cpp:166
std::vector< std::shared_ptr< CPVRChannelGroupMember > > GetMembers(Include eFilter=Include::ALL) const
Get the current members of this group.
Definition: PVRChannelGroup.cpp:443
void SetClientID(int clientID)
Set the identifier of the client that serves this channel group.
Definition: PVRChannelGroup.cpp:146
Definition: PVRDatabase.h:33
bool HasNewChannels() const
Check whether this container has any new channels.
Definition: PVRChannelGroup.cpp:923
time_t LastWatched() const
Definition: PVRChannelGroup.cpp:1058
virtual bool AppendToGroup(const std::shared_ptr< CPVRChannelGroupMember > &groupMember)
Append a channel group member to this container.
Definition: PVRChannelGroup.cpp:785
Definition: PVRChannelNumber.h:15
bool m_bHidden
Definition: PVRChannelGroup.h:524
Definition: PVRChannelGroupSettings.h:20
bool IsDeleted() const
Whether this group is deleted.
Definition: PVRChannelGroup.h:442
void Unload()
Clear all data.
Definition: PVRChannelGroup.cpp:132
uint64_t LastOpened() const
Definition: PVRChannelGroup.cpp:1078
int m_iGroupId
Definition: PVRChannelGroup.h:518
virtual bool IsGroupMember(const std::shared_ptr< CPVRChannelGroupMember > &groupMember) const
Check whether a channel group member is in this container.
Definition: PVRChannelGroup.cpp:816
void SetGroupID(int iGroupId)
Set the database ID of this group.
Definition: PVRChannelGroup.cpp:989
Definition: PVRChannelGroup.h:52
GroupMemberPair GetLastAndPreviousToLastPlayedChannelGroupMember() const
Get the last and previous to last played channel group members.
Definition: PVRChannelGroup.cpp:330
bool IsRadio() const
True if this group holds radio channels, false if it holds TV channels.
Definition: PVRChannelGroup.cpp:1052
bool IsNew() const
Definition: PVRChannelGroup.cpp:936
std::vector< std::shared_ptr< CPVRChannelGroupMember > > m_sortedMembers
Definition: PVRChannelGroup.h:527
void SortByChannelNumber()
Sort the current channel list by channel number.
Definition: PVRChannelGroup.cpp:229
void Delete()
Remove this group from database.
Definition: PVRChannelGroup.cpp:854
CEventStream< PVREvent > & Events()
Query the events available for CEventStream.
Definition: PVRChannelGroup.h:82
virtual bool SupportsMemberAdd() const =0
Check whether members could be added to this group by the user.
void SetClientGroupName(const std::string &groupName)
Set the name this group has on the client.
Definition: PVRChannelGroup.cpp:1037
bool UpdateMembersClientPriority()
Update the client priority for all members of this group.
Definition: PVRChannelGroup.cpp:248