Changeset View
Changeset View
Standalone View
Standalone View
krusader/Splitter/combiner.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 72 | if (!file.isReadable()) { | |||
---|---|---|---|---|---|
80 | } | 80 | } | ||
81 | 81 | | |||
82 | statDest(); | 82 | statDest(); | ||
83 | } else { | 83 | } else { | ||
84 | permissions = file.permissions() | QFile::WriteUser; | 84 | permissions = file.permissions() | QFile::WriteUser; | ||
85 | 85 | | |||
86 | combineReadJob = KIO::get(splURL, KIO::NoReload, KIO::HideProgressInfo); | 86 | combineReadJob = KIO::get(splURL, KIO::NoReload, KIO::HideProgressInfo); | ||
87 | 87 | | |||
88 | connect(combineReadJob, SIGNAL(data(KIO::Job*,QByteArray)), | 88 | connect(combineReadJob, &KIO::TransferJob::data, this, &Combiner::combineSplitFileDataReceived); | ||
89 | this, SLOT(combineSplitFileDataReceived(KIO::Job*,QByteArray))); | 89 | connect(combineReadJob, &KIO::TransferJob::result, this, &Combiner::combineSplitFileFinished); | ||
90 | connect(combineReadJob, SIGNAL(result(KJob*)), | | |||
91 | this, SLOT(combineSplitFileFinished(KJob*))); | | |||
92 | } | 90 | } | ||
93 | 91 | | |||
94 | exec(); | 92 | exec(); | ||
95 | } | 93 | } | ||
96 | 94 | | |||
97 | void Combiner::combineSplitFileDataReceived(KIO::Job *, const QByteArray &byteArray) | 95 | void Combiner::combineSplitFileDataReceived(KIO::Job *, const QByteArray &byteArray) | ||
98 | { | 96 | { | ||
99 | splitFile += QString(byteArray); | 97 | splitFile += QString(byteArray); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 156 | if (hasValidSplitFile) | |||
159 | writeURL.setPath(writeURL.path() + expectedFileName); | 157 | writeURL.setPath(writeURL.path() + expectedFileName); | ||
160 | else if (unixNaming) | 158 | else if (unixNaming) | ||
161 | writeURL.setPath(writeURL.path() + baseURL.fileName() + ".out"); | 159 | writeURL.setPath(writeURL.path() + baseURL.fileName() + ".out"); | ||
162 | else | 160 | else | ||
163 | writeURL.setPath(writeURL.path() + baseURL.fileName()); | 161 | writeURL.setPath(writeURL.path() + baseURL.fileName()); | ||
164 | } | 162 | } | ||
165 | 163 | | |||
166 | statJob = KIO::stat(writeURL, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo); | 164 | statJob = KIO::stat(writeURL, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo); | ||
167 | connect(statJob, SIGNAL(result(KJob*)), SLOT(statDestResult(KJob*))); | 165 | connect(statJob, &KIO::StatJob::result, this, &Combiner::statDestResult); | ||
168 | } | 166 | } | ||
169 | 167 | | |||
170 | void Combiner::statDestResult(KJob* job) | 168 | void Combiner::statDestResult(KJob* job) | ||
171 | { | 169 | { | ||
172 | statJob = 0; | 170 | statJob = 0; | ||
173 | 171 | | |||
174 | if (job->error()) { | 172 | if (job->error()) { | ||
175 | if (job->error() == KIO::ERR_DOES_NOT_EXIST) { | 173 | if (job->error() == KIO::ERR_DOES_NOT_EXIST) { | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 220 | } else { | |||
224 | index = index.arg(fileCounter++).rightJustified(3, '0'); | 222 | index = index.arg(fileCounter++).rightJustified(3, '0'); | ||
225 | readURL = baseURL.adjusted(QUrl::RemoveFilename); | 223 | readURL = baseURL.adjusted(QUrl::RemoveFilename); | ||
226 | readURL.setPath(readURL.path() + baseURL.fileName() + '.' + index); | 224 | readURL.setPath(readURL.path() + baseURL.fileName() + '.' + index); | ||
227 | } | 225 | } | ||
228 | 226 | | |||
229 | /* creating a read job */ | 227 | /* creating a read job */ | ||
230 | combineReadJob = KIO::get(readURL, KIO::NoReload, KIO::HideProgressInfo); | 228 | combineReadJob = KIO::get(readURL, KIO::NoReload, KIO::HideProgressInfo); | ||
231 | 229 | | |||
232 | connect(combineReadJob, SIGNAL(data(KIO::Job*,QByteArray)), | 230 | connect(combineReadJob, &KIO::TransferJob::data, this, &Combiner::combineDataReceived); | ||
233 | this, SLOT(combineDataReceived(KIO::Job*,QByteArray))); | 231 | connect(combineReadJob, &KIO::TransferJob::result, this, &Combiner::combineReceiveFinished); | ||
234 | connect(combineReadJob, SIGNAL(result(KJob*)), | | |||
235 | this, SLOT(combineReceiveFinished(KJob*))); | | |||
236 | if (hasValidSplitFile) | 232 | if (hasValidSplitFile) | ||
237 | connect(combineReadJob, SIGNAL(percent(KJob*,ulong)), | 233 | connect(combineReadJob, SIGNAL(percent(KJob*,ulong)), | ||
238 | this, SLOT(combineWritePercent(KJob*,ulong))); | 234 | this, SLOT(combineWritePercent(KJob*,ulong))); | ||
239 | 235 | | |||
240 | } | 236 | } | ||
241 | 237 | | |||
242 | void Combiner::combineDataReceived(KIO::Job *, const QByteArray &byteArray) | 238 | void Combiner::combineDataReceived(KIO::Job *, const QByteArray &byteArray) | ||
243 | { | 239 | { | ||
244 | if (byteArray.size() == 0) | 240 | if (byteArray.size() == 0) | ||
245 | return; | 241 | return; | ||
246 | 242 | | |||
247 | crcContext->update((unsigned char *)byteArray.data(), byteArray.size()); | 243 | crcContext->update((unsigned char *)byteArray.data(), byteArray.size()); | ||
248 | transferArray = QByteArray(byteArray.data(), byteArray.length()); | 244 | transferArray = QByteArray(byteArray.data(), byteArray.length()); | ||
249 | 245 | | |||
250 | receivedSize += byteArray.size(); | 246 | receivedSize += byteArray.size(); | ||
251 | 247 | | |||
252 | if (combineWriteJob == 0) { | 248 | if (combineWriteJob == 0) { | ||
253 | combineWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | 249 | combineWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | ||
254 | 250 | | |||
255 | connect(combineWriteJob, SIGNAL(dataReq(KIO::Job*,QByteArray&)), | 251 | connect(combineWriteJob, &KIO::TransferJob::dataReq, this, &Combiner::combineDataSend); | ||
256 | this, SLOT(combineDataSend(KIO::Job*,QByteArray&))); | 252 | connect(combineWriteJob, &KIO::TransferJob::result, this, &Combiner::combineSendFinished); | ||
257 | connect(combineWriteJob, SIGNAL(result(KJob*)), | | |||
258 | this, SLOT(combineSendFinished(KJob*))); | | |||
259 | } | 253 | } | ||
260 | 254 | | |||
261 | // continue writing and suspend read job until received data is handed over to the write job | 255 | // continue writing and suspend read job until received data is handed over to the write job | ||
262 | combineReadJob->suspend(); | 256 | combineReadJob->suspend(); | ||
263 | combineWriteJob->resume(); | 257 | combineWriteJob->resume(); | ||
264 | } | 258 | } | ||
265 | 259 | | |||
266 | void Combiner::combineReceiveFinished(KJob *job) | 260 | void Combiner::combineReceiveFinished(KJob *job) | ||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |