DownloadManager.h 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef COMMON_DOWNLOADMANAGER_H_
  2. #define COMMON_DOWNLOADMANAGER_H_
  3. #include <list>
  4. typedef void* TaskID;
  5. #define TaskIDNULL NULL
  6. enum HttpMethod
  7. {
  8. HM_GET = 0,
  9. HM_POST,
  10. HM_END,
  11. };
  12. struct DownloadProgress
  13. {
  14. double fNow;
  15. double fTotal;
  16. };
  17. struct DownloadData{
  18. void* ptr;
  19. unsigned int nLen;
  20. };
  21. struct TaskInitData
  22. {
  23. typedef std::list<std::pair<std::string, std::string>> ParamList;
  24. std::string strRequestURL;
  25. std::string strFilename;
  26. HttpMethod hm;
  27. std::string strParam;
  28. //ParamList lsParams;
  29. };
  30. struct DownloadManager
  31. {
  32. virtual TaskID CreateTask(TaskInitData* pInit) = 0;
  33. virtual bool StartTask(TaskID taskID) = 0;
  34. virtual bool StopTask(TaskID taskID) = 0;
  35. };
  36. struct ParamConstructor
  37. {
  38. virtual void ParamAlloc(
  39. unsigned int nEvent,
  40. unsigned int nSubEvent,
  41. void** param1,
  42. void** param2
  43. ) = 0;
  44. virtual void ParamFree(
  45. unsigned int nEvent,
  46. unsigned int nSubEvent,
  47. void* param1,
  48. void* param2
  49. ) = 0;
  50. };
  51. #endif // COMMON_DOWNLOADMANAGER_H_