|
1
|
1 #pragma once
|
|
|
2 #include "callback_merit.h"
|
|
|
3
|
|
|
4 class library_callback_dynamic; class library_callback_v2_dynamic;
|
|
|
5
|
|
|
6 /*!
|
|
|
7 This service implements methods allowing you to interact with the Media Library.\n
|
|
|
8 All methods are valid from main thread only, unless noted otherwise.\n
|
|
|
9 Usage: Use library_manager::get() to instantiate.
|
|
|
10 */
|
|
|
11
|
|
|
12 class NOVTABLE library_manager : public service_base {
|
|
|
13 FB2K_MAKE_SERVICE_COREAPI(library_manager);
|
|
|
14 public:
|
|
|
15 //! Interface for use with library_manager::enum_items().
|
|
|
16 class NOVTABLE enum_callback {
|
|
|
17 public:
|
|
|
18 //! Return true to continue enumeration, false to abort.
|
|
|
19 virtual bool on_item(const metadb_handle_ptr & p_item) = 0;
|
|
|
20 };
|
|
|
21
|
|
|
22 //! Returns whether the specified item is in the Media Library or not.
|
|
|
23 //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0
|
|
|
24 virtual bool is_item_in_library(const metadb_handle_ptr & p_item) = 0;
|
|
|
25 //! Returns whether current user settings allow the specified item to be added to the Media Library or not.
|
|
|
26 //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0
|
|
|
27 virtual bool is_item_addable(const metadb_handle_ptr & p_item) = 0;
|
|
|
28 //! Returns whether current user settings allow the specified item path to be added to the Media Library or not.
|
|
|
29 //! MAIN THREAD ONLY until foobar2000 v2.0; valid to call from anywhere since v2.0
|
|
|
30 virtual bool is_path_addable(const char * p_path) = 0;
|
|
|
31 //! Retrieves path of the specified item relative to the Media Library folder it is in. Returns true on success, false when the item is not in the Media Library.
|
|
|
32 //! SPECIAL WARNING: to allow multi-CPU optimizations to parse relative track paths, this API works in threads other than the main app thread. Main thread MUST be blocked while working in such scenarios, it's NOT safe to call from worker threads while the Media Library content/configuration might be getting altered.
|
|
|
33 //! foobar2000 v2.0 and newer: legal to call from any thread with no restrictions.
|
|
|
34 virtual bool get_relative_path(const metadb_handle_ptr & p_item,pfc::string_base & p_out) = 0;
|
|
|
35 //! Calls callback method for every item in the Media Library. Note that order of items in Media Library is undefined.
|
|
|
36 virtual void enum_items(enum_callback & p_callback) = 0;
|
|
|
37 protected:
|
|
|
38 //! OBSOLETE, do not call, does nothing.
|
|
|
39 FB2K_DEPRECATED virtual void add_items(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
|
|
|
40 //! OBSOLETE, do not call, does nothing.
|
|
|
41 FB2K_DEPRECATED virtual void remove_items(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
|
|
|
42 //! OBSOLETE, do not call, does nothing.
|
|
|
43 FB2K_DEPRECATED virtual void add_items_async(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
|
|
|
44
|
|
|
45 //! OBSOLETE, do not call, does nothing.
|
|
|
46 FB2K_DEPRECATED virtual void on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_data) = 0;
|
|
|
47 public:
|
|
|
48 //! Retrieves the entire Media Library content.
|
|
|
49 virtual void get_all_items(pfc::list_base_t<metadb_handle_ptr> & p_out) = 0;
|
|
|
50
|
|
|
51 //! Returns whether Media Library functionality is enabled or not (to be exact: whether there's at least one Media Library folder present in settings), for e.g. notifying the user to change settings when trying to use a Media Library viewer without having configured the Media Library first.
|
|
|
52 virtual bool is_library_enabled() = 0;
|
|
|
53 //! Pops up the Media Library preferences page.
|
|
|
54 virtual void show_preferences() = 0;
|
|
|
55
|
|
|
56 //! OBSOLETE, do not call.
|
|
|
57 virtual void rescan() = 0;
|
|
|
58
|
|
|
59 protected:
|
|
|
60 //! OBSOLETE, do not call, does nothing.
|
|
|
61 FB2K_DEPRECATED virtual void check_dead_entries(const pfc::list_base_t<metadb_handle_ptr> & p_list) = 0;
|
|
|
62 public:
|
|
|
63
|
|
|
64
|
|
|
65 };
|
|
|
66
|
|
|
67 //! \since 0.9.3
|
|
|
68 class NOVTABLE library_manager_v2 : public library_manager {
|
|
|
69 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v2,library_manager);
|
|
|
70 protected:
|
|
|
71 //! OBSOLETE, do not call, does nothing.
|
|
|
72 FB2K_DEPRECATED virtual bool is_rescan_running() = 0;
|
|
|
73
|
|
|
74 //! OBSOLETE, do not call, does nothing.
|
|
|
75 FB2K_DEPRECATED virtual void rescan_async(fb2k::hwnd_t p_parent,completion_notify_ptr p_notify) = 0;
|
|
|
76
|
|
|
77 //! OBSOLETE, do not call, does nothing.
|
|
|
78 FB2K_DEPRECATED virtual void check_dead_entries_async(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,fb2k::hwnd_t p_parent,completion_notify_ptr p_notify) = 0;
|
|
|
79
|
|
|
80
|
|
|
81 };
|
|
|
82
|
|
|
83
|
|
|
84 //! \since 0.9.5
|
|
|
85 class NOVTABLE library_manager_v3 : public library_manager_v2 {
|
|
|
86 public:
|
|
|
87 //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved tracks.
|
|
|
88 //! @returns True on success, false when the feature has not been configured.
|
|
|
89 virtual bool get_new_file_pattern_tracks(pfc::string_base & p_directory,pfc::string_base & p_format) = 0;
|
|
|
90 //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved full album images.
|
|
|
91 //! @returns True on success, false when the feature has not been configured.
|
|
|
92 virtual bool get_new_file_pattern_images(pfc::string_base & p_directory,pfc::string_base & p_format) = 0;
|
|
|
93
|
|
|
94 virtual void register_callback(library_callback_dynamic * p_callback) = 0;
|
|
|
95 virtual void unregister_callback(library_callback_dynamic * p_callback) = 0;
|
|
|
96
|
|
|
97 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v3,library_manager_v2);
|
|
|
98 };
|
|
|
99
|
|
|
100 //! \since 2.0
|
|
|
101 class NOVTABLE library_manager_v4 : public library_manager_v3 {
|
|
|
102 public:
|
|
|
103 virtual void register_callback_v2(library_callback_v2_dynamic*) = 0;
|
|
|
104 virtual void unregister_callback_v2(library_callback_v2_dynamic*) = 0;
|
|
|
105 virtual bool is_initialized() = 0;
|
|
|
106
|
|
|
107 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v4, library_manager_v3);
|
|
|
108 };
|
|
|
109
|
|
|
110 //! \since 2.0
|
|
|
111 class NOVTABLE library_manager_v5 : public library_manager_v4 {
|
|
|
112 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v5, library_manager_v4);
|
|
|
113 public:
|
|
|
114 //! foobar2000 v2.0 late addition: let callbacks know if the current notification comes from actual changed tags or a display hook operation. Returns 1 or 0 for true or false.
|
|
|
115 static const GUID status_current_callback_from_hook;
|
|
|
116
|
|
|
117 //! Extensible status query method. Returns 0 for unrecognized commands.
|
|
|
118 virtual size_t library_status(const GUID& arg, size_t arg1, void* arg2, size_t arg2bytes) = 0;
|
|
|
119
|
|
|
120 bool is_current_callback_from_hook() { return library_status(status_current_callback_from_hook, 0, nullptr, 0) != 0; }
|
|
|
121 };
|
|
|
122
|
|
|
123 //! \since 2.0
|
|
|
124 class NOVTABLE library_manager_v6 : public library_manager_v5 {
|
|
|
125 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(library_manager_v6, library_manager_v5);
|
|
|
126 public:
|
|
|
127 virtual void set_callback_merit(library_callback_v2_dynamic*, fb2k::callback_merit_t) = 0;
|
|
|
128 };
|
|
|
129
|
|
|
130 //! Implement this service to appear on "library viewers" list in Media Library preferences page.\n
|
|
|
131 //! Use library_viewer_factory_t to register.
|
|
|
132 class NOVTABLE library_viewer : public service_base {
|
|
|
133 public:
|
|
|
134 //! Retrieves GUID of your preferences page (pfc::guid_null if you don't have one).
|
|
|
135 virtual GUID get_preferences_page() = 0;
|
|
|
136 //! Queries whether "activate" action is supported (relevant button will be disabled if it's not).
|
|
|
137 virtual bool have_activate() = 0;
|
|
|
138 //! Activates your Media Library viewer component (e.g. shows its window).
|
|
|
139 virtual void activate() = 0;
|
|
|
140 //! Retrieves GUID of your library_viewer implementation, for internal identification. Note that this not the same as preferences page GUID.
|
|
|
141 virtual GUID get_guid() = 0;
|
|
|
142 //! Retrieves name of your Media Library viewer, a null-terminated UTF-8 encoded string.
|
|
|
143 virtual const char * get_name() = 0;
|
|
|
144
|
|
|
145 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_viewer);
|
|
|
146 };
|
|
|
147
|
|
|
148 template<typename T>
|
|
|
149 class library_viewer_factory_t : public service_factory_single_t<T> {};
|
|
|
150
|
|
|
151
|
|
|
152 //! \since 0.9.5.4
|
|
|
153 //! Allows you to spawn a popup Media Library Search window with any query string that you specify. \n
|
|
|
154 //! Usage: library_search_ui::get()->show("querygoeshere");
|
|
|
155 class NOVTABLE library_search_ui : public service_base {
|
|
|
156 public:
|
|
|
157 virtual void show(const char * query) = 0;
|
|
|
158
|
|
|
159 FB2K_MAKE_SERVICE_COREAPI(library_search_ui)
|
|
|
160 };
|
|
|
161
|
|
|
162 //! \since 0.9.6
|
|
|
163 class NOVTABLE library_file_move_scope : public service_base {
|
|
|
164 FB2K_MAKE_SERVICE_INTERFACE(library_file_move_scope, service_base)
|
|
|
165 public:
|
|
|
166 };
|
|
|
167
|
|
|
168 //! \since 0.9.6
|
|
|
169 class NOVTABLE library_file_move_manager : public service_base {
|
|
|
170 FB2K_MAKE_SERVICE_COREAPI(library_file_move_manager)
|
|
|
171 public:
|
|
|
172 virtual library_file_move_scope::ptr acquire_scope() = 0;
|
|
|
173 virtual bool is_move_in_progress() = 0;
|
|
|
174 };
|
|
|
175
|
|
|
176 //! \since 0.9.6
|
|
|
177 class NOVTABLE library_file_move_notify_ {
|
|
|
178 public:
|
|
|
179 virtual void on_state_change(bool isMoving) = 0;
|
|
|
180 };
|
|
|
181
|
|
|
182 //! \since 0.9.6
|
|
|
183 class NOVTABLE library_file_move_notify : public service_base, public library_file_move_notify_ {
|
|
|
184 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_file_move_notify)
|
|
|
185 public:
|
|
|
186 };
|
|
|
187
|
|
|
188
|
|
|
189 #ifdef _WIN32
|
|
|
190
|
|
|
191 //! \since 0.9.6.1
|
|
|
192 class NOVTABLE library_meta_autocomplete : public service_base {
|
|
|
193 FB2K_MAKE_SERVICE_COREAPI(library_meta_autocomplete)
|
|
|
194 public:
|
|
|
195 virtual bool get_value_list(const char * metaName, pfc::com_ptr_t<IUnknown> & out) = 0;
|
|
|
196 };
|
|
|
197
|
|
|
198 //! \since 1.6.1
|
|
|
199 //! Caching & asynchronous version. \n
|
|
|
200 //! Keep a reference to your library_meta_autocomplete_v2 object in your dialog class to cache the looked up values & speed up the operation.
|
|
|
201 class NOVTABLE library_meta_autocomplete_v2 : public service_base {
|
|
|
202 FB2K_MAKE_SERVICE_COREAPI(library_meta_autocomplete_v2)
|
|
|
203 public:
|
|
|
204 virtual bool get_value_list_async(const char* metaName, pfc::com_ptr_t<IUnknown>& out) = 0;
|
|
|
205 };
|
|
|
206
|
|
|
207 #endif // _WIN32
|
|
|
208
|