1
0

api_devicemanager.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. #ifndef _NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_INTERFACE_HEADER
  2. #define _NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_INTERFACE_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <bfc/platform/guid.h>
  7. // {CB360A8F-0636-4a0d-9374-3BBCC18C8B40}
  8. static const GUID DeviceManagerGUID =
  9. { 0xcb360a8f, 0x636, 0x4a0d, { 0x93, 0x74, 0x3b, 0xbc, 0xc1, 0x8c, 0x8b, 0x40 } };
  10. #include <bfc/dispatch.h>
  11. #include "ifc_device.h"
  12. #include "ifc_deviceobjectenum.h"
  13. #include "ifc_devicetype.h"
  14. #include "ifc_devicetypeeditor.h"
  15. #include "ifc_devicecommand.h"
  16. #include "ifc_devicecommandeditor.h"
  17. #include "ifc_deviceconnection.h"
  18. #include "ifc_deviceconnectioneditor.h"
  19. #include "ifc_devicemanagerevent.h"
  20. #include "ifc_deviceprovider.h"
  21. #include "ifc_deviceeventmanager.h"
  22. #include "ifc_devicesupportedcommand.h"
  23. #include "ifc_devicesupportedcommandstore.h"
  24. #include "ifc_devicesupportedcommandenum.h"
  25. #include "ifc_deviceiconstore.h"
  26. #include "ifc_deviceactivity.h"
  27. typedef ifc_devicetype *(_cdecl *DeviceTypeCreator)(const char * /*name*/, void * /*user*/);
  28. typedef ifc_devicecommand *(_cdecl *DeviceCommandCreator)(const char * /*name*/, void * /*user*/);
  29. typedef ifc_deviceconnection *(_cdecl *DeviceConnectionCreator)(const char * /*name*/, void * /*user*/);
  30. // supports AddRef(), Release(), QueryInterface()
  31. class __declspec(novtable) api_devicemanager : public Dispatchable
  32. {
  33. protected:
  34. api_devicemanager() {}
  35. ~api_devicemanager() {}
  36. public:
  37. /* types */
  38. size_t TypeRegister(ifc_devicetype **types, size_t count); // return number of registered types
  39. size_t TypeRegisterIndirect(const char **names, size_t count, DeviceTypeCreator callback, void *user);
  40. HRESULT TypeUnregister(const char *name);
  41. HRESULT TypeFind(const char *name, ifc_devicetype **type);
  42. HRESULT TypeEnumerate(ifc_deviceobjectenum **enumerator);
  43. /* connections */
  44. size_t ConnectionRegister(ifc_deviceconnection **connections, size_t count);
  45. size_t ConnectionRegisterIndirect(const char **names, size_t count, DeviceConnectionCreator callback, void *user);
  46. HRESULT ConnectionUnregister(const char *name);
  47. HRESULT ConnectionFind(const char *name, ifc_deviceconnection **connection);
  48. HRESULT ConnectionEnumerate(ifc_deviceobjectenum **enumerator);
  49. /* commmands */
  50. size_t CommandRegister(ifc_devicecommand **commands, size_t count);
  51. size_t CommandRegisterIndirect(const char **names, size_t count, DeviceCommandCreator callback, void *user);
  52. HRESULT CommandUnregister(const char *name);
  53. HRESULT CommandFind(const char *name, ifc_devicecommand **command);
  54. HRESULT CommandEnumerate(ifc_deviceobjectenum **enumerator);
  55. /* devices */
  56. size_t DeviceRegister(ifc_device **devices, size_t count);
  57. HRESULT DeviceUnregister(const char *name);
  58. HRESULT DeviceFind(const char *name, ifc_device **device);
  59. HRESULT DeviceEnumerate(ifc_deviceobjectenum **enumerator);
  60. /* discovery */
  61. HRESULT IsDiscoveryActive();
  62. HRESULT BeginDiscovery();
  63. HRESULT CancelDiscovery();
  64. HRESULT RegisterProvider(ifc_deviceprovider *provider);
  65. HRESULT UnregisterProvider(ifc_deviceprovider *provider);
  66. HRESULT SetProviderActive(ifc_deviceprovider *provider, BOOL activeState);
  67. /* events */
  68. HRESULT Advise(ifc_devicemanagerevent *handler);
  69. HRESULT Unadvise(ifc_devicemanagerevent *handler);
  70. /* misc helpers */
  71. HRESULT CreateDeviceEventManager(ifc_deviceeventmanager **eventManager);
  72. HRESULT CreateSupportedCommandStore(ifc_devicesupportedcommandstore **store);
  73. HRESULT CreateSupportedCommandEnum(ifc_devicesupportedcommand **commands, size_t count, ifc_devicesupportedcommandenum **enumerator);
  74. HRESULT CreateIconStore(ifc_deviceiconstore **store);
  75. HRESULT CreateType(const char *name, ifc_devicetype **type);
  76. HRESULT CreateCommand(const char *name, ifc_devicecommand **command);
  77. HRESULT CreateConnection(const char *name, ifc_deviceconnection **connection);
  78. public:
  79. DISPATCH_CODES
  80. {
  81. API_TYPEREGISTER = 10,
  82. API_TYPEREGISTERINDIRECT = 20,
  83. API_TYPEUNREGISTER = 30,
  84. API_TYPEFIND = 40,
  85. API_TYPEENUMERATE = 50,
  86. API_CONNECTIONREGISTER = 60,
  87. API_CONNECTIONREGISTERINDIRECT = 70,
  88. API_CONNECTIONUNREGISTER = 80,
  89. API_CONNECTIONFIND = 90,
  90. API_CONNECTIONENUMERATE = 100,
  91. API_COMMANDREGISTER = 110,
  92. API_COMMANDREGISTERINDIRECT = 120,
  93. API_COMMANDUNREGISTER = 130,
  94. API_COMMANDFIND = 140,
  95. API_COMMANDENUMERATE = 150,
  96. API_DEVICEREGISTER = 160,
  97. API_DEVICEUNREGISTER = 170,
  98. API_DEVICEFIND = 180,
  99. API_DEVICEENUMERATE = 190,
  100. API_ISDISCOVERYACTIVE = 200,
  101. API_BEGINDISCOVERY = 210,
  102. API_CANCELDISCOVERY = 220,
  103. API_REGISTERPROVIDER = 230,
  104. API_UNREGISTERPROVIDER = 240,
  105. API_SETPROVIDERACTIVE = 250,
  106. API_ADVISE = 260,
  107. API_UNADVISE = 270,
  108. API_CREATEDEVICEEVENTMANAGER = 400,
  109. API_CREATESUPPORTEDCOMMANDSTORE = 410,
  110. API_CREATESUPPORTEDCOMMANDENUM = 420,
  111. API_CREATEICONSTORE = 430,
  112. API_CREATETYPE = 440,
  113. API_CREATECOMMAND = 450,
  114. API_CREATECONNECTION = 460,
  115. };
  116. };
  117. inline size_t api_devicemanager::TypeRegister(ifc_devicetype **types, size_t count)
  118. {
  119. return _call(API_TYPEREGISTER, (size_t)0, types, count);
  120. }
  121. inline size_t api_devicemanager::TypeRegisterIndirect(const char **names, size_t count, DeviceTypeCreator callback, void *user)
  122. {
  123. return _call(API_TYPEREGISTERINDIRECT, (size_t)0, names, count, callback, user);
  124. }
  125. inline HRESULT api_devicemanager::TypeUnregister(const char *name)
  126. {
  127. return _call(API_TYPEUNREGISTER, (HRESULT)E_NOTIMPL, name);
  128. }
  129. inline HRESULT api_devicemanager::TypeFind(const char *name, ifc_devicetype **type)
  130. {
  131. return _call(API_TYPEFIND, (HRESULT)E_NOTIMPL, name, type);
  132. }
  133. inline HRESULT api_devicemanager::TypeEnumerate(ifc_deviceobjectenum **enumerator)
  134. {
  135. return _call(API_TYPEENUMERATE, (HRESULT)E_NOTIMPL, enumerator);
  136. }
  137. inline size_t api_devicemanager::ConnectionRegister(ifc_deviceconnection **connections, size_t count)
  138. {
  139. return _call(API_CONNECTIONREGISTER, (size_t)0, connections, count);
  140. }
  141. inline size_t api_devicemanager::ConnectionRegisterIndirect(const char **names, size_t count, DeviceConnectionCreator callback, void *user)
  142. {
  143. return _call(API_CONNECTIONREGISTERINDIRECT, (size_t)0, names, count, callback, user);
  144. }
  145. inline HRESULT api_devicemanager::ConnectionUnregister(const char *name)
  146. {
  147. return _call(API_CONNECTIONUNREGISTER, (HRESULT)E_NOTIMPL, name);
  148. }
  149. inline HRESULT api_devicemanager::ConnectionFind(const char *name, ifc_deviceconnection **connection)
  150. {
  151. return _call(API_CONNECTIONFIND, (HRESULT)E_NOTIMPL, name, connection);
  152. }
  153. inline HRESULT api_devicemanager::ConnectionEnumerate(ifc_deviceobjectenum **enumerator)
  154. {
  155. return _call(API_CONNECTIONENUMERATE, (HRESULT)E_NOTIMPL, enumerator);
  156. }
  157. inline size_t api_devicemanager::CommandRegister(ifc_devicecommand **commands, size_t count)
  158. {
  159. return _call(API_COMMANDREGISTER, (size_t)0, commands, count);
  160. }
  161. inline size_t api_devicemanager::CommandRegisterIndirect(const char **names, size_t count, DeviceCommandCreator callback, void *user)
  162. {
  163. return _call(API_COMMANDREGISTERINDIRECT, (size_t)0, names, count, callback, user);
  164. }
  165. inline HRESULT api_devicemanager::CommandUnregister(const char *name)
  166. {
  167. return _call(API_COMMANDUNREGISTER, (HRESULT)E_NOTIMPL, name);
  168. }
  169. inline HRESULT api_devicemanager::CommandFind(const char *name, ifc_devicecommand **command)
  170. {
  171. return _call(API_COMMANDFIND, (HRESULT)E_NOTIMPL, name, command);
  172. }
  173. inline HRESULT api_devicemanager::CommandEnumerate(ifc_deviceobjectenum **enumerator)
  174. {
  175. return _call(API_COMMANDENUMERATE, (HRESULT)E_NOTIMPL, enumerator);
  176. }
  177. inline size_t api_devicemanager::DeviceRegister(ifc_device **devices, size_t count)
  178. {
  179. return _call(API_DEVICEREGISTER, (size_t)0, devices, count);
  180. }
  181. inline HRESULT api_devicemanager::DeviceUnregister(const char *name)
  182. {
  183. return _call(API_DEVICEUNREGISTER, (HRESULT)E_NOTIMPL, name);
  184. }
  185. inline HRESULT api_devicemanager::DeviceFind(const char *name, ifc_device **device)
  186. {
  187. return _call(API_DEVICEFIND, (HRESULT)E_NOTIMPL, name, device);
  188. }
  189. inline HRESULT api_devicemanager::DeviceEnumerate(ifc_deviceobjectenum **enumerator)
  190. {
  191. return _call(API_DEVICEENUMERATE, (HRESULT)E_NOTIMPL, enumerator);
  192. }
  193. inline HRESULT api_devicemanager::IsDiscoveryActive()
  194. {
  195. return _call(API_ISDISCOVERYACTIVE, (HRESULT)E_NOTIMPL);
  196. }
  197. inline HRESULT api_devicemanager::BeginDiscovery()
  198. {
  199. return _call(API_BEGINDISCOVERY, (HRESULT)E_NOTIMPL);
  200. }
  201. inline HRESULT api_devicemanager::CancelDiscovery()
  202. {
  203. return _call(API_CANCELDISCOVERY, (HRESULT)E_NOTIMPL);
  204. }
  205. inline HRESULT api_devicemanager::RegisterProvider(ifc_deviceprovider *provider)
  206. {
  207. return _call(API_REGISTERPROVIDER, (HRESULT)E_NOTIMPL, provider);
  208. }
  209. inline HRESULT api_devicemanager::UnregisterProvider(ifc_deviceprovider *provider)
  210. {
  211. return _call(API_UNREGISTERPROVIDER, (HRESULT)E_NOTIMPL, provider);
  212. }
  213. inline HRESULT api_devicemanager::SetProviderActive(ifc_deviceprovider *provider, BOOL activeState)
  214. {
  215. return _call(API_SETPROVIDERACTIVE, (HRESULT)E_NOTIMPL, provider, activeState);
  216. }
  217. inline HRESULT api_devicemanager::Advise(ifc_devicemanagerevent *handler)
  218. {
  219. return _call(API_ADVISE, (HRESULT)E_NOTIMPL, handler);
  220. }
  221. inline HRESULT api_devicemanager::Unadvise(ifc_devicemanagerevent *handler)
  222. {
  223. return _call(API_UNADVISE, (HRESULT)E_NOTIMPL, handler);
  224. }
  225. inline HRESULT api_devicemanager::CreateDeviceEventManager(ifc_deviceeventmanager **eventManager)
  226. {
  227. return _call(API_CREATEDEVICEEVENTMANAGER, (HRESULT)E_NOTIMPL, eventManager);
  228. }
  229. inline HRESULT api_devicemanager::CreateSupportedCommandStore(ifc_devicesupportedcommandstore **store)
  230. {
  231. return _call(API_CREATESUPPORTEDCOMMANDSTORE, (HRESULT)E_NOTIMPL, store);
  232. }
  233. inline HRESULT api_devicemanager::CreateSupportedCommandEnum(ifc_devicesupportedcommand **commands, size_t count, ifc_devicesupportedcommandenum **enumerator)
  234. {
  235. return _call(API_CREATESUPPORTEDCOMMANDENUM, (HRESULT)E_NOTIMPL, commands, count, enumerator);
  236. }
  237. inline HRESULT api_devicemanager::CreateIconStore(ifc_deviceiconstore **store)
  238. {
  239. return _call(API_CREATEICONSTORE, (HRESULT)E_NOTIMPL, store);
  240. }
  241. inline HRESULT api_devicemanager::CreateType(const char *name, ifc_devicetype **type)
  242. {
  243. return _call(API_CREATETYPE, (HRESULT)E_NOTIMPL, name, type);
  244. }
  245. inline HRESULT api_devicemanager::CreateCommand(const char *name, ifc_devicecommand **command)
  246. {
  247. return _call(API_CREATECOMMAND, (HRESULT)E_NOTIMPL, name, command);
  248. }
  249. inline HRESULT api_devicemanager::CreateConnection(const char *name, ifc_deviceconnection **connection)
  250. {
  251. return _call(API_CREATECONNECTION, (HRESULT)E_NOTIMPL, name, connection);
  252. }
  253. #endif //_NULLSOFT_WINAMP_DEVICES_DEVICE_MANAGER_INTERFACE_HEADER