~dantti/apper/master

« back to all changes in this revision

Viewing changes to PkSession/SessionTask.h

  • Committer: Daniel Nicoletti
  • Date: 2012-12-16 13:51:04 UTC
  • Revision ID: git-v1:4e1499a55d1ec8a637f03979cde84aaa4a4440ba
Renaming ApperSentinel to ApperPkSession since that's all it will do now

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2009-2011 by Daniel Nicoletti                           *
 
3
 *   dantti12@gmail.com                                                    *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; see the file COPYING. If not, write to       *
 
17
 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
 
18
 *   Boston, MA 02110-1301, USA.                                           *
 
19
 ***************************************************************************/
 
20
 
 
21
#ifndef SESSION_TASK_H
 
22
#define SESSION_TASK_H
 
23
 
 
24
#include <Transaction>
 
25
#include <PkTransaction.h>
 
26
 
 
27
#include <QDBusMessage>
 
28
#include <KDialog>
 
29
 
 
30
namespace Ui {
 
31
    class SessionTask;
 
32
}
 
33
 
 
34
class PackageModel;
 
35
class ReviewChanges;
 
36
class PkTransactionWidget;
 
37
class SessionTask : public KDialog
 
38
{
 
39
    Q_OBJECT
 
40
    Q_ENUMS(Errors)
 
41
public:
 
42
    SessionTask(uint xid, const QString &interaction, const QDBusMessage &message, QWidget *parent = 0);
 
43
    ~SessionTask();
 
44
 
 
45
    typedef enum{
 
46
        Failed,
 
47
        InternalError,
 
48
        NoPackagesFound,
 
49
        Forbidden,
 
50
        Cancelled
 
51
    } DBusError;
 
52
 
 
53
    enum Interaction {
 
54
        ConfirmSearch   = 0x001,
 
55
        ConfirmDeps     = 0x002,
 
56
        ConfirmInstall  = 0x004,
 
57
        Progress        = 0x010,
 
58
        Finished        = 0x020,
 
59
        Warning         = 0x040,
 
60
        Unknown         = 0x100
 
61
    };
 
62
    Q_DECLARE_FLAGS(Interactions, Interaction)
 
63
 
 
64
    typedef struct {
 
65
        Transaction::Info info;
 
66
        QString packageID;
 
67
        QString summary;
 
68
    } IPackage;
 
69
 
 
70
    bool showConfirmSearch() const;
 
71
    bool showConfirmDeps() const;
 
72
    bool showConfirmInstall() const;
 
73
    bool showProgress() const;
 
74
    bool showFinished() const;
 
75
    bool showWarning() const;
 
76
 
 
77
    virtual void slotButtonClicked(int button);
 
78
 
 
79
    Interactions interactions() const;
 
80
    uint timeout() const;
 
81
 
 
82
    QWidget* mainWidget();
 
83
    uint parentWId() const;
 
84
 
 
85
public slots:
 
86
    void enableButtonOk(bool state);
 
87
    void setMainWidget(QWidget *widget);
 
88
 
 
89
protected:
 
90
    // Virtual methods to easy subclasses
 
91
    virtual void search();
 
92
    virtual void commit();
 
93
    virtual void notFound();
 
94
    virtual void searchFailed();
 
95
    virtual void searchSuccess();
 
96
    virtual void commitFailed();
 
97
    virtual void commitSuccess(QWidget *widget = 0);
 
98
 
 
99
    bool foundPackages() const;
 
100
    int  foundPackagesSize() const;
 
101
    PackageModel* model() const;
 
102
    void setTransaction(Transaction::Role role, PkTransaction *transaction = 0);
 
103
    void finishTaskOk();
 
104
    void sendErrorFinished(DBusError error, const QString &msg);
 
105
    bool sendMessageFinished(const QDBusMessage &message);
 
106
    QString parentTitle;
 
107
 
 
108
protected slots:
 
109
    void setTitle(const QString &title);
 
110
    void setInfo(const QString &title, const QString &text, const QString &details = QString());
 
111
    void setError(const QString &title, const QString &text, const QString &details = QString());
 
112
    void setFinish(const QString &title, const QString &text, QWidget *widget = 0);
 
113
    virtual void addPackage(PackageKit::Transaction::Info info, const QString &packageID, const QString &summary);
 
114
    virtual void searchFinished(PkTransaction::ExitStatus status);
 
115
    virtual void commitFinished(PkTransaction::ExitStatus status);
 
116
 
 
117
private slots:
 
118
    void updatePallete();
 
119
    void setDialog(KDialog *dialog);
 
120
 
 
121
private:
 
122
    void removePackages();
 
123
    void parseInteraction(const QString &interaction);
 
124
    uint getPidSystem();
 
125
    uint getPidSession();
 
126
    QString getCmdLine(uint pid);
 
127
    bool pathIsTrusted(const QString &exec);
 
128
    void setExec(const QString &exec);
 
129
 
 
130
    uint m_xid;
 
131
    uint m_pid;
 
132
    QDBusMessage m_message;
 
133
    Interactions m_interactions;
 
134
    uint m_timeout;
 
135
    PackageModel *m_model;
 
136
    QStringList m_removePackages;
 
137
    ReviewChanges *m_reviewChanges;
 
138
    PkTransactionWidget *m_pkTransaction;
 
139
    Ui::SessionTask *ui;
 
140
};
 
141
 
 
142
Q_DECLARE_OPERATORS_FOR_FLAGS(SessionTask::Interactions)
 
143
 
 
144
#endif