~ubuntu-branches/ubuntu/maverick/kdebase-workspace/maverick-proposed

« back to all changes in this revision

Viewing changes to kdm/kfrontend/kgverify.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-07-08 01:11:52 UTC
  • mfrom: (1.1.43 upstream)
  • Revision ID: james.westby@ubuntu.com-20100708011152-z0h26httnjr91mmy
Tags: 4:4.4.92-0ubuntu1
* New upstream rc release:
  - Bump kde-sc-dev-latest to 4.4.92
  - Refresh patches
  - Update symbols
  - plasma-widgets-workspace replaces/conflicts plasma-widget-logout

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
// helper class, nuke when qt supports suspend()/resume()
47
47
class QXTimer : public QObject {
48
 
        Q_OBJECT
49
 
        typedef QObject inherited;
 
48
    Q_OBJECT
 
49
    typedef QObject inherited;
50
50
 
51
51
  public:
52
 
        QXTimer();
53
 
        void start( int msec );
54
 
        void stop();
55
 
        void suspend();
56
 
        void resume();
 
52
    QXTimer();
 
53
    void start(int msec);
 
54
    void stop();
 
55
    void suspend();
 
56
    void resume();
57
57
 
58
58
  Q_SIGNALS:
59
 
        void timeout();
 
59
    void timeout();
60
60
 
61
61
  private Q_SLOTS:
62
 
        void slotTimeout();
 
62
    void slotTimeout();
63
63
 
64
64
  private:
65
 
        QTimer timer;
66
 
        struct timeval stv;
67
 
        long left;
 
65
    QTimer timer;
 
66
    struct timeval stv;
 
67
    long left;
68
68
};
69
69
 
70
70
class KGVerifyHandler {
71
71
  public:
72
 
        virtual ~KGVerifyHandler(){}
73
 
        virtual void verifyPluginChanged( int id ) = 0;
74
 
        virtual void verifyClear();
75
 
        virtual void verifyOk() = 0;
76
 
        virtual void verifyFailed() = 0;
77
 
        virtual void verifyRetry() = 0;
78
 
        virtual void verifySetUser( const QString &user ) = 0;
79
 
        virtual void updateStatus( bool fail, bool caps, int left ); // for themed only
 
72
    virtual ~KGVerifyHandler() {}
 
73
    virtual void verifyPluginChanged(int id) = 0;
 
74
    virtual void verifyClear();
 
75
    virtual void verifyOk() = 0;
 
76
    virtual void verifyFailed() = 0;
 
77
    virtual void verifyRetry() = 0;
 
78
    virtual void verifySetUser(const QString &user) = 0;
 
79
    virtual void updateStatus(bool fail, bool caps, int left); // for themed only
80
80
};
81
81
 
82
82
struct GreeterPluginHandle {
83
 
        KLibrary *library;
84
 
        KGreeterPluginInfo *info;
85
 
        QAction *action;
 
83
    KLibrary *library;
 
84
    KGreeterPluginInfo *info;
 
85
    QAction *action;
86
86
};
87
87
 
88
88
typedef QVector<int> PluginList;
89
89
 
90
90
class KGVerify : public QObject, public KGreeterPluginHandler {
91
 
        Q_OBJECT
92
 
        typedef QObject inherited;
 
91
    Q_OBJECT
 
92
    typedef QObject inherited;
93
93
 
94
94
  public:
95
 
