Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nemo-qml-plugin-systemsettings] enablers for devicelock passcode age #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/devicelockiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,28 @@
#include <QDebug>
#include "devicelockiface.h"

static bool runPlugin(QStringList args)
static int runPlugin(QStringList args)
{
QSettings s("/usr/share/lipstick/devicelock/devicelock.conf", QSettings::IniFormat);
QString pluginName = s.value("DeviceLock/pluginName").toString();

if (pluginName.isEmpty()) {
qWarning("DeviceLock: no plugin configuration set in /usr/share/lipstick/devicelock/devicelock.conf");
return false;
return DeviceLockInterface::Failed;
}

QProcess p;
p.start(pluginName, args);
if (!p.waitForFinished()) {
qWarning("DeviceLock: plugin did not finish in time");
return false;
return DeviceLockInterface::Failed;
}

qDebug() << p.readAllStandardOutput();
qWarning() << p.readAllStandardError();
return p.exitCode() == 0;
if (p.exitCode() == 0) return DeviceLockInterface::OK;
else if (p.exitCode() == 1) return DeviceLockInterface::Failed;
else return p.exitCode(); // special cases like Expired and InHistory
}

DeviceLockInterface::DeviceLockInterface(QObject *parent)
Expand All @@ -67,12 +69,12 @@ DeviceLockInterface::~DeviceLockInterface()
{
}

bool DeviceLockInterface::checkCode(const QString &code)
int DeviceLockInterface::checkCode(const QString &code)
{
return runPlugin(QStringList() << "--check-code" << code);
}

bool DeviceLockInterface::setCode(const QString &oldCode, const QString &newCode)
int DeviceLockInterface::setCode(const QString &oldCode, const QString &newCode)
{
bool return_value = runPlugin(QStringList() << "--set-code" << oldCode << newCode);
if (return_value) {
Expand Down
15 changes: 13 additions & 2 deletions src/devicelockiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,25 @@
class DeviceLockInterface : public QObject
{
Q_OBJECT
Q_ENUMS(ReturnValue)
Q_PROPERTY(bool isSet READ isSet NOTIFY isSetChanged)

public:
explicit DeviceLockInterface(QObject *parent = 0);
virtual ~DeviceLockInterface();

Q_INVOKABLE bool checkCode(const QString &code);
Q_INVOKABLE bool setCode(const QString &oldCode, const QString &newCode);

/*!< note: encryption binary returns 0==OK and 1==Failed, switching is done in runPlugin for the QML */
enum ReturnValue
{
Failed = 0, /*!< Failed - syscall returned with default error */
OK, /*!< OK - syscall returned without errors */
Expired, /*!< Expired - lockcode creation date is over the settings limit */
InHistory /*!< InHistory - lockcode was found in history file. */
};

Q_INVOKABLE int checkCode(const QString &code);
Q_INVOKABLE int setCode(const QString &oldCode, const QString &newCode);
Q_INVOKABLE bool clearCode(const QString &currentCode);
Q_INVOKABLE bool isSet();
Q_INVOKABLE void refresh();
Expand Down