Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/playlist.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 | |
| 3 #include "titleformat.h" | |
| 4 #include "playback_control.h" | |
| 5 #include <functional> | |
| 6 #include "callback_merit.h" | |
| 7 | |
| 8 //! This interface allows filtering of playlist modification operations.\n | |
| 9 //! Implemented by components "locking" playlists; use playlist_manager::playlist_lock_install() etc to takeover specific playlist with your instance of playlist_lock. | |
| 10 class NOVTABLE playlist_lock : public service_base { | |
| 11 public: | |
| 12 enum { | |
| 13 filter_add = 1 << 0, | |
| 14 filter_remove = 1 << 1, | |
| 15 filter_reorder = 1 << 2, | |
| 16 filter_replace = 1 << 3, | |
| 17 filter_rename = 1 << 4, | |
| 18 filter_remove_playlist = 1 << 5, | |
| 19 filter_default_action = 1 << 6, | |
| 20 }; | |
| 21 | |
| 22 //! Queries whether specified item insertiion operation is allowed in the locked playlist. | |
| 23 //! @param p_base Index from which the items are being inserted. | |
| 24 //! @param p_data Items being inserted. | |
| 25 //! @param p_selection Caller-requested selection state of items being inserted. | |
| 26 //! @returns True to allow the operation, false to block it. | |
| 27 virtual bool query_items_add(t_size p_base, const pfc::list_base_const_t<metadb_handle_ptr> & p_data,const bit_array & p_selection) = 0; | |
| 28 //! Queries whether specified item reorder operation is allowed in the locked playlist. | |
| 29 //! @param p_order Pointer to array containing permutation defining requested reorder operation. | |
| 30 //! @param p_count Number of items in array pointed to by p_order. This should always be equal to number of items on the locked playlist. | |
| 31 //! @returns True to allow the operation, false to block it. | |
| 32 virtual bool query_items_reorder(const t_size * p_order,t_size p_count) = 0; | |
| 33 //! Queries whether specified item removal operation is allowed in the locked playlist. | |
| 34 //! @param p_mask Specifies which items from locked playlist are being removed. | |
| 35 //! @param p_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). | |
| 36 //! @returns True to allow the operation, false to block it. Note that return value is ignored if p_force is set to true. | |
| 37 virtual bool query_items_remove(const bit_array & p_mask,bool p_force) = 0; | |
| 38 //! Queries whether specified item replacement operation is allowed in the locked playlist. | |
| 39 //! @param p_index Index of the item being replaced. | |
| 40 //! @param p_old Old value of the item being replaced. | |
| 41 //! @param p_new New value of the item being replaced. | |
| 42 //! @returns True to allow the operation, false to block it. | |
| 43 virtual bool query_item_replace(t_size p_index,const metadb_handle_ptr & p_old,const metadb_handle_ptr & p_new)=0; | |
| 44 //! Queries whether renaming the locked playlist is allowed. | |
| 45 //! @param p_new_name Requested new name of the playlist; a UTF-8 encoded string. | |
| 46 //! @param p_new_name_len 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. | |
| 47 //! @returns True to allow the operation, false to block it. | |
| 48 virtual bool query_playlist_rename(const char * p_new_name,t_size p_new_name_len) = 0; | |
| 49 //! Queries whether removal of the locked playlist is allowed. Note that the lock will be released when the playlist is removed. | |
| 50 //! @returns True to allow the operation, false to block it. | |
| 51 virtual bool query_playlist_remove() = 0; | |
| 52 //! Executes "default action" (doubleclick etc) for specified playlist item. When the playlist is not locked, default action starts playback of the item. | |
| 53 //! @returns True if custom default action was executed, false to fall-through to default one for non-locked playlists (start playback). | |
| 54 virtual bool execute_default_action(t_size p_item) = 0; | |
| 55 //! Notifies lock about changed index of the playlist, in result of user reordering playlists or removing other playlists. | |
| 56 virtual void on_playlist_index_change(t_size p_new_index) = 0; | |
| 57 //! Notifies lock about the locked playlist getting removed. | |
| 58 virtual void on_playlist_remove() = 0; | |
| 59 //! Retrieves human-readable name of playlist lock to display. | |
| 60 virtual void get_lock_name(pfc::string_base & p_out) = 0; | |
| 61 //! Requests user interface of component controlling the playlist lock to be shown. | |
| 62 virtual void show_ui() = 0; | |
| 63 //! 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. | |
| 64 virtual t_uint32 get_filter_mask() = 0; | |
| 65 | |
| 66 FB2K_MAKE_SERVICE_INTERFACE(playlist_lock,service_base); | |
| 67 }; | |
| 68 | |
| 69 struct t_playback_queue_item { | |
| 70 metadb_handle_ptr m_handle; | |
| 71 t_size m_playlist,m_item; | |
| 72 | |
| 73 bool operator==(const t_playback_queue_item & p_item) const; | |
| 74 bool operator!=(const t_playback_queue_item & p_item) const; | |
| 75 }; | |
| 76 | |
| 77 | |
| 78 //! This service provides methods for all sorts of playlist interaction.\n | |
| 79 //! All playlist_manager methods are valid only from main app thread.\n | |
| 80 //! Usage: playlist_manager::get() to obtain an instance. | |
| 81 class NOVTABLE playlist_manager : public service_base | |
| 82 { | |
| 83 public: | |
| 84 | |
| 85 typedef std::function<bool(size_t, const metadb_handle_ptr&, bool) > enum_items_func; | |
| 86 | |
| 87 //! Callback interface for playlist enumeration methods. | |
| 88 class NOVTABLE enum_items_callback { | |
| 89 public: | |
| 90 //! @returns True to continue enumeration, false to abort. | |
| 91 virtual bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) = 0;//return false to stop | |
| 92 }; | |
| 93 | |
| 94 //! Retrieves number of playlists. | |
| 95 virtual t_size get_playlist_count() = 0; | |
| 96 //! Retrieves index of active playlist; infinite if no playlist is active. | |
| 97 virtual t_size get_active_playlist() = 0; | |
| 98 //! Sets active playlist (infinite to set no active playlist). | |
| 99 virtual void set_active_playlist(t_size p_index) = 0; | |
| 100 //! Retrieves playlist from which items to be played are taken from. | |
| 101 virtual t_size get_playing_playlist() = 0; | |
| 102 //! Sets playlist from which items to be played are taken from. | |
| 103 virtual void set_playing_playlist(t_size p_index) = 0; | |
| 104 //! Removes playlists according to specified mask. See also: bit_array. | |
| 105 virtual bool remove_playlists(const bit_array & p_mask) = 0; | |
| 106 //! Creates a new playlist. | |
| 107 //! @param p_name Name of playlist to create; a UTF-8 encoded string. | |
| 108 //! @param p_name_length Length limit of playlist 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. | |
| 109 //! @param p_index Index at which to insert new playlist; set to infinite to put it at the end of playlist list. | |
| 110 //! @returns Actual index of newly inserted playlist, infinite on failure (call from invalid context). | |
| 111 virtual t_size create_playlist(const char * p_name,t_size p_name_length,t_size p_index) = 0; | |
| 112 //! Reorders the playlist list according to specified permutation. | |
| 113 //! @returns True on success, false on failure (call from invalid context). | |
| 114 virtual bool reorder(const t_size * p_order,t_size p_count) = 0; | |
| 115 | |
| 116 | |
| 117 //! Retrieves number of items on specified playlist. | |
| 118 virtual t_size playlist_get_item_count(t_size p_playlist) = 0; | |
| 119 //! Enumerates contents of specified playlist. | |
| 120 virtual void playlist_enum_items(t_size p_playlist,enum_items_callback & p_callback,const bit_array & p_mask) = 0; | |
| 121 void playlist_enum_items(size_t which, enum_items_func, const bit_array&); | |
| 122 //! Retrieves index of focus item on specified playlist; returns infinite when no item has focus. | |
| 123 virtual t_size playlist_get_focus_item(t_size p_playlist) = 0; | |
| 124 //! Retrieves name of specified playlist. Should never fail unless the parameters are invalid. | |
| 125 virtual bool playlist_get_name(t_size p_playlist,pfc::string_base & p_out) = 0; | |
| 126 | |
| 127 //! Reorders items in specified playlist according to specified permutation. | |
| 128 virtual bool playlist_reorder_items(t_size p_playlist,const t_size * p_order,t_size p_count) = 0; | |
| 129 //! Selects/deselects items on specified playlist. | |
| 130 //! @param p_playlist Index of playlist to alter. | |
| 131 //! @param p_affected Mask of items to alter. | |
| 132 //! @param p_status Mask of selected/deselected state to apply to items specified by p_affected. | |
| 133 virtual void playlist_set_selection(t_size p_playlist,const bit_array & p_affected,const bit_array & p_status) = 0; | |
| 134 //! Removes specified items from specified playlist. Returns true on success or false on failure (playlist locked). | |
| 135 virtual bool playlist_remove_items(t_size p_playlist,const bit_array & mask)=0; | |
| 136 //! Replaces specified item on specified playlist. Returns true on success or false on failure (playlist locked). | |
| 137 virtual bool playlist_replace_item(t_size p_playlist,t_size p_item,const metadb_handle_ptr & p_new_item) = 0; | |
| 138 //! Sets index of focus item on specified playlist; use infinite to set no focus item. | |
| 139 virtual void playlist_set_focus_item(t_size p_playlist,t_size p_item) = 0; | |
| 140 //! Inserts new items into specified playlist, at specified position. | |
| 141 virtual t_size playlist_insert_items(t_size p_playlist,t_size p_base,const pfc::list_base_const_t<metadb_handle_ptr> & data,const bit_array & p_selection) = 0; | |
| 142 //! Tells playlist renderers to make sure that specified item is visible. | |
| 143 virtual void playlist_ensure_visible(t_size p_playlist,t_size p_item) = 0; | |
| 144 //! Renames specified playlist. | |
| 145 //! @param p_name New name of playlist; a UTF-8 encoded string. | |
| 146 //! @param p_name_length Length limit of playlist 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. | |
| 147 //! @returns True on success, false on failure (playlist locked). | |
| 148 virtual bool playlist_rename(t_size p_index,const char * p_name,t_size p_name_length) = 0; | |
| 149 | |
| 150 | |
| 151 //! Creates an undo restore point for specified playlist. | |
| 152 virtual void playlist_undo_backup(t_size p_playlist) = 0; | |
| 153 //! Reverts specified playlist to last undo restore point and generates a redo restore point. | |
| 154 //! @returns True on success, false on failure (playlist locked or no restore point available). | |
| 155 virtual bool playlist_undo_restore(t_size p_playlist) = 0; | |
| 156 //! Reverts specified playlist to next redo restore point and generates an undo restore point. | |
| 157 //! @returns True on success, false on failure (playlist locked or no restore point available). | |
| 158 virtual bool playlist_redo_restore(t_size p_playlist) = 0; | |
| 159 //! Returns whether an undo restore point is available for specified playlist. | |
| 160 virtual bool playlist_is_undo_available(t_size p_playlist) = 0; | |
| 161 //! Returns whether a redo restore point is available for specified playlist. | |
| 162 virtual bool playlist_is_redo_available(t_size p_playlist) = 0; | |
| 163 | |
| 164 //! Renders information about specified playlist item, using specified titleformatting script parameters. | |
| 165 //! @param p_playlist Index of playlist containing item being processed. | |
| 166 //! @param p_item Index of item being processed in the playlist containing it. | |
| 167 //! @param p_hook Titleformatting script hook to use; see titleformat_hook documentation for more info. Set to NULL when hook functionality is not needed. | |
| 168 //! @param p_out String object receiving results. | |
| 169 //! @param p_script Compiled titleformatting script to use; see titleformat_object cocumentation for more info. | |
| 170 //! @param p_filter Text filter to use; see titleformat_text_filter documentation for more info. Set to NULL when text filter functionality is not needed. | |
| 171 //! @param p_playback_info_level Level of playback related information requested. See playback_control::t_display_level documentation for more info. | |
| 172 virtual void playlist_item_format_title(t_size p_playlist,t_size p_item,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t<titleformat_object> & p_script,titleformat_text_filter * p_filter,playback_control::t_display_level p_playback_info_level)=0; | |
| 173 | |
| 174 | |
| 175 //! Retrieves playlist position of currently playing item. | |
| 176 //! @param p_playlist Receives index of playlist containing currently playing item on success. | |
| 177 //! @param p_index Receives index of currently playing item in the playlist that contains it on success. | |
| 178 //! @returns True on success, false on failure (not playing or currently played item has been removed from the playlist it was on when starting). | |
| 179 virtual bool get_playing_item_location(t_size * p_playlist,t_size * p_index) = 0; | |
| 180 | |
| 181 //! Sorts specified playlist - entire playlist or selection only - by specified title formatting pattern, or randomizes the order. | |
| 182 //! @param p_playlist Index of playlist to alter. | |
| 183 //! @param p_pattern Title formatting pattern to sort by (an UTF-8 encoded null-termindated string). Set to NULL to randomize the order of items. | |
| 184 //! @param p_sel_only Set to false to sort/randomize whole playlist, or to true to sort/randomize only selection on the playlist. | |
| 185 //! @returns True on success, false on failure (playlist locked etc). | |
| 186 virtual bool playlist_sort_by_format(t_size p_playlist,const char * p_pattern,bool p_sel_only) = 0; | |
| 187 | |
| 188 //! For internal use only; p_items must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. | |
| 189 virtual void on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_items) = 0; | |
| 190 //! For internal use only; p_from must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. | |
| 191 virtual void on_files_moved_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) = 0; | |
| 192 | |
| 193 virtual bool playlist_lock_install(t_size p_playlist,const service_ptr_t<playlist_lock> & p_lock) = 0;//returns false when invalid playlist or already locked | |
| 194 virtual bool playlist_lock_uninstall(t_size p_playlist,const service_ptr_t<playlist_lock> & p_lock) = 0; | |
| 195 virtual bool playlist_lock_is_present(t_size p_playlist) = 0; | |
| 196 virtual bool playlist_lock_query_name(t_size p_playlist,pfc::string_base & p_out) = 0; | |
| 197 virtual bool playlist_lock_show_ui(t_size p_playlist) = 0; | |
| 198 virtual t_uint32 playlist_lock_get_filter_mask(t_size p_playlist) = 0; | |
| 199 | |
| 200 | |
| 201 //! Retrieves number of available playback order modes. | |
| 202 virtual t_size playback_order_get_count() = 0; | |
| 203 //! Retrieves name of specified playback order move. | |
| 204 //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. | |
| 205 //! @returns Null-terminated UTF-8 encoded string containing name of the playback order mode. Returned pointer points to statically allocated string and can be safely stored without having to free it later. | |
| 206 virtual const char * playback_order_get_name(t_size p_index) = 0; | |
| 207 //! Retrieves GUID of specified playback order mode. Used for managing playback modes without relying on names. | |
| 208 //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. | |
| 209 virtual GUID playback_order_get_guid(t_size p_index) = 0; | |
| 210 //! Retrieves index of active playback order mode. | |
| 211 virtual t_size playback_order_get_active() = 0; | |
| 212 //! Sets index of active playback order mode. | |
| 213 virtual void playback_order_set_active(t_size p_index) = 0; | |
| 214 | |
| 215 virtual void queue_remove_mask(bit_array const & p_mask) = 0; | |
| 216 virtual void queue_add_item_playlist(t_size p_playlist,t_size p_item) = 0; | |
| 217 virtual void queue_add_item(metadb_handle_ptr p_item) = 0; | |
| 218 virtual t_size queue_get_count() = 0; | |
| 219 virtual void queue_get_contents(pfc::list_base_t<t_playback_queue_item> & p_out) = 0; | |
| 220 //! Returns index (0-based) on success, infinite on failure (item not in queue). | |
| 221 virtual t_size queue_find_index(t_playback_queue_item const & p_item) = 0; | |
| 222 | |
| 223 //! Registers a playlist callback; registered object receives notifications about any modifications of any of loaded playlists. | |
| 224 //! @param p_callback Callback interface to register. | |
| 225 //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. | |
| 226 virtual void register_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; | |
| 227 //! Registers a playlist callback; registered object receives notifications about any modifications of active playlist. | |
| 228 //! @param p_callback Callback interface to register. | |
| 229 //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback_single::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. | |
| 230 virtual void register_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; | |
| 231 //! Unregisters a playlist callback (playlist_callback version). | |
| 232 virtual void unregister_callback(class playlist_callback * p_callback) = 0; | |
| 233 //! Unregisters a playlist callback (playlist_callback_single version). | |
| 234 virtual void unregister_callback(class playlist_callback_single * p_callback) = 0; | |
| 235 //! Modifies flags indicating which calback methods are requested (playlist_callback version). | |
| 236 virtual void modify_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; | |
| 237 //! Modifies flags indicating which calback methods are requested (playlist_callback_single version). | |
| 238 virtual void modify_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; | |
| 239 | |
| 240 //! Executes default doubleclick/enter action for specified item on specified playlist (starts playing the item unless overridden by a lock to do something else). | |
| 241 virtual bool playlist_execute_default_action(t_size p_playlist,t_size p_item) = 0; | |
| 242 | |
| 243 | |
| 244 //! Helper; removes all items from the playback queue. | |
| 245 void queue_flush() {queue_remove_mask(pfc::bit_array_true());} | |
| 246 //! Helper; returns whether there are items in the playback queue. | |
| 247 bool queue_is_active() {return queue_get_count() > 0;} | |
| 248 | |
| 249 //! Helper; highlights currently playing item; returns true on success or false on failure (not playing or currently played item has been removed from playlist since playback started). | |
| 250 bool highlight_playing_item(); | |
| 251 //! Helper; removes single playlist of specified index. | |
| 252 bool remove_playlist(t_size p_playlist); | |
| 253 //! Helper; removes single playlist of specified index, and switches to another playlist when possible. | |
| 254 bool remove_playlist_switch(t_size p_playlist); | |
| 255 //! Helper; removes a playlist switching to another; gracefully refuses to remove the only playlist. \n | |
| 256 //! It is recommended to call this as a result of user input requesting playlist removal. \n | |
| 257 //! Do not call MessageBeep() etc when it returns false, the function handles these for you. | |
| 258 bool remove_playlist_user(size_t which); | |
| 259 bool remove_playlist_user(); | |
| 260 | |
| 261 //! Helper; returns whether specified item on specified playlist is selected or not. | |
| 262 bool playlist_is_item_selected(t_size p_playlist,t_size p_item); | |
| 263 //! Helper; retrieves metadb_handle of the specified playlist item. Returns true on success, false on failure (invalid parameters). | |
| 264 bool playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item); | |
| 265 //! Helper; retrieves metadb_handle of the specified playlist item; throws pfc::exception_invalid_params() on failure. | |
| 266 metadb_handle_ptr playlist_get_item_handle(t_size playlist, t_size item); | |
| 267 | |
| 268 //! Moves selected items up/down in the playlist by specified offset. | |
| 269 //! @param p_playlist Index of playlist to alter. | |
| 270 //! @param p_delta Offset to move items by. Set it to a negative valuye to move up, or to a positive value to move down. | |
| 271 //! @returns True on success, false on failure (e.g. playlist locked). | |
| 272 bool playlist_move_selection(t_size p_playlist,int p_delta); | |
| 273 //! Retrieves selection map of specific playlist, using bit_array_var interface. | |
| 274 void playlist_get_selection_mask(t_size p_playlist,bit_array_var & out); | |
| 275 void playlist_get_items(t_size p_playlist,pfc::list_base_t<metadb_handle_ptr> & out,const bit_array & p_mask); | |
| 276 void playlist_get_all_items(t_size p_playlist,pfc::list_base_t<metadb_handle_ptr> & out); | |
| 277 void playlist_get_selected_items(t_size p_playlist,pfc::list_base_t<metadb_handle_ptr> & out); | |
| 278 | |
| 279 //! Clears contents of specified playlist (removes all items from it). | |
| 280 void playlist_clear(t_size p_playlist); | |
| 281 bool playlist_add_items(t_size playlist,const pfc::list_base_const_t<metadb_handle_ptr> & data,const bit_array & p_selection); | |
| 282 void playlist_clear_selection(t_size p_playlist); | |
| 283 void playlist_remove_selection(t_size p_playlist,bool p_crop = false); | |
| 284 | |
| 285 | |
| 286 //! Changes contents of the specified playlist to the specified items, trying to reuse existing playlist content as much as possible (preserving selection/focus/etc). Order of items in playlist not guaranteed to be the same as in the specified item list. | |
| 287 //! @returns true if the playlist has been altered, false if there was nothing to update. | |
| 288 bool playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup); | |
| 289 | |
| 290 //retrieving status | |
| 291 t_size activeplaylist_get_item_count(); | |
| 292 void activeplaylist_enum_items(enum_items_callback & p_callback,const bit_array & p_mask); | |
| 293 void activeplaylist_enum_items(enum_items_func, const bit_array&); | |
| 294 t_size activeplaylist_get_focus_item();//focus may be infinite if no item is focused | |
| 295 bool activeplaylist_get_name(pfc::string_base & p_out); | |
| 296 | |
| 297 //modifying playlist | |
| 298 bool activeplaylist_reorder_items(const t_size * order,t_size count); | |
| 299 void activeplaylist_set_selection(const bit_array & affected,const bit_array & status); | |
| 300 bool activeplaylist_remove_items(const bit_array & mask); | |
| 301 bool activeplaylist_replace_item(t_size p_item,const metadb_handle_ptr & p_new_item); | |
| 302 void activeplaylist_set_focus_item(t_size p_item); | |
| 303 t_size activeplaylist_insert_items(t_size p_base,const pfc::list_base_const_t<metadb_handle_ptr> & data,const bit_array & p_selection); | |
| 304 void activeplaylist_ensure_visible(t_size p_item); | |
| 305 bool activeplaylist_rename(const char * p_name,t_size p_name_len); | |
| 306 | |
| 307 void activeplaylist_undo_backup(); | |
| 308 bool activeplaylist_undo_restore(); | |
| 309 bool activeplaylist_redo_restore(); | |
| 310 | |
| 311 bool activeplaylist_is_item_selected(t_size p_item); | |
| 312 bool activeplaylist_get_item_handle(metadb_handle_ptr & item,t_size p_item); | |
| 313 metadb_handle_ptr activeplaylist_get_item_handle(t_size p_item); | |
| 314 void activeplaylist_move_selection(int p_delta); | |
| 315 void activeplaylist_get_selection_mask(bit_array_var & out); | |
| 316 void activeplaylist_get_items(pfc::list_base_t<metadb_handle_ptr> & out,const bit_array & p_mask); | |
| 317 void activeplaylist_get_all_items(pfc::list_base_t<metadb_handle_ptr> & out); | |
| 318 void activeplaylist_get_selected_items(pfc::list_base_t<metadb_handle_ptr> & out); | |
| 319 void activeplaylist_clear(); | |
| 320 | |
| 321 bool activeplaylist_add_items(const pfc::list_base_const_t<metadb_handle_ptr> & data,const bit_array & p_selection); | |
| 322 | |
| 323 bool playlist_insert_items_filter(t_size p_playlist,t_size p_base,const pfc::list_base_const_t<metadb_handle_ptr> & p_data,bool p_select); | |
| 324 bool activeplaylist_insert_items_filter(t_size p_base,const pfc::list_base_const_t<metadb_handle_ptr> & p_data,bool p_select); | |
| 325 | |
| 326 //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible | |
| 327 bool playlist_insert_locations(t_size p_playlist,t_size p_base,const pfc::list_base_const_t<const char*> & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); | |
| 328 //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible | |
| 329 bool activeplaylist_insert_locations(t_size p_base,const pfc::list_base_const_t<const char*> & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); | |
| 330 | |
| 331 bool playlist_add_items_filter(t_size p_playlist,const pfc::list_base_const_t<metadb_handle_ptr> & p_data,bool p_select); | |
| 332 bool activeplaylist_add_items_filter(const pfc::list_base_const_t<metadb_handle_ptr> & p_data,bool p_select); | |
| 333 | |
| 334 bool playlist_add_locations(t_size p_playlist,const pfc::list_base_const_t<const char*> & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); | |
| 335 bool activeplaylist_add_locations(const pfc::list_base_const_t<const char*> & p_urls,bool p_select,fb2k::hwnd_t p_parentwnd); | |
| 336 | |
| 337 void reset_playing_playlist(); | |
| 338 | |
| 339 void activeplaylist_clear_selection(); | |
| 340 void activeplaylist_remove_selection(bool p_crop = false); | |
| 341 | |
| 342 void activeplaylist_item_format_title(t_size p_item,titleformat_hook * p_hook,pfc::string_base & out,const service_ptr_t<titleformat_object> & p_script,titleformat_text_filter * p_filter,play_control::t_display_level p_playback_info_level); | |
| 343 | |
| 344 void playlist_set_selection_single(t_size p_playlist,t_size p_item,bool p_state); | |
| 345 void activeplaylist_set_selection_single(t_size p_item,bool p_state); | |
| 346 | |
| 347 t_size playlist_get_selection_count(t_size p_playlist,t_size p_max); | |
| 348 t_size activeplaylist_get_selection_count(t_size p_max); | |
| 349 | |
| 350 bool playlist_get_focus_item_handle(metadb_handle_ptr & p_item,t_size p_playlist); | |
| 351 bool activeplaylist_get_focus_item_handle(metadb_handle_ptr & item); | |
| 352 | |
| 353 t_size find_playlist(const char * p_name,t_size p_name_length = ~0); | |
| 354 t_size find_or_create_playlist(const char * p_name,t_size p_name_length = ~0); | |
| 355 t_size find_or_create_playlist_unlocked(const char * p_name,t_size p_name_length = ~0); | |
| 356 | |
| 357 t_size create_playlist_autoname(t_size p_index = ~0); | |
| 358 | |
| 359 bool activeplaylist_sort_by_format(const char * spec,bool p_sel_only); | |
| 360 | |
| 361 t_uint32 activeplaylist_lock_get_filter_mask(); | |
| 362 bool activeplaylist_is_undo_available(); | |
| 363 bool activeplaylist_is_redo_available(); | |
| 364 | |
| 365 bool activeplaylist_execute_default_action(t_size p_item); | |
| 366 | |
| 367 void remove_items_from_all_playlists(const pfc::list_base_const_t<metadb_handle_ptr> & p_data); | |
| 368 | |
| 369 void active_playlist_fix(); | |
| 370 | |
| 371 bool get_all_items(pfc::list_base_t<metadb_handle_ptr> & out); | |
| 372 | |
| 373 void playlist_activate_delta(int p_delta); | |
| 374 void playlist_activate_next() {playlist_activate_delta(1);} | |
| 375 void playlist_activate_previous() {playlist_activate_delta(-1);} | |
| 376 | |
| 377 | |
| 378 t_size playlist_get_selected_count(t_size p_playlist,bit_array const & p_mask); | |
| 379 t_size activeplaylist_get_selected_count(bit_array const & p_mask) {return playlist_get_selected_count(get_active_playlist(),p_mask);} | |
| 380 | |
| 381 bool playlist_find_item(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist | |
| 382 bool playlist_find_item_selected(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist | |
| 383 t_size playlist_set_focus_by_handle(t_size p_playlist,metadb_handle_ptr p_item); | |
| 384 bool activeplaylist_find_item(metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist | |
| 385 t_size activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item); | |
| 386 | |
| 387 static void g_make_selection_move_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta); | |
| 388 | |
| 389 //! Helper to update playlists after rechaptering a file. \n | |
| 390 //! You typically want to call metadb_io_v2::on_file_rechaptered() instead, as it will forcibly reload info first. | |
| 391 void on_file_rechaptered(const char * path, metadb_handle_list_cref items); | |
| 392 void on_files_rechaptered( metadb_handle_list_cref newHandles ); | |
| 393 | |
| 394 FB2K_MAKE_SERVICE_COREAPI(playlist_manager); | |
| 395 }; | |
| 396 | |
| 397 //! Extension of the playlist_manager service that manages playlist properties. | |
| 398 //! Playlist properties come in two flavors: persistent and runtime. | |
| 399 //! Persistent properties are blocks of binary that that will be preserved when the application is exited and restarted. | |
| 400 //! Runtime properties are service pointers that will be lost when the application exits. | |
| 401 //! \since 0.9.5 | |
| 402 class NOVTABLE playlist_manager_v2 : public playlist_manager { | |
| 403 public: | |
| 404 //! Write a persistent playlist property. | |
| 405 //! \param p_playlist Index of the playlist | |
| 406 //! \param p_property GUID that identifies the property | |
| 407 //! \param p_stream stream that contains the data that will be associated with the property | |
| 408 //! \param p_abort abort_callback that will be used when reading from p_stream | |
| 409 virtual void playlist_set_property(t_size p_playlist,const GUID & p_property,stream_reader * p_stream,t_size p_size_hint,abort_callback & p_abort) = 0; | |
| 410 //! Read a persistent playlist property. | |
| 411 //! \param p_playlist Index of the playlist | |
| 412 //! \param p_property GUID that identifies the property | |
| 413 //! \param p_stream stream that will receive the stored data | |
| 414 //! \param p_abort abort_callback that will be used when writing to p_stream | |
| 415 //! \return true if the property exists, false otherwise | |
| 416 virtual bool playlist_get_property(t_size p_playlist,const GUID & p_property,stream_writer * p_stream,abort_callback & p_abort) = 0; | |
| 417 //! Test existence of a persistent playlist property. | |
| 418 //! \param p_playlist Index of the playlist | |
| 419 //! \param p_property GUID that identifies the property | |
| 420 //! \return true if the property exists, false otherwise | |
| 421 virtual bool playlist_have_property(t_size p_playlist,const GUID & p_property) = 0; | |
| 422 //! Remove a persistent playlist property. | |
| 423 //! \param p_playlist Index of the playlist | |
| 424 //! \param p_property GUID that identifies the property | |
| 425 //! \return true if the property existed, false otherwise | |
| 426 virtual bool playlist_remove_property(t_size p_playlist,const GUID & p_property) = 0; | |
| 427 | |
| 428 //! Write a runtime playlist property. | |
| 429 //! \param p_playlist Index of the playlist | |
| 430 //! \param p_property GUID that identifies the property | |
| 431 //! \param p_data service pointer that will be associated with the property | |
| 432 virtual void playlist_set_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t<service_base> p_data) = 0; | |
| 433 //! Read a runtime playlist property. | |
| 434 //! \param p_playlist Index of the playlist | |
| 435 //! \param p_property GUID that identifies the property | |
| 436 //! \param p_data base service pointer reference that will receive the stored servive pointer | |
| 437 //! \return true if the property exists, false otherwise | |
| 438 virtual bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t<service_base> & p_data) = 0; | |
| 439 //! Test existence of a runtime playlist property. | |
| 440 //! \param p_playlist Index of the playlist | |
| 441 //! \param p_property GUID that identifies the property | |
| 442 //! \return true if the property exists, false otherwise | |
| 443 virtual bool playlist_have_runtime_property(t_size p_playlist,const GUID & p_property) = 0; | |
| 444 //! Remove a runtime playlist property. | |
| 445 //! \param p_playlist Index of the playlist | |
| 446 //! \param p_property GUID that identifies the property | |
| 447 //! \return true if the property existed, false otherwise | |
| 448 virtual bool playlist_remove_runtime_property(t_size p_playlist,const GUID & p_property) = 0; | |
| 449 | |
| 450 //! Write a persistent playlist property. | |
| 451 //! \param p_playlist Index of the playlist | |
| 452 //! \param p_property GUID that identifies the property | |
| 453 //! \param p_data array that contains the data that will be associated with the property | |
| 454 template<typename t_array> void playlist_set_property(t_size p_playlist,const GUID & p_property,const t_array & p_data) { | |
| 455 PFC_STATIC_ASSERT( sizeof(p_data[0]) == 1 ); | |
| 456 stream_reader_memblock_ref reader(p_data); | |
| 457 playlist_set_property(p_playlist,p_property,&reader,p_data.get_size(),fb2k::noAbort); | |
| 458 } | |
| 459 //! Read a persistent playlist property. | |
| 460 //! \param p_playlist Index of the playlist | |
| 461 //! \param p_property GUID that identifies the property | |
| 462 //! \param p_data array that will receive the stored data | |
| 463 //! \return true if the property exists, false otherwise | |
| 464 template<typename t_array> bool playlist_get_property(t_size p_playlist,const GUID & p_property,t_array & p_data) { | |
| 465 PFC_STATIC_ASSERT( sizeof(p_data[0]) == 1 ); | |
| 466 typedef pfc::array_t<t_uint8,pfc::alloc_fast_aggressive> t_temp; | |
| 467 t_temp temp; | |
| 468 { | |
| 469 stream_writer_buffer_append_ref_t<t_temp> reader(temp); | |
| 470 if (!playlist_get_property(p_playlist,p_property,&reader,fb2k::noAbort)) return false; | |
| 471 } | |
| 472 p_data = temp; | |
| 473 return true; | |
| 474 } | |
| 475 pfc::array_t<uint8_t> playlist_get_property(t_size playlist, const GUID& prop) { | |
| 476 pfc::array_t<uint8_t> ret; | |
| 477 this->playlist_get_property(playlist, prop, ret); | |
| 478 return ret; | |
| 479 } | |
| 480 //! Read a runtime playlist property. | |
| 481 //! \param p_playlist Index of the playlist | |
| 482 //! \param p_property GUID that identifies the property | |
| 483 //! \param p_data specific service pointer reference that will receive the stored servive pointer | |
| 484 //! \return true if the property exists and can be converted to the type of p_data, false otherwise | |
| 485 template<typename _t_interface> bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t<_t_interface> & p_data) { | |
| 486 service_ptr_t<service_base> ptr; | |
| 487 if (!playlist_get_runtime_property(p_playlist,p_property,ptr)) return false; | |
| 488 return ptr->service_query_t(p_data); | |
| 489 } | |
| 490 | |
| 491 //! Write a persistent playlist property. | |
| 492 //! \param p_playlist Index of the playlist | |
| 493 //! \param p_property GUID that identifies the property | |
| 494 //! \param p_value integer that will be associated with the property | |
| 495 template<typename _t_int> | |
| 496 void playlist_set_property_int(t_size p_playlist,const GUID & p_property,_t_int p_value) { | |
| 497 pfc::array_t<t_uint8> temp; temp.set_size(sizeof(_t_int)); | |
| 498 pfc::encode_little_endian(temp.get_ptr(),p_value); | |
| 499 playlist_set_property(p_playlist,p_property,temp); | |
| 500 } | |
| 501 //! Read a persistent playlist property. | |
| 502 //! \param p_playlist Index of the playlist | |
| 503 //! \param p_property GUID that identifies the property | |
| 504 //! \param p_value integer reference that will receive the stored data | |
| 505 //! \return true if the property exists and if the data is compatible with p_value, false otherwise | |
| 506 template<typename _t_int> | |
| 507 bool playlist_get_property_int(t_size p_playlist,const GUID & p_property,_t_int & p_value) { | |
| 508 pfc::array_t<t_uint8> temp; | |
| 509 if (!playlist_get_property(p_playlist,p_property,temp)) return false; | |
| 510 if (temp.get_size() != sizeof(_t_int)) return false; | |
| 511 pfc::decode_little_endian(p_value,temp.get_ptr()); | |
| 512 return true; | |
| 513 } | |
| 514 | |
| 515 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v2,playlist_manager) | |
| 516 }; | |
| 517 | |
| 518 //! \since 0.9.5 | |
| 519 class NOVTABLE playlist_manager_v3 : public playlist_manager_v2 { | |
| 520 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v3,playlist_manager_v2) | |
| 521 public: | |
| 522 virtual t_size recycler_get_count() = 0; | |
| 523 virtual void recycler_get_content(t_size which, metadb_handle_list_ref out) = 0; | |
| 524 virtual void recycler_get_name(t_size which, pfc::string_base & out) = 0; | |
| 525 virtual t_uint32 recycler_get_id(t_size which) = 0; | |
| 526 virtual void recycler_purge(const bit_array & mask) = 0; | |
| 527 virtual void recycler_restore(t_size which) = 0; | |
| 528 | |
| 529 void recycler_restore_by_id(t_uint32 id); | |
| 530 t_size recycler_find_by_id(t_uint32 id); | |
| 531 }; | |
| 532 | |
| 533 //! \since 0.9.5.4 | |
| 534 class NOVTABLE playlist_manager_v4 : public playlist_manager_v3 { | |
| 535 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v4, playlist_manager_v3) | |
| 536 public: | |
| 537 virtual void playlist_get_sideinfo(t_size which, stream_writer * stream, abort_callback & abort) = 0; | |
| 538 virtual t_size create_playlist_ex(const char * p_name,t_size p_name_length,t_size p_index, metadb_handle_list_cref content, stream_reader * sideInfo, abort_callback & abort) = 0; | |
| 539 }; | |
| 540 | |
| 541 //! \since 2.0 | |
| 542 class NOVTABLE playlist_manager_v5 : public playlist_manager_v4 { | |
| 543 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v5, playlist_manager_v4) | |
| 544 public: | |
| 545 virtual GUID playlist_get_guid(size_t idx) = 0; | |
| 546 virtual size_t find_playlist_by_guid(const GUID&) = 0; | |
| 547 }; | |
| 548 | |
| 549 //! \since 2.0 beta 8 | |
| 550 class NOVTABLE playlist_manager_v6 : public playlist_manager_v5 { | |
| 551 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_manager_v6, playlist_manager_v5); | |
| 552 public: | |
| 553 virtual void set_callback_merit(class playlist_callback*, fb2k::callback_merit_t) = 0; | |
| 554 virtual void set_callback_merit(class playlist_callback_single*, fb2k::callback_merit_t) = 0; | |
| 555 | |
| 556 }; | |
| 557 | |
| 558 // IMPLEMENTATION NOTE: all playlist_callback methods could not be declared noexcept for historical reasons, but it's strongly recommended that your overrides of these methods are noexcept. | |
| 559 | |
| 560 class NOVTABLE playlist_callback | |
| 561 { | |
| 562 public: | |
| 563 virtual void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t<metadb_handle_ptr> & p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) | |
| 564 virtual void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order | |
| 565 virtual void on_items_removing(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them | |
| 566 virtual void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; | |
| 567 virtual void on_items_selection_change(t_size p_playlist,const bit_array & p_affected,const bit_array & p_state) = 0; | |
| 568 virtual void on_item_focus_change(t_size p_playlist,t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks | |
| 569 | |
| 570 virtual void on_items_modified(t_size p_playlist,const bit_array & p_mask)=0; | |
| 571 virtual void on_items_modified_fromplayback(t_size p_playlist,const bit_array & p_mask,play_control::t_display_level p_level)=0; | |
| 572 | |
| 573 struct t_on_items_replaced_entry | |
| 574 { | |
| 575 t_size m_index; | |
| 576 metadb_handle_ptr m_old,m_new; | |
| 577 }; | |
| 578 | |
| 579 virtual void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t<t_on_items_replaced_entry> & p_data)=0; | |
| 580 | |
| 581 virtual void on_item_ensure_visible(t_size p_playlist,t_size p_idx)=0; | |
| 582 | |
| 583 virtual void on_playlist_activate(t_size p_old,t_size p_new) = 0; | |
| 584 virtual void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) = 0; | |
| 585 virtual void on_playlists_reorder(const t_size * p_order,t_size p_count) = 0; | |
| 586 virtual void on_playlists_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; | |
| 587 virtual void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; | |
| 588 virtual void on_playlist_renamed(t_size p_index,const char * p_new_name,t_size p_new_name_len) = 0; | |
| 589 | |
| 590 virtual void on_default_format_changed() = 0; | |
| 591 virtual void on_playback_order_changed(t_size p_new_index) = 0; | |
| 592 virtual void on_playlist_locked(t_size p_playlist,bool p_locked) = 0; | |
| 593 | |
| 594 enum { | |
| 595 flag_on_items_added = 1 << 0, | |
| 596 flag_on_items_reordered = 1 << 1, | |
| 597 flag_on_items_removing = 1 << 2, | |
| 598 flag_on_items_removed = 1 << 3, | |
| 599 flag_on_items_selection_change = 1 << 4, | |
| 600 flag_on_item_focus_change = 1 << 5, | |
| 601 flag_on_items_modified = 1 << 6, | |
| 602 flag_on_items_modified_fromplayback = 1 << 7, | |
| 603 flag_on_items_replaced = 1 << 8, | |
| 604 flag_on_item_ensure_visible = 1 << 9, | |
| 605 flag_on_playlist_activate = 1 << 10, | |
| 606 flag_on_playlist_created = 1 << 11, | |
| 607 flag_on_playlists_reorder = 1 << 12, | |
| 608 flag_on_playlists_removing = 1 << 13, | |
| 609 flag_on_playlists_removed = 1 << 14, | |
| 610 flag_on_playlist_renamed = 1 << 15, | |
| 611 flag_on_default_format_changed = 1 << 16, | |
| 612 flag_on_playback_order_changed = 1 << 17, | |
| 613 flag_on_playlist_locked = 1 << 18, | |
| 614 | |
| 615 flag_all = ~0, | |
| 616 flag_item_ops = flag_on_items_added | flag_on_items_reordered | flag_on_items_removing | flag_on_items_removed | flag_on_items_selection_change | flag_on_item_focus_change | flag_on_items_modified | flag_on_items_modified_fromplayback | flag_on_items_replaced | flag_on_item_ensure_visible, | |
| 617 flag_playlist_ops = flag_on_playlist_activate | flag_on_playlist_created | flag_on_playlists_reorder | flag_on_playlists_removing | flag_on_playlists_removed | flag_on_playlist_renamed | flag_on_playlist_locked, | |
| 618 }; | |
| 619 protected: | |
| 620 playlist_callback() {} | |
| 621 ~playlist_callback() {} | |
| 622 }; | |
| 623 | |
| 624 class NOVTABLE playlist_callback_static : public service_base, public playlist_callback | |
| 625 { | |
| 626 public: | |
| 627 virtual unsigned get_flags() = 0; | |
| 628 | |
| 629 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_static); | |
| 630 }; | |
| 631 | |
| 632 class NOVTABLE playlist_callback_single | |
| 633 { | |
| 634 public: | |
| 635 virtual void on_items_added(t_size p_base, metadb_handle_list_cref p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) | |
| 636 virtual void on_items_reordered(const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order | |
| 637 virtual void on_items_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them | |
| 638 virtual void on_items_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; | |
| 639 virtual void on_items_selection_change(const bit_array & p_affected,const bit_array & p_state) = 0; | |
| 640 virtual void on_item_focus_change(t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks | |
| 641 virtual void on_items_modified(const bit_array & p_mask)=0; | |
| 642 virtual void on_items_modified_fromplayback(const bit_array & p_mask,play_control::t_display_level p_level)=0; | |
| 643 virtual void on_items_replaced(const bit_array & p_mask,const pfc::list_base_const_t<playlist_callback::t_on_items_replaced_entry> & p_data)=0; | |
| 644 virtual void on_item_ensure_visible(t_size p_idx)=0; | |
| 645 | |
| 646 virtual void on_playlist_switch() = 0; | |
| 647 virtual void on_playlist_renamed(const char * p_new_name,t_size p_new_name_len) = 0; | |
| 648 virtual void on_playlist_locked(bool p_locked) = 0; | |
| 649 | |
| 650 virtual void on_default_format_changed() = 0; | |
| 651 virtual void on_playback_order_changed(t_size p_new_index) = 0; | |
| 652 | |
| 653 enum { | |
| 654 flag_on_items_added = 1 << 0, | |
| 655 flag_on_items_reordered = 1 << 1, | |
| 656 flag_on_items_removing = 1 << 2, | |
| 657 flag_on_items_removed = 1 << 3, | |
| 658 flag_on_items_selection_change = 1 << 4, | |
| 659 flag_on_item_focus_change = 1 << 5, | |
| 660 flag_on_items_modified = 1 << 6, | |
| 661 flag_on_items_modified_fromplayback = 1 << 7, | |
| 662 flag_on_items_replaced = 1 << 8, | |
| 663 flag_on_item_ensure_visible = 1 << 9, | |
| 664 flag_on_playlist_switch = 1 << 10, | |
| 665 flag_on_playlist_renamed = 1 << 11, | |
| 666 flag_on_playlist_locked = 1 << 12, | |
| 667 flag_on_default_format_changed = 1 << 13, | |
| 668 flag_on_playback_order_changed = 1 << 14, | |
| 669 flag_all = ~0, | |
| 670 }; | |
| 671 protected: | |
| 672 playlist_callback_single() {} | |
| 673 ~playlist_callback_single() {} | |
| 674 }; | |
| 675 | |
| 676 //! playlist_callback implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! | |
| 677 class playlist_callback_impl_base : public playlist_callback { | |
| 678 public: | |
| 679 playlist_callback_impl_base(t_uint32 p_flags = 0) { | |
| 680 playlist_manager::get()->register_callback(this,p_flags); | |
| 681 } | |
| 682 ~playlist_callback_impl_base() { | |
| 683 playlist_manager::get()->unregister_callback(this); | |
| 684 } | |
| 685 void set_callback_flags(t_uint32 p_flags) { | |
| 686 playlist_manager::get()->modify_callback(this,p_flags); | |
| 687 } | |
| 688 //dummy implementations - avoid possible pure virtual function calls! | |
| 689 void on_items_added(t_size p_playlist, t_size p_start, metadb_handle_list_cref p_data, const bit_array& p_selection) override { (void)p_playlist; (void)p_start; (void)p_data; (void)p_selection; } | |
| 690 void on_items_reordered(t_size p_playlist, const t_size* p_order, t_size p_count) override { (void)p_playlist; (void)p_order; (void)p_count; } | |
| 691 void on_items_removing(t_size p_playlist, const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_playlist; (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 692 void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) override { (void)p_playlist; (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 693 void on_items_selection_change(t_size p_playlist, const bit_array& p_affected, const bit_array& p_state) override { (void)p_playlist; (void)p_affected; (void)p_state; } | |
| 694 void on_item_focus_change(t_size p_playlist, t_size p_from, t_size p_to) override { (void)p_playlist; (void)p_from; (void)p_to; } | |
| 695 | |
| 696 void on_items_modified(t_size p_playlist, const bit_array& p_mask) override { (void)p_playlist; (void)p_mask; } | |
| 697 void on_items_modified_fromplayback(t_size p_playlist, const bit_array& p_mask, play_control::t_display_level p_level) override { (void)p_playlist; (void)p_mask; (void)p_level; } | |
| 698 | |
| 699 void on_items_replaced(t_size p_playlist, const bit_array& p_mask, const pfc::list_base_const_t<t_on_items_replaced_entry>& p_data) override { (void)p_playlist; (void)p_mask; (void)p_data; } | |
| 700 | |
| 701 void on_item_ensure_visible(t_size p_playlist, t_size p_idx) override { (void)p_playlist; (void)p_idx; } | |
| 702 | |
| 703 void on_playlist_activate(t_size p_old, t_size p_new) override { (void)p_old; (void)p_new; } | |
| 704 void on_playlist_created(t_size p_index, const char* p_name, t_size p_name_len) override { (void)p_index; (void)p_name; (void)p_name_len; } | |
| 705 void on_playlists_reorder(const t_size* p_order, t_size p_count) override { (void)p_order; (void)p_count; } | |
| 706 void on_playlists_removing(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 707 void on_playlists_removed(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 708 void on_playlist_renamed(t_size p_index, const char* p_new_name, t_size p_new_name_len) override { (void)p_index; (void)p_new_name; (void)p_new_name_len; } | |
| 709 | |
| 710 void on_default_format_changed() override {} | |
| 711 void on_playback_order_changed(t_size p_new_index) override { (void)p_new_index; } | |
| 712 void on_playlist_locked(t_size p_playlist, bool p_locked) override { (void)p_playlist; (void)p_locked; } | |
| 713 }; | |
| 714 | |
| 715 //! playlist_callback_single implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! | |
| 716 class playlist_callback_single_impl_base : public playlist_callback_single { | |
| 717 protected: | |
| 718 playlist_callback_single_impl_base(t_uint32 p_flags = 0) { | |
| 719 playlist_manager::get()->register_callback(this,p_flags); | |
| 720 } | |
| 721 void set_callback_flags(t_uint32 p_flags) { | |
| 722 playlist_manager::get()->modify_callback(this,p_flags); | |
| 723 } | |
| 724 ~playlist_callback_single_impl_base() { | |
| 725 playlist_manager::get()->unregister_callback(this); | |
| 726 } | |
| 727 | |
| 728 //dummy implementations - avoid possible pure virtual function calls! | |
| 729 void on_items_added(t_size p_base, metadb_handle_list_cref p_data, const bit_array& p_selection) override { (void)p_base; (void)p_data; (void)p_selection; } | |
| 730 void on_items_reordered(const t_size* p_order, t_size p_count) override { (void)p_order; (void)p_count; } | |
| 731 void on_items_removing(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 732 void on_items_removed(const bit_array& p_mask, t_size p_old_count, t_size p_new_count) override { (void)p_mask; (void)p_old_count; (void)p_new_count; } | |
| 733 void on_items_selection_change(const bit_array& p_affected, const bit_array& p_state) override { (void)p_affected; (void)p_state; } | |
| 734 void on_item_focus_change(t_size p_from, t_size p_to) override { (void)p_from; (void)p_to; } | |
| 735 void on_items_modified(const bit_array& p_mask) override { (void)p_mask; } | |
| 736 void on_items_modified_fromplayback(const bit_array& p_mask, play_control::t_display_level p_level) override { (void)p_mask; (void)p_level; } | |
| 737 void on_items_replaced(const bit_array& p_mask, const pfc::list_base_const_t<playlist_callback::t_on_items_replaced_entry>& p_data) override { (void)p_mask; (void)p_data; } | |
| 738 void on_item_ensure_visible(t_size p_idx) override { (void)p_idx; } | |
| 739 | |
| 740 void on_playlist_switch() override {} | |
| 741 void on_playlist_renamed(const char* p_new_name, t_size p_new_name_len) override { (void)p_new_name; (void)p_new_name_len; } | |
| 742 void on_playlist_locked(bool p_locked) override { (void)p_locked; } | |
| 743 | |
| 744 void on_default_format_changed() override {} | |
| 745 void on_playback_order_changed(t_size p_new_index) override { (void)p_new_index; } | |
| 746 | |
| 747 PFC_CLASS_NOT_COPYABLE(playlist_callback_single_impl_base,playlist_callback_single_impl_base); | |
| 748 }; | |
| 749 | |
| 750 class playlist_callback_single_static : public service_base, public playlist_callback_single | |
| 751 { | |
| 752 public: | |
| 753 virtual unsigned get_flags() = 0; | |
| 754 | |
| 755 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_single_static); | |
| 756 }; | |
| 757 | |
| 758 | |
| 759 //! Class used for async processing of IDataObject. Content of IDataObject can be dumped into dropped_files_data without any time-consuming operations - won't block calling app when used inside drag&drop handler - and actual time-consuming processing (listing directories and reading infos) can be done later.\n | |
| 760 //! \deprecated In 0.9.3 and up, instead of going thru dropped_files_data, you can use playlist_incoming_item_filter_v2::process_dropped_files_async(). | |
| 761 class NOVTABLE dropped_files_data { | |
| 762 public: | |
| 763 virtual void set_paths(pfc::string_list_const const & p_paths) = 0; | |
| 764 virtual void set_handles(const pfc::list_base_const_t<metadb_handle_ptr> & p_handles) = 0; | |
| 765 protected: | |
| 766 dropped_files_data() {} | |
| 767 ~dropped_files_data() {} | |
| 768 }; | |
| 769 | |
| 770 | |
| 771 class NOVTABLE playlist_incoming_item_filter : public service_base { | |
| 772 FB2K_MAKE_SERVICE_COREAPI(playlist_incoming_item_filter); | |
| 773 public: | |
| 774 //! Pre-sorts incoming items according to user-configured settings, removes duplicates. \n | |
| 775 //! As of 1.4, this is the same as sort_by_pointer_remove_duplicates() + sort_by_format( get_incoming_item_sorter() ), see playlist_incoming_item_filter_v4 \n | |
| 776 //! This method is valid in main thread only. However, using playlist_incoming_item_filter_v4::get_incoming_item_sorter() lets you do the same off main thread. | |
| 777 //! @param in Items to process. | |
| 778 //! @param out Receives processed item list. \n | |
| 779 //! @returns True when there's one or more item in the output list, false when the output list is empty. | |
| 780 virtual bool filter_items(metadb_handle_list_cref in,metadb_handle_list_ref out) = 0; | |
| 781 | |
| 782 //! Converts one or more paths to a list of metadb_handles; displays a progress dialog.\n | |
| 783 //! Note that this function creates modal dialog and does not return until the operation has completed. | |
| 784 //! @returns True on success, false on user abort. | |
| 785 //! \deprecated Use playlist_incoming_item_filter_v2::process_locations_async() when possible. | |
| 786 virtual bool process_locations(const pfc::list_base_const_t<const char*> & p_urls,pfc::list_base_t<metadb_handle_ptr> & p_out,bool p_filter,const char * p_restrict_mask_override, const char * p_exclude_mask_override,fb2k::hwnd_t p_parentwnd) = 0; | |
| 787 | |
| 788 #ifdef _WIN32 | |
| 789 //! Converts an IDataObject to a list of metadb_handles. | |
| 790 //! Using this function is strongly disrecommended as it implies blocking the drag&drop source app (as well as our app).\n | |
| 791 //! @returns True on success, false on user abort or unknown data format. | |
| 792 //! \deprecated Use playlist_incoming_item_filter_v2::process_dropped_files_async() when possible. | |
| 793 virtual bool process_dropped_files(interface IDataObject * pDataObject,pfc::list_base_t<metadb_handle_ptr> & p_out,bool p_filter,HWND p_parentwnd) = 0; | |
| 794 | |
| 795 //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles. | |
| 796 virtual bool process_dropped_files_check(interface IDataObject * pDataObject) = 0; | |
| 797 | |
| 798 //! Checks whether IDataObject contains our own private data format (drag&drop within the app etc). | |
| 799 virtual bool process_dropped_files_check_if_native(interface IDataObject * pDataObject) = 0; | |
| 800 | |
| 801 //! Creates an IDataObject from specified metadb_handle list. The caller is responsible for releasing the returned object. It is recommended that you use create_dataobject_ex() to get an autopointer that ensures proper deletion. | |
| 802 virtual interface IDataObject * create_dataobject(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0; | |
| 803 | |
| 804 //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles.\n | |
| 805 //! This function also returns drop effects to use (see: IDropTarget::DragEnter(), IDropTarget::DragOver() ). In certain cases, drag effects are necessary for drag&drop to work at all (such as dragging links from IE).\n | |
| 806 virtual bool process_dropped_files_check_ex(interface IDataObject * pDataObject, DWORD * p_effect) = 0; | |
| 807 | |
| 808 //! Dumps IDataObject content to specified dropped_files_data object, without any time-consuming processing.\n | |
| 809 //! Using this function instead of process_dropped_files() and processing dropped_files_data outside drop handler allows you to avoid blocking drop source app when processing large directories etc.\n | |
| 810 //! Note: since 0.9.3, it is recommended to use playlist_incoming_item_filter_v2::process_dropped_files_async() instead. | |
| 811 //! @returns True on success, false when IDataObject does not contain any of known data formats. | |
| 812 virtual bool process_dropped_files_delayed(dropped_files_data & p_out,interface IDataObject * pDataObject) = 0; | |
| 813 #endif // _WIN32 | |
| 814 //! Helper - calls process_locations() with a single URL. See process_locations() for more info. | |
| 815 bool process_location(const char * url,pfc::list_base_t<metadb_handle_ptr> & out,bool filter,const char * p_mask,const char * p_exclude,fb2k::hwnd_t p_parentwnd); | |
| 816 | |
| 817 #ifdef _WIN32 | |
| 818 //! Helper - returns a pfc::com_ptr_t<> rather than a raw pointer. | |
| 819 pfc::com_ptr_t<interface IDataObject> create_dataobject_ex(metadb_handle_list_cref data); | |
| 820 #endif // _WIN32 | |
| 821 }; | |
| 822 | |
| 823 //! For use with playlist_incoming_item_filter_v2::process_locations_async(). | |
| 824 //! \since 0.9.3 | |
| 825 class NOVTABLE process_locations_notify : public service_base { | |
| 826 FB2K_MAKE_SERVICE_INTERFACE(process_locations_notify, service_base); | |
| 827 public: | |
| 828 virtual void on_completion(metadb_handle_list_cref p_items) = 0; | |
| 829 virtual void on_aborted() = 0; | |
| 830 | |
| 831 typedef std::function<void(metadb_handle_list_cref)> func_t; | |
| 832 static process_locations_notify::ptr create(func_t); | |
| 833 }; | |
| 834 | |
| 835 typedef service_ptr_t<process_locations_notify> process_locations_notify_ptr; | |
| 836 | |
| 837 //! \since 0.9.3 | |
| 838 class NOVTABLE playlist_incoming_item_filter_v2 : public playlist_incoming_item_filter { | |
| 839 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v2, playlist_incoming_item_filter) | |
| 840 public: | |
| 841 enum { | |
| 842 //! Set this to disable presorting (according to user settings) and duplicate removal in output list. Should be unset in most cases. | |
| 843 op_flag_no_filter = 1 << 0, | |
| 844 //! Set this flag to make the progress dialog not steal focus on creation. | |
| 845 op_flag_background = 1 << 1, | |
| 846 //! Set this flag to delay the progress dialog becoming visible, so it does not appear at all during short operations. Also implies op_flag_background effect. | |
| 847 op_flag_delay_ui = 1 << 2, | |
| 848 }; | |
| 849 | |
| 850 //! Converts one or more paths to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. | |
| 851 //! @param p_urls List of paths to process. | |
| 852 //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. | |
| 853 //! @param p_restrict_mask_override Override of "restrict incoming items to" setting. Pass NULL to use the value from preferences. | |
| 854 //! @param p_exclude_mask_override Override of "exclude file types" setting. Pass NULL to use value from preferences. | |
| 855 //! @param p_parentwnd Parent window for spawned progress dialogs. | |
| 856 //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. | |
| 857 virtual void process_locations_async(const pfc::list_base_const_t<const char*> & p_urls,t_uint32 p_op_flags,const char * p_restrict_mask_override, const char * p_exclude_mask_override,fb2k::hwnd_t p_parentwnd,process_locations_notify_ptr p_notify) = 0; | |
| 858 | |
| 859 #ifdef _WIN32 | |
| 860 //! Converts an IDataObject to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. | |
| 861 //! @param p_dataobject IDataObject to process. | |
| 862 //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. | |
| 863 //! @param p_parentwnd Parent window for spawned progress dialogs. | |
| 864 //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. | |
| 865 virtual void process_dropped_files_async(interface IDataObject * p_dataobject,t_uint32 p_op_flags,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0; | |
| 866 #endif // _WIN32 | |
| 867 }; | |
| 868 | |
| 869 //! \since 0.9.5 | |
| 870 class playlist_incoming_item_filter_v3 : public playlist_incoming_item_filter_v2 { | |
| 871 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v3, playlist_incoming_item_filter_v2) | |
| 872 public: | |
| 873 virtual bool auto_playlist_name(metadb_handle_list_cref data,pfc::string_base & out) = 0; | |
| 874 }; | |
| 875 | |
| 876 //! \since 1.4 | |
| 877 class playlist_incoming_item_filter_v4 : public playlist_incoming_item_filter_v3 { | |
| 878 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(playlist_incoming_item_filter_v4, playlist_incoming_item_filter_v3); | |
| 879 public: | |
| 880 //! Retrieves title formatting pattern for sorting incoming files. \n | |
| 881 //! Valid from main thread only - however you can use the value for off-main-thread operations. | |
| 882 virtual void get_incoming_item_sort_pattern( pfc::string_base & out ) = 0; | |
| 883 //! Retrieves shared title formatting object for sorting incoming files. \n | |
| 884 //! This is the same as compiling the string returned from get_incoming_item_sort_pattern, except the returned object is shared with others using this API. \n | |
| 885 //! Valid from main thread only - however you can use the returned object for off-main-thread operations. | |
| 886 virtual titleformat_object::ptr get_incoming_item_sorter() = 0; | |
| 887 }; | |
| 888 | |
| 889 //! Implementation of dropped_files_data. | |
| 890 class dropped_files_data_impl : public dropped_files_data { | |
| 891 public: | |
| 892 dropped_files_data_impl() : m_is_paths(false) {} | |
| 893 void set_paths(pfc::string_list_const const & p_paths) { | |
| 894 m_is_paths = true; | |
| 895 m_paths = p_paths; | |
| 896 } | |
| 897 void set_paths(pfc::string_list_impl && paths) { | |
| 898 m_paths = std::move(paths); | |
| 899 m_is_paths = true; | |
| 900 } | |
| 901 void set_handles(const pfc::list_base_const_t<metadb_handle_ptr> & p_handles) { | |
| 902 m_is_paths = false; | |
| 903 m_handles = p_handles; | |
| 904 } | |
| 905 | |
| 906 void to_handles_async(bool p_filter,fb2k::hwnd_t p_parentwnd,service_ptr_t<process_locations_notify> p_notify); | |
| 907 //! @param p_op_flags Can be null, or one or more of playlist_incoming_item_filter_v2::op_flag_* enum values combined, altering behaviors of the operation. | |
| 908 void to_handles_async_ex(t_uint32 p_op_flags,fb2k::hwnd_t p_parentwnd,service_ptr_t<process_locations_notify> p_notify); | |
| 909 bool to_handles(pfc::list_base_t<metadb_handle_ptr> & p_out,bool p_filter,fb2k::hwnd_t p_parentwnd); | |
| 910 private: | |
| 911 pfc::string_list_impl m_paths; | |
| 912 metadb_handle_list m_handles; | |
| 913 bool m_is_paths; | |
| 914 }; | |
| 915 | |
| 916 | |
| 917 class NOVTABLE playback_queue_callback : public service_base | |
| 918 { | |
| 919 public: | |
| 920 enum t_change_origin { | |
| 921 changed_user_added, | |
| 922 changed_user_removed, | |
| 923 changed_playback_advance, | |
| 924 }; | |
| 925 virtual void on_changed(t_change_origin p_origin) = 0; | |
| 926 | |
| 927 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_queue_callback); | |
| 928 }; | |
| 929 | |
| 930 | |
| 931 class playlist_lock_change_notify : private playlist_callback_single_impl_base { | |
| 932 public: | |
| 933 playlist_lock_change_notify() : playlist_callback_single_impl_base(flag_on_playlist_switch|flag_on_playlist_locked) {} | |
| 934 protected: | |
| 935 virtual void on_lock_state_change() {} | |
| 936 bool is_playlist_command_available(t_uint32 what) const { | |
| 937 auto api = playlist_manager::get(); | |
| 938 const t_size active = api->get_active_playlist(); | |
| 939 if (active == SIZE_MAX) return false; | |
| 940 return (api->playlist_lock_get_filter_mask(active) & what) == 0; | |
| 941 } | |
| 942 private: | |
| 943 void on_playlist_switch() override {on_lock_state_change();} | |
| 944 void on_playlist_locked(bool) override {on_lock_state_change();} | |
| 945 }; |
