InfoDownloader.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "device.h"
  3. #include "../xml/obj_xml.h"
  4. #include "../Components/wac_downloadManager/DownloadCallbackT.h"
  5. #include "WifiDevice.h"
  6. #include "../xml/ifc_xmlreadercallbackT.h"
  7. #include "main.h"
  8. namespace Wasabi2
  9. {
  10. #include "nx/nxstring.h"
  11. }
  12. class DeviceXML : public ifc_xmlreadercallbackT<DeviceXML>
  13. {
  14. public:
  15. DeviceXML();
  16. void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params);
  17. DeviceInfo device_info;
  18. };
  19. class InfoXML : public DeviceXML
  20. {
  21. public:
  22. InfoXML(obj_xml *parser);
  23. ~InfoXML();
  24. WifiDevice *CreateDevice(uint64_t device_id_check, const char *root_url);
  25. private:
  26. obj_xml *parser;
  27. };
  28. class InfoDownloader : public DownloadCallbackT<InfoDownloader>
  29. {
  30. public:
  31. InfoDownloader(const char *root_url, uint64_t id, Wasabi2::nx_string_t usn);
  32. ~InfoDownloader();
  33. void OnInit(DownloadToken token);
  34. void OnData(DownloadToken token, void *data, size_t datalen);
  35. void OnCancel(DownloadToken token);
  36. void OnError(DownloadToken token, int error);
  37. void OnFinish(DownloadToken token);
  38. bool Done(WifiDevice **device);
  39. void Cancel();
  40. uint64_t id;
  41. Wasabi2::nx_string_t usn;
  42. private:
  43. char *root_url;
  44. obj_xml *parser;
  45. InfoXML *info;
  46. volatile int done; // 1 for successfully done, 2 for cancelled/error
  47. };