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.4 kB

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

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

Contributors (1)