-
Notifications
You must be signed in to change notification settings - Fork 1
/
Interface.cpp
230 lines (220 loc) · 9.31 KB
/
Interface.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#include "Interface.h"
#include "bitset"
#include <boost/dynamic_bitset.hpp>
bool CCInterface::DoConfigFile(qiuwanli::ConfigFile* conf
, const std::string& ID
, const std::string& IP
, const std::string& PriKey
, const std::string& PriKeyMD5
, const unsigned long long TotalSize
, const unsigned long long RemainSize
, const std::string& ServersIP
, const std::string& ServersPort)
{
conf->set_id(ID);
conf->set_ip(IP);
conf->set_prikey(PriKey);
conf->set_prikeymd5(PriKeyMD5);
conf->set_totalsize(TotalSize);
conf->set_remainsize(RemainSize);
conf->set_serversip(ServersIP);
conf->set_serversport(ServersPort);
return true;
}
bool CCInterface::DoBlockInfoTable(qiuwanli::BlockInfo* blockInfo
, const std::string& FileSHA512
, const std::string& BlockMD5
, const std::string& SaveFileName
, const unsigned long long BlockNumer
, const unsigned long long CurSize
, const unsigned long long FileBlockOffset)
{
blockInfo->set_filesha512(FileSHA512);
blockInfo->set_blockmd5(BlockMD5);
blockInfo->set_savefilename(SaveFileName);
blockInfo->set_blocknumer(BlockNumer);
blockInfo->set_cursize(CurSize);
blockInfo->set_fileblockoffset(FileBlockOffset);
return true;
}
bool CCInterface::DoFile2ClientTable(qiuwanli::File2Cilent* file2Client
, const std::string& FileName
, const std::string& FileSHA512
, const std::string& ClientID
, const std::string& ClientPort)
{
file2Client->set_filename(FileName);
file2Client->set_filesha512(FileSHA512);
file2Client->set_cilentid(ClientID);
file2Client->set_cilentport(ClientPort);
return true;
}
bool CCInterface::DoClientConfigFileTable(qiuwanli::ClientConfigFile* conf
, const std::string& CilentID
, const std::string& SaveIP
, const std::string& PriKey
, const std::string& PriKeyMD5
, unsigned long long TotalSize
, unsigned long long RemainSize)
{
conf->set_cilentid(CilentID);
conf->set_saveip(SaveIP);
conf->set_prikey(PriKey);
conf->set_keymd5(PriKeyMD5);
conf->set_totalsize(TotalSize);
//conf->set_totalsize(TotalSize);
conf->set_remainsize(RemainSize);
return true;
}
bool CCInterface::DoFileInfoListTable(qiuwanli::FileInfoList* fileInfo
, const std::string& FileSHA512
, const std::string& FileMD5
, const std::string& FileName
, const std::string& FileCreateDate
, const std::string& FileChangeDate
, unsigned long long FileAllBlocks
, unsigned long long FileTotalSize
, const std::string& Tag)
{
fileInfo->set_filesha512(FileSHA512);
fileInfo->set_filemd5(FileMD5);
fileInfo->set_filename(FileName);
fileInfo->set_filecreatedate(FileCreateDate);
fileInfo->set_filechangedate(FileChangeDate);
fileInfo->set_fileallblock(FileAllBlocks);
fileInfo->set_filetotalsize(FileTotalSize);
fileInfo->set_tag(Tag);
return true;
}
bool CCInterface::DoUserInfoTable(qiuwanli::UserInfo* user
, const std::string& UserID
, const std::string& UserPS
, const std::vector<std::string>& FileSHA512List)
{
user->set_userid(UserID);
user->set_userps(UserPS);
for (const auto item : FileSHA512List)
{
user->add_filesha512(item);
}
return true;
}
bool CCInterface::DoFileListTable(qiuwanli::FileList* FileList
, const std::string& FileName
, unsigned long long FileSize
, const std::string& FileSHA512
, const std::string& Filestyle)
{
FileList->set_filename(FileName);
FileList->set_filesize(FileSize);
FileList->set_filesha512(FileSHA512);
FileList->set_filestyle(Filestyle);
return true;
}
//bool CInterface::DoFileDownLogTable(qiuwanli::FileDownLog* fileDownLog
// , const std::string& FileName
// , unsigned long long FileSize
// , const std::string& FileDownTime
// , const std::string& DowningStatus
// , const std::string& FileSHA512
// , const std::string& FileMD5)
//{
// fileDownLog->set_filename(FileName);
// fileDownLog->set_filesize(FileSize);
// fileDownLog->set_filedowntime(FileDownTime);
// fileDownLog->set_downingstatus(DowningStatus);
// fileDownLog->set_filesha512(FileSHA512);
// fileDownLog->set_filemd5(FileMD5);
//}
//
//bool CInterface::DoFileDowningTable(qiuwanli::FileDowning *fileDowning
// , const std::string& FileSHA512
// , const std::string& FileMD5
// , const std::string& FilePauseTime
// , unsigned long long FileDownloadBlockCount
// , unsigned long long FileTotalBlockCount
// , unsigned long long FileSize
// , const std::string& BitMap)
//{
// fileDowning->set_filesha512(FileSHA512);
// fileDowning->set_filemd5(FileMD5);
// fileDowning->set_filepausetime(FilePauseTime);
// fileDowning->set_filedownloadblockcount(FileDownloadBlockCount);
// fileDowning->set_filetotalblockcount(FileTotalBlockCount);
// fileDowning->set_filesize(FileSize);
// fileDowning->set_bitmap(BitMap);
//}
//
//bool CInterface::DoHeart(qiuwanli::Heart* heart
// , const std::string& ID
// , unsigned long long RemainSize
// , unsigned long long TotalSize
// , const std::string& PriKeyMd5)
//{
// heart->set_id(ID);
// heart->set_remainsize(RemainSize);
// heart->set_totlesize(TotalSize);
// heart->set_prikeymd5(PriKeyMd5);
//}
//
//bool CInterface::DoSomethingTable(qiuwanli::DoSomething* doit
// , const std::string& Key
// , const std::string& FileSHA512)
//{
// doit->set_key(Key);
// doit->set_filesha512(FileSHA512);
//}
//
//bool CInterface::DoBlockListForDownCheck(qiuwanli::BlockCheck* check
// , const std::string& BlockMD5
// , unsigned long long BlockItem)
//{
// check->set_blockmd5(BlockMD5);
// check->set_blockitem(BlockItem);
//}
//
//bool CInterface::DoBlockListForDownCheckTable(
// qiuwanli::BlockListForDownCheck* DownListChcek
// , const std::string& FileSHA512
// , const std::string& SaveServerIP
// , const std::string& FileMd5
// , std::vector<std::pair<std::string, unsigned long long >>& vList)
//{
// DownListChcek->set_filesha512(FileSHA512);
// DownListChcek->set_saveserversip(SaveServerIP);
// DownListChcek->set_filemd5(FileMd5);
// for (const auto iter : vList)
// {
// auto itemCheck=DownListChcek->add_blocks( );
// itemCheck->set_blockmd5( iter.first);
// itemCheck->set_blockitem( iter.second);
// }
//}
//
//bool CInterface::DoSharedTable(qiuwanli::SharedUrl* Url
// , const std::string& FileSha512
// , const std::string& VerificationCode
// , const std::string& SharedTime
// , unsigned long long FileSize
// , const std::string& UserStutas
// , const std::string& UserID)
//{
// Url->set_sha512(FileSha512);
// Url->set_verificationcode(VerificationCode);
// Url->set_sharedtime(SharedTime);
// Url->set_filesize(FileSize);
// Url->set_userstutas(UserStutas);
// Url->set_userid(UserID);
//}
//
//bool CInterface::DoBlockList4DownTable(qiuwanli::BlockList4Down* BlockList
// , const std::string& FileSHA512
// , unsigned long long BlockNumer
// , const std::string& BlockMD5
// , const std::string& SaveServersIP)
//{
// BlockList->set_filesha512(FileSHA512);
// BlockList->set_blocknumer(BlockNumer);
// BlockList->set_blockmd5(BlockMD5);
// BlockList->set_saveserversip(SaveServersIP);
//}