        KGVerify( KGVerifyHandler *handler,
96
 
                  QWidget *parent, QWidget *predecessor,
97
 
                  const QString &fixedEntity, const PluginList &pluginList,
98
 
                  KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
99
 
        virtual ~KGVerify();
100
 
        QMenu *getPlugMenu();
101
 
        void loadUsers( const QStringList &users );
102
 
        void presetEntity( const QString &entity, int field );
103
 
        QString getEntity() const;
104
 
        void setUser( const QString &user );
105
 
        virtual void selectPlugin( int id );
106
 
        bool entitiesLocal() const;
107
 
        bool entitiesFielded() const;
108
 
        bool entityPresettable() const;
109
 
        bool isClassic() const;
110
 
        QString pluginName() const;
111
 
        void setEnabled( bool on );
112
 
        void abort();
113
 
        void suspend();
114
 
        void resume();
115
 
        void accept();
116
 
        void reject();
117
 
 
118
 
        enum { CoreIdle, CorePrompting, CoreBusy } coreState;
119
 
 
120
 
        static bool handleFailVerify( QWidget *parent, bool showUser );
121
 
        static PluginList init( const QStringList &plugins );
122
 
        static void done();
 
95
    KGVerify(KGVerifyHandler *handler,
 
96
             QWidget *parent, QWidget *predecessor,
 
97
             const QString &fixedEntity, const PluginList &pluginList,
 
98
             KGreeterPlugin::Function func, KGreeterPlugin::Context ctx);
 
99
    virtual ~KGVerify();
 
100
    QMenu *getPlugMenu();
 
101
    void loadUsers(const QStringList &users);
 
102
    void presetEntity(const QString &entity, int field);
 
103
    QString getEntity() const;
 
104
    void setUser(const QString &user);
 
105
    virtual void selectPlugin(int id);
 
106
    bool entitiesLocal() const;
 
107
    bool entitiesFielded() const;
 
108
    bool entityPresettable() const;
 
109
    bool isClassic() const;
 
110
    QString pluginName() const;
 
111
    void setEnabled(bool on);
 
112
    void abort();
 
113
    void suspend();
 
114
    void resume();
 
115
    void accept();
 
116
    void reject();
 
117
 
 
118
    enum { CoreIdle, CorePrompting, CoreBusy } coreState;
 
119
 
 
120
    static bool handleFailVerify(QWidget *parent, bool showUser);
 
121
    static PluginList init(const QStringList &plugins);
 
122
    static void done();
123
123
 
124
124
  public Q_SLOTS:
125
 
        void start();
 
125
    void start();
126
126
 
127
127
  protected:
128
 
        bool eventFilter( QObject *, QEvent * );
129
 
        void msgBox( QMessageBox::Icon typ, const QString &msg );
130
 
        void setTimer();
131
 
        void updateLockStatus();
132
 
        virtual void updateStatus() = 0;
133
 
 
134
 
        QXTimer timer;
135
 
        QString fixedEntity, presEnt, curUser, pamUser;
136
 
        PluginList pluginList;
137
 
        KGVerifyHandler *handler;
138
 
        QSocketNotifier *sockNot;
139
 
        QWidget *parent, *predecessor;
140
 
        KGreeterPlugin *greet;
141
 
        QMenu *plugMenu;
142
 
        int curPlugin, presFld, timedLeft, deadTicks;
143
 
        QByteArray pName;
144
 
        KGreeterPlugin::Function func;
145
 
        KGreeterPlugin::Context ctx;
146
 
        bool capsLocked;
147
 
        bool enabled, running, suspended, failed, delayed;
148
 
        bool authTok, isClear, timeable;
149
 
 
150
 
        static void vrfMsgBox( QWidget *parent, const QString &user, QMessageBox::Icon type, const QString &mesg );
151
 
        static void vrfErrBox( QWidget *parent, const QString &user, const char *msg );
152
 
        static void vrfInfoBox( QWidget *parent, const QString &user, const char *msg );
153
 
 
154
 
        static QVector<GreeterPluginHandle> greetPlugins;
 
128
    bool eventFilter(QObject *, QEvent *);
 
129
    void msgBox(QMessageBox::Icon typ, const QString &msg);
 
130
    void setTimer();
 
131
    void updateLockStatus();
 
132
    virtual void updateStatus() = 0;
 
133
 
 
134
    QXTimer timer;
 
135
    QString fixedEntity, presEnt, curUser, pamUser;
 
136
    PluginList pluginList;
 
137
    KGVerifyHandler *handler;
 
138
    QSocketNotifier *sockNot;
 
139
    QWidget *parent, *predecessor;
 
140
    KGreeterPlugin *greet;
 
141
    QMenu *plugMenu;
 
142
    int curPlugin, presFld, timedLeft, deadTicks;
 
143
    QByteArray pName;
 
144
    KGreeterPlugin::Function func;
 
145
    KGreeterPlugin::Context ctx;
 
146
    bool capsLocked;
 
147
    bool enabled, running, suspended, failed, delayed;
 
148
    bool authTok, isClear, timeable;
 
149
 
 
150
    static void vrfMsgBox(QWidget *parent, const QString &user, QMessageBox::Icon type, const QString &mesg);
 
151
    static void vrfErrBox(QWidget *parent, const QString &user, const char *msg);
 
152
    static void vrfInfoBox(QWidget *parent, const QString &user, const char *msg);
 
153
 
 
154
    static QVector<GreeterPluginHandle> greetPlugins;
155
155
 
156
156
  private:
157
 
        bool applyPreset();
158
 
        void performAutoLogin();
159
 
        bool scheduleAutoLogin( bool initial );
160
 
        void doReject( bool initial );
161
 
        void talkerEdits();
 
157
    bool applyPreset();
 
158
    void performAutoLogin();
 
159
    bool scheduleAutoLogin(bool initial);
 
160
    void doReject(bool initial);
 
161
    void talkerEdits();
162
162
 
163
163
  private Q_SLOTS:
164
 
        void slotPluginSelected( QAction * );
165
 
        void slotTimeout();
166
 
        void slotActivity();
167
 
        void handleVerify();
 
164
    void slotPluginSelected(QAction *);
 
165
    void slotTimeout();
 
166
    void slotActivity();
 
167
    void handleVerify();
168
168
 
169
169
  public: // from KGreetPluginHandler
170
 
        virtual void gplugReturnText( const char *text, int tag );
171
 
        virtual void gplugReturnBinary( const char *data );
172
 
        virtual void gplugSetUser( const QString &user );
173
 
        virtual void gplugStart();
174
 
        virtual void gplugChanged();
175
 
        virtual void gplugActivity();
176
 
        virtual void gplugMsgBox( QMessageBox::Icon type, const QString &text );
 
170
    virtual void gplugReturnText(const char *text, int tag);
 
171
    virtual void gplugReturnBinary(const char *data);
 
172
    virtual void gplugSetUser(const QString &user);
 
173
    virtual void gplugStart();
 
174
    virtual void gplugChanged();
 
175
    virtual void gplugActivity();
 
176
    virtual void gplugMsgBox(QMessageBox::Icon type, const QString &text);
177
177
 
178
 
        static QVariant getConf( void *ctx, const char *key, const QVariant &dflt );
 
178
    static QVariant getConf(void *ctx, const char *key, const QVariant &dflt);
179
179
};
180
180
 
181
181
class KGStdVerify : public KGVerify {
182
 
