foobar2000 SDK  2015-08-03
ole_interaction.h
Go to the documentation of this file.
1 class NOVTABLE playlist_dataobject_desc {
2 public:
3  virtual t_size get_entry_count() const = 0;
4  virtual void get_entry_name(t_size which, pfc::string_base & out) const = 0;
5  virtual void get_entry_content(t_size which, metadb_handle_list_ref out) const = 0;
6 
7  virtual void set_entry_count(t_size count) = 0;
8  virtual void set_entry_name(t_size which, const char * name) = 0;
9  virtual void set_entry_content(t_size which, metadb_handle_list_cref content) = 0;
10 
11  void copy(playlist_dataobject_desc const & source) {
12  const t_size count = source.get_entry_count(); set_entry_count(count);
13  metadb_handle_list content; pfc::string8 name;
14  for(t_size walk = 0; walk < count; ++walk) {
15  source.get_entry_name(walk,name); source.get_entry_content(walk,content);
16  set_entry_name(walk,name); set_entry_content(walk,content);
17  }
18  }
19 protected:
21 private:
23 };
24 
26 public:
27  virtual void get_side_data(t_size which, mem_block_container & out) const = 0;
28  virtual void set_side_data(t_size which, const void * data, t_size size) = 0;
29 
30  void copy(playlist_dataobject_desc_v2 const & source) {
31  const t_size count = source.get_entry_count(); set_entry_count(count);
32  metadb_handle_list content; pfc::string8 name;
34  for(t_size walk = 0; walk < count; ++walk) {
35  source.get_entry_name(walk,name); source.get_entry_content(walk,content); source.get_side_data(walk, sideData);
36  set_entry_name(walk,name); set_entry_content(walk,content); set_side_data(walk, sideData.get_ptr(), sideData.get_size());
37  }
38  }
39 
40  void set_from_playlist_manager(bit_array const & mask) {
42  const t_size pltotal = api->get_playlist_count();
43  const t_size total = mask.calc_count(true,0,pltotal);
44  set_entry_count(total);
45  t_size done = 0;
46  pfc::string8 name; metadb_handle_list content;
48  for(t_size walk = 0; walk < pltotal; ++walk) if (mask[walk]) {
49  pfc::dynamic_assert( done < total );
50  api->playlist_get_name(walk,name); api->playlist_get_all_items(walk,content);
51  set_entry_name(done,name); set_entry_content(done,content);
52  stream_writer_buffer_simple sideData; api->playlist_get_sideinfo(walk, &sideData, abort);
53  set_side_data(done,sideData.m_buffer.get_ptr(), sideData.m_buffer.get_size());
54  ++done;
55  }
56  pfc::dynamic_assert( done == total );
57  }
58 
59  const playlist_dataobject_desc_v2 & operator=(const playlist_dataobject_desc_v2& source) {copy(source); return *this;}
60 protected:
62 };
63 
65 public:
68 
69  t_size get_entry_count() const {return m_entries.get_size();}
70  void get_entry_name(t_size which, pfc::string_base & out) const {
71  if (which < m_entries.get_size()) out = m_entries[which].m_name;
72  else throw pfc::exception_invalid_params();
73  }
75  if (which < m_entries.get_size()) out = m_entries[which].m_content;
76  else throw pfc::exception_invalid_params();
77  }
78  void set_entry_count(t_size count) {
79  m_entries.set_size(count);
80  }
81  void set_entry_name(t_size which, const char * name) {
82  if (which < m_entries.get_size()) m_entries[which].m_name = name;
83  else throw pfc::exception_invalid_params();
84  }
86  if (which < m_entries.get_size()) m_entries[which].m_content = content;
87  else throw pfc::exception_invalid_params();
88  }
89  void get_side_data(t_size which, mem_block_container & out) const {
90  if (which < m_entries.get_size()) out.set(m_entries[which].m_sideData);
91  else throw pfc::exception_invalid_params();
92  }
93  void set_side_data(t_size which, const void * data, t_size size) {
94  if (which < m_entries.get_size()) m_entries[which].m_sideData.set_data_fromptr(reinterpret_cast<const t_uint8*>(data), size);
95  else throw pfc::exception_invalid_params();
96  }
97 private:
100 };
101 
105 class NOVTABLE ole_interaction : public service_base {
106  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ole_interaction)
107 public:
108  enum {
109  KClipboardFormatSimpleLocations,
110  KClipboardFormatFPL,
111  KClipboardFormatMultiFPL,
112  KClipboardFormatTotal
113  };
116  virtual t_uint32 get_clipboard_format(t_uint32 which) = 0;
117 
119  virtual pfc::com_ptr_t<IDataObject> create_dataobject(metadb_handle_list_cref source) = 0;
120 
122  virtual pfc::com_ptr_t<IDataObject> create_dataobject(const playlist_dataobject_desc & source) = 0;
123 
125  virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj, playlist_dataobject_desc & out) = 0;
126 
128  virtual HRESULT parse_dataobject_immediate(pfc::com_ptr_t<IDataObject> obj, metadb_handle_list_ref out) = 0;
129 
131  virtual HRESULT parse_dataobject(pfc::com_ptr_t<IDataObject> obj, dropped_files_data & out) = 0;
132 
134  virtual HRESULT check_dataobject(pfc::com_ptr_t<IDataObject> obj, DWORD & dropEffect, bool & isNative) = 0;
135 
137  virtual HRESULT check_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj) = 0;
138 };
139 
141 class NOVTABLE ole_interaction_v2 : public ole_interaction {
142  FB2K_MAKE_SERVICE_INTERFACE(ole_interaction_v2, ole_interaction)
143 public:
145  virtual pfc::com_ptr_t<IDataObject> create_dataobject(const playlist_dataobject_desc_v2 & source) = 0;
146 
148  virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t<IDataObject> obj, playlist_dataobject_desc_v2 & out) = 0;
149 };
const void * get_ptr() const
const playlist_dataobject_desc & operator=(const playlist_dataobject_desc &)
const t_item * get_ptr() const
Definition: array.h:213
void set_entry_name(t_size which, const char *name)
void copy(playlist_dataobject_desc_v2 const &source)
playlist_dataobject_desc_impl(const playlist_dataobject_desc_v2 &source)
virtual t_size get_entry_count() const =0
pfc::array_t< t_uint8 > m_sideData
void get_entry_name(t_size which, pfc::string_base &out) const
abort_callback_impl abort_callback_dummy
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
Definition: bit_array.h:6
virtual void set_entry_content(t_size which, metadb_handle_list_cref content)=0
void copy(playlist_dataobject_desc const &source)
t_size calc_count(bool val, t_size start, t_size count, t_size count_max=~0) const
Definition: bit_array.h:22
const playlist_dataobject_desc_v2 & operator=(const playlist_dataobject_desc_v2 &source)
void dynamic_assert(bool p_condition, const char *p_msg)
Definition: primitives.h:239
Class used for async processing of IDataObject. Content of IDataObject can be dumped into dropped_fil...
Definition: playlist.h:712
virtual void get_side_data(t_size which, mem_block_container &out) const =0
void get_entry_content(t_size which, metadb_handle_list_ref out) const
virtual void get_entry_content(t_size which, metadb_handle_list_ref out) const =0
size_t t_size
Definition: int_types.h:48
void set(const void *p_buffer, t_size p_size)
void set_entry_content(t_size which, metadb_handle_list_cref content)
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
void set_side_data(t_size which, const void *data, t_size size)
void get_side_data(t_size which, mem_block_container &out) const
virtual void set_entry_count(t_size count)=0
virtual void get_entry_name(t_size which, pfc::string_base &out) const =0
Generic interface for a memory block; used by various other interfaces to return memory blocks while ...
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
void set_from_playlist_manager(bit_array const &mask)
This is free and unencumbered software released into the public domain Anyone is free to copy
Definition: pfc-license.txt:3
pfc::array_t< entry > m_entries
t_size get_size() const
Definition: array.h:130
virtual void set_entry_name(t_size which, const char *name)=0
void set_entry_count(t_size count)
mem_block_container implementation.
pfc::array_t< t_uint8, pfc::alloc_fast > m_buffer
uint32_t t_uint32
Definition: int_types.h:5