-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaylistLockManager.h
More file actions
166 lines (139 loc) · 7.19 KB
/
Copy pathPlaylistLockManager.h
File metadata and controls
166 lines (139 loc) · 7.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/** $VER: PlaylistLockManager.h (2026.07.25) P. Stuer **/
#pragma once
#include "Resources.h"
#include <sdk/playlist.h>
/// <summary>
/// Implements our lock.
/// </summary>
class playlist_lock_t : public playlist_lock
{
public:
playlist_lock_t(uint32_t mask) noexcept : _Mask(mask) { };
playlist_lock_t(const playlist_lock_t &&) = delete;
playlist_lock_t & operator=(playlist_lock_t &&) = delete;
virtual ~playlist_lock_t() noexcept { };
#pragma region playlist_lock
/// <summary>
/// Queries whether specified item insertion operation is allowed in the locked playlist.
/// </summary>
/// <param name="sourceIndex">Index from which the items are being inserted</param>
/// <param name="items">Items being inserted</param>
/// <param name="selection">Caller-requested selection state of items being inserted</param>
/// <returns>True to allow the operation, false to block it</returns>
bool query_items_add(t_size sourceIndex, const pfc::list_base_const_t<metadb_handle_ptr> & items, const bit_array & selection) noexcept final
{
return ((_Mask & playlist_lock::filter_add) != 0);
}
/// <summary>
/// Queries whether specified item reorder operation is allowed in the locked playlist.
/// </summary>
/// <param name="order">Pointer to array containing permutation defining requested reorder operation</param>
/// <param name="count">Number of items in array pointed to by 'order'. This should always be equal to number of items on the locked playlist</param>
/// <returns>True to allow the operation, false to block it</returns>
bool query_items_reorder(const t_size * p_order, t_size p_count) noexcept final
{
return ((_Mask & playlist_lock::filter_reorder) != 0);
}
/// <summary>
/// Queries whether specified item removal operation is allowed in the locked playlist.
/// </summary>
/// <param name="mask">Specifies which items from locked playlist are being removed</param>
/// <param name="force">If set to true, the call is made only for notification purpose and items are getting removed regardless (after e.g. they have been physically removed)</param>
/// <returns>True to allow the operation, false to block it. Note that return value is ignored if p_force is set to true</returns>
bool query_items_remove(const bit_array & mask, bool force) noexcept final
{
return ((_Mask & playlist_lock::filter_remove) != 0);
}
/// <summary>
/// Queries whether specified item replacement operation is allowed in the locked playlist.
/// </summary>
/// <param name="itemIndex">Index of the item being replaced</param>
/// <param name="oldHandle">Old value of the item being replaced</param>
/// <param name="newHandle">New value of the item being replaced</param>
/// <returns>True to allow the operation, false to block it</returns>
bool query_item_replace(t_size itemIndex, const metadb_handle_ptr & oldHandle, const metadb_handle_ptr & newHandle) noexcept final
{
return ((_Mask & playlist_lock::filter_replace) != 0);
}
/// <summary>
/// Queries whether renaming the locked playlist is allowed.
/// </summary>
/// <param name="newName">Requested new name of the playlist; a UTF-8 encoded string</param>
/// <param name="newNameSize">Length limit of the name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings</param>
/// <returns>True to allow the operation, false to block it</returns>
bool query_playlist_rename(const char * p_new_name, t_size p_new_name_len) noexcept final
{
return ((_Mask & playlist_lock::filter_rename) != 0);
}
/// <summary>
/// Queries whether removal of the locked playlist is allowed. Note that the lock will be released when the playlist is removed.
/// </summary>
/// <returns>True to allow the operation, false to block it</returns>
bool query_playlist_remove() noexcept final
{
return ((_Mask & playlist_lock::filter_remove_playlist) != 0);
}
/// <summary>
/// Executes "default action" (doubleclick etc) for specified playlist item. When the playlist is not locked, default action starts playback of the item.
/// </summary>
/// <returns>True if custom default action was executed, false to fall-through to default one for non-locked playlists (start playback).</returns>
bool execute_default_action(t_size p_item) noexcept final
{
return false;
}
/// <summary>
/// Notifies lock about changed index of the playlist, in result of user reordering playlists or removing other playlists.
/// </summary>
void on_playlist_index_change(t_size newIndex) noexcept final
{
}
/// <summary>
/// Notifies lock about the locked playlist getting removed.
/// </summary>
void on_playlist_remove() noexcept final
{
}
/// <summary>
/// Retrieves human-readable name of playlist lock to display.
/// </summary>
void get_lock_name(pfc::string_base & name) noexcept final
{
name = STR_COMPONENT_NAME;
}
/// <summary>
/// Requests user interface of component controlling the playlist lock to be shown.
/// </summary>
void show_ui() noexcept final
{
}
/// <summary>
/// Queries which actions the lock filters. The return value must not change while the lock is registered with playlist_manager.
/// The return value is a combination of one or more filter_* constants.
/// </summary>
t_uint32 get_filter_mask() noexcept final
{
return _Mask;
}
#pragma endregion
static inline bool IsAddProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_add) != 0); }
static inline bool IsRemoveProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_remove) != 0); }
static inline bool IsReorderProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_reorder) != 0); }
static inline bool IsReplaceProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_replace) != 0); }
static inline bool IsRenamePlaylistProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_rename) != 0); }
static inline bool IsRemovePlaylistProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_remove_playlist) != 0); }
static inline bool IsDefaultActionProhibited (uint32_t filterMask) noexcept { return ((filterMask & playlist_lock::filter_default_action) != 0); }
private:
uint32_t _Mask;
};
/// <summary>
/// Declares the playlist lock manager service.
/// </summary>
class NOVTABLE playlist_lock_manager_t : public service_base
{
public:
virtual HRESULT LockPlaylist(const GUID & id, uint32_t filterMask) noexcept = 0;
virtual HRESULT UnlockPlaylist(const GUID & id) noexcept = 0;
virtual bool IsLockedByMe(const GUID & id) const noexcept = 0;
virtual HRESULT GetFilterMask(const GUID & id, uint32_t & filterMask) const noexcept = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_lock_manager_t);
};