RenameDownloader.cpp 992 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "RenameDownloader.h"
  2. #include "api.h"
  3. #include "../nu/AutoUrl.h"
  4. #include "main.h"
  5. #include "../../..\Components\wac_network\wac_network_http_receiver_api.h"
  6. #include <strsafe.h>
  7. class PingCallback : public ifc_downloadManagerCallback
  8. {
  9. public:
  10. void OnInit(DownloadToken token)
  11. {
  12. api_httpreceiver *jnet = WAC_API_DOWNLOADMANAGER->GetReceiver(token);
  13. if (jnet)
  14. {
  15. jnet->AddHeaderValue("X-Winamp-ID", winamp_id_str);
  16. jnet->AddHeaderValue("X-Winamp-Name", winamp_name);
  17. }
  18. }
  19. RECVS_DISPATCH;
  20. };
  21. #define CBCLASS PingCallback
  22. START_DISPATCH;
  23. VCB(IFC_DOWNLOADMANAGERCALLBACK_ONINIT, OnInit)
  24. END_DISPATCH;
  25. #undef CBCLASS
  26. static PingCallback ping_callback;
  27. void RenameDevice(const char *root_url, const wchar_t *new_name)
  28. {
  29. if ( WAC_API_DOWNLOADMANAGER )
  30. {
  31. char url[1024] = {0};
  32. StringCbPrintfA(url, sizeof(url), "%s/set?nick=%s", root_url, AutoUrl(new_name));
  33. WAC_API_DOWNLOADMANAGER->DownloadEx(url, &ping_callback, api_downloadManager::DOWNLOADEX_BUFFER);
  34. }
  35. }