akabeidelta.h 3.11 KB
Newer Older
Dario Freddi's avatar
Dario Freddi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
   This file is part of the Chakra project

   Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#ifndef AKABEI_AKABEIDELTA_H
#define AKABEI_AKABEIDELTA_H

15
#include <QtCore/QObject>
Dario Freddi's avatar
Dario Freddi committed
16 17 18 19

namespace Akabei {

class DeltaPrivate;
Lukas Appelhans's avatar
Lukas Appelhans committed
20 21 22 23 24 25 26 27 28 29 30 31 32

/**
 * \class Delta Akabei/Delta
 *
 * \brief This class describes a binary patch we use to upgrade from one package version to another.
 * 
 * Akabei Deltas can either be loaded from the \c Database or from a local file (\c Backend). If both the
 * path to the .delta.tar.xz-file and the original package are set, it's just a matter of running the command
 * generated by \c xdeltaApplyCommand.
 * @see setPathToDelta()
 * @see setPathToSource()
 * @see xdeltaApplyCommand
 */
Dario Freddi's avatar
Dario Freddi committed
33 34 35 36 37 38
class Delta {
    Q_DISABLE_COPY(Delta)
    Q_DECLARE_PRIVATE(Delta)
    public:
        virtual ~Delta();

Lukas Appelhans's avatar
Lukas Appelhans committed
39 40 41
        /**
         * @returns the correct md5sum of the delta
         */
Dario Freddi's avatar
Dario Freddi committed
42 43
        QByteArray md5sum() const;

Lukas Appelhans's avatar
Lukas Appelhans committed
44 45 46
        /**
         * @returns the name of the package the delta needs to be applied on
         */
Dario Freddi's avatar
Dario Freddi committed
47
        QString targetName() const;
Lukas Appelhans's avatar
Lukas Appelhans committed
48 49 50
        /**
         * @returns the version of the package which the delta needs to be applied on
         */
51
        QByteArray versionFrom() const;
Lukas Appelhans's avatar
Lukas Appelhans committed
52 53 54 55
        /**
         * @returns the version of the package which is generated after the delta got applied to
         * a package with \c versionFrom
         */
56
        QByteArray versionTo() const;
Dario Freddi's avatar
Dario Freddi committed
57

Lukas Appelhans's avatar
Lukas Appelhans committed
58 59 60
        /**
         * @returns the filename of the .delta.tar.xz-file on disk
         */
Dario Freddi's avatar
Dario Freddi committed
61 62
        QString filename() const;

Lukas Appelhans's avatar
Lukas Appelhans committed
63 64 65 66
        /**
         * Checks whether the md5sum given in the .DELTAINFO and the real md5sum match
         * @returns true when both match
         */
Dario Freddi's avatar
Dario Freddi committed
67 68
        bool checkMD5Sum();

Lukas Appelhans's avatar
Lukas Appelhans committed
69 70 71 72
        /**
         * @returns the command used for generating the package with version \c versionTo
         * @param pathToDestination the path to the package with \c versionTo, not existent at this point
         */
Dario Freddi's avatar
Dario Freddi committed
73 74
        QString xdeltaApplyCommand(const QString &pathToDestination) const;

Lukas Appelhans's avatar
Lukas Appelhans committed
75 76 77
        /**
         * @returns the path to the .delta.tar.xz-file
         */
Dario Freddi's avatar
Dario Freddi committed
78
        QString pathToDelta() const;
Lukas Appelhans's avatar
Lukas Appelhans committed
79 80 81 82
        /**
         * Set the path to the .delta.tar.xz-file
         * @param path the path of the file
         */
Dario Freddi's avatar
Dario Freddi committed
83 84
        void setPathToDelta(const QString &path);

Lukas Appelhans's avatar
Lukas Appelhans committed
85 86 87
        /**
         * @returns the path to the package with version \c versionFrom
         */
Dario Freddi's avatar
Dario Freddi committed
88
        QString pathToSource() const;
Lukas Appelhans's avatar
Lukas Appelhans committed
89 90 91 92
        /**
         * Sets the path to the package with version \c versionFrom
         * @param path the path to the package
         */
Dario Freddi's avatar
Dario Freddi committed
93 94 95
        void setPathToSource(const QString &path);

    private:
96
        Delta(const QString &targetName, const QByteArray &versionFrom, const QByteArray &versionTo);
Dario Freddi's avatar
Dario Freddi committed
97

98
        DeltaPrivate * const d_ptr;
Dario Freddi's avatar
Dario Freddi committed
99

100
        friend class Backend;
Dario Freddi's avatar
Dario Freddi committed
101 102 103 104 105 106 107
        friend class Database;
        friend class DatabasePrivate;
};

}

#endif // AKABEI_AKABEIDELTA_H