Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/ole_interaction.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 #ifdef _WIN32 | |
| 4 | |
| 5 #include "mem_block_container.h" | |
| 6 #include "playlist.h" | |
| 7 | |
| 8 class NOVTABLE playlist_dataobject_desc { | |
| 9 public: | |
| 10 virtual t_size get_entry_count() const = 0; | |
| 11 virtual void get_entry_name(t_size which, pfc::string_base & out) const = 0; | |
| 12 virtual void get_entry_content(t_size which, metadb_handle_list_ref out) const = 0; | |
| 13 | |
| 14 virtual void set_entry_count(t_size count) = 0; | |
| 15 virtual void set_entry_name(t_size which, const char * name) = 0; | |
| 16 virtual void set_entry_content(t_size which, metadb_handle_list_cref content) = 0; | |
| 17 | |
| 18 void copy(playlist_dataobject_desc const & source) { | |
| 19 const t_size count = source.get_entry_count(); set_entry_count(count); | |
| 20 metadb_handle_list content; pfc::string8 name; | |
| 21 for(t_size walk = 0; walk < count; ++walk) { | |
| 22 source.get_entry_name(walk,name); source.get_entry_content(walk,content); | |
| 23 set_entry_name(walk,name); set_entry_content(walk,content); | |
| 24 } | |
| 25 } | |
| 26 protected: | |
| 27 ~playlist_dataobject_desc() {} | |
| 28 private: | |
| 29 const playlist_dataobject_desc & operator=(const playlist_dataobject_desc &) {return *this;} | |
| 30 }; | |
| 31 | |
| 32 class NOVTABLE playlist_dataobject_desc_v2 : public playlist_dataobject_desc { | |
| 33 public: | |
| 34 virtual void get_side_data(t_size which, mem_block_container & out) const = 0; | |
| 35 virtual void set_side_data(t_size which, const void * data, t_size size) = 0; | |
| 36 | |
| 37 void copy(playlist_dataobject_desc_v2 const & source) { | |
| 38 const t_size count = source.get_entry_count(); set_entry_count(count); | |
| 39 metadb_handle_list content; pfc::string8 name; | |
| 40 mem_block_container_impl_t<pfc::alloc_fast_aggressive> sideData; | |
| 41 for(t_size walk = 0; walk < count; ++walk) { | |
| 42 source.get_entry_name(walk,name); source.get_entry_content(walk,content); source.get_side_data(walk, sideData); | |
| 43 set_entry_name(walk,name); set_entry_content(walk,content); set_side_data(walk, sideData.get_ptr(), sideData.get_size()); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 void set_from_playlist_manager(bit_array const & mask) { | |
| 48 auto api = playlist_manager_v4::get(); | |
| 49 const t_size pltotal = api->get_playlist_count(); | |
| 50 const t_size total = mask.calc_count(true,0,pltotal); | |
| 51 set_entry_count(total); | |
| 52 t_size done = 0; | |
| 53 pfc::string8 name; metadb_handle_list content; | |
| 54 for(t_size walk = 0; walk < pltotal; ++walk) if (mask[walk]) { | |
| 55 pfc::dynamic_assert( done < total ); | |
| 56 api->playlist_get_name(walk,name); api->playlist_get_all_items(walk,content); | |
| 57 set_entry_name(done,name); set_entry_content(done,content); | |
| 58 stream_writer_buffer_simple sideData; api->playlist_get_sideinfo(walk, &sideData, fb2k::noAbort); | |
| 59 set_side_data(done,sideData.m_buffer.get_ptr(), sideData.m_buffer.get_size()); | |
| 60 ++done; | |
| 61 } | |
| 62 pfc::dynamic_assert( done == total ); | |
| 63 } | |
| 64 | |
| 65 const playlist_dataobject_desc_v2 & operator=(const playlist_dataobject_desc_v2& source) {copy(source); return *this;} | |
| 66 protected: | |
| 67 ~playlist_dataobject_desc_v2() {} | |
| 68 }; | |
| 69 | |
| 70 class playlist_dataobject_desc_impl : public playlist_dataobject_desc_v2 { | |
| 71 public: | |
| 72 playlist_dataobject_desc_impl() {} | |
| 73 playlist_dataobject_desc_impl(const playlist_dataobject_desc_v2 & source) {copy(source);} | |
| 74 | |
| 75 t_size get_entry_count() const {return m_entries.get_size();} | |
| 76 void get_entry_name(t_size which, pfc::string_base & out) const { | |
| 77 if (which < m_entries.get_size()) out = m_entries[which].m_name; | |
| 78 else throw pfc::exception_invalid_params(); | |
| 79 } | |
| 80 void get_entry_content(t_size which, metadb_handle_list_ref out) const { | |
| 81 if (which < m_entries.get_size()) out = m_entries[which].m_content; | |
| 82 else throw pfc::exception_invalid_params(); | |
| 83 } | |
| 84 void set_entry_count(t_size count) { | |
| 85 m_entries.set_size(count); | |
| 86 } | |
| 87 void set_entry_name(t_size which, const char * name) { | |
| 88 if (which < m_entries.get_size()) m_entries[which].m_name = name; | |
| 89 else throw pfc::exception_invalid_params(); | |
| 90 } | |
| 91 void set_entry_content(t_size which, metadb_handle_list_cref content) { | |
| 92 if (which < m_entries.get_size()) m_entries[which].m_content = content; | |
| 93 else throw pfc::exception_invalid_params(); | |
| 94 } | |
| 95 void get_side_data(t_size which, mem_block_container & out) const { | |
| 96 if (which < m_entries.get_size()) out.set(m_entries[which].m_sideData); | |
| 97 else throw pfc::exception_invalid_params(); | |
| 98 } | |
| 99 void set_side_data(t_size which, const void * data, t_size size) { | |
| 100 if (which < m_entries.get_size()) m_entries[which].m_sideData.set_data_fromptr(reinterpret_cast<const t_uint8*>(data), size); | |
| 101 else throw pfc::exception_invalid_params(); | |
| 102 } | |
| 103 private: | |
| 104 struct entry { metadb_handle_list m_content; pfc::string8 m_name; pfc::array_t<t_uint8> m_sideData; }; | |
| 105 pfc::array_t<entry> m_entries; | |
| 106 }; | |
| 107 | |
| 108 //! \since 0.9.5 | |
| 109 //! Provides various methods for interaction between foobar2000 and OLE IDataObjects, Windows Clipboard, drag&drop and such. \n | |
| 110 //! To instantiate, use ole_interaction::get(). | |
| 111 class NOVTABLE ole_interaction : public service_base { | |
| 112 FB2K_MAKE_SERVICE_COREAPI(ole_interaction) | |
| 113 public: | |
| 114 enum { | |
| 115 KClipboardFormatSimpleLocations, | |
| 116 KClipboardFormatFPL, | |
| 117 KClipboardFormatMultiFPL, | |
| 118 KClipboardFormatTotal | |
| 119 }; | |
| 120 //! Retrieves clipboard format ID for one of foobar2000's internal data formats. | |
| 121 //! @param which One of KClipboardFormat* constants. | |
| 122 virtual t_uint32 get_clipboard_format(t_uint32 which) = 0; | |
| 123 | |
| 124 //! Creates an IDataObject from a group of tracks. | |
| 125 virtual pfc::com_ptr_t<IDataObject> create_dataobject(metadb_handle_list_cref source) = 0; | |
| 126 | |
| 127 //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. | |
| 128 virtual pfc::com_ptr_t<IDataObject> create_dataobject(const playlist_dataobject_desc & source) = 0; | |
| 129 | |
| 130 //! Attempts to parse an IDataObject as playlists. | |
| 131 virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj, playlist_dataobject_desc & out) = 0; | |
| 132 | |
| 133 //! For internal use only. Will succeed only if the metadb_handle list can be generated immediately, without performing potentially timeconsuming tasks such as parsing media files (for an example when the specified IDataObject contains data in one of our internal formats). | |
| 134 virtual HRESULT parse_dataobject_immediate(pfc::com_ptr_t<IDataObject> obj, metadb_handle_list_ref out) = 0; | |
| 135 | |
| 136 //! Attempts to parse an IDataObject into a dropped_files_data object (list of metadb_handles if immediately available, list of file paths otherwise). | |
| 137 virtual HRESULT parse_dataobject(pfc::com_ptr_t<IDataObject> obj, dropped_files_data & out) = 0; | |
| 138 | |
| 139 //! Checks whether the specified IDataObject appears to be parsable by our parse_dataobject methods. | |
| 140 virtual HRESULT check_dataobject(pfc::com_ptr_t<IDataObject> obj, DWORD & dropEffect, bool & isNative) = 0; | |
| 141 | |
| 142 //! Checks whether the specified IDataObject appears to be parsable as playlists (parse_dataobject_playlists method). | |
| 143 virtual HRESULT check_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj) = 0; | |
| 144 }; | |
| 145 | |
| 146 //! \since 0.9.5.4 | |
| 147 class NOVTABLE ole_interaction_v2 : public ole_interaction { | |
| 148 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(ole_interaction_v2, ole_interaction) | |
| 149 public: | |
| 150 //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. | |
| 151 virtual pfc::com_ptr_t<IDataObject> create_dataobject(const playlist_dataobject_desc_v2 & source) = 0; | |
| 152 | |
| 153 //! Attempts to parse an IDataObject as playlists. | |
| 154 virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj, playlist_dataobject_desc_v2 & out) = 0; | |
| 155 }; | |
| 156 | |
| 157 #endif // _WIN32 | |
| 158 |
