device.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef _NULLSOFT_WINAMP_GEN_DEVICE_PROVIDER_DEVICE_HEADER
  2. #define _NULLSOFT_WINAMP_GEN_DEVICE_PROVIDER_DEVICE_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. class DeviceActivity;
  8. class Device: public ifc_device
  9. {
  10. protected:
  11. Device();
  12. ~Device();
  13. public:
  14. static HRESULT CreateInstance(const char *name,
  15. const char *type,
  16. const char *connection,
  17. Device**instance);
  18. public:
  19. /* Dispatchable */
  20. size_t AddRef();
  21. size_t Release();
  22. int QueryInterface(GUID interface_guid, void **object);
  23. /* ifc_device */
  24. const char *GetName();
  25. const char *GetType();
  26. const char *GetConnection();
  27. HRESULT GetIcon(wchar_t *buffer, size_t bufferSize, int width, int height);
  28. HRESULT GetDisplayName(wchar_t *buffer, size_t bufferSize);
  29. BOOL GetHidden();
  30. HRESULT GetTotalSpace(uint64_t *size);
  31. HRESULT GetUsedSpace(uint64_t *size);
  32. BOOL GetAttached();
  33. HRESULT Attach(HWND hostWindow);
  34. HRESULT Detach(HWND hostWindow);
  35. HRESULT EnumerateCommands(ifc_devicesupportedcommandenum **enumerator, DeviceCommandContext context);
  36. HRESULT SendCommand(const char *command, HWND hostWindow, ULONG_PTR param);
  37. HRESULT GetCommandFlags(const char *command, DeviceCommandFlags *flags);
  38. HRESULT GetActivity(ifc_deviceactivity **activity);
  39. HRESULT Advise(ifc_deviceevent *handler);
  40. HRESULT Unadvise(ifc_deviceevent *handler);
  41. HWND CreateView(HWND parentWindow);
  42. void SetNavigationItem(void *navigationItem);
  43. HRESULT GetModel(wchar_t *buffer, size_t bufferSize);
  44. HRESULT GetStatus(wchar_t *buffer, size_t bufferSize);
  45. public:
  46. HRESULT SetConnection(const char *connection);
  47. HRESULT SetDisplayName(const wchar_t *name);
  48. HRESULT SetTotalSpace(uint64_t size);
  49. HRESULT SetUsedSpace(uint64_t size);
  50. HRESULT SetHidden(BOOL hiddenState);
  51. HRESULT SetModel(const wchar_t *deviceModel);
  52. HRESULT SetStatus(const wchar_t *deviceStatus);
  53. HRESULT AddIcon(const wchar_t *path, unsigned int width, unsigned int height);
  54. HRESULT EnumerateIcons(ifc_deviceiconstore::EnumeratorCallback callback, void *user);
  55. HRESULT RemoveIcon(unsigned int width, unsigned int height);
  56. HRESULT AddCommand(const char *command, DeviceCommandFlags flags);
  57. HRESULT RemoveCommand(const char *command);
  58. HRESULT SetCommandFlags(const char *command, DeviceCommandFlags mask, DeviceCommandFlags flags);
  59. HRESULT IsConnected();
  60. HRESULT Connect();
  61. HRESULT Disconnect();
  62. HRESULT CopyTo(Device *target);
  63. HRESULT SetIconBase(const wchar_t *path);
  64. HRESULT StartSyncActivity(HWND hostWindow);
  65. protected:
  66. void Lock();
  67. void Unlock();
  68. static void ActivityStartedCb(DeviceActivity *activity);
  69. static void ActivityFinishedCb(DeviceActivity *activity);
  70. static void ActivityProgressCb(DeviceActivity *activity, unsigned int progress, unsigned int duration);
  71. protected:
  72. size_t ref;
  73. char *name;
  74. char *type;
  75. char *connection;
  76. wchar_t *displayName;
  77. wchar_t *model;
  78. wchar_t *status;
  79. uint64_t totalSpace;
  80. uint64_t usedSpace;
  81. BOOL attached;
  82. BOOL hidden;
  83. BOOL connected;
  84. ifc_deviceiconstore *iconStore;
  85. ifc_deviceeventmanager *eventManager;
  86. ifc_devicesupportedcommandstore *commands;
  87. DeviceActivity *activity;
  88. CRITICAL_SECTION lock;
  89. protected:
  90. RECVS_DISPATCH;
  91. };
  92. #endif //_NULLSOFT_WINAMP_GEN_DEVICE_PROVIDER_DEVICE_HEADER