You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

filetask.h 1.5 kB

8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef FILETASK_H
  2. #define FILETASK_H
  3. #include "content.h"
  4. #include <memory>
  5. #include <functional>
  6. #include "fellow.h"
  7. #include <string>
  8. using namespace std;
  9. enum class FileTaskType{
  10. Download,
  11. Upload
  12. };
  13. enum class FileTaskState{
  14. NotStart,
  15. Running,
  16. Finish,
  17. Error,
  18. Canceled
  19. };
  20. class FileTask;
  21. class IFileTaskObserver
  22. {
  23. public:
  24. virtual void onStateChanged(FileTask* fileTask) = 0;
  25. virtual void onProgress(FileTask* fileTask) = 0;
  26. };
  27. class FileTask
  28. {
  29. public:
  30. FileTask();
  31. FileTask(shared_ptr<FileContent> fileContent, FileTaskType type);
  32. void setObserver(IFileTaskObserver* observer);
  33. public:
  34. void setProcess(int val);
  35. void setState(FileTaskState val, const string& msg="");
  36. void setFellow(shared_ptr<Fellow> fellow);
  37. void cancel();
  38. bool hasCancelPending();
  39. public:
  40. shared_ptr<Fellow> fellow() const;
  41. int getProcess() const;
  42. FileTaskState getState() const;
  43. string getDetailInfo() const;
  44. shared_ptr<FileContent> getContent() const;
  45. FileTaskType type() const;
  46. string getTaskTypeDes() const;
  47. private:
  48. shared_ptr<Fellow> mFellow;//要发送给的用户,或文件来自该用户
  49. int mProcess=0;
  50. FileTaskState mState = FileTaskState::NotStart;
  51. shared_ptr<FileContent> mContent;
  52. IFileTaskObserver* mObserver;
  53. FileTaskType mType = FileTaskType::Upload;
  54. string mMsg;
  55. bool mCancelPending=false;
  56. int mNotifySize;
  57. int mLastProcess=0;
  58. };
  59. #endif // FILETASK_H

mac下的“飞秋”大多数只是飞鸽传书协议,而且未发现令人满意的开源项目,所以基于c++与qt实现了基础的飞秋协议。

Contributors (1)