summaryrefslogtreecommitdiffstats
path: root/pass.h
blob: a12c737c0083a2d064836b3fef0a99fc7686a1d0 (plain)
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
/******************************************************************************
 *  Copyright (C) 2017 by Lukas Fürmetz <fuermetz@mailbox.org>                *
 *                                                                            *
 *  This library 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 3 of the License or (at   *
 *  your option) any later version.                                           *
 *                                                                            *
 *  This library 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         *
 *  Library General Public License for more details.                          *
 *                                                                            *
 *  You should have received a copy of the GNU General Public License         *
 *  along with this library; see the file LICENSE.                            *
 *  If not, see <http://www.gnu.org/licenses/>.                               *
 *****************************************************************************/

#ifndef PASS_H
#define PASS_H

#include <KRunner/AbstractRunner>
#include <QDir>
#include <QReadWriteLock>
#include <QFileSystemWatcher>

class Pass : public Plasma::AbstractRunner
{
    Q_OBJECT

public:
    Pass(QObject *parent, const QVariantList &args);
    ~Pass() override;

    void clip(const QString &msg);
    void match(Plasma::RunnerContext &) override;
    void run(const Plasma::RunnerContext &, const Plasma::QueryMatch &) override;
    QList<QAction *> actionsForMatch(const Plasma::QueryMatch &) override;
    void reloadConfiguration() override;
    
    
public Q_SLOTS:
    void reinitPasswords(const QString &path);

protected:
    void init() override;
    void initPasswords();
    void showNotification(const QString &, const QString & = QString());

private:
    QDir baseDir;
    QString passOtpIdentifier;
    int timeout;
    QReadWriteLock lock;
    QList<QString> passwords;
    QFileSystemWatcher watcher;
    
    bool showActions;
    QList<QAction *> orderedActions;

    const QLatin1String queryPrefix = QLatin1String("pass");
};

#endif