| 1 |
/* |
| 2 |
* Copyright (C) 2012-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "pvr/channels/PVRChannelGroupSettings.h" |
| 12 |
#include "pvr/channels/PVRChannelNumber.h" |
| 13 |
#include "pvr/channels/PVRChannelsPath.h" |
| 14 |
#include "utils/EventStream.h" |
| 15 |
|
| 16 |
#include <map> |
| 17 |
#include <memory> |
| 18 |
#include <optional> |
| 19 |
#include <string> |
| 20 |
#include <utility> |
| 21 |
#include <vector> |
| 22 |
|
| 23 |
struct PVR_CHANNEL_GROUP; |
| 24 |
|
| 25 |
namespace PVR |
| 26 |
{ |
| 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; |
| 30 |
|
| 31 |
static constexpr int PVR_GROUP_CLIENT_ID_UNKNOWN = -2; |
| 32 |
static constexpr int PVR_GROUP_CLIENT_ID_LOCAL = -1; |
| 33 |
|
| 34 |
static constexpr int PVR_GROUP_ID_UNNKOWN{-1}; |
| 35 |
|
| 36 |
enum class PVREvent; |
| 37 |
|
| 38 |
class CPVRChannel; |
| 39 |
class CPVRChannelGroupMember; |
| 40 |
class CPVRClient; |
| 41 |
class CPVREpgInfoTag; |
| 42 |
|
| 43 |
enum RenumberMode |
| 44 |
{ |
| 45 |
NORMAL = 0, |
| 46 |
IGNORE_NUMBERING_FROM_ONE = 1 |
| 47 |
}; |
| 48 |
|
| 49 |
using GroupMemberPair = |
| 50 |
std::pair<std::shared_ptr<CPVRChannelGroupMember>, std::shared_ptr<CPVRChannelGroupMember>>; |
| 51 |
|
| 52 |
class CPVRChannelGroup : public IChannelGroupSettingsCallback |
| 53 |
{ |
| 54 |
friend class CPVRChannelGroups; // for GroupType() |
| 55 |
friend class CPVRDatabase; // for GroupType() |
| 56 |
|
| 57 |
public: |
| 58 |
static const int INVALID_GROUP_ID = -1; |
| 59 |
|
| 60 |
/*! |
| 61 |
* @brief Create a new channel group instance. |
| 62 |
* @param path The channel group path. |
| 63 |
* @param allChannelsGroup The channel group containing all TV or radio channels. |
| 64 |
*/ |
| 65 |
CPVRChannelGroup(const CPVRChannelsPath& path, |
| 66 |
const std::shared_ptr<const CPVRChannelGroup>& allChannelsGroup); |
| 67 |
|
| 68 |
~CPVRChannelGroup() override; |
| 69 |
|
| 70 |
bool operator==(const CPVRChannelGroup& right) const; |
| 71 |
bool operator!=(const CPVRChannelGroup& right) const; |
| 72 |
|
| 73 |
/*! |
| 74 |
* @brief Copy over data to the given PVR_CHANNEL_GROUP instance. |
| 75 |
* @param group The group instance to fill. |
| 76 |
*/ |
| 77 |
void FillAddonData(PVR_CHANNEL_GROUP& group) const; |
| 78 |
|
| 79 |
/*! |
| 80 |
* @brief Query the events available for CEventStream |
| 81 |
*/ |
| 82 |
CEventStream<PVREvent>& Events() { return m_events; } |
| 83 |
|
| 84 |
/*! |
| 85 |
* @brief Load the channels from the database. |
| 86 |
* @param channels All available channels. |
| 87 |
* @param clients The PVR clients data should be loaded for. Leave empty for all clients. |
| 88 |
* @return True when loaded successfully, false otherwise. |
| 89 |
*/ |
| 90 |
bool LoadFromDatabase(const std::map<std::pair<int, int>, std::shared_ptr<CPVRChannel>>& channels, |
| 91 |
const std::vector<std::shared_ptr<CPVRClient>>& clients); |
| 92 |
|
| 93 |
/*! |
| 94 |
* @brief Clear all data. |
| 95 |
*/ |
| 96 |
void Unload(); |
| 97 |
|
| 98 |
/*! |
| 99 |
* @return The amount of group members |
| 100 |
*/ |
| 101 |
size_t Size() const; |
| 102 |
|
| 103 |
/*! |
| 104 |
* @brief Update data with channel group members from the given clients, sync with local data. |
| 105 |
* @param clients The clients to fetch data from. Leave empty to fetch data from all created clients. |
| 106 |
* @return True on success, false otherwise. |
| 107 |
*/ |
| 108 |
virtual bool UpdateFromClients(const std::vector<std::shared_ptr<CPVRClient>>& clients) = 0; |
| 109 |
|
| 110 |
/*! |
| 111 |
* @brief Get the identifier of the client that serves this channel group. |
| 112 |
* @return The identifier or PVR_GROUP_CLIENT_ID_LOCAL for local groups. |
| 113 |
*/ |
| 114 |
int GetClientID() const; |
| 115 |
|
| 116 |
/*! |
| 117 |
* @brief Set the identifier of the client that serves this channel group. |
| 118 |
* @param clientID The identifier; must be PVR_GROUP_CLIENT_ID_LOCAL for local groups. |
| 119 |
*/ |
| 120 |
void SetClientID(int clientID); |
| 121 |
|
| 122 |
/*! |
| 123 |
* @brief Get the path of this group. |
| 124 |
* @return the path. |
| 125 |
*/ |
| 126 |
const CPVRChannelsPath& GetPath() const; |
| 127 |
|
| 128 |
/*! |
| 129 |
* @brief Set the path of this group. |
| 130 |
* @param the path. |
| 131 |
*/ |
| 132 |
void SetPath(const CPVRChannelsPath& path); |
| 133 |
|
| 134 |
/*! |
| 135 |
* @brief Remove a channel group member from this container. |
| 136 |
* @param groupMember The channel group member to remove. |
| 137 |
* @return True if the channel group member was removed, false otherwise. |
| 138 |
*/ |
| 139 |
virtual bool RemoveFromGroup(const std::shared_ptr<const CPVRChannelGroupMember>& groupMember); |
| 140 |
|
| 141 |
/*! |
| 142 |
* @brief Append a channel group member to this container. |
| 143 |
* @param groupMember The channel group member to append. |
| 144 |
* @return True if the channel group member was appended, false otherwise. |
| 145 |
*/ |
| 146 |
virtual bool AppendToGroup(const std::shared_ptr<const CPVRChannelGroupMember>& groupMember); |
| 147 |
|
| 148 |
/*! |
| 149 |
* @brief Check whether a channel group member is in this container. |
| 150 |
* @param groupMember The channel group member to check. |
| 151 |
* @return True if the channel group member was found, false otherwise. |
| 152 |
*/ |
| 153 |
virtual bool IsGroupMember( |
| 154 |
const std::shared_ptr<const CPVRChannelGroupMember>& groupMember) const; |
| 155 |
|
| 156 |
/*! |
| 157 |
* @brief Change the name of this group. |
| 158 |
* @param strGroupName The new group name. |
| 159 |
* @param isUserSetName Whether the name was set by the user. |
| 160 |
*/ |
| 161 |
void SetGroupName(const std::string& strGroupName, bool isUserSetName = false); |
| 162 |
|
| 163 |
/*! |
| 164 |
* @brief Set the name this group has on the client. |
| 165 |
* @param groupName The client group name. |
| 166 |
*/ |
| 167 |
void SetClientGroupName(const std::string& groupName); |
| 168 |
|
| 169 |
/*! |
| 170 |
* @brief Check whether the group name was set by the user. |
| 171 |
* @return True if set by user, false otherwise; |
| 172 |
*/ |
| 173 |
bool IsUserSetName() const { return m_isUserSetName; } |
| 174 |
|
| 175 |
/*! |
| 176 |
* @brief Persist changed or new data. |
| 177 |
* @return True if the channel was persisted, false otherwise. |
| 178 |
*/ |
| 179 |
bool Persist(); |
| 180 |
|
| 181 |
/*! |
| 182 |
* @brief True if this group holds radio channels, false if it holds TV channels. |
| 183 |
* @return True if this group holds radio channels, false if it holds TV channels. |
| 184 |
*/ |
| 185 |
bool IsRadio() const; |
| 186 |
|
| 187 |
/*! |
| 188 |
* @brief The database ID of this group. |
| 189 |
* @return The database ID of this group. |
| 190 |
*/ |
| 191 |
int GroupID() const; |
| 192 |
|
| 193 |
/*! |
| 194 |
* @brief Set the database ID of this group. |
| 195 |
* @param iGroupId The new database ID. |
| 196 |
*/ |
| 197 |
void SetGroupID(int iGroupId); |
| 198 |
|
| 199 |
/*! |
| 200 |
* @return Time group has been watched last. |
| 201 |
*/ |
| 202 |
time_t LastWatched() const; |
| 203 |
|
| 204 |
/*! |
| 205 |
* @brief Last time group has been watched |
| 206 |
* @param iLastWatched The new value. |
| 207 |
*/ |
| 208 |
void SetLastWatched(time_t iLastWatched); |
| 209 |
|
| 210 |
/*! |
| 211 |
* @return Time in milliseconds from epoch this group was last opened. |
| 212 |
*/ |
| 213 |
uint64_t LastOpened() const; |
| 214 |
|
| 215 |
/*! |
| 216 |
* @brief Set the time in milliseconds from epoch this group was last opened. |
| 217 |
* @param iLastOpened The new value. |
| 218 |
*/ |
| 219 |
void SetLastOpened(uint64_t iLastOpened); |
| 220 |
|
| 221 |
/*! |
| 222 |
* @brief The name of this group. |
| 223 |
* @return The name of this group. |
| 224 |
*/ |
| 225 |
std::string GroupName() const; |
| 226 |
|
| 227 |
/*! |
| 228 |
* @brief Get the name of this group on the client. |
| 229 |
* @return The group's name. |
| 230 |
*/ |
| 231 |
std::string ClientGroupName() const; |
| 232 |
|
| 233 |
/*! @name Sort methods |
| 234 |
*/ |
| 235 |
//@{ |
| 236 |
|
| 237 |
/*! |
| 238 |
* @brief Sort the group. |
| 239 |
*/ |
| 240 |
void Sort(); |
| 241 |
|
| 242 |
/*! |
| 243 |
* @brief Sort the group and fix up channel numbers. |
| 244 |
* @return True when numbering changed, false otherwise |
| 245 |
*/ |
| 246 |
bool SortAndRenumber(); |
| 247 |
|
| 248 |
/*! |
| 249 |
* @brief Remove invalid channels and updates the channel numbers. |
| 250 |
* @param mode the numbering mode to use |
| 251 |
* @return True if something changed, false otherwise. |
| 252 |
*/ |
| 253 |
bool Renumber(RenumberMode mode = NORMAL); |
| 254 |
|
| 255 |
//@} |
| 256 |
|
| 257 |
// IChannelGroupSettingsCallback implementation |
| 258 |
void UseBackendChannelOrderChanged() override; |
| 259 |
void UseBackendChannelNumbersChanged() override; |
| 260 |
void StartGroupChannelNumbersFromOneChanged() override; |
| 261 |
|
| 262 |
/*! |
| 263 |
* @brief Get the channel group member that was played last. |
| 264 |
* @param iCurrentChannel The channelid of the current channel that is playing, or -1 if none |
| 265 |
* @return The requested channel group member or nullptr. |
| 266 |
*/ |
| 267 |
std::shared_ptr<CPVRChannelGroupMember> GetLastPlayedChannelGroupMember( |
| 268 |
int iCurrentChannel = -1) const; |
| 269 |
|
| 270 |
/*! |
| 271 |
* @brief Get the last and previous to last played channel group members. |
| 272 |
* @return The members. pair.first contains the last, pair.second the previous to last member. |
| 273 |
*/ |
| 274 |
GroupMemberPair GetLastAndPreviousToLastPlayedChannelGroupMember() const; |
| 275 |
|
| 276 |
/*! |
| 277 |
* @brief Get a channel group member given it's active channel number |
| 278 |
* @param channelNumber The channel number. |
| 279 |
* @return The channel group member or nullptr if it wasn't found. |
| 280 |
*/ |
| 281 |
std::shared_ptr<CPVRChannelGroupMember> GetByChannelNumber( |
| 282 |
const CPVRChannelNumber& channelNumber) const; |
| 283 |
|
| 284 |
/*! |
| 285 |
* @brief Get the channel number in this group of the given channel. |
| 286 |
* @param channel The channel to get the channel number for. |
| 287 |
* @return The channel number in this group. |
| 288 |
*/ |
| 289 |
CPVRChannelNumber GetChannelNumber(const std::shared_ptr<const CPVRChannel>& channel) const; |
| 290 |
|
| 291 |
/*! |
| 292 |
* @brief Get the client channel number in this group of the given channel. |
| 293 |
* @param channel The channel to get the channel number for. |
| 294 |
* @return The client channel number in this group. |
| 295 |
*/ |
| 296 |
CPVRChannelNumber GetClientChannelNumber(const std::shared_ptr<const CPVRChannel>& channel) const; |
| 297 |
|
| 298 |
/*! |
| 299 |
* @brief Get the next channel group member in this group. |
| 300 |
* @param groupMember The current channel group member. |
| 301 |
* @return The channel group member or nullptr if it wasn't found. |
| 302 |
*/ |
| 303 |
std::shared_ptr<CPVRChannelGroupMember> GetNextChannelGroupMember( |
| 304 |
const std::shared_ptr<const CPVRChannelGroupMember>& groupMember) const; |
| 305 |
|
| 306 |
/*! |
| 307 |
* @brief Get the previous channel group member in this group. |
| 308 |
* @param groupMember The current channel group member. |
| 309 |
* @return The channel group member or nullptr if it wasn't found. |
| 310 |
*/ |
| 311 |
std::shared_ptr<CPVRChannelGroupMember> GetPreviousChannelGroupMember( |
| 312 |
const std::shared_ptr<const CPVRChannelGroupMember>& groupMember) const; |
| 313 |
|
| 314 |
/*! |
| 315 |
* @brief Get a channel given it's channel ID. |
| 316 |
* @param iChannelID The channel ID. |
| 317 |
* @return The channel or NULL if it wasn't found. |
| 318 |
*/ |
| 319 |
std::shared_ptr<CPVRChannel> GetByChannelID(int iChannelID) const; |
| 320 |
|
| 321 |
enum class Include |
| 322 |
{ |
| 323 |
ALL, |
| 324 |
ONLY_HIDDEN, |
| 325 |
ONLY_VISIBLE |
| 326 |
}; |
| 327 |
|
| 328 |
/*! |
| 329 |
* @brief Get the current members of this group |
| 330 |
* @param eFilter A filter to apply. |
| 331 |
* @return The group members |
| 332 |
*/ |
| 333 |
std::vector<std::shared_ptr<CPVRChannelGroupMember>> GetMembers( |
| 334 |
Include eFilter = Include::ALL) const; |
| 335 |
|
| 336 |
/*! |
| 337 |
* @brief Get the list of active channel numbers in a group. |
| 338 |
* @param channelNumbers The list to store the numbers in. |
| 339 |
*/ |
| 340 |
void GetChannelNumbers(std::vector<std::string>& channelNumbers) const; |
| 341 |
|
| 342 |
/*! |
| 343 |
* @brief Check whether this container has any channels. |
| 344 |
* @return True if there is at least one channel in this container, otherwise false. |
| 345 |
*/ |
| 346 |
bool HasChannels() const; |
| 347 |
|
| 348 |
/*! |
| 349 |
* @brief Check whether this container has any new channels. |
| 350 |
* @return True if there is at least one new channel in this group that hasn't been persisted, false otherwise. |
| 351 |
*/ |
| 352 |
bool HasNewChannels() const; |
| 353 |
|
| 354 |
/*! |
| 355 |
* @brief Check whether this container has any hidden channels. |
| 356 |
* @return True if at least one hidden channel is present, false otherwise. |
| 357 |
*/ |
| 358 |
bool HasHiddenChannels() const; |
| 359 |
|
| 360 |
/*! |
| 361 |
* @return True if anything changed in this group that hasn't been persisted, false otherwise. |
| 362 |
*/ |
| 363 |
bool HasChanges() const; |
| 364 |
|
| 365 |
/*! |
| 366 |
* @return True if the group was never persisted, false otherwise. |
| 367 |
*/ |
| 368 |
bool IsNew() const; |
| 369 |
|
| 370 |
/*! |
| 371 |
* @brief Get a channel given the channel number on the client. |
| 372 |
* @param iUniqueChannelId The unique channel id on the client. |
| 373 |
* @param iClientID The ID of the client. |
| 374 |
* @return The channel or NULL if it wasn't found. |
| 375 |
*/ |
| 376 |
std::shared_ptr<CPVRChannel> GetByUniqueID(int iUniqueChannelId, int iClientID) const; |
| 377 |
|
| 378 |
/*! |
| 379 |
* @brief Get a channel group member given its storage id. |
| 380 |
* @param id The storage id (a pair of client id and unique channel id). |
| 381 |
* @return The channel group member or nullptr if it wasn't found. |
| 382 |
*/ |
| 383 |
std::shared_ptr<CPVRChannelGroupMember> GetByUniqueID(const std::pair<int, int>& id) const; |
| 384 |
|
| 385 |
bool SetHidden(bool bHidden); |
| 386 |
bool IsHidden() const; |
| 387 |
|
| 388 |
/*! |
| 389 |
* @brief Get the local position of this group. |
| 390 |
* @return The local group position. |
| 391 |
*/ |
| 392 |
int GetPosition() const; |
| 393 |
|
| 394 |
/*! |
| 395 |
* @brief Set the local position of this group. |
| 396 |
* @param iPosition The new local group position. |
| 397 |
*/ |
| 398 |
void SetPosition(int iPosition); |
| 399 |
|
| 400 |
/*! |
| 401 |
* @brief Get the position of this group as supplied by the PVR client. |
| 402 |
* @return The client-supplied group position. |
| 403 |
*/ |
| 404 |
int GetClientPosition() const; |
| 405 |
|
| 406 |
/*! |
| 407 |
* @brief Set the client-supplied position of this group. |
| 408 |
* @param iPosition The new client-supplied group position. |
| 409 |
*/ |
| 410 |
void SetClientPosition(int iPosition); |
| 411 |
|
| 412 |
/*! |
| 413 |
* @brief Check, whether data for a given pvr client are currently valid. For instance, data |
| 414 |
* can be invalid because the client's backend was offline when data was last queried. |
| 415 |
* @param iClientId The id of the client. |
| 416 |
* @return True, if data is currently valid, false otherwise. |
| 417 |
*/ |
| 418 |
bool HasValidDataForClient(int iClientId) const; |
| 419 |
|
| 420 |
/*! |
| 421 |
* @brief Check, whether data for given pvr clients are currently valid. For instance, data |
| 422 |
* can be invalid because the client's backend was offline when data was last queried. |
| 423 |
* @param clients The clients to check. Check all active clients if vector is empty. |
| 424 |
* @return True, if data is currently valid, false otherwise. |
| 425 |
*/ |
| 426 |
bool HasValidDataForClients(const std::vector<std::shared_ptr<CPVRClient>>& clients) const; |
| 427 |
|
| 428 |
/*! |
| 429 |
* @brief Update the channel numbers according to the all channels group and publish event. |
| 430 |
* @return True, if a channel number was changed, false otherwise. |
| 431 |
*/ |
| 432 |
bool UpdateChannelNumbersFromAllChannelsGroup(); |
| 433 |
|
| 434 |
/*! |
| 435 |
* @brief Remove this group from database. |
| 436 |
*/ |
| 437 |
void Delete(); |
| 438 |
|
| 439 |
/*! |
| 440 |
* @brief Whether this group is deleted. |
| 441 |
* @return True, if deleted, false otherwise. |
| 442 |
*/ |
| 443 |
bool IsDeleted() const { return m_bDeleted; } |
| 444 |
|
| 445 |
/*! |
| 446 |
* @brief Erase stale texture db entries and image files. |
| 447 |
* @return number of cleaned up images. |
| 448 |
*/ |
| 449 |
int CleanupCachedImages(); |
| 450 |
|
| 451 |
/*! |
| 452 |
* @brief Get the priority of the client that provides this group. |
| 453 |
* @return the priority, as set by the user or 0. Always 0 for non-backend-supplied groups. |
| 454 |
*/ |
| 455 |
int GetClientPriority() const; |
| 456 |
|
| 457 |
/*! |
| 458 |
* @brief Update the client priority for this group and all members of this group. |
| 459 |
*/ |
| 460 |
void UpdateClientPriorities(); |
| 461 |
|
| 462 |
/*! |
| 463 |
* @brief Check whether this group could be deleted by the user. |
| 464 |
* @return True if the group could be deleted, false otherwise. |
| 465 |
*/ |
| 466 |
virtual bool SupportsDelete() const = 0; |
| 467 |
|
| 468 |
/*! |
| 469 |
* @brief Check whether members could be added to this group by the user. |
| 470 |
* @return True if members could be added, false otherwise. |
| 471 |
*/ |
| 472 |
virtual bool SupportsMemberAdd() const = 0; |
| 473 |
|
| 474 |
/*! |
| 475 |
* @brief Check whether members could be removed from this group by the user. |
| 476 |
* @return True if members could be removed, false otherwise. |
| 477 |
*/ |
| 478 |
virtual bool SupportsMemberRemove() const = 0; |
| 479 |
|
| 480 |
/*! |
| 481 |
* @brief Check whether this group is owner of the channel instances it contains. |
| 482 |
* @return True if owner, false otherwise. |
| 483 |
*/ |
| 484 |
virtual bool IsChannelsOwner() const = 0; |
| 485 |
|
| 486 |
protected: |
| 487 |
/*! |
| 488 |
* @brief Remove deleted group members from this group. |
| 489 |
* @param groupMembers The group members to use to update this list. |
| 490 |
* @return The removed members . |
| 491 |
*/ |
| 492 |
virtual std::vector<std::shared_ptr<CPVRChannelGroupMember>> RemoveDeletedGroupMembers( |
| 493 |
const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers); |
| 494 |
|
| 495 |
/*! |
| 496 |
* @brief Update the current channel group members with the given list. |
| 497 |
* @param groupMembers The group members to use to update this list. |
| 498 |
* @return True if everything went well, false otherwise. |
| 499 |
*/ |
| 500 |
bool UpdateGroupEntries(const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers); |
| 501 |
|
| 502 |
/*! |
| 503 |
* @brief Sort the current channel list by client channel number. |
| 504 |
*/ |
| 505 |
void SortByClientChannelNumber(); |
| 506 |
|
| 507 |
/*! |
| 508 |
* @brief Sort the current channel list by channel number. |
| 509 |
*/ |
| 510 |
void SortByChannelNumber(); |
| 511 |
|
| 512 |
/*! |
| 513 |
* @brief Update the client priority for all members of this group. |
| 514 |
*/ |
| 515 |
bool UpdateMembersClientPriority(); |
| 516 |
|
| 517 |
std::shared_ptr<CPVRChannelGroupSettings> GetSettings() const; |
| 518 |
|
| 519 |
int m_iGroupId = INVALID_GROUP_ID; /*!< The ID of this group in the database */ |
| 520 |
bool m_bLoaded = false; /*!< True if this container is loaded, false otherwise */ |
| 521 |
bool m_bChanged = |
| 522 |
false; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */ |
| 523 |
time_t m_iLastWatched = 0; /*!< last time group has been watched */ |
| 524 |
uint64_t m_iLastOpened = 0; /*!< time in milliseconds from epoch this group was last opened */ |
| 525 |
bool m_bHidden = false; /*!< true if this group is hidden, false otherwise */ |
| 526 |
int m_iPosition = 0; /*!< the local position of this group within the group list */ |
| 527 |
std::vector<std::shared_ptr<CPVRChannelGroupMember>> |
| 528 |
m_sortedMembers; /*!< members sorted by channel number */ |
| 529 |
std::map<std::pair<int, int>, std::shared_ptr<CPVRChannelGroupMember>> |
| 530 |
m_members; /*!< members with key clientid+uniqueid */ |
| 531 |
mutable CCriticalSection m_critSection; |
| 532 |
std::vector<int> m_failedClients; |
| 533 |
CEventSource<PVREvent> m_events; |
| 534 |
mutable std::shared_ptr<CPVRChannelGroupSettings> m_settings; |
| 535 |
|
| 536 |
// the settings singleton shared between all group instances |
| 537 |
static CCriticalSection m_settingsSingletonCritSection; |
| 538 |
static std::weak_ptr<CPVRChannelGroupSettings> m_settingsSingleton; |
| 539 |
|
| 540 |
private: |
| 541 |
/*! |
| 542 |
* @brief Return the type of this group. |
| 543 |
*/ |
| 544 |
virtual int GroupType() const = 0; |
| 545 |
|
| 546 |
/*! |
| 547 |
* @brief Load the channel group members stored in the database. |
| 548 |
* @param clients The PVR clients to load data for. Leave empty for all clients. |
| 549 |
* @return The amount of channel group members that were added. |
| 550 |
*/ |
| 551 |
int LoadFromDatabase(const std::vector<std::shared_ptr<CPVRClient>>& clients); |
| 552 |
|
| 553 |
/*! |
| 554 |
* @brief Delete channel group members from database. |
| 555 |
* @param membersToDelete The channel group members. |
| 556 |
*/ |
| 557 |
void DeleteGroupMembersFromDb( |
| 558 |
const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& membersToDelete); |
| 559 |
|
| 560 |
/*! |
| 561 |
* @brief Update this group's data with a channel group member provided by a client. |
| 562 |
* @param groupMember The updated group member. |
| 563 |
* @return True if group member data were changed, false otherwise. |
| 564 |
*/ |
| 565 |
bool UpdateFromClient(const std::shared_ptr<CPVRChannelGroupMember>& groupMember); |
| 566 |
|
| 567 |
/*! |
| 568 |
* @brief Add new channel group members to this group; update data. |
| 569 |
* @param groupMembers The group members to use to update this list. |
| 570 |
* @return True if group member data were changed, false otherwise. |
| 571 |
*/ |
| 572 |
bool AddAndUpdateGroupMembers( |
| 573 |
const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers); |
| 574 |
|
| 575 |
void OnSettingChanged(); |
| 576 |
|
| 577 |
std::shared_ptr<const CPVRChannelGroup> m_allChannelsGroup; |
| 578 |
CPVRChannelsPath m_path; |
| 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}; |
| 584 |
}; |
| 585 |
} // namespace PVR |