• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • core
verifier.cpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2009-2011 Matthias Fuchs <mat69@gmx.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #include "verifier_p.h"
21 #include "verificationmodel.h"
22 #include "../dbus/dbusverifierwrapper.h"
23 #include "verifieradaptor.h"
24 #include "settings.h"
25 
26 #include <QtCore/QFile>
27 #include <QtCore/QScopedPointer>
28 #include <QtXml/QDomElement>
29 
30 #include <KCodecs>
31 #include <KDebug>
32 
33 #ifdef HAVE_QCA2
34 #include <QtCrypto>
35 #endif
36 
37 //TODO use mutable to make some methods const?
38 const QStringList VerifierPrivate::SUPPORTED = (QStringList() << "sha512" << "sha384" << "sha256" << "ripmed160" << "sha1" << "md5" << "md4");
39 const QString VerifierPrivate::MD5 = QString("md5");
40 const int VerifierPrivate::DIGGESTLENGTH[] = {128, 96, 64, 40, 40, 32, 32};
41 const int VerifierPrivate::MD5LENGTH = 32;
42 const int VerifierPrivate::PARTSIZE = 500 * 1024;
43 
44 VerifierPrivate::~VerifierPrivate()
45 {
46  delete model;
47  qDeleteAll(partialSums.begin(), partialSums.end());
48 }
49 
50 QString VerifierPrivate::calculatePartialChecksum(QFile *file, const QString &type, KIO::fileoffset_t startOffset, int pieceLength, KIO::filesize_t fileSize, bool *abortPtr)
51 {
52  if (!file)
53  {
54  return QString();
55  }
56 
57  if (!fileSize)
58  {
59  fileSize = file->size();
60  }
61  //longer than the file, so adapt it
62  if (static_cast<KIO::fileoffset_t>(fileSize) < startOffset + pieceLength)
63  {
64  pieceLength = fileSize - startOffset;
65  }
66 
67 #ifdef HAVE_QCA2
68  QCA::Hash hash(type);
69 
70  //it can be that QCA2 does not support md5, e.g. when Qt is compiled locally
71  KMD5 md5Hash;
72  const bool useMd5 = (type == MD5);
73 #else //NO QCA2
74  if (type != MD5)
75  {
76  return QString();
77  }
78  KMD5 hash;
79 #endif //HAVE_QCA2
80 
81  //we only read 512kb each time, to save RAM
82  int numData = pieceLength / PARTSIZE;
83  KIO::fileoffset_t dataRest = pieceLength % PARTSIZE;
84 
85  if (!numData && !dataRest)
86  {
87  QString();
88  }
89 
90  int k = 0;
91  for (k = 0; k < numData; ++k)
92  {
93  if (!file->seek(startOffset + PARTSIZE * k))
94  {
95  return QString();
96  }
97 
98  if (abortPtr && *abortPtr)
99  {
100  return QString();
101  }
102 
103  QByteArray data = file->read(PARTSIZE);
104 #ifdef HAVE_QCA2
105  if (useMd5) {
106  md5Hash.update(data);
107  } else {
108  hash.update(data);
109  }
110 #else //NO QCA2
111  hash.update(data);
112 #endif //HAVE_QCA2
113  }
114 
115  //now read the rest
116  if (dataRest)
117  {
118  if (!file->seek(startOffset + PARTSIZE * k))
119  {
120  return QString();
121  }
122 
123  QByteArray data = file->read(dataRest);
124 #ifdef HAVE_QCA2
125  if (useMd5) {
126  md5Hash.update(data);
127  } else {
128  hash.update(data);
129  }
130 #else //NO QCA2
131  hash.update(data);
132 #endif //HAVE_QCA2
133  }
134 
135 #ifdef HAVE_QCA2
136  return (useMd5 ? QString(md5Hash.hexDigest()) : QString(QCA::arrayToHex(hash.final().toByteArray())));
137 #else //NO QCA2
138  return QString(hash.hexDigest());
139 #endif //HAVE_QCA2
140 }
141 
142 QStringList VerifierPrivate::orderChecksumTypes(Verifier::ChecksumStrength strength) const
143 {
144  QStringList checksumTypes;
145  if (strength == Verifier::Weak) {
146  for (int i = SUPPORTED.count() - 1; i >= 0; --i) {
147  checksumTypes.append(SUPPORTED.at(i));
148  }
149  checksumTypes.move(0, 1); //md4 second position
150  } else if (strength == Verifier::Strong) {
151  for (int i = SUPPORTED.count() - 1; i >= 0; --i) {
152  checksumTypes.append(SUPPORTED.at(i));
153  }
154  checksumTypes.move(1, checksumTypes.count() - 1); //md5 second last position
155  checksumTypes.move(0, checksumTypes.count() - 1); //md4 last position
156  } else if (strength == Verifier::Strongest) {
157  checksumTypes = SUPPORTED;
158  }
159 
160  return checksumTypes;
161 }
162 
163 Verifier::Verifier(const KUrl &dest, QObject *parent)
164  : QObject(parent),
165  d(new VerifierPrivate(this))
166 {
167  d->dest = dest;
168  d->status = NoResult;
169 
170  static int dBusObjIdx = 0;
171  d->dBusObjectPath = "/KGet/Verifiers/" + QString::number(dBusObjIdx++);
172 
173  DBusVerifierWrapper *wrapper = new DBusVerifierWrapper(this);
174  new VerifierAdaptor(wrapper);
175  QDBusConnection::sessionBus().registerObject(d->dBusObjectPath, wrapper);
176 
177  qRegisterMetaType<KIO::filesize_t>("KIO::filesize_t");
178  qRegisterMetaType<KIO::fileoffset_t>("KIO::fileoffset_t");
179  qRegisterMetaType<QList<KIO::fileoffset_t> >("QList<KIO::fileoffset_t>");
180 
181  d->model = new VerificationModel();
182  connect(&d->thread, SIGNAL(verified(QString,bool,KUrl)), this, SLOT(changeStatus(QString,bool)));
183  connect(&d->thread, SIGNAL(brokenPieces(QList<KIO::fileoffset_t>,KIO::filesize_t)), this, SIGNAL(brokenPieces(QList<KIO::fileoffset_t>,KIO::filesize_t)));
184 }
185 
186 Verifier::~Verifier()
187 {
188  delete d;
189 }
190 
191 QString Verifier::dBusObjectPath() const
192 {
193  return d->dBusObjectPath;
194 }
195 
196 KUrl Verifier::destination() const
197 {
198  return d->dest;
199 }
200 
201 void Verifier::setDestination(const KUrl &destination)
202 {
203  d->dest = destination;
204 }
205 
206 Verifier::VerificationStatus Verifier::status() const
207 {
208  return d->status;
209 }
210 
211 VerificationModel *Verifier::model()
212 {
213  return d->model;
214 }
215 
216 QStringList Verifier::supportedVerficationTypes()
217 {
218  QStringList supported;
219 #ifdef HAVE_QCA2
220  QStringList supportedTypes = QCA::Hash::supportedTypes();
221  for (int i = 0; i < VerifierPrivate::SUPPORTED.count(); ++i)
222  {
223  if (supportedTypes.contains(VerifierPrivate::SUPPORTED.at(i)))
224  {
225  supported << VerifierPrivate::SUPPORTED.at(i);
226  }
227  }
228 #endif //HAVE_QCA2
229 
230  if (!supported.contains(VerifierPrivate::MD5))
231  {
232  supported << VerifierPrivate::MD5;
233  }
234 
235  return supported;
236 
237 }
238 
239 int Verifier::diggestLength(const QString &type)
240 {
241  if (type == VerifierPrivate::MD5)
242  {
243  return VerifierPrivate::MD5LENGTH;
244  }
245 
246 #ifdef HAVE_QCA2
247  if (QCA::isSupported(type.toLatin1()))
248  {
249  return VerifierPrivate::DIGGESTLENGTH[VerifierPrivate::SUPPORTED.indexOf(type)];
250  }
251 #endif //HAVE_QCA2
252 
253  return 0;
254 }
255 
256 bool Verifier::isChecksum(const QString &type, const QString &checksum)
257 {
258  const int length = diggestLength(type);
259  const QString pattern = QString("[0-9a-z]{%1}").arg(length);
260  //needs correct length and only word characters
261  if (length && (checksum.length() == length) && checksum.toLower().contains(QRegExp(pattern)))
262  {
263  return true;
264  }
265 
266  return false;
267 }
268 
269 QString Verifier::cleanChecksumType(const QString &type)
270 {
271  QString hashType = type.toUpper();
272  if (hashType.contains(QRegExp("^SHA\\d+"))) {
273  hashType.insert(3, '-');
274  }
275 
276  return hashType;
277 }
278 
279 bool Verifier::isVerifyable() const
280 {
281  return QFile::exists(d->dest.pathOrUrl()) && d->model->rowCount();
282 }
283 
284 bool Verifier::isVerifyable(const QModelIndex &index) const
285 {
286  int row = -1;
287  if (index.isValid())
288  {
289  row = index.row();
290  }
291  if (QFile::exists(d->dest.pathOrUrl()) && (row >= 0) && (row < d->model->rowCount()))
292  {
293  return true;
294  }
295  return false;
296 }
297 
298 Checksum Verifier::availableChecksum(Verifier::ChecksumStrength strength) const
299 {
300  Checksum pair;
301 
302  //check if there is at least one entry
303  QModelIndex index = d->model->index(0, 0);
304  if (!index.isValid())
305  {
306  return pair;
307  }
308 
309  const QStringList available = supportedVerficationTypes();
310  const QStringList supported = d->orderChecksumTypes(strength);
311  for (int i = 0; i < supported.count(); ++i) {
312  QModelIndexList indexList = d->model->match(index, Qt::DisplayRole, supported.at(i));
313  if (!indexList.isEmpty() && available.contains(supported.at(i))) {
314  QModelIndex match = d->model->index(indexList.first().row(), VerificationModel::Checksum);
315  pair.first = supported.at(i);
316  pair.second = match.data().toString();
317  break;
318  }
319  }
320 
321  return pair;
322 }
323 
324 QList<Checksum> Verifier::availableChecksums() const
325 {
326  QList<Checksum> checksums;
327 
328  for (int i = 0; i < d->model->rowCount(); ++i) {
329  const QString type = d->model->index(i, VerificationModel::Type).data().toString();
330  const QString hash = d->model->index(i, VerificationModel::Checksum).data().toString();
331  checksums << qMakePair(type, hash);
332  }
333 
334  return checksums;
335 }
336 
337 QPair<QString, PartialChecksums*> Verifier::availablePartialChecksum(Verifier::ChecksumStrength strength) const
338 {
339  QPair<QString, PartialChecksums*> pair;
340  QString type;
341  PartialChecksums *checksum = 0;
342 
343  const QStringList available = supportedVerficationTypes();
344  const QStringList supported = d->orderChecksumTypes(strength);
345  for (int i = 0; i < supported.size(); ++i) {
346  if (d->partialSums.contains(supported.at(i)) && available.contains(supported.at(i))) {
347  type = supported.at(i);
348  checksum = d->partialSums[type];
349  break;
350  }
351  }
352 
353  return QPair<QString, PartialChecksums*>(type, checksum);
354 }
355 
356 void Verifier::changeStatus(const QString &type, bool isVerified)
357 {
358  kDebug(5001) << "Verified:" << isVerified;
359  d->status = isVerified ? Verifier::Verified : Verifier::NotVerified;
360  d->model->setVerificationStatus(type, d->status);
361  emit verified(isVerified);
362 }
363 
364 void Verifier::verify(const QModelIndex &index)
365 {
366  int row = -1;
367  if (index.isValid()) {
368  row = index.row();
369  }
370 
371  QString type;
372  QString checksum;
373 
374  if (row == -1) {
375  Checksum pair = availableChecksum(static_cast<Verifier::ChecksumStrength>(Settings::checksumStrength()));
376  type = pair.first;
377  checksum = pair.second;
378  } else if ((row >= 0) && (row < d->model->rowCount())) {
379  type = d->model->index(row, VerificationModel::Type).data().toString();
380  checksum = d->model->index(row, VerificationModel::Checksum).data().toString();
381  }
382 
383  d->thread.verifiy(type, checksum, d->dest);
384 }
385 
386 void Verifier::brokenPieces() const
387 {
388  QPair<QString, PartialChecksums*> pair = availablePartialChecksum(static_cast<Verifier::ChecksumStrength>(Settings::checksumStrength()));
389  QList<QString> checksums;
390  KIO::filesize_t length = 0;
391  if (pair.second) {
392  checksums = pair.second->checksums();
393  length = pair.second->length();
394  }
395  d->thread.findBrokenPieces(pair.first, checksums, length, d->dest);
396 }
397 
398 QString Verifier::checksum(const KUrl &dest, const QString &type, bool *abortPtr)
399 {
400  QStringList supported = supportedVerficationTypes();
401  if (!supported.contains(type))
402  {
403  return QString();
404  }
405 
406  QFile file(dest.pathOrUrl());
407  if (!file.open(QIODevice::ReadOnly))
408  {
409  return QString();
410  }
411 
412  if (type == VerifierPrivate::MD5) {
413  KMD5 hash;
414  hash.update(file);
415  QString final = QString(hash.hexDigest());
416  file.close();
417  return final;
418  }
419 
420 
421 #ifdef HAVE_QCA2
422  QCA::Hash hash(type);
423 
424  //BEGIN taken from qca_basic.h and slightly adopted to allow abort
425  char buffer[1024];
426  int len;
427 
428  while ((len=file.read(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0)
429  {
430  hash.update(buffer, len);
431  if (abortPtr && *abortPtr)
432  {
433  hash.final();
434  file.close();
435  return QString();
436  }
437  }
438  //END
439 
440  QString final = QString(QCA::arrayToHex(hash.final().toByteArray()));
441  file.close();
442  return final;
443 #endif //HAVE_QCA2
444 
445  return QString();
446 }
447 
448 PartialChecksums Verifier::partialChecksums(const KUrl &dest, const QString &type, KIO::filesize_t length, bool *abortPtr)
449 {
450  QStringList checksums;
451 
452  QStringList supported = supportedVerficationTypes();
453  if (!supported.contains(type))
454  {
455  return PartialChecksums();
456  }
457 
458  QFile file(dest.pathOrUrl());
459  if (!file.open(QIODevice::ReadOnly))
460  {
461  return PartialChecksums();
462  }
463 
464  const KIO::filesize_t fileSize = file.size();
465  if (!fileSize)
466  {
467  return PartialChecksums();
468  }
469 
470  int numPieces = 0;
471 
472  //the piece length has been defined
473  if (length)
474  {
475  numPieces = fileSize / length;
476  }
477  else
478  {
479  length = VerifierPrivate::PARTSIZE;
480  numPieces = fileSize / length;
481  if (numPieces > 100)
482  {
483  numPieces = 100;
484  length = fileSize / numPieces;
485  }
486  }
487 
488  //there is a rest, so increase numPieces by one
489  if (fileSize % length)
490  {
491  ++numPieces;
492  }
493 
494  PartialChecksums partialChecksums;
495 
496  //create all the checksums for the pieces
497  for (int i = 0; i < numPieces; ++i)
498  {
499  QString hash = VerifierPrivate::calculatePartialChecksum(&file, type, length * i, length, fileSize, abortPtr);
500  if (hash.isEmpty())
501  {
502  file.close();
503  return PartialChecksums();
504  }
505  checksums.append(hash);
506  }
507 
508  partialChecksums.setLength(length);
509  partialChecksums.setChecksums(checksums);
510  file.close();
511  return partialChecksums;
512 }
513 
514 void Verifier::addChecksum(const QString &type, const QString &checksum, int verified)
515 {
516  d->model->addChecksum(type, checksum, verified);
517 }
518 
519 void Verifier::addChecksums(const QHash<QString, QString> &checksums)
520 {
521  d->model->addChecksums(checksums);
522 }
523 
524 void Verifier::addPartialChecksums(const QString &type, KIO::filesize_t length, const QStringList &checksums)
525 {
526  if (!d->partialSums.contains(type) && length && !checksums.isEmpty())
527  {
528  d->partialSums[type] = new PartialChecksums(length, checksums);
529  }
530 }
531 
532 KIO::filesize_t Verifier::partialChunkLength() const
533 {
534  QStringList::const_iterator it;
535  QStringList::const_iterator itEnd = VerifierPrivate::SUPPORTED.constEnd();
536  for (it = VerifierPrivate::SUPPORTED.constBegin(); it != itEnd; ++it)
537  {
538  if (d->partialSums.contains(*it))
539  {
540  return d->partialSums[*it]->length();
541  }
542  }
543 
544  return 0;
545 }
546 
547 void Verifier::save(const QDomElement &element)
548 {
549  QDomElement e = element;
550  e.setAttribute("verificationStatus", d->status);
551 
552  QDomElement verification = e.ownerDocument().createElement("verification");
553  for (int i = 0; i < d->model->rowCount(); ++i)
554  {
555  QDomElement hash = e.ownerDocument().createElement("hash");
556  hash.setAttribute("type", d->model->index(i, VerificationModel::Type).data().toString());
557  hash.setAttribute("verified", d->model->index(i, VerificationModel::Verified).data(Qt::EditRole).toInt());
558  QDomText value = e.ownerDocument().createTextNode(d->model->index(i, VerificationModel::Checksum).data().toString());
559  hash.appendChild(value);
560  verification.appendChild(hash);
561  }
562 
563  QHash<QString, PartialChecksums*>::const_iterator it;
564  QHash<QString, PartialChecksums*>::const_iterator itEnd = d->partialSums.constEnd();
565  for (it = d->partialSums.constBegin(); it != itEnd; ++it)
566  {
567  QDomElement pieces = e.ownerDocument().createElement("pieces");
568  pieces.setAttribute("type", it.key());
569  pieces.setAttribute("length", (*it)->length());
570  QList<QString> checksums = (*it)->checksums();
571  for (int i = 0; i < checksums.size(); ++i)
572  {
573  QDomElement hash = e.ownerDocument().createElement("hash");
574  hash.setAttribute("piece", i);
575  QDomText value = e.ownerDocument().createTextNode(checksums[i]);
576  hash.appendChild(value);
577  pieces.appendChild(hash);
578  }
579  verification.appendChild(pieces);
580  }
581  e.appendChild(verification);
582 }
583 
584 void Verifier::load(const QDomElement &e)
585 {
586  if (e.hasAttribute("verificationStatus"))
587  {
588  const int status = e.attribute("verificationStatus").toInt();
589  switch (status)
590  {
591  case NoResult:
592  d->status = NoResult;
593  break;
594  case NotVerified:
595  d->status = NotVerified;
596  break;
597  case Verified:
598  d->status = Verified;
599  break;
600  default:
601  d->status = NotVerified;
602  break;
603  }
604  }
605 
606  QDomElement verification = e.firstChildElement("verification");
607  QDomNodeList const hashList = verification.elementsByTagName("hash");
608 
609  for (uint i = 0; i < hashList.length(); ++i)
610  {
611  const QDomElement hash = hashList.item(i).toElement();
612  const QString value = hash.text();
613  const QString type = hash.attribute("type");
614  const int verificationStatus = hash.attribute("verified").toInt();
615  if (!type.isEmpty() && !value.isEmpty())
616  {
617  d->model->addChecksum(type, value, verificationStatus);
618  }
619  }
620 
621  QDomNodeList const piecesList = verification.elementsByTagName("pieces");
622 
623  for (uint i = 0; i < piecesList.length(); ++i)
624  {
625  QDomElement pieces = piecesList.at(i).toElement();
626 
627  const QString type = pieces.attribute("type");
628  const KIO::filesize_t length = pieces.attribute("length").toULongLong();
629  QStringList partialChecksums;
630 
631  const QDomNodeList partialHashList = pieces.elementsByTagName("hash");
632  for (int i = 0; i < partialHashList.size(); ++i)//TODO give this function the size of the file, to calculate how many hashs are needed as an additional check, do that check in addPartialChecksums?!
633  {
634  const QString hash = partialHashList.at(i).toElement().text();
635  if (hash.isEmpty())
636  {
637  break;
638  }
639  partialChecksums.append(hash);
640  }
641 
642  addPartialChecksums(type, length, partialChecksums);
643  }
644 }
645 
646 #include "verifier.moc"
VerifierPrivate::MD5
static const QString MD5
Definition: verifier_p.h:55
Verifier::availableChecksums
QList< Checksum > availableChecksums() const
Returns all set checksums.
Definition: verifier.cpp:324
Checksum
QPair< QString, QString > Checksum
Definition: verifier.h:36
VerifierPrivate::dBusObjectPath
QString dBusObjectPath
Definition: verifier_p.h:45
VerifierPrivate::thread
VerificationThread thread
Definition: verifier_p.h:52
VerifierPrivate::orderChecksumTypes
QStringList orderChecksumTypes(Verifier::ChecksumStrength strength) const
Definition: verifier.cpp:142
Verifier::ChecksumStrength
ChecksumStrength
Definition: verifier.h:83
Verifier::addPartialChecksums
void addPartialChecksums(const QString &type, KIO::filesize_t length, const QStringList &checksums)
Add partial checksums that can be used as repairinformation.
Definition: verifier.cpp:524
verificationmodel.h
VerifierPrivate::~VerifierPrivate
~VerifierPrivate()
Definition: verifier.cpp:44
Verifier::Verified
Definition: verifier.h:80
verifier_p.h
Verifier::verify
void verify(const QModelIndex &index=QModelIndex())
Call this method if you want to verify() in its own thread, then signals with the result are emitted...
Definition: verifier.cpp:364
Settings::checksumStrength
static int checksumStrength()
Get ChecksumStrength.
Definition: settings.h:1038
VerifierPrivate::PARTSIZE
static const int PARTSIZE
Definition: verifier_p.h:58
Verifier::partialChunkLength
KIO::filesize_t partialChunkLength() const
Returns the length of the "best" partialChecksums.
Definition: verifier.cpp:532
Verifier::diggestLength
static int diggestLength(const QString &type)
Returns the diggest length of type.
Definition: verifier.cpp:239
VerificationThread::verifiy
void verifiy(const QString &type, const QString &checksum, const KUrl &file)
Definition: verificationthread.cpp:44
Verifier::NoResult
Definition: verifier.h:78
Verifier::verified
void verified(bool verified)
Emitted when the verification of a file finishes.
DBusVerifierWrapper
Definition: dbusverifierwrapper.h:28
Verifier::destination
KUrl destination() const
Definition: verifier.cpp:196
Verifier::supportedVerficationTypes
static QStringList supportedVerficationTypes()
Returns the supported verification types.
Definition: verifier.cpp:216
Verifier::Strongest
Definition: verifier.h:87
Verifier::VerificationStatus
VerificationStatus
Definition: verifier.h:76
Verifier::isChecksum
static bool isChecksum(const QString &type, const QString &checksum)
Tries to check if the checksum is a checksum and if it is supported it compares the diggestLength and...
Definition: verifier.cpp:256
QObject
Verifier::load
void load(const QDomElement &e)
Definition: verifier.cpp:584
Verifier::setDestination
void setDestination(const KUrl &destination)
Definition: verifier.cpp:201
VerifierPrivate::SUPPORTED
static const QStringList SUPPORTED
Definition: verifier_p.h:54
Verifier::status
VerificationStatus status() const
Definition: verifier.cpp:206
Verifier::availableChecksum
Checksum availableChecksum(ChecksumStrength strength) const
Returns a checksum and a type.
Definition: verifier.cpp:298
VerificationModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: verificationmodel.cpp:130
VerifierPrivate::status
Verifier::VerificationStatus status
Definition: verifier_p.h:48
PartialChecksums::setLength
void setLength(KIO::filesize_t length)
Definition: verifier.h:56
PartialChecksums::setChecksums
void setChecksums(const QStringList &checksums)
Definition: verifier.h:59
VerificationModel::setVerificationStatus
void setVerificationStatus(const QString &type, int verified)
Sets the verificationStatus for type.
Definition: verificationmodel.cpp:212
Verifier::Weak
Definition: verifier.h:85
Verifier::dBusObjectPath
QString dBusObjectPath() const
Definition: verifier.cpp:191
Verifier::save
void save(const QDomElement &element)
Definition: verifier.cpp:547
Verifier::Verifier
Verifier(const KUrl &dest, QObject *parent=0)
Definition: verifier.cpp:163
VerificationThread::findBrokenPieces
void findBrokenPieces(const QString &type, const QList< QString > checksums, KIO::filesize_t length, const KUrl &file)
Definition: verificationthread.cpp:58
VerificationModel::Verified
Definition: verificationmodel.h:40
Verifier::availablePartialChecksum
QPair< QString, PartialChecksums * > availablePartialChecksum(Verifier::ChecksumStrength strength) const
Returns a PartialChecksum and a type.
Definition: verifier.cpp:337
VerificationModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: verificationmodel.cpp:50
Verifier::partialChecksums
static PartialChecksums partialChecksums(const KUrl &dest, const QString &type, KIO::filesize_t length=0, bool *abortPtr=0)
Create partial checksums of type for file dest.
Definition: verifier.cpp:448
VerifierPrivate::partialSums
QHash< QString, PartialChecksums * > partialSums
Definition: verifier_p.h:50
Verifier::cleanChecksumType
static QString cleanChecksumType(const QString &type)
Cleans the checksum type, that it should match the official name, i.e.
Definition: verifier.cpp:269
VerifierPrivate::model
VerificationModel * model
Definition: verifier_p.h:46
settings.h
Verifier::model
VerificationModel * model()
Definition: verifier.cpp:211
Verifier::Strong
Definition: verifier.h:86
VerifierPrivate::calculatePartialChecksum
static QString calculatePartialChecksum(QFile *file, const QString &type, KIO::fileoffset_t startOffset, int pieceLength, KIO::filesize_t fileSize=0, bool *abortPtr=0)
Definition: verifier.cpp:50
Verifier::isVerifyable
bool isVerifyable() const
Definition: verifier.cpp:279
Verifier::addChecksums
void addChecksums(const QHash< QString, QString > &checksums)
Add multiple checksums that will later be used in the verification process.
Definition: verifier.cpp:519
VerificationModel
Definition: verificationmodel.h:29
VerifierPrivate::dest
KUrl dest
Definition: verifier_p.h:47
VerificationModel::addChecksum
void addChecksum(const QString &type, const QString &checksum, int verified=0)
Add a checksum that is later used in the verification process.
Definition: verificationmodel.cpp:179
VerifierPrivate::DIGGESTLENGTH
static const int DIGGESTLENGTH[]
Definition: verifier_p.h:56
VerificationModel::addChecksums
void addChecksums(const QHash< QString, QString > &checksums)
Add multiple checksums that will later be used in the verification process.
Definition: verificationmodel.cpp:203
Verifier::addChecksum
void addChecksum(const QString &type, const QString &checksum, int verified=0)
Add a checksum that is later used in the verification process.
Definition: verifier.cpp:514
Verifier::checksum
static QString checksum(const KUrl &dest, const QString &type, bool *abortPtr)
Creates the checksum type of the file dest.
Definition: verifier.cpp:398
VerifierPrivate::MD5LENGTH
static const int MD5LENGTH
Definition: verifier_p.h:57
Verifier::NotVerified
Definition: verifier.h:79
Verifier::~Verifier
~Verifier()
Definition: verifier.cpp:186
VerificationModel::Type
Definition: verificationmodel.h:38
VerifierPrivate
Definition: verifier_p.h:29
VerificationModel::Checksum
Definition: verificationmodel.h:39
Verifier::brokenPieces
void brokenPieces() const
Call this method after calling verify() with a negative result, it will emit a list of the broken pie...
Definition: verifier.cpp:386
PartialChecksums
Definition: verifier.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal