File: SessionTask.h

package info (click to toggle)
apper 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,868 kB
  • sloc: cpp: 14,381; xml: 941; makefile: 15; sh: 4
file content (150 lines) | stat: -rw-r--r-- 5,006 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/***************************************************************************
 *   Copyright (C) 2009-2011 by Daniel Nicoletti                           *
 *   dantti12@gmail.com                                                    *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; see the file COPYING. If not, write to       *
 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
 *   Boston, MA 02110-1301, USA.                                           *
 ***************************************************************************/

#ifndef SESSION_TASK_H
#define SESSION_TASK_H

#include <Transaction>
#include <PkTransaction.h>

#include <QDBusMessage>
#include <QDialog>

namespace Ui {
    class SessionTask;
}

class PackageModel;
class ReviewChanges;
class PkTransactionWidget;
class SessionTask : public QDialog
{
    Q_OBJECT
    Q_ENUMS(Errors)
public:
    SessionTask(uint xid, const QString &interaction, const QDBusMessage &message, QWidget *parent = 0);
    ~SessionTask();

    typedef enum{
        Failed,
        InternalError,
        NoPackagesFound,
        Forbidden,
        Cancelled
    } DBusError;

    enum Interaction {
        ConfirmSearch   = 0x001,
        ConfirmDeps     = 0x002,
        ConfirmInstall  = 0x004,
        Progress        = 0x010,
        Finished        = 0x020,
        Warning         = 0x040,
        Unknown         = 0x100
    };
    Q_DECLARE_FLAGS(Interactions, Interaction)

    typedef struct {
        Transaction::Info info;
        QString packageID;
        QString summary;
    } IPackage;

    bool showConfirmSearch() const;
    bool showConfirmDeps() const;
    bool showConfirmInstall() const;
    bool showProgress() const;
    bool showFinished() const;
    bool showWarning() const;

    Interactions interactions() const;
    uint timeout() const;

    QWidget* mainWidget();
    uint parentWId() const;

    void slotContinueClicked();
    void slotCancelClicked();

Q_SIGNALS:
    void continueClicked();
    void cancelClicked();

public Q_SLOTS:
    void enableButtonOk(bool enable);
    void setMainWidget(QWidget *widget);

protected:
    // Virtual methods to easy subclasses
    virtual void search();
    virtual void commit();
    virtual void notFound();
    virtual void searchFailed();
    virtual void searchSuccess();
    virtual void commitFailed();
    virtual void commitSuccess(QWidget *widget = 0);

    void showCloseButton();
    bool foundPackages() const;
    int  foundPackagesSize() const;
    PackageModel* model() const;
    void setTransaction(Transaction::Role role, PkTransaction *transaction = 0);
    void finishTaskOk();
    void sendErrorFinished(DBusError error, const QString &msg);
    bool sendMessageFinished(const QDBusMessage &message);
    QString parentTitle;

protected Q_SLOTS:
    void setTitle(const QString &title);
    void setInfo(const QString &title, const QString &text, const QString &details = QString());
    void setError(const QString &title, const QString &text, const QString &details = QString());
    void setFinish(const QString &title, const QString &text, QWidget *widget = 0);
    virtual void addPackage(PackageKit::Transaction::Info info, const QString &packageID, const QString &summary);
    virtual void searchFinished(PkTransaction::ExitStatus status);
    virtual void commitFinished(PkTransaction::ExitStatus status);

private Q_SLOTS:
    void updatePallete();
    void setDialog(QDialog *dialog);

private:
    void removePackages();
    void parseInteraction(const QString &interaction);
    uint getPidSystem();
    uint getPidSession();
    QString getCmdLine(uint pid);
    bool pathIsTrusted(const QString &exec);
    void setExec(const QString &exec);

    uint m_xid;
    uint m_pid;
    QDBusMessage m_message;
    Interactions m_interactions;
    uint m_timeout;
    PackageModel *m_model;
    QStringList m_removePackages;
    ReviewChanges *m_reviewChanges = nullptr;
    PkTransactionWidget *m_pkTransaction = nullptr;
    Ui::SessionTask *ui;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(SessionTask::Interactions)

#endif