        Q_OBJECT
183
 
        typedef KGVerify inherited;
 
182
    Q_OBJECT
 
183
    typedef KGVerify inherited;
184
184
 
185
185
  public:
186
 
        KGStdVerify( KGVerifyHandler *handler, QWidget *parent,
187
 
                     QWidget *predecessor, const QString &fixedEntity,
188
 
                     const PluginList &pluginList,
189
 
                     KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
190
 
        virtual ~KGStdVerify();
191
 
        QLayout *getLayout() const { return grid; }
192
 
        void selectPlugin( int id );
 
186
    KGStdVerify(KGVerifyHandler *handler, QWidget *parent,
 
187
                QWidget *predecessor, const QString &fixedEntity,
 
188
                const PluginList &pluginList,
 
189
                KGreeterPlugin::Function func, KGreeterPlugin::Context ctx);
 
190
    virtual ~KGStdVerify();
 
191
    QLayout *getLayout() const { return grid; }
 
192
    void selectPlugin(int id);
193
193
 
194
194
  protected:
195
 
        void updateStatus();
 
195
    void updateStatus();
196
196
 
197
197
  private:
198
 
        QGridLayout *grid;
199
 
        QLabel *failedLabel;
200
 
        int failedLabelState;
 
198
    QGridLayout *grid;
 
199
    QLabel *failedLabel;
 
200
    int failedLabelState;
201
201
 
202
202
  public: // from KGreetPluginHandler
203
 
        virtual bool gplugHasNode( const QString &id );
 
203
    virtual bool gplugHasNode(const QString &id);
204
204
};
205
205
 
206
206
class KGThemedVerify : public KGVerify {
207
 
        Q_OBJECT
208
 
        typedef KGVerify inherited;
 
207
    Q_OBJECT
 
208
    typedef KGVerify inherited;
209
209
 
210
210
  public:
211
 
        KGThemedVerify( KGVerifyHandler *handler, KdmThemer *themer,
212
 
                        QWidget *parent, QWidget *predecessor,
213
 
                        const QString &fixedEntity,
214
 
                        const PluginList &pluginList,
215
 
                        KGreeterPlugin::Function func,
216
 
                        KGreeterPlugin::Context ctx );
217
 
        virtual ~KGThemedVerify();
218
 
        void selectPlugin( int id );
 
211
    KGThemedVerify(KGVerifyHandler *handler, KdmThemer *themer,
 
212
                   QWidget *parent, QWidget *predecessor,
 
213
                   const QString &fixedEntity,
 
214
                   const PluginList &pluginList,
 
215
                   KGreeterPlugin::Function func,
 
216
                   KGreeterPlugin::Context ctx);
 
217
    virtual ~KGThemedVerify();
 
218
    void selectPlugin(int id);
219
219
 
220
220
  protected:
221
 
        void updateStatus();
 
221
    void updateStatus();
222
222
 
223
223
  private:
224
 
        KdmThemer *themer;
225
 
        QSet<QString> showTypes;
 
224
    KdmThemer *themer;
 
225
    QSet<QString> showTypes;
226
226
 
227
227
  public: // from KGreetPluginHandler
228
 
        virtual bool gplugHasNode( const QString &id );
 
228
    virtual bool gplugHasNode(const QString &id);
229
229
};
230
230
 
231
231
class KGChTok : public FDialog, public KGVerifyHandler {
232
 
        Q_OBJECT
233
 
        typedef FDialog inherited;
 
232
    Q_OBJECT
 
233
    typedef FDialog inherited;
234
234
 
235
235
  public:
236
 
        KGChTok( QWidget *parent, const QString &user,
237
 
                 const PluginList &pluginList, int curPlugin,
238
 
                 KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
239
 
        ~KGChTok();
 
236
    KGChTok(QWidget *parent, const QString &user,
 
237
            const PluginList &pluginList, int curPlugin,
 
238
            KGreeterPlugin::Function func, KGreeterPlugin::Context ctx);
 
239
    ~KGChTok();
240
240
 
241
241
  public Q_SLOTS:
242
 
        void accept();
 
242
    void accept();
243
243
 
244
244
  private:
245
 
        KPushButton *okButton, *cancelButton;
246
 
        KGStdVerify *verify;
 
245
    KPushButton *okButton, *cancelButton;
 
246
    KGStdVerify *verify;
247
247
 
248
248
  public: // from KGVerifyHandler
249
 
        virtual void verifyPluginChanged( int id );
250
 
        virtual void verifyOk();
251
 
        virtual void verifyFailed();
252
 
        virtual void verifyRetry();
253
 
        virtual void verifySetUser( const QString &user );
 
249
    virtual void verifyPluginChanged(int id);
 
250
    virtual void verifyOk();
 
251
    virtual void verifyFailed();
 
252
    virtual void verifyRetry();
 
253
    virtual void verifySetUser(const QString &user);
254
254
};
255
255
 
256
256
#endif /* KGVERIFY_H */