forked from compilelife/feiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiletask.h
More file actions
66 lines (59 loc) · 1.45 KB
/
filetask.h
File metadata and controls
66 lines (59 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef FILETASK_H
#define FILETASK_H
#include "content.h"
#include <memory>
#include <functional>
#include "fellow.h"
#include <string>
using namespace std;
enum class FileTaskType{
Download,
Upload
};
enum class FileTaskState{
NotStart,
Running,
Finish,
Error,
Canceled
};
class FileTask;
class IFileTaskObserver
{
public:
virtual void onStateChanged(FileTask* fileTask) = 0;
virtual void onProgress(FileTask* fileTask) = 0;
};
class FileTask
{
public:
FileTask();
FileTask(shared_ptr<FileContent> fileContent, FileTaskType type);
void setObserver(IFileTaskObserver* observer);
public:
void setProcess(int val);
void setState(FileTaskState val, const string& msg="");
void setFellow(shared_ptr<Fellow> fellow);
void cancel();
bool hasCancelPending();
public:
shared_ptr<Fellow> fellow() const;
int getProcess() const;
FileTaskState getState() const;
string getDetailInfo() const;
shared_ptr<FileContent> getContent() const;
FileTaskType type() const;
string getTaskTypeDes() const;
private:
shared_ptr<Fellow> mFellow;//要发送给的用户,或文件来自该用户
int mProcess=0;
FileTaskState mState = FileTaskState::NotStart;
shared_ptr<FileContent> mContent;
IFileTaskObserver* mObserver;
FileTaskType mType = FileTaskType::Upload;
string mMsg;
bool mCancelPending=false;
int mNotifySize;
int mLastProcess=0;
};
#endif // FILETASK_H