-
Notifications
You must be signed in to change notification settings - Fork 39
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
[lipstick] enablers for devicelock pass code age #195
base: master
Are you sure you want to change the base?
Conversation
Can't it return an enum instead of a generic int with no defined meaning? |
This is called from qml which doesn't have support for enum's as such. So I need to use int in qml side anyways. I tought that it might be clearer to have int also in c++ side. And its also more future proof, so if devicelock encryption plugin introduces new return value, then I wouldnt have to create new pull request to lipstick. But yes with enum's c++ side might be a bit more readable. |
What do you mean? You can have enums in QML. |
Please tell more? http://qt-project.org/doc/qt-5/qml-enumeration.html#using-the-enumeration-type-in-qml at least states that enums are vars or ints. |
Mmh.. ok, but i was thinking that you could still define an enum with the values returned by the plugin. |
Concur that it would be nice having some named values instead of magic numbers somewhere. This could be the place since it's already swapping return codes 0 and 1. |
Sure if it makes code more readable I can add named values. I'll make an update to pull request tomorrow or so. |
Added enum. |
still using "return 0" though :) |
well yes still using return value trickery, because I dont want to lock people out of their devices who using Jolla devel when they update lipstick only. But enum should now 'ducument' the current possible return values from the plugin. |
What do you mean? Failed is 0, so returning that, or using it to compare it against a value is safe. |
Q_ENUMS(ReturnValue) is already declared in line 33 in .h file. It is returning failed as 0 to QML. (Binary itself returns 1 on failed and 0 on success). Ah sorry my crosseyes didnt notice return 0 lines... fixing. |
Now should be better. |
LGTM |
Updated pull request with qmlRegisterUncreatableType so that Q_ENUM is also exported in qml side so for example jolla-home can access enum values. |
|
||
class MGConfItem; | ||
class QTimer; | ||
|
||
class DeviceLock : public QObject, protected QDBusContext | ||
class LIPSTICK_EXPORT DeviceLock : public QObject, protected QDBusContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the LIPSTICK_EXPORT necessary for the qmlRegisterUncreatableType call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, without the export there was undefined symbol when trying to use the library.
Ok, looks good. |
@@ -199,7 +199,9 @@ bool DeviceLock::runPlugin(const QStringList &args) | |||
qWarning() << process.readAllStandardError(); | |||
#endif | |||
|
|||
return process.exitCode() == 0; | |||
if (process.exitCode() == 0) return OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change the enum, so that OK is 0 and Failed is 1, you don't need do have that thing here, and can just say return process.exitCode();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't - that would mean if (!runPlugin(...)) { /* plugin returned success */ }
, which seems more error-prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..although, since there are positive error codes that also mean failure now, you might be right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current enum order is there because of keeping compatibility with jolla-home and settings-system. That way people don't get locked out of their devices if they only update lipstick and somehow forget to update jolla-home and settings-system at the same time. (as those projects have hard coded in some places that OK == 1), so it would be safer to keep compatibility and gradually create pull request to switch hardcoded values to use the enum.
And anyways this pull request is currently on hold as devicelock rewrite study might change the way how the pass code age is handled.
I guess this is on hold for now, keeping it open? |
devicelock encryption plugin is introducing new return values (exit 2 and exit 3) for special cases like lockcode is found in history file (stores xx values that config key states) and for lockcode has expired (older than xx days). This change changes boolean call to return int (but keeping the interoperability with for example jolla-home package with the kludge in lines 201-203).