• 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.h
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 #ifndef VERIFIER_H
21 #define VERIFIER_H
22 
23 #include <kio/global.h>
24 #include <KUrl>
25 
26 #include <QtCore/QModelIndex>
27 #include <QtCore/QHash>
28 #include <QtCore/QStringList>
29 
30 #include "../kget_export.h"
31 
32 class QDomElement;
33 class QFile;
34 class TransferHandler;
35 class VerificationModel;
36 class VerifierPrivate;
37 typedef QPair<QString, QString> Checksum;
38 
39 
40 class KGET_EXPORT PartialChecksums
41 {
42  public:
43  PartialChecksums()
44  : m_length(0)
45  {
46  }
47 
48  PartialChecksums(KIO::filesize_t len, const QStringList &sums)
49  : m_length(len), m_checksums(sums)
50  {
51  }
52 
53  bool isValid() const {return (length() && m_checksums.count());}
54 
55  KIO::filesize_t length() const {return m_length;}
56  void setLength(KIO::filesize_t length) {m_length = length;}
57 
58  QStringList checksums() const {return m_checksums;}
59  void setChecksums(const QStringList &checksums) {m_checksums = checksums;}
60 
61  private:
62  KIO::filesize_t m_length;
63  QStringList m_checksums;
64 };
65 
66 Q_DECLARE_METATYPE(PartialChecksums)
67 
68 class KGET_EXPORT Verifier : public QObject
69 {
70  Q_OBJECT
71 
72  public:
73  explicit Verifier(const KUrl &dest, QObject *parent = 0);
74  ~Verifier();
75 
76  enum VerificationStatus
77  {
78  NoResult, //either not tried, or not enough information
79  NotVerified,
80  Verified
81  };
82 
83  enum ChecksumStrength
84  {
85  Weak,
86  Strong,
87  Strongest
88  };
89 
93  QString dBusObjectPath() const;
94 
95  KUrl destination() const;
96  void setDestination(const KUrl &destination);//TODO handle the case when m_thread is working, while the file gets moved
97 
98  VerificationStatus status() const;
99 
104  static QStringList supportedVerficationTypes();
105 
111  static int diggestLength(const QString &type);
112 
119  static bool isChecksum(const QString &type, const QString &checksum);
120 
125  static QString cleanChecksumType(const QString &type);
126 
131  static QString checksum(const KUrl &dest, const QString &type, bool *abortPtr);
132 
139  static PartialChecksums partialChecksums(const KUrl &dest, const QString &type, KIO::filesize_t length = 0, bool *abortPtr = 0);
140 
145  bool isVerifyable() const;
146 
153  bool isVerifyable(const QModelIndex &index) const;
154 
161  void verify(const QModelIndex &index = QModelIndex());
162 
168  void brokenPieces() const;
169 
181  void addChecksum(const QString &type, const QString &checksum, int verified = 0);
182 
192  void addChecksums(const QHash<QString, QString> &checksums);
193 
203  void addPartialChecksums(const QString &type, KIO::filesize_t length, const QStringList &checksums);
204 
208  KIO::filesize_t partialChunkLength() const;
209 
218  Checksum availableChecksum(ChecksumStrength strength) const;
219 
223  QList<Checksum> availableChecksums() const;
224 
233  QPair<QString, PartialChecksums*> availablePartialChecksum(Verifier::ChecksumStrength strength) const;
234 
238  VerificationModel *model();
239 
240  void save(const QDomElement &element);
241  void load(const QDomElement &e);
242 
243  signals:
247  void verified(bool verified);
248 
252  void brokenPieces(const QList<KIO::fileoffset_t> &offsets, KIO::filesize_t length);
253 
254  private slots:
255  void changeStatus(const QString &type, bool verified);
256 
257  private:
258  VerifierPrivate *const d;
259 
260  friend class VerifierPrivate;
261 };
262 
263 #endif //VERIFIER_H
Checksum
QPair< QString, QString > Checksum
Definition: verifier.h:36
TransferHandler
Class TransferHandler:
Definition: transferhandler.h:48
Verifier::ChecksumStrength
ChecksumStrength
Definition: verifier.h:83
Verifier::NoResult
Definition: verifier.h:78
PartialChecksums::length
KIO::filesize_t length() const
Definition: verifier.h:55
Verifier::VerificationStatus
VerificationStatus
Definition: verifier.h:76
QObject
PartialChecksums::PartialChecksums
PartialChecksums()
Definition: verifier.h:43
PartialChecksums::setLength
void setLength(KIO::filesize_t length)
Definition: verifier.h:56
PartialChecksums::isValid
bool isValid() const
Definition: verifier.h:53
PartialChecksums::setChecksums
void setChecksums(const QStringList &checksums)
Definition: verifier.h:59
PartialChecksums::checksums
QStringList checksums() const
Definition: verifier.h:58
Verifier::Weak
Definition: verifier.h:85
PartialChecksums::PartialChecksums
PartialChecksums(KIO::filesize_t len, const QStringList &sums)
Definition: verifier.h:48
Verifier
Definition: verifier.h:68
Verifier::Strong
Definition: verifier.h:86
VerificationModel
Definition: verificationmodel.h:29
KGET_EXPORT
#define KGET_EXPORT
Definition: kget_export.h:24
Verifier::NotVerified
Definition: verifier.h:79
VerifierPrivate
Definition: verifier_p.h:29
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