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<const 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<const CPVRChannelGroupMember>& groupMember);
146 virtual bool AppendToGroup(
const std::shared_ptr<const CPVRChannelGroupMember>& groupMember);
154 const std::shared_ptr<const CPVRChannelGroupMember>& groupMember)
const;
161 void SetGroupName(
const std::string& strGroupName,
bool isUserSetName =
false);
253 bool Renumber(RenumberMode mode = NORMAL);
258 void UseBackendChannelOrderChanged()
override;
259 void UseBackendChannelNumbersChanged()
override;
260 void StartGroupChannelNumbersFromOneChanged()
override;
268 int iCurrentChannel = -1)
const;
304 const std::shared_ptr<const CPVRChannelGroupMember>& groupMember)
const;
312 const std::shared_ptr<const CPVRChannelGroupMember>& groupMember)
const;
319 std::shared_ptr<CPVRChannel>
GetByChannelID(
int iChannelID)
const;
333 std::vector<std::shared_ptr<CPVRChannelGroupMember>>
GetMembers(
334 Include eFilter = Include::ALL)
const;
376 std::shared_ptr<CPVRChannel>
GetByUniqueID(
int iUniqueChannelId,
int iClientID)
const;
383 std::shared_ptr<CPVRChannelGroupMember>
GetByUniqueID(
const std::pair<int, int>&
id)
const;
385 bool SetHidden(
bool bHidden);
386 bool IsHidden()
const;
493 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
500 bool UpdateGroupEntries(
const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
517 std::shared_ptr<CPVRChannelGroupSettings> GetSettings()
const;
527 std::vector<std::shared_ptr<CPVRChannelGroupMember>>
529 std::map<std::pair<int, int>, std::shared_ptr<CPVRChannelGroupMember>>
531 mutable CCriticalSection m_critSection;
532 std::vector<int> m_failedClients;
534 mutable std::shared_ptr<CPVRChannelGroupSettings> m_settings;
537 static CCriticalSection m_settingsSingletonCritSection;
538 static std::weak_ptr<CPVRChannelGroupSettings> m_settingsSingleton;
544 virtual int GroupType()
const = 0;
551 int LoadFromDatabase(
const std::vector<std::shared_ptr<CPVRClient>>& clients);
557 void DeleteGroupMembersFromDb(
558 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& membersToDelete);
565 bool UpdateFromClient(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
572 bool AddAndUpdateGroupMembers(
573 const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers);
575 void OnSettingChanged();
577 std::shared_ptr<const CPVRChannelGroup> m_allChannelsGroup;
579 bool m_bDeleted =
false;
580 mutable std::optional<int> m_clientPriority;
581 bool m_isUserSetName{
false};
582 std::string m_clientGroupName;
583 int m_iClientPosition{0};
void SetLastWatched(time_t iLastWatched)
Last time group has been watched.
Definition: PVRChannelGroup.cpp:1068
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
uint64_t m_iLastOpened
Definition: PVRChannelGroup.h:524
std::shared_ptr< CPVRChannelGroupMember > GetByChannelNumber(const CPVRChannelNumber &channelNumber) const
Get a channel group member given it's active channel number.
Definition: PVRChannelGroup.cpp:371
CPVRChannelNumber GetChannelNumber(const std::shared_ptr< const CPVRChannel > &channel) const
Get the channel number in this group of the given channel.
Definition: PVRChannelGroup.cpp:355
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
Definition: ContextMenuManager.h:24
virtual bool AppendToGroup(const std::shared_ptr< const CPVRChannelGroupMember > &groupMember)
Append a channel group member to this container.
Definition: PVRChannelGroup.cpp:788
int CleanupCachedImages()
Erase stale texture db entries and image files.
Definition: PVRChannelGroup.cpp:1177
std::string ClientGroupName() const
Get the name of this group on the client.
Definition: PVRChannelGroup.cpp:1035
CPVRChannelGroup(const CPVRChannelsPath &path, const std::shared_ptr< const CPVRChannelGroup > &allChannelsGroup)
Create a new channel group instance.
Definition: PVRChannelGroup.cpp:40
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:523
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:1141
std::shared_ptr< CPVRChannelGroupMember > GetNextChannelGroupMember(const std::shared_ptr< const CPVRChannelGroupMember > &groupMember) const
Get the next channel group member in this group.
Definition: PVRChannelGroup.cpp:387
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:1192
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:672
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:1006
bool UpdateGroupEntries(const std::vector< std::shared_ptr< CPVRChannelGroupMember >> &groupMembers)
Update the current channel group members with the given list.
Definition: PVRChannelGroup.cpp:731
void SetLastOpened(uint64_t iLastOpened)
Set the time in milliseconds from epoch this group was last opened.
Definition: PVRChannelGroup.cpp:1088
bool Persist()
Persist changed or new data.
Definition: PVRChannelGroup.cpp:827
bool HasChannels() const
Check whether this container has any channels.
Definition: PVRChannelGroup.cpp:1108
bool m_bChanged
Definition: PVRChannelGroup.h:521
size_t Size() const
Definition: PVRChannelGroup.cpp:1102
void SetClientPosition(int iPosition)
Set the client-supplied position of this group.
Definition: PVRChannelGroup.cpp:1165
void SetPosition(int iPosition)
Set the local position of this group.
Definition: PVRChannelGroup.cpp:1147
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:642
virtual bool RemoveFromGroup(const std::shared_ptr< const CPVRChannelGroupMember > &groupMember)
Remove a channel group member from this container.
Definition: PVRChannelGroup.cpp:761
void SetGroupName(const std::string &strGroupName, bool isUserSetName=false)
Change the name of this group.
Definition: PVRChannelGroup.cpp:1012
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:173
bool UpdateChannelNumbersFromAllChannelsGroup()
Update the channel numbers according to the all channels group and publish event. ...
Definition: PVRChannelGroup.cpp:652
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:876
bool m_bLoaded
Definition: PVRChannelGroup.h:520
virtual bool SupportsMemberRemove() const =0
Check whether members could be removed from this group by the user.
bool HasChanges() const
Definition: PVRChannelGroup.cpp:934
int m_iPosition
Definition: PVRChannelGroup.h:526
bool HasHiddenChannels() const
Check whether this container has any hidden channels.
Definition: PVRChannelGroup.cpp:1114
int GetClientPosition() const
Get the position of this group as supplied by the PVR client.
Definition: PVRChannelGroup.cpp:1159
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:988
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:636
std::map< std::pair< int, int >, std::shared_ptr< CPVRChannelGroupMember > > m_members
Definition: PVRChannelGroup.h:530
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:927
time_t LastWatched() const
Definition: PVRChannelGroup.cpp:1062
Definition: PVRChannelNumber.h:15
bool m_bHidden
Definition: PVRChannelGroup.h:525
Definition: PVRChannelGroupSettings.h:20
virtual bool IsGroupMember(const std::shared_ptr< const CPVRChannelGroupMember > &groupMember) const
Check whether a channel group member is in this container.
Definition: PVRChannelGroup.cpp:820
bool IsDeleted() const
Whether this group is deleted.
Definition: PVRChannelGroup.h:443
void Unload()
Clear all data.
Definition: PVRChannelGroup.cpp:132
CPVRChannelNumber GetClientChannelNumber(const std::shared_ptr< const CPVRChannel > &channel) const
Get the client channel number in this group of the given channel.
Definition: PVRChannelGroup.cpp:363
uint64_t LastOpened() const
Definition: PVRChannelGroup.cpp:1082
int m_iGroupId
Definition: PVRChannelGroup.h:519
void SetGroupID(int iGroupId)
Set the database ID of this group.
Definition: PVRChannelGroup.cpp:993
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:1056
bool IsNew() const
Definition: PVRChannelGroup.cpp:940
std::vector< std::shared_ptr< CPVRChannelGroupMember > > m_sortedMembers
Definition: PVRChannelGroup.h:528
void SortByChannelNumber()
Sort the current channel list by channel number.
Definition: PVRChannelGroup.cpp:229
void Delete()
Remove this group from database.
Definition: PVRChannelGroup.cpp:858
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:1041
bool UpdateMembersClientPriority()
Update the client priority for all members of this group.
Definition: PVRChannelGroup.cpp:248
std::shared_ptr< CPVRChannelGroupMember > GetPreviousChannelGroupMember(const std::shared_ptr< const CPVRChannelGroupMember > &groupMember) const
Get the previous channel group member in this group.
Definition: PVRChannelGroup.cpp:415