File: AlpineApkAuthHelper.h

package info (click to toggle)
plasma-discover 6.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,288 kB
  • sloc: cpp: 30,576; xml: 2,710; python: 311; sh: 5; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 1,636 bytes parent folder | download | duplicates (2)
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
/*
 *   SPDX-FileCopyrightText: 2020 Alexey Minnekhanov <alexey.min@gmail.com>
 *
 *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
 */

#include <QEventLoop>
#include <QObject>
#include <QVariant>

#include <KAuth/ActionReply>

#include <QtApk>

using namespace KAuth;

class AlpineApkAuthHelper : public QObject
{
    Q_OBJECT
public:
    AlpineApkAuthHelper();
    ~AlpineApkAuthHelper() override;

public Q_SLOTS:
    // single entry point for all package management operations
    ActionReply pkgmgmt(const QVariantMap &args);

protected:
    // helpers
    bool openDatabase(const QVariantMap &args, bool readwrite = true);
    void closeDatabase();
    void setupTransactionPostCreate(QtApk::Transaction *trans);

    // individual pakckage management actions
    void update(const QVariantMap &args);
    void add(const QVariantMap &args);
    void del(const QVariantMap &args);
    void upgrade(const QVariantMap &args);
    void repoconfig(const QVariantMap &args);

protected Q_SLOTS:
    void reportProgress(float percent);
    void onTransactionError(const QString &msg);
    void onTransactionFinished();

private:
    QtApk::DatabaseAsync m_apkdb; // runs transactions in bg thread
    QtApk::Transaction *m_currentTransaction = nullptr;
    QEventLoop *m_loop = nullptr; // event loop that will run and wait while bg transaction is in progress
    ActionReply m_actionReply; // return value for main action slots
    bool m_trans_ok = true; // flag to indicate if bg transaction was successful
    QtApk::Changeset m_lastChangeset; // changeset from last completed transaction